List of usage examples for android.os Messenger Messenger
public Messenger(IBinder target)
From source file:pl.itiner.grave.ResultList.java
public void search(QueryParams params) { getView().findViewById(R.id.list_offline_warninig_view).setVisibility(View.GONE); Bundle b = new Bundle(); String queryUriStr = GraveFinderProvider.createUri(params).toString(); b.putString(CONTENT_PROVIDER_URI, queryUriStr); b.putParcelable(JsonFetchService.QUERY_PARAMS_BUNDLE, params); getLoaderManager().destroyLoader(GRAVE_DATA_LOADER_ID); getLoaderManager().initLoader(GRAVE_DATA_LOADER_ID, b, this); if (activity.isConnectionAvailable()) { Intent i = new Intent(getActivity(), JsonFetchService.class); i.putExtra(JsonFetchService.MESSENGER_BUNDLE, new Messenger(HANDLER)); i.putExtras(b);//from w ww.j av a 2 s.co m getActivity().startService(i); } }
From source file:org.sufficientlysecure.keychain.ui.EncryptFileActivity.java
public void startEncrypt() { if (!inputIsValid()) { // Notify was created by inputIsValid. return;/* w w w . j ava 2 s . c o m*/ } // Send all information needed to service to edit key in other thread Intent intent = new Intent(this, KeychainIntentService.class); intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); intent.putExtra(KeychainIntentService.EXTRA_DATA, createEncryptBundle()); // Message is received after encrypting is done in KeychainIntentService KeychainIntentServiceHandler serviceHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { Notify.showNotify(EncryptFileActivity.this, R.string.encrypt_sign_successful, Notify.Style.INFO); if (mDeleteAfterEncrypt) { for (Uri inputUri : mInputUris) { DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment .newInstance(inputUri); deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); } mInputUris.clear(); notifyUpdate(); } if (mShareAfterEncrypt) { // Share encrypted message/file startActivity(sendWithChooserExcludingEncrypt(message)); } else { // Copy to clipboard copyToClipboard(message); Notify.showNotify(EncryptFileActivity.this, R.string.encrypt_sign_clipboard_successful, Notify.Style.INFO); } } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(serviceHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog serviceHandler.showProgressDialog(this); // start service with intent startService(intent); }
From source file:org.anhonesteffort.flock.ImportOtherAccountFragment.java
private void ImportAccountAsync() { if (messageHandler != null && messageHandler.serviceStarted) return;/* ww w . ja v a 2 s . c om*/ else if (messageHandler == null) messageHandler = new MessageHandler(setupActivity, this); Bundle result = new Bundle(); String hrefWebDAVHost = ((TextView) getView().findViewById(R.id.href_webdav_host)).getText().toString() .trim(); String accountUsername = ((TextView) getView().findViewById(R.id.account_username)).getText().toString() .trim(); String accountPassword = ((TextView) getView().findViewById(R.id.account_password)).getText().toString() .trim(); String cipherPassphrase = ((TextView) getView().findViewById(R.id.cipher_passphrase)).getText().toString() .trim(); String cipherPassphraseRepeat = ((TextView) getView().findViewById(R.id.cipher_passphrase_repeat)).getText() .toString().trim(); if (StringUtils.isEmpty(hrefWebDAVHost)) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_EMPTY_DAV_URL); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); return; } if (!accountUsername.contains("@")) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_ILLEGAL_ACCOUNT_ID); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); return; } if (StringUtils.isEmpty(cipherPassphrase) || StringUtils.isEmpty(accountPassword)) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SHORT_PASSWORD); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); ((TextView) getView().findViewById(R.id.cipher_passphrase)).setText(""); ((TextView) getView().findViewById(R.id.cipher_passphrase_repeat)).setText(""); return; } if (!cipherPassphrase.equals(cipherPassphraseRepeat)) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_PASSWORDS_DO_NOT_MATCH); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); ((TextView) getView().findViewById(R.id.cipher_passphrase)).setText(""); ((TextView) getView().findViewById(R.id.cipher_passphrase_repeat)).setText(""); return; } DavAccount importAccount = new DavAccount(accountUsername, accountPassword, hrefWebDAVHost); Intent importService = new Intent(getActivity(), ImportOtherAccountService.class); importService.putExtra(ImportOtherAccountService.KEY_MESSENGER, new Messenger(messageHandler)); importService.putExtra(ImportOtherAccountService.KEY_ACCOUNT, importAccount.toBundle()); importService.putExtra(ImportOtherAccountService.KEY_MASTER_PASSPHRASE, cipherPassphrase); getActivity().startService(importService); messageHandler.serviceStarted = true; setupActivity.setNavigationDisabled(true); getActivity().setProgressBarIndeterminateVisibility(true); getActivity().setProgressBarVisibility(true); }
From source file:ac.robinson.bettertogether.hotspot.HotspotManagerService.java
public HotspotManagerService() { // initialise the handler - actual service is initialised in onBind as we can't get a context here mMessenger = new Messenger(new IncomingHandler(HotspotManagerService.this)); }
From source file:fr.julienvermet.bugdroid.ui.DashboardFragment.java
private void loadBugs(int requestCode, int searchType) { DashboardSearch dashboardSearch = new DashboardSearch("", requestCode, mInstance, searchType); Intent intent = BugsIntentService.getIntent(getActivity(), dashboardSearch); Messenger messenger = new Messenger(onBugReceivedHandler); intent.putExtra(BugIntentService.MESSENGER, messenger); getActivity().startService(intent);//from w w w.j ava 2s .co m }
From source file:org.thialfihar.android.apg.ui.KeyListSecretFragment.java
/** * Show dialog to delete key/*from w ww. j av a2 s . c om*/ * * @param keyRingRowIds */ @TargetApi(11) public void showDeleteKeyDialog(final ActionMode mode, long[] keyRingRowIds) { // Message is received after key is deleted Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { mode.finish(); } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(returnHandler); DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, keyRingRowIds, Id.type.secret_key); deleteKeyDialog.show(getActivity().getSupportFragmentManager(), "deleteKeyDialog"); }
From source file:org.sufficientlysecure.keychain.ui.QrCodeScanActivity.java
public void importKeys(String fingerprint) { // Message is received after importing is done in KeychainIntentService KeychainIntentServiceHandler serviceHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_importing), ProgressDialog.STYLE_HORIZONTAL, true) { public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get returned data bundle Bundle returnData = message.getData(); if (returnData == null) { finish();/* ww w .ja v a2 s. co m*/ return; } final ImportKeyResult result = returnData.getParcelable(OperationResult.EXTRA_RESULT); if (result == null) { Log.e(Constants.TAG, "result == null"); finish(); return; } if (!result.success()) { // only return if no success... Intent data = new Intent(); data.putExtras(returnData); returnResult(data); return; } Intent certifyIntent = new Intent(QrCodeScanActivity.this, CertifyKeyActivity.class); certifyIntent.putExtra(CertifyKeyActivity.EXTRA_RESULT, result); certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds()); startActivityForResult(certifyIntent, 0); } } }; // search config Preferences prefs = Preferences.getPreferences(this); Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); // Send all information needed to service to query keys in other thread Intent intent = new Intent(this, KeychainIntentService.class); intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver); ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null); ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<ParcelableKeyRing>(); selectedEntries.add(keyEntry); data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, selectedEntries); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Create a new Messenger for the communication back Messenger messenger = new Messenger(serviceHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog serviceHandler.showProgressDialog(this); // start service with intent startService(intent); }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
/** * Show to dialog from where to import keys *//* w w w . j a v a 2s . com*/ public void showImportFromFileDialog() { // Message is received after file is selected Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == FileDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); mImportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); mDeleteAfterImport = data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED); Log.d(Constants.TAG, "mImportFilename: " + mImportFilename); Log.d(Constants.TAG, "mDeleteAfterImport: " + mDeleteAfterImport); loadKeyListFragment(); } } }; // Create a new Messenger for the communication back final Messenger messenger = new Messenger(returnHandler); DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { public void run() { mFileDialog = FileDialogFragment.newInstance(messenger, getString(R.string.title_importKeys), getString(R.string.specifyFileToImportFrom), Constants.path.APP_DIR + "/", null, Id.request.filename); mFileDialog.show(getSupportFragmentManager(), "fileDialog"); } }); }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvUserIdsFragment.java
private void addUserId() { Handler returnHandler = new Handler() { @Override/* w w w. ja v a 2 s.c o m*/ public void handleMessage(Message message) { if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); // add new user id mUserIdsAddedAdapter.add(data.getString(AddUserIdDialogFragment.MESSAGE_DATA_USER_ID)); } } }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(returnHandler); // pre-fill out primary name AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger, ""); addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); }
From source file:org.sufficientlysecure.keychain.ui.CreateKeyYubiKeyImportFragment.java
public void importKey() { // Message is received after decrypting is done in KeychainService ServiceProgressHandler saveHandler = new ServiceProgressHandler(getActivity(), getString(R.string.progress_importing), ProgressDialog.STYLE_HORIZONTAL) { @Override// w w w. jav a 2 s .c o m public void handleMessage(Message message) { // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == MessageStatus.OKAY.ordinal()) { // get returned data bundle Bundle returnData = message.getData(); ImportKeyResult result = returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT); long[] masterKeyIds = result.getImportedMasterKeyIds(); // TODO handle masterKeyIds.length != 1...? sorta outlandish scenario if (!result.success() || masterKeyIds.length == 0) { result.createNotify(getActivity()).show(); return; } Intent intent = new Intent(getActivity(), ViewKeyActivity.class); // use the imported masterKeyId, not the one from the yubikey, because // that one might* just have been a subkey of the imported key intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyIds[0])); intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result); intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid); intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId); intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints); startActivity(intent); getActivity().finish(); } } }; // Send all information needed to service to decrypt in other thread Intent intent = new Intent(getActivity(), KeychainService.class); // fill values for this action Bundle data = new Bundle(); intent.setAction(KeychainService.ACTION_IMPORT_KEYRING); ArrayList<ParcelableKeyRing> keyList = new ArrayList<>(); keyList.add(new ParcelableKeyRing(mNfcFingerprint, null, null)); data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keyList); { Preferences prefs = Preferences.getPreferences(getActivity()); Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver); } intent.putExtra(KeychainService.EXTRA_DATA, data); // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger); saveHandler.showProgressDialog(getActivity()); // start service with intent getActivity().startService(intent); }