aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java89
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabLayout.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabLayout.java)2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabStrip.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabStrip.java)2
-rw-r--r--OpenKeychain/src/main/res/layout/help_activity.xml2
-rw-r--r--OpenKeychain/src/main/res/layout/view_key_activity.xml2
-rw-r--r--OpenKeychain/src/main/res/menu/key_view.xml6
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml1
9 files changed, 100 insertions, 16 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java
index 9edaff19a..bbc1e4b1f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java
@@ -25,7 +25,7 @@ import android.support.v7.app.ActionBarActivity;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
-import org.sufficientlysecure.keychain.util.SlidingTabLayout;
+import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
public class HelpActivity extends ActionBarActivity {
public static final String EXTRA_SELECTED_TAB = "selected_tab";
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index a1d026e43..463c800d2 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -57,7 +57,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
import org.sufficientlysecure.keychain.util.Log;
-import org.sufficientlysecure.keychain.util.SlidingTabLayout;
+import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
import java.util.Date;
import java.util.HashMap;
@@ -95,6 +95,8 @@ public class ViewKeyActivity extends ActionBarActivity implements
private static final int LOADER_ID_UNIFIED = 0;
+ private boolean mShowAdvancedTabs;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -119,9 +121,6 @@ public class ViewKeyActivity extends ActionBarActivity implements
mViewPager = (ViewPager) findViewById(R.id.view_key_pager);
mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.view_key_sliding_tab_layout);
- mTabsAdapter = new PagerTabStripAdapter(this);
- mViewPager.setAdapter(mTabsAdapter);
-
int switchToTab = TAB_MAIN;
Intent intent = getIntent();
if (intent.getExtras() != null && intent.getExtras().containsKey(EXTRA_SELECTED_TAB)) {
@@ -139,6 +138,18 @@ public class ViewKeyActivity extends ActionBarActivity implements
initNfc(dataUri);
+ mShowAdvancedTabs = false;
+
+ initTabs(dataUri);
+
+ // switch to tab selected by extra
+ mViewPager.setCurrentItem(switchToTab);
+ }
+
+ private void initTabs(Uri dataUri) {
+ mTabsAdapter = new PagerTabStripAdapter(this);
+ mViewPager.setAdapter(mTabsAdapter);
+
Bundle mainBundle = new Bundle();
mainBundle.putParcelable(ViewKeyMainFragment.ARG_DATA_URI, dataUri);
mTabsAdapter.addTab(ViewKeyMainFragment.class,
@@ -149,6 +160,11 @@ public class ViewKeyActivity extends ActionBarActivity implements
mTabsAdapter.addTab(ViewKeyShareFragment.class,
mainBundle, getString(R.string.key_view_tab_share));
+ // update layout after operations
+ mSlidingTabLayout.setViewPager(mViewPager);
+ }
+
+ private void addAdvancedTabs(Uri dataUri) {
Bundle keyDetailsBundle = new Bundle();
keyDetailsBundle.putParcelable(ViewKeyKeysFragment.ARG_DATA_URI, dataUri);
mTabsAdapter.addTab(ViewKeyKeysFragment.class,
@@ -159,11 +175,46 @@ public class ViewKeyActivity extends ActionBarActivity implements
mTabsAdapter.addTab(ViewKeyCertsFragment.class,
certBundle, getString(R.string.key_view_tab_certs));
- // NOTE: must be after adding the tabs!
+ // update layout after operations
mSlidingTabLayout.setViewPager(mViewPager);
+ }
- // switch to tab selected by extra
- mViewPager.setCurrentItem(switchToTab);
+ private void removeAdvancedTabs() {
+ // before removing, switch to the first tab if necessary
+ if (mViewPager.getCurrentItem() >= TAB_KEYS) {
+ // remove _after_ switching to the main tab
+ mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ if (ViewPager.SCROLL_STATE_SETTLING == state) {
+ mTabsAdapter.removeTab(TAB_CERTS);
+ mTabsAdapter.removeTab(TAB_KEYS);
+
+ // update layout after operations
+ mSlidingTabLayout.setViewPager(mViewPager);
+
+ // remove this listener again
+// mViewPager.setOnPageChangeListener(null);
+ }
+ }
+ });
+
+ mViewPager.setCurrentItem(TAB_MAIN);
+ } else {
+ mTabsAdapter.removeTab(TAB_CERTS);
+ mTabsAdapter.removeTab(TAB_KEYS);
+ }
+
+ // update layout after operations
+ mSlidingTabLayout.setViewPager(mViewPager);
}
private Uri getDataUri() {
@@ -188,6 +239,9 @@ public class ViewKeyActivity extends ActionBarActivity implements
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.key_view, menu);
+
+ MenuItem showAdvancedInfoItem = menu.findItem(R.id.menu_key_view_advanced);
+ showAdvancedInfoItem.setChecked(mShowAdvancedTabs);
return true;
}
@@ -195,24 +249,37 @@ public class ViewKeyActivity extends ActionBarActivity implements
public boolean onOptionsItemSelected(MenuItem item) {
try {
switch (item.getItemId()) {
- case android.R.id.home:
+ case android.R.id.home: {
Intent homeIntent = new Intent(this, KeyListActivity.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
return true;
- case R.id.menu_key_view_update:
+ }
+ case R.id.menu_key_view_update: {
updateFromKeyserver(mDataUri, mProviderHelper);
return true;
- case R.id.menu_key_view_export_keyserver:
+ }
+ case R.id.menu_key_view_export_keyserver: {
uploadToKeyserver(mDataUri);
return true;
- case R.id.menu_key_view_export_file:
+ }
+ case R.id.menu_key_view_export_file: {
exportToFile(mDataUri, mExportHelper, mProviderHelper);
return true;
+ }
case R.id.menu_key_view_delete: {
deleteKey(mDataUri, mExportHelper);
return true;
}
+ case R.id.menu_key_view_advanced: {
+ mShowAdvancedTabs = !mShowAdvancedTabs;
+ item.setChecked(mShowAdvancedTabs);
+ if (mShowAdvancedTabs) {
+ addAdvancedTabs(mDataUri);
+ } else {
+ removeAdvancedTabs();
+ }
+ }
}
} catch (ProviderHelper.NotFoundException e) {
AppMsg.makeText(this, R.string.error_key_not_found, AppMsg.STYLE_ALERT).show();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java
index 977740567..3e3098b10 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java
@@ -20,8 +20,13 @@ package org.sufficientlysecure.keychain.ui.adapter;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarActivity;
+import android.view.ViewGroup;
+
+import org.sufficientlysecure.keychain.Constants;
import java.util.ArrayList;
@@ -52,6 +57,11 @@ public class PagerTabStripAdapter extends FragmentPagerAdapter {
notifyDataSetChanged();
}
+ public void removeTab(int index) {
+ mTabs.remove(index);
+ notifyDataSetChanged();
+ }
+
@Override
public int getCount() {
return mTabs.size();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabLayout.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabLayout.java
index 065034be1..17471c86c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabLayout.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabLayout.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.sufficientlysecure.keychain.util;
+package org.sufficientlysecure.keychain.ui.widget;
import android.content.Context;
import android.graphics.Typeface;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabStrip.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabStrip.java
index 9ce6f943e..4c41e12c5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/SlidingTabStrip.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SlidingTabStrip.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.sufficientlysecure.keychain.util;
+package org.sufficientlysecure.keychain.ui.widget;
import android.R;
import android.content.Context;
diff --git a/OpenKeychain/src/main/res/layout/help_activity.xml b/OpenKeychain/src/main/res/layout/help_activity.xml
index 76ba183b7..3ad087da3 100644
--- a/OpenKeychain/src/main/res/layout/help_activity.xml
+++ b/OpenKeychain/src/main/res/layout/help_activity.xml
@@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical" >
- <org.sufficientlysecure.keychain.util.SlidingTabLayout
+ <org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
android:id="@+id/sliding_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml
index f43aade25..5aa1cd167 100644
--- a/OpenKeychain/src/main/res/layout/view_key_activity.xml
+++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml
@@ -35,7 +35,7 @@
android:visibility="gone"
android:id="@+id/status_divider" />
- <org.sufficientlysecure.keychain.util.SlidingTabLayout
+ <org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
android:id="@+id/view_key_sliding_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/OpenKeychain/src/main/res/menu/key_view.xml b/OpenKeychain/src/main/res/menu/key_view.xml
index 864016801..64877d725 100644
--- a/OpenKeychain/src/main/res/menu/key_view.xml
+++ b/OpenKeychain/src/main/res/menu/key_view.xml
@@ -31,4 +31,10 @@
app:showAsAction="never"
android:title="@string/menu_delete_key" />
+ <item
+ android:id="@+id/menu_key_view_advanced"
+ app:showAsAction="never"
+ android:checkable="true"
+ android:title="@string/menu_advanced" />
+
</menu> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 9545c1ed4..ad8abe78f 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -102,6 +102,7 @@
<string name="menu_select_all">Select all</string>
<string name="menu_add_keys">Add keys</string>
<string name="menu_export_all_keys">Export all keys</string>
+ <string name="menu_advanced">Show advanced info</string>
<!-- label -->
<string name="label_sign">Sign</string>