mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-29 19:17:41 +00:00
Merge pull request #1470 from keymanapp/android-cancel-download
[android] Add "cancel" button when downloading keyboard catalog
This commit is contained in:
commit
47c5c382dc
6 changed files with 32 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
|
@ -44,6 +45,10 @@ public final class JSONParser {
|
|||
Log.e(logTag, (e.getMessage() == null) ? "UnsupportedEncodingException" : e.getMessage());
|
||||
jsonObj = null;
|
||||
System.err.println(e);
|
||||
} catch (InterruptedIOException e) {
|
||||
// Disregard from cancelling action
|
||||
Log.e(logTag, (e.getMessage() == null) ? "InterruptedIOException" : e.getMessage());
|
||||
jsonObj = null;
|
||||
} catch (IOException e) {
|
||||
Log.e(logTag, (e.getMessage() == null) ? "IOException" : e.getMessage());
|
||||
jsonObj = null;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class KMKeyboardDownloaderActivity extends AppCompatActivity {
|
|||
private static String filename;
|
||||
|
||||
private static ArrayList<KeyboardEventHandler.OnKeyboardDownloadEventListener> kbDownloadEventListeners = null;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -372,7 +372,6 @@ public class KMKeyboardDownloaderActivity extends AppCompatActivity {
|
|||
* @param showProgressDialog
|
||||
*/
|
||||
public static void download(final Context context, final boolean showProgressDialog) {
|
||||
|
||||
new DownloadTask(context, showProgressDialog).execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.tavultesoft.kmea.KeyboardEventHandler.OnKeyboardDownloadEventListener
|
|||
import com.tavultesoft.kmea.BuildConfig;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
|
|
@ -338,9 +339,21 @@ public final class LanguageListActivity extends AppCompatActivity implements OnK
|
|||
}
|
||||
|
||||
if (hasConnection && !loadFromCache) {
|
||||
progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setMessage(getString(R.string.loading));
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog = new ProgressDialog(context, R.style.ProgressDialog);
|
||||
progressDialog.setMessage(getString(R.string.getting_keyboard_catalog));
|
||||
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.label_cancel),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
cancel(true);
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
LanguageListActivity.this.finish();
|
||||
return;
|
||||
}
|
||||
});
|
||||
progressDialog.setCancelable(true);
|
||||
if (!((AppCompatActivity) context).isFinishing()) {
|
||||
progressDialog.show();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
<string name="custom_keyboard" translatable="false">Custom Keyboard</string>
|
||||
<string name="downloading_keyboard" translatable="false">Downloading keyboard…</string>
|
||||
<string name="keyboard_updates_available" translatable="false">Keyboard Updates Available</string>
|
||||
<string name="loading" translatable="false">Loading…</string>
|
||||
<string name="getting_keyboard_catalog" translatable="false">Getting keyboard catalog.\nThis may take a while…</string>
|
||||
<string name="updating_keyboards" translatable="false">Updating keyboards…</string>
|
||||
|
||||
<!-- Keyboard Info -->
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@
|
|||
<item name="android:background">@android:color/white</item>
|
||||
</style-->
|
||||
|
||||
<style name="ProgressDialog">
|
||||
<item name="android:textColor">@android:color/black</item>
|
||||
<item name="android:textColorHint">@android:color/darker_gray</item>
|
||||
<item name="android:textColorPrimary">@android:color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="PopupAnim">
|
||||
<item name="android:windowEnterAnimation">@anim/fade_in</item>
|
||||
<item name="android:windowExitAnimation">@anim/fade_out</item>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# Keyman for Android
|
||||
|
||||
## 2019-01-03 11.0.2051 beta
|
||||
* Add option to cancel when downloading the keyboard catalog (#1470)
|
||||
|
||||
## 2019-01-02 11.0.2050 beta
|
||||
* Initial beta release of Keyman for Android 11
|
||||
* [Pull Requests](https://github.com/keymanapp/keyman/pulls?utf8=%E2%9C%93&q=is%3Apr+merged%3A2018-07-01..2019-01-01+label%3Aandroid+-label%3Acherry-pick+-label%3Astable)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue