From c97c57d34ea1994312ad7e409042ec55cf27c1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 6 Sep 2013 10:03:25 +0200 Subject: [PATCH] remove dead code --- OpenPGP-Keychain/res/values/strings.xml | 3 +- .../remote_api/AppSettingsActivity.java | 15 ++----- .../keychain/remote_api/ServiceActivity.java | 41 +++++++++++-------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index 7503170a5..bcae942aa 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -372,5 +372,6 @@ The following application requests access to OpenPGP Keychain\'s API.\n\nAllow permanent access? Allow access Disallow access - + Please select a key! + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java index 4e069f3b0..55fa72b0e 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java @@ -12,7 +12,6 @@ import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; -import android.widget.Button; import android.widget.TextView; import com.actionbarsherlock.app.ActionBar; @@ -22,22 +21,15 @@ import com.actionbarsherlock.view.MenuItem; public class AppSettingsActivity extends SherlockFragmentActivity { // model - Uri mAppUri; - String mPackageName; + private Uri mAppUri; + private String mPackageName; - // view - Button saveButton; - Button revokeButton; - - AppSettingsFragment settingsFragment; + private AppSettingsFragment settingsFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // pm = getApplicationContext().getPackageManager(); - - // BEGIN_INCLUDE (inflate_set_custom_view) // Inflate a "Done" custom action bar view to serve as the "Up" affordance. final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); @@ -60,7 +52,6 @@ public class AppSettingsActivity extends SherlockFragmentActivity { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView); - // END_INCLUDE (inflate_set_custom_view) setContentView(R.layout.api_app_settings_activity); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java index 5f36075f5..422026a19 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java @@ -17,16 +17,13 @@ package org.sufficientlysecure.keychain.remote_api; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.remote_api.IServiceActivityCallback; import org.sufficientlysecure.keychain.helper.PgpMain; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; - import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -41,6 +38,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import android.widget.Toast; + +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; public class ServiceActivity extends SherlockFragmentActivity { @@ -53,6 +54,9 @@ public class ServiceActivity extends SherlockFragmentActivity { private IServiceActivityCallback mServiceCallback; private boolean mServiceBound; + // view + AppSettingsFragment settingsFragment; + private ServiceConnection mServiceActivityConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service) { mServiceCallback = IServiceActivityCallback.Stub.asInterface(service); @@ -132,7 +136,6 @@ public class ServiceActivity extends SherlockFragmentActivity { if (ACTION_REGISTER.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); - // BEGIN_INCLUDE (inflate_set_custom_view) // Inflate a "Done"/"Cancel" custom action bar view final LayoutInflater inflater = (LayoutInflater) getSupportActionBar() .getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE); @@ -146,15 +149,22 @@ public class ServiceActivity extends SherlockFragmentActivity { @Override public void onClick(View v) { // Allow - ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName); - // Intent data = new Intent(); - try { - mServiceCallback.onRegistered(true, packageName); - } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + if (settingsFragment.getSecretKeyId() == Id.key.none) { + Toast.makeText(ServiceActivity.this, + R.string.api_register_error_select_key, Toast.LENGTH_LONG) + .show(); + } else { + ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName); + // Intent data = new Intent(); + + try { + mServiceCallback.onRegistered(true, packageName); + } catch (RemoteException e) { + Log.e(Constants.TAG, "ServiceActivity"); + } + finish(); } - finish(); } }); ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text)) @@ -180,13 +190,12 @@ public class ServiceActivity extends SherlockFragmentActivity { | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - // END_INCLUDE (inflate_set_custom_view) setContentView(R.layout.api_app_register_activity); - AppSettingsFragment settingsFragment = (AppSettingsFragment) getSupportFragmentManager() - .findFragmentById(R.id.api_app_settings_fragment); - + settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_app_settings_fragment); + settingsFragment.setPackage(packageName); // TODO: handle if app is already registered