diff options
author | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-03-22 03:31:13 +0530 |
---|---|---|
committer | Adithya Abraham Philip <adithyaphilip@gmail.com> | 2015-03-23 15:37:05 +0530 |
commit | 9f5581463f1b2d07217f59fa32346c786069dbf5 (patch) | |
tree | 3f3e8688dce87ba5253a9efe600f39456dbecc77 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java | |
parent | 19775c399b106149e8906a7482a4b5a4af2ac8fa (diff) | |
download | open-keychain-9f5581463f1b2d07217f59fa32346c786069dbf5.tar.gz open-keychain-9f5581463f1b2d07217f59fa32346c786069dbf5.tar.bz2 open-keychain-9f5581463f1b2d07217f59fa32346c786069dbf5.zip |
shifted multi-threading to own service
added multi-threaded cloud import, restored KeychainIntentService
eliminated code duplication in multi-threaded import
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 513da7785..861ae12d9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui; import android.animation.ObjectAnimator; import android.annotation.TargetApi; -import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; @@ -59,7 +58,6 @@ import com.getbase.floatingactionbutton.FloatingActionsMenu; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; import org.sufficientlysecure.keychain.operations.results.ConsolidateResult; import org.sufficientlysecure.keychain.operations.results.DeleteResult; @@ -70,9 +68,11 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.CloudImportService; import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.service.ServiceProgressHandler; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; import org.sufficientlysecure.keychain.ui.util.Highlighter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State; @@ -572,7 +572,7 @@ public class KeyListFragment extends LoaderFragment } private void updateAllKeys() { - Context context = this.getActivity(); + Context context = getActivity(); ProviderHelper providerHelper = new ProviderHelper(context); @@ -591,11 +591,12 @@ public class KeyListFragment extends LoaderFragment keyList.add(keyEntry); } - KeychainIntentServiceHandler serviceHandler = new KeychainIntentServiceHandler( + ServiceProgressHandler serviceHandler = new ServiceProgressHandler( getActivity(), - getString(R.string.progress_importing), + getString(R.string.progress_updating), ProgressDialog.STYLE_HORIZONTAL, - true) { + true, + ProgressDialogFragment.ServiceType.CLOUD_IMPORT) { public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); @@ -613,15 +614,13 @@ public class KeyListFragment extends LoaderFragment return; } - result.createNotify(KeyListFragment.this.getActivity()).show(); + result.createNotify(getActivity()).show(); } } }; // Send all information needed to service to query keys in other thread - Intent intent = new Intent(getActivity(), KeychainIntentService.class); - - intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING); + Intent intent = new Intent(getActivity(), CloudImportService.class); // fill values for this action Bundle data = new Bundle(); @@ -631,16 +630,16 @@ public class KeyListFragment extends LoaderFragment Preferences prefs = Preferences.getPreferences(getActivity()); Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); - data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver); + data.putString(CloudImportService.IMPORT_KEY_SERVER, cloudPrefs.keyserver); } - data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, keyList); + data.putParcelableArrayList(CloudImportService.IMPORT_KEY_LIST, keyList); - intent.putExtra(KeychainIntentService.EXTRA_DATA, data); + intent.putExtra(CloudImportService.EXTRA_DATA, data); // Create a new Messenger for the communication back Messenger messenger = new Messenger(serviceHandler); - intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger); // show progress dialog serviceHandler.showProgressDialog(getActivity()); @@ -651,10 +650,11 @@ public class KeyListFragment extends LoaderFragment private void consolidate() { // Message is received after importing is done in KeychainIntentService - KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler( + ServiceProgressHandler saveHandler = new ServiceProgressHandler( getActivity(), getString(R.string.progress_importing), - ProgressDialog.STYLE_HORIZONTAL) { + ProgressDialog.STYLE_HORIZONTAL, + ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) { public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); |