aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-05-07 14:33:20 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-05-07 14:33:20 +0200
commite14ce09186cde662ec24312a1722692cac25d5c3 (patch)
tree5046ce1454375c5df34d9fb7091005d9a5a2a15f /OpenKeychain
parentf4cbd8cabbe9dcd01e430a4f9953f061092cdfe6 (diff)
downloadopen-keychain-e14ce09186cde662ec24312a1722692cac25d5c3.tar.gz
open-keychain-e14ce09186cde662ec24312a1722692cac25d5c3.tar.bz2
open-keychain-e14ce09186cde662ec24312a1722692cac25d5c3.zip
Better handling of actionbars back
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/AndroidManifest.xml14
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java19
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java30
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java15
-rw-r--r--OpenKeychain/src/main/res/layout/view_cert_activity.xml6
8 files changed, 65 insertions, 51 deletions
diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml
index caefafb54..c3ef16409 100644
--- a/OpenKeychain/src/main/AndroidManifest.xml
+++ b/OpenKeychain/src/main/AndroidManifest.xml
@@ -232,7 +232,12 @@
<activity
android:name=".ui.UploadKeyActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
- android:label="@string/title_send_key" />
+ android:label="@string/title_send_key"
+ android:parentActivityName=".ui.ViewKeyActivity">
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".ui.ViewKeyActivity" />
+ </activity>
<activity
android:name=".ui.PreferencesActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
@@ -254,7 +259,12 @@
<activity
android:name=".ui.CertifyKeyActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
- android:label="@string/title_certify_key" />
+ android:label="@string/title_certify_key"
+ android:parentActivityName=".ui.ViewKeyActivity">
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".ui.ViewKeyActivity" />
+ </activity>
<activity
android:name=".ui.ImportKeysActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java
index 72b6d9e1d..46e7936ce 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java
@@ -33,25 +33,6 @@ import org.sufficientlysecure.keychain.util.Log;
public class ActionBarHelper {
/**
- * Set actionbar without home button if called from another app
- *
- * @param activity
- */
- public static void setBackButton(ActionBarActivity activity) {
- final ActionBar actionBar = activity.getSupportActionBar();
- Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
- + activity.getCallingPackage());
- if (activity.getCallingPackage() != null
- && activity.getCallingPackage().equals(Constants.PACKAGE_NAME)) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
- } else {
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setHomeButtonEnabled(false);
- }
- }
-
- /**
* Sets custom view on ActionBar for Done/Cancel activities
*
* @param actionBar
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java
index 1c851de0a..29969ca55 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java
@@ -26,10 +26,12 @@ import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.support.v4.app.LoaderManager;
+import android.support.v4.app.NavUtils;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
@@ -88,11 +90,6 @@ public class CertifyKeyActivity extends ActionBarActivity implements
setContentView(R.layout.certify_key_activity);
- final ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setHomeButtonEnabled(false);
-
mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getSupportFragmentManager()
.findFragmentById(R.id.sign_key_select_key_fragment);
mSelectKeyFragment.setCallback(this);
@@ -101,7 +98,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements
mSelectKeyserverSpinner = (Spinner) findViewById(R.id.sign_key_keyserver);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
- .getKeyServers());
+ .getKeyServers()
+ );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSelectKeyserverSpinner.setAdapter(adapter);
@@ -258,7 +256,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements
startSigning();
}
}
- });
+ }
+ );
// bail out; need to wait until the user has entered the passphrase before trying again
return;
} else {
@@ -392,4 +391,17 @@ public class CertifyKeyActivity extends ActionBarActivity implements
public void onKeySelected(long secretKeyId) {
mMasterKeyId = secretKeyId;
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home: {
+ Intent viewIntent = NavUtils.getParentActivityIntent(this);
+ viewIntent.setData(KeyRings.buildGenericKeyRingUri(mDataUri));
+ NavUtils.navigateUpTo(this, viewIntent);
+ return true;
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
index 1877a43b5..5b21be6e4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java
@@ -27,7 +27,6 @@ import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.pgp.PgpHelper;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
@@ -68,9 +67,6 @@ public class DecryptActivity extends DrawerActivity {
setContentView(R.layout.decrypt_activity);
- // set actionbar without home button if called from another app
- ActionBarHelper.setBackButton(this);
-
initView();
setupDrawerNavigation(savedInstanceState);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java
index 6c71c641f..39d4a09bc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java
@@ -27,7 +27,6 @@ import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
import org.sufficientlysecure.keychain.util.Log;
@@ -145,26 +144,28 @@ public class EncryptActivity extends DrawerActivity implements
setContentView(R.layout.encrypt_activity);
- // set actionbar without home button if called from another app
- ActionBarHelper.setBackButton(this);
-
initView();
- setupDrawerNavigation(savedInstanceState);
+ // if called with an intent action, do not init drawer navigation
+ if (ACTION_ENCRYPT.equals(getIntent().getAction())) {
+ // TODO: back button to key?
+ } else {
+ setupDrawerNavigation(savedInstanceState);
+ }
// Handle intent actions
handleActions(getIntent());
mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class,
- mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
+ mAsymmetricFragmentBundle, getString(R.string.label_asymmetric));
mTabsAdapterMode.addTab(EncryptSymmetricFragment.class,
- mSymmetricFragmentBundle, getString(R.string.label_symmetric));
+ mSymmetricFragmentBundle, getString(R.string.label_symmetric));
mViewPagerMode.setCurrentItem(mSwitchToMode);
mTabsAdapterContent.addTab(EncryptMessageFragment.class,
- mMessageFragmentBundle, getString(R.string.label_message));
+ mMessageFragmentBundle, getString(R.string.label_message));
mTabsAdapterContent.addTab(EncryptFileFragment.class,
- mFileFragmentBundle, getString(R.string.label_file));
+ mFileFragmentBundle, getString(R.string.label_file));
mViewPagerContent.setCurrentItem(mSwitchToContent);
}
@@ -217,9 +218,9 @@ public class EncryptActivity extends DrawerActivity implements
// preselect keys given by intent
mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS,
- encryptionKeyIds);
+ encryptionKeyIds);
mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID,
- signatureKeyId);
+ signatureKeyId);
mSwitchToMode = PAGER_MODE_ASYMMETRIC;
/**
@@ -241,9 +242,10 @@ public class EncryptActivity extends DrawerActivity implements
} else {
Log.e(Constants.TAG,
"Direct binary data without actual file in filesystem is not supported " +
- "by Intents. Please use the Remote Service API!");
- Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG)
- .show();
+ "by Intents. Please use the Remote Service API!"
+ );
+ Toast.makeText(this, R.string.error_only_files_are_supported,
+ Toast.LENGTH_LONG).show();
// end activity
finish();
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index 66224dd0b..f71ef6d46 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -43,7 +43,6 @@ import com.devspark.appmsg.AppMsg;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
@@ -125,7 +124,6 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) {
setTitle(R.string.nav_import);
} else {
- ActionBarHelper.setBackButton(this);
getSupportActionBar().setDisplayShowTitleEnabled(false);
// set drop down navigation
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java
index 97a2af645..90783aa8b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java
@@ -23,7 +23,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
+import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
@@ -129,4 +131,17 @@ public class UploadKeyActivity extends ActionBarActivity {
// start service with intent
startService(intent);
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home: {
+ Intent viewIntent = NavUtils.getParentActivityIntent(this);
+ viewIntent.setData(KeychainContract.KeyRings.buildGenericKeyRingUri(mDataUri));
+ NavUtils.navigateUpTo(this, viewIntent);
+ return true;
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
}
diff --git a/OpenKeychain/src/main/res/layout/view_cert_activity.xml b/OpenKeychain/src/main/res/layout/view_cert_activity.xml
index 12357fa0c..66c635599 100644
--- a/OpenKeychain/src/main/res/layout/view_cert_activity.xml
+++ b/OpenKeychain/src/main/res/layout/view_cert_activity.xml
@@ -42,7 +42,7 @@
android:text="@string/section_cert" />
<TableLayout
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_weight="1"
@@ -163,7 +163,7 @@
android:text="@string/section_certifier_id" />
<TableLayout
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="4dp"
@@ -193,7 +193,7 @@
android:id="@+id/label_algorithm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
+ android:layout_gravity="top"
android:paddingRight="10dip"
android:text="@string/label_user_id" />