aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java31
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java27
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java224
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java34
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptDecryptActivity.java175
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/HelpActivity.java44
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java29
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java4
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java4
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListSecretActivity.java15
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java109
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesActivity.java26
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java17
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/DashboardLayout.java186
14 files changed, 186 insertions, 739 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java
index 4530ac2fc..3c553fff5 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java
@@ -18,44 +18,19 @@
package org.sufficientlysecure.keychain.service.remote;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.ui.MainActivity;
+import org.sufficientlysecure.keychain.ui.DrawerActivity;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.MenuItem;
-
-import android.content.Intent;
import android.os.Bundle;
-public class RegisteredAppsListActivity extends SherlockFragmentActivity {
- private ActionBar mActionBar;
+public class RegisteredAppsListActivity extends DrawerActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mActionBar = getSupportActionBar();
-
setContentView(R.layout.api_apps_list_activity);
- mActionBar.setDisplayShowTitleEnabled(true);
- mActionBar.setDisplayHomeAsUpEnabled(true);
+ setupDrawerNavigation(savedInstanceState);
}
- /**
- * Menu Options
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
index f7fc49083..87229f6c3 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
@@ -66,13 +66,12 @@ import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.beardedhen.androidbootstrap.BootstrapButton;
@SuppressLint("NewApi")
-public class DecryptActivity extends SherlockFragmentActivity {
+public class DecryptActivity extends DrawerActivity {
/* Intents */
// without permission
@@ -144,13 +143,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
case Id.menu.option.decrypt: {
decryptClicked();
@@ -245,6 +237,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
initView();
+ setupDrawerNavigation(savedInstanceState);
+
// Handle intent actions
handleActions(getIntent());
@@ -262,7 +256,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (matcher.matches()) {
data = matcher.group(1);
mMessage.setText(data);
- Toast.makeText(this, R.string.using_clipboard_content, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, R.string.using_clipboard_content, Toast.LENGTH_SHORT)
+ .show();
}
}
}
@@ -472,8 +467,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (!file.exists() || !file.isFile()) {
Toast.makeText(
this,
- getString(R.string.error_message, getString(R.string.error_file_not_found)),
- Toast.LENGTH_SHORT).show();
+ getString(R.string.error_message,
+ getString(R.string.error_file_not_found)), Toast.LENGTH_SHORT)
+ .show();
return;
}
}
@@ -592,7 +588,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
}
mSecretKeyId = Id.key.symmetric;
if (!PgpOperation.hasSymmetricEncryption(this, inStream)) {
- throw new PgpGeneralException(getString(R.string.error_no_known_encryption_found));
+ throw new PgpGeneralException(
+ getString(R.string.error_no_known_encryption_found));
}
mAssumeSymmetricEncryption = true;
}
@@ -790,8 +787,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
.getBoolean(KeychainIntentService.RESULT_SIGNATURE_UNKNOWN)) {
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
Toast.makeText(DecryptActivity.this,
- R.string.unknown_signature_key_touch_to_look_up, Toast.LENGTH_LONG)
- .show();
+ R.string.unknown_signature_key_touch_to_look_up,
+ Toast.LENGTH_LONG).show();
} else {
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java
index e278af5e3..db6a3a155 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java
@@ -1,26 +1,27 @@
/*
- *
- * from https://github.com/tobykurien/SherlockNavigationDrawer
- *
- * Copyright 2013 The Android Open Source Project
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity;
+import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
@@ -30,45 +31,24 @@ import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.ActionProvider;
import android.view.ContextMenu.ContextMenuInfo;
+import android.view.LayoutInflater;
import android.view.SubMenu;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
+import com.beardedhen.androidbootstrap.FontAwesomeText;
/**
- * This example illustrates a common usage of the DrawerLayout widget in the Android support
- * library.
- * <p/>
- * <p>
- * When a navigation (left) drawer is present, the host activity should detect presses of the action
- * bar's Up affordance as a signal to open and close the navigation drawer. The
- * ActionBarDrawerToggle facilitates this behavior. Items within the drawer should fall into one of
- * two categories:
- * </p>
- * <p/>
- * <ul>
- * <li><strong>View switches</strong>. A view switch follows the same basic policies as list or tab
- * navigation in that a view switch does not create navigation history. This pattern should only be
- * used at the root activity of a task, leaving some form of Up navigation active for activities
- * further down the navigation hierarchy.</li>
- * <li><strong>Selective Up</strong>. The drawer allows the user to choose an alternate parent for
- * Up navigation. This allows a user to jump across an app's navigation hierarchy at will. The
- * application should treat this as it treats Up navigation from a different task, replacing the
- * current task stack using TaskStackBuilder or similar. This is the only form of navigation drawer
- * that should be used outside of the root activity of a task.</li>
- * </ul>
- * <p/>
- * <p>
- * Right side drawers should be used for actions, not navigation. This follows the pattern
- * established by the Action Bar that navigation should be to the left and actions to the right. An
- * action should be an operation performed on the current contents of the window, for example
- * enabling or disabling a data overlay on top of the current content.
- * </p>
+ * some fundamental ideas from https://github.com/tobykurien/SherlockNavigationDrawer
+ *
+ *
*/
public class DrawerActivity extends SherlockFragmentActivity {
private DrawerLayout mDrawerLayout;
@@ -77,11 +57,14 @@ public class DrawerActivity extends SherlockFragmentActivity {
private CharSequence mDrawerTitle;
private CharSequence mTitle;
- private String[] mDrawerTitles;
+
+ private static Class[] mItemsClass = new Class[] { KeyListPublicActivity.class,
+ EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class,
+ KeyListSecretActivity.class, PreferencesActivity.class,
+ RegisteredAppsListActivity.class, HelpActivity.class };
protected void setupDrawerNavigation(Bundle savedInstanceState) {
- // mTitle = mDrawerTitle = getTitle();
- mDrawerTitles = getResources().getStringArray(R.array.drawer_array);
+ mDrawerTitle = getString(R.string.app_name);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
@@ -89,10 +72,31 @@ public class DrawerActivity extends SherlockFragmentActivity {
// opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
- mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item,
- mDrawerTitles));
+ // mDrawerList
+ // .setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mItemsText));
+
+ NavItem mItemIconTexts[] = new NavItem[] {
+ new NavItem("fa-user", getString(R.string.nav_contacts)),
+ new NavItem("fa-lock", getString(R.string.nav_encrypt)),
+ new NavItem("fa-unlock", getString(R.string.nav_decrypt)),
+ new NavItem("fa-download", getString(R.string.nav_import)),
+ new NavItem("fa-key", getString(R.string.nav_secret_keys)),
+ new NavItem("fa-wrench", getString(R.string.nav_settings)),
+ new NavItem("fa-android", getString(R.string.nav_apps)),
+ new NavItem("fa-question", getString(R.string.nav_help)), };
+
+ mDrawerList.setAdapter(new NavigationDrawerAdapter(this, R.layout.drawer_list_item,
+ mItemIconTexts));
+
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
+ // <com.beardedhen.androidbootstrap.FontAwesomeText
+ // android:layout_width="wrap_content"
+ // android:layout_height="wrap_content"
+ // android:layout_margin="10dp"
+ // android:textSize="32sp"
+ // fontawesometext:fa_icon="fa-github" />
+
// enable ActionBar app icon to behave as action to toggle nav drawer
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
@@ -107,21 +111,22 @@ public class DrawerActivity extends SherlockFragmentActivity {
) {
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
- supportInvalidateOptionsMenu(); // creates call to
- // onPrepareOptionsMenu()
+ // creates call to onPrepareOptionsMenu()
+ supportInvalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
+ mTitle = getSupportActionBar().getTitle();
getSupportActionBar().setTitle(mDrawerTitle);
- supportInvalidateOptionsMenu(); // creates call to
- // onPrepareOptionsMenu()
+ // creates call to onPrepareOptionsMenu()
+ supportInvalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
- if (savedInstanceState == null) {
- selectItem(0);
- }
+ // if (savedInstanceState == null) {
+ // selectItem(0);
+ // }
}
/* Called whenever we call invalidateOptionsMenu() */
@@ -142,8 +147,10 @@ public class DrawerActivity extends SherlockFragmentActivity {
return true;
}
+ return super.onOptionsItemSelected(item);
+
// Handle action buttons
- switch (item.getItemId()) {
+ // switch (item.getItemId()) {
// case R.id.action_websearch:
// // create intent to perform web search for this planet
// Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
@@ -155,9 +162,9 @@ public class DrawerActivity extends SherlockFragmentActivity {
// Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
// }
// return true;
- default:
- return super.onOptionsItemSelected(item);
- }
+ // default:
+ // return super.onOptionsItemSelected(item);
+ // }
}
private android.view.MenuItem getMenuItem(final MenuItem item) {
@@ -377,32 +384,24 @@ public class DrawerActivity extends SherlockFragmentActivity {
}
private void selectItem(int position) {
- // update the main content by replacing fragments
- // Fragment fragment = new PlanetFragment();
- // Bundle args = new Bundle();
- // args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
- // fragment.setArguments(args);
-
- // FragmentManager fragmentManager = getSupportFragmentManager();
- // fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
-
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
// setTitle(mDrawerTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
- }
- // @Override
- // public void setTitle(CharSequence title) {
- // mTitle = title;
- // getSupportActionBar().setTitle(mTitle);
- // }
+ finish();
+ overridePendingTransition(0, 0);
+
+ Intent intent = new Intent(this, mItemsClass[position]);
+ startActivity(intent);
+ // disable animation of activity start
+ overridePendingTransition(0, 0);
+ }
/**
* When using the ActionBarDrawerToggle, you must call it during onPostCreate() and
* onConfigurationChanged()...
*/
-
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
@@ -417,28 +416,59 @@ public class DrawerActivity extends SherlockFragmentActivity {
mDrawerToggle.onConfigurationChanged(newConfig);
}
- /**
- * Fragment that appears in the "content_frame", shows a planet
- */
- // public static class PlanetFragment extends SherlockFragment {
- // public static final String ARG_PLANET_NUMBER = "planet_number";
- //
- // public PlanetFragment() {
- // // Empty constructor required for fragment subclasses
- // }
- //
- // @Override
- // public View onCreateView(LayoutInflater inflater, ViewGroup container,
- // Bundle savedInstanceState) {
- // View rootView = inflater.inflate(R.layout.fragment_planet, container, false);
- // int i = getArguments().getInt(ARG_PLANET_NUMBER);
- // String planet = getResources().getStringArray(R.array.drawer_array)[i];
- //
- // int imageId = getResources().getIdentifier(planet.toLowerCase(Locale.getDefault()),
- // "drawable", getActivity().getPackageName());
- // ((ImageView) rootView.findViewById(R.id.image)).setImageResource(imageId);
- // getActivity().setTitle(planet);
- // return rootView;
- // }
- // }
+ private class NavItem {
+ public String icon;
+ public String title;
+
+ public NavItem(String icon, String title) {
+ super();
+ this.icon = icon;
+ this.title = title;
+ }
+ }
+
+ private class NavigationDrawerAdapter extends ArrayAdapter<NavItem> {
+ Context context;
+ int layoutResourceId;
+ NavItem data[] = null;
+
+ public NavigationDrawerAdapter(Context context, int layoutResourceId, NavItem[] data) {
+ super(context, layoutResourceId, data);
+ this.layoutResourceId = layoutResourceId;
+ this.context = context;
+ this.data = data;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View row = convertView;
+ NavItemHolder holder = null;
+
+ if (row == null) {
+ LayoutInflater inflater = ((Activity) context).getLayoutInflater();
+ row = inflater.inflate(layoutResourceId, parent, false);
+
+ holder = new NavItemHolder();
+ holder.img = (FontAwesomeText) row.findViewById(R.id.drawer_item_icon);
+ holder.txtTitle = (TextView) row.findViewById(R.id.drawer_item_text);
+
+ row.setTag(holder);
+ } else {
+ holder = (NavItemHolder) row.getTag();
+ }
+
+ NavItem item = data[position];
+ holder.txtTitle.setText(item.title);
+ holder.img.setIcon(item.icon);
+
+ return row;
+ }
+
+ }
+
+ static class NavItemHolder {
+ FontAwesomeText img;
+ TextView txtTitle;
+ }
+
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
index 681548c9b..24caebb3a 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
@@ -63,12 +63,11 @@ import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.beardedhen.androidbootstrap.BootstrapButton;
-public class EncryptActivity extends SherlockFragmentActivity {
+public class EncryptActivity extends DrawerActivity {
/* Intents */
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
@@ -153,13 +152,6 @@ public class EncryptActivity extends SherlockFragmentActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
case Id.menu.option.encrypt_to_clipboard:
encryptToClipboardClicked();
@@ -187,6 +179,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
initView();
+ setupDrawerNavigation(savedInstanceState);
+
// Handle intent actions
handleActions(getIntent());
@@ -491,8 +485,9 @@ public class EncryptActivity extends SherlockFragmentActivity {
if (!file.exists() || !file.isFile()) {
Toast.makeText(
this,
- getString(R.string.error_message, getString(R.string.error_file_not_found)),
- Toast.LENGTH_SHORT).show();
+ getString(R.string.error_message,
+ getString(R.string.error_file_not_found)), Toast.LENGTH_SHORT)
+ .show();
return;
}
}
@@ -510,7 +505,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
gotPassPhrase = (passPhrase.length() != 0);
if (!gotPassPhrase) {
- Toast.makeText(this, R.string.passphrase_must_not_be_empty, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, R.string.passphrase_must_not_be_empty, Toast.LENGTH_SHORT)
+ .show();
return;
}
} else {
@@ -522,8 +518,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
}
if (!encryptIt && mSecretKeyId == 0) {
- Toast.makeText(this, R.string.select_encryption_or_signature_key, Toast.LENGTH_SHORT)
- .show();
+ Toast.makeText(this, R.string.select_encryption_or_signature_key,
+ Toast.LENGTH_SHORT).show();
return;
}
@@ -852,10 +848,12 @@ public class EncryptActivity extends SherlockFragmentActivity {
Choice[] choices = new Choice[] {
new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " ("
+ getString(R.string.compression_fast) + ")"),
- new Choice(Id.choice.compression.zip, "ZIP (" + getString(R.string.compression_fast) + ")"),
- new Choice(Id.choice.compression.zlib, "ZLIB (" + getString(R.string.compression_fast) + ")"),
- new Choice(Id.choice.compression.bzip2, "BZIP2 (" + getString(R.string.compression_very_slow)
- + ")"), };
+ new Choice(Id.choice.compression.zip, "ZIP ("
+ + getString(R.string.compression_fast) + ")"),
+ new Choice(Id.choice.compression.zlib, "ZLIB ("
+ + getString(R.string.compression_fast) + ")"),
+ new Choice(Id.choice.compression.bzip2, "BZIP2 ("
+ + getString(R.string.compression_very_slow) + ")"), };
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(this,
android.R.layout.simple_spinner_item, choices);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptDecryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptDecryptActivity.java
deleted file mode 100644
index 7f0184381..000000000
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptDecryptActivity.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package org.sufficientlysecure.keychain.ui;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.util.Log;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.ActionBar.Tab;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-
-public class EncryptDecryptActivity extends SherlockFragmentActivity {
- private FragmentActivity mActivity;
- private ActionBar mActionBar;
- private ActionBar.Tab mTab1;
- private ActionBar.Tab mTab2;
- private ActionBar.Tab mTab3;
-
- // @Override
- // public boolean onCreateOptionsMenu(Menu menu) {
- // MenuInflater inflater = getSupportMenuInflater();
- // inflater.inflate(R.menu.lists_activity, menu);
- // return true;
- // }
-
- /**
- * Menu item to go back home in ActionBar, other menu items are defined in Fragments
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(mActivity, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- // case R.id.menu_import:
- // ImportExportHelper.openFileStream(mActivity);
- // return true;
- //
- // case R.id.menu_export:
- // ImportExportHelper.exportLists(mActivity);
- // return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- /**
- * Set up Tabs on create
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mActivity = this;
-
- setContentView(R.layout.lists_activity);
-
- mActionBar = getSupportActionBar();
- mActionBar.setDisplayShowTitleEnabled(true);
- mActionBar.setDisplayHomeAsUpEnabled(true);
-
- mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
-
- mTab1 = getSupportActionBar().newTab();
- mTab2 = getSupportActionBar().newTab();
- mTab3 = getSupportActionBar().newTab();
-
- mTab1.setTabListener(new TabListener<KeyListPublicFragment>(this, "publicList",
- KeyListPublicFragment.class));
- mTab2.setTabListener(new TabListener<KeyListPublicFragment>(this, "import",
- KeyListPublicFragment.class));
-
- setTabTextBasedOnOrientation(getResources().getConfiguration());
-
- mActionBar.addTab(mTab1);
- mActionBar.addTab(mTab2);
- // mActionBar.addTab(mTab3);
- }
-
- private void setTabTextBasedOnOrientation(Configuration config) {
- // longer names for landscape mode or tablets
- // if (config.orientation == Configuration.ORIENTATION_LANDSCAPE
- // || config.screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
- mTab1.setText(getString(R.string.dashboard_manage_keys));
- mTab2.setText(getString(R.string.dashboard_manage_keys));
-
- // } else {
- // mTab1.setText(getString(R.string.lists_tab_blacklist_short));
- // mTab2.setText(getString(R.string.lists_tab_whitelist_short));
- // mTab3.setText(getString(R.string.lists_tab_redirection_list_short));
- // }
- }
-
- /**
- * Change text on orientation change
- */
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- setTabTextBasedOnOrientation(newConfig);
- }
-
- public static class TabListener<T extends Fragment> implements ActionBar.TabListener {
- private Fragment mFragment;
- private final Activity mActivity;
- private final String mTag;
- private final Class<T> mClass;
-
- /**
- * Constructor used each time a new tab is created.
- *
- * @param activity
- * The host Activity, used to instantiate the fragment
- * @param tag
- * The identifier tag for the fragment
- * @param clz
- * The fragment's Class, used to instantiate the fragment
- */
- public TabListener(Activity activity, String tag, Class<T> clz) {
- mActivity = activity;
- mTag = tag;
- mClass = clz;
- }
-
- @Override
- public void onTabReselected(Tab tab, FragmentTransaction ft) {
- }
-
- /**
- * Open Fragment based on selected Tab
- */
- @Override
- public void onTabSelected(Tab tab, FragmentTransaction ignoredFt) {
- // bug in compatibility lib:
- // http://stackoverflow.com/questions/8645549/null-fragmenttransaction-being-passed-to-tablistener-ontabselected
- FragmentManager fragMgr = ((FragmentActivity) mActivity).getSupportFragmentManager();
- FragmentTransaction ft = fragMgr.beginTransaction();
-
- mFragment = Fragment.instantiate(mActivity, mClass.getName());
- ft.replace(R.id.lists_tabs_container, mFragment, mTag);
- ft.commit();
- }
-
- @Override
- public void onTabUnselected(Tab tab, FragmentTransaction ignoredFt) {
- FragmentManager fragMgr = ((FragmentActivity) mActivity).getSupportFragmentManager();
- FragmentTransaction ft = fragMgr.beginTransaction();
-
- if (mFragment != null) {
- // Remove the fragment
- ft.remove(mFragment);
- }
-
- ft.commit();
- }
- }
-
-} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/HelpActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/HelpActivity.java
index 13350b6c6..7407564a9 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/HelpActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/HelpActivity.java
@@ -17,27 +17,24 @@
package org.sufficientlysecure.keychain.ui;
+import java.util.ArrayList;
+
import org.sufficientlysecure.keychain.R;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.ViewPager;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
-import com.actionbarsherlock.view.MenuItem;
-
-import java.util.ArrayList;
-
-import android.content.Context;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-
import com.actionbarsherlock.app.SherlockFragmentActivity;
-public class HelpActivity extends SherlockFragmentActivity {
+public class HelpActivity extends DrawerActivity {
public static final String EXTRA_SELECTED_TAB = "selectedTab";
ViewPager mViewPager;
@@ -45,37 +42,18 @@ public class HelpActivity extends SherlockFragmentActivity {
TextView tabCenter;
TextView tabText;
- /**
- * Menu Items
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
setContentView(R.layout.help_activity);
- mViewPager = new ViewPager(this);
- mViewPager.setId(R.id.pager);
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+
+ setupDrawerNavigation(savedInstanceState);
- setContentView(mViewPager);
ActionBar bar = getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- bar.setDisplayShowTitleEnabled(true);
- bar.setDisplayHomeAsUpEnabled(true);
mTabsAdapter = new TabsAdapter(this, mViewPager);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index 94b5304a1..1842364e7 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
@@ -51,11 +50,9 @@ import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.MenuItem;
import com.beardedhen.androidbootstrap.BootstrapButton;
-public class ImportKeysActivity extends SherlockFragmentActivity implements OnNavigationListener {
+public class ImportKeysActivity extends DrawerActivity implements OnNavigationListener {
public static final String ACTION_IMPORT_KEY = Constants.INTENT_PREFIX + "IMPORT_KEY";
public static final String ACTION_IMPORT_KEY_FROM_QR_CODE = Constants.INTENT_PREFIX
+ "IMPORT_KEY_FROM_QR_CODE";
@@ -103,8 +100,12 @@ public class ImportKeysActivity extends SherlockFragmentActivity implements OnNa
}
});
+ getSupportActionBar().setDisplayShowTitleEnabled(false);
+
+ setupDrawerNavigation(savedInstanceState);
+
// set actionbar without home button if called from another app
- ActionBarHelper.setBackButton(this);
+ // ActionBarHelper.setBackButton(this);
// set drop down navigation
mNavigationStrings = getResources().getStringArray(R.array.import_action_list);
@@ -114,7 +115,6 @@ public class ImportKeysActivity extends SherlockFragmentActivity implements OnNa
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
- getSupportActionBar().setDisplayShowTitleEnabled(false);
handleActions(savedInstanceState, getIntent());
}
@@ -240,23 +240,6 @@ public class ImportKeysActivity extends SherlockFragmentActivity implements OnNa
mListFragment.loadNew(importData, importFilename);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
-
- }
- }
-
// private void importAndSignOld(final long keyId, final String expectedFingerprint) {
// if (expectedFingerprint != null && expectedFingerprint.length() > 0) {
//
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java
index 3766b1c42..91481d2b4 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,8 +37,6 @@ import android.os.Message;
import android.os.Messenger;
import android.widget.Toast;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-
/**
* This implements export key method and delete key method. Used in lists and key view and key edit.
*
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java
index 476d3c96c..cb04ddf0d 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java
@@ -50,8 +50,8 @@ public class KeyListPublicActivity extends KeyActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_key_list_public_import:
- Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
- startActivityForResult(intentImportFromFile, Id.request.import_from_qr_code);
+ Intent intentImport = new Intent(this, ImportKeysActivity.class);
+ startActivityForResult(intentImport, Id.request.import_from_qr_code);
return true;
case R.id.menu_key_list_public_export:
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListSecretActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListSecretActivity.java
index d95f03ae1..747055a47 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListSecretActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListSecretActivity.java
@@ -35,8 +35,8 @@ public class KeyListSecretActivity extends KeyActivity {
setContentView(R.layout.key_list_secret_activity);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeButtonEnabled(true);
+ // now setup navigation drawer in DrawerActivity...
+ setupDrawerNavigation(savedInstanceState);
}
@Override
@@ -49,13 +49,6 @@ public class KeyListSecretActivity extends KeyActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
-
- return true;
case R.id.menu_key_list_secret_create:
createKey();
@@ -70,8 +63,8 @@ public class KeyListSecretActivity extends KeyActivity {
return true;
case R.id.menu_key_list_secret_import:
- Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
- startActivityForResult(intentImportFromFile, Id.request.import_from_qr_code);
+ Intent intentImport = new Intent(this, ImportKeysActivity.class);
+ startActivityForResult(intentImport, Id.request.import_from_qr_code);
return true;
default:
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java
deleted file mode 100644
index 9a270e60b..000000000
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.sufficientlysecure.keychain.ui;
-
-import org.sufficientlysecure.keychain.Id;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-public class MainActivity extends SherlockActivity {
-
- public void manageKeysOnClick(View view) {
- // used instead of startActivity set actionbar based on callingPackage
- startActivityForResult(new Intent(this, KeyListPublicActivity.class), 0);
- }
-
- public void myKeysOnClick(View view) {
- // used instead of startActivity set actionbar based on callingPackage
- startActivityForResult(new Intent(this, KeyListSecretActivity.class), 0);
- }
-
- public void encryptOnClick(View view) {
- Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
- intent.setAction(EncryptActivity.ACTION_ENCRYPT);
- // used instead of startActivity set actionbar based on callingPackage
- startActivityForResult(intent, 0);
- }
-
- public void decryptOnClick(View view) {
- Intent intent = new Intent(MainActivity.this, DecryptActivity.class);
- intent.setAction(DecryptActivity.ACTION_DECRYPT);
- // used instead of startActivity set actionbar based on callingPackage
- startActivityForResult(intent, 0);
- }
-
- public void scanQrcodeOnClick(View view) {
- Intent intent = new Intent(this, ImportKeysActivity.class);
- startActivityForResult(intent, 0);
- }
-
- public void helpOnClick(View view) {
- startActivity(new Intent(this, HelpActivity.class));
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- final ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setHomeButtonEnabled(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
- .setIcon(R.drawable.ic_menu_settings)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- menu.add(0, Id.menu.option.crypto_consumers, 0, R.string.menu_api_app_settings)
- .setIcon(R.drawable.ic_menu_settings)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case Id.menu.option.preferences:
- startActivity(new Intent(this, PreferencesActivity.class));
- return true;
-
- case Id.menu.option.crypto_consumers:
- startActivity(new Intent(this, RegisteredAppsListActivity.class));
- return true;
-
- default:
- break;
-
- }
- return false;
- }
-
-} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesActivity.java
index 6607ab4d5..43ad0c93d 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesActivity.java
@@ -20,13 +20,9 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.openpgp.PGPEncryptedData;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.ui.widget.IntegerListPreference;
-import org.sufficientlysecure.keychain.R;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockPreferenceActivity;
-import com.actionbarsherlock.view.MenuItem;
import android.content.Intent;
import android.os.Bundle;
@@ -34,6 +30,9 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockPreferenceActivity;
+
public class PreferencesActivity extends SherlockPreferenceActivity {
private IntegerListPreference mPassPhraseCacheTtl = null;
private IntegerListPreference mEncryptionAlgorithm = null;
@@ -220,21 +219,4 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
}
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- default:
- break;
-
- }
- return false;
- }
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java
index b0711ed31..83669a523 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java
@@ -137,21 +137,4 @@ public class SelectSecretKeyActivity extends SherlockFragmentActivity {
return true;
}
- /**
- * Menu Options
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
- }
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/DashboardLayout.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/DashboardLayout.java
deleted file mode 100644
index 158a271bc..000000000
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/DashboardLayout.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.sufficientlysecure.keychain.ui.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-
-/**
- * Custom layout that arranges children in a grid-like manner, optimizing for even horizontal and
- * vertical whitespace.
- */
-public class DashboardLayout extends ViewGroup {
- private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10;
-
- private int mMaxChildWidth = 0;
- private int mMaxChildHeight = 0;
-
- public DashboardLayout(Context context) {
- super(context, null);
- }
-
- public DashboardLayout(Context context, AttributeSet attrs) {
- super(context, attrs, 0);
- }
-
- public DashboardLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- mMaxChildWidth = 0;
- mMaxChildHeight = 0;
-
- // Measure once to find the maximum child size.
-
- int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
- MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
- int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
- MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.AT_MOST);
-
- final int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
-
- mMaxChildWidth = Math.max(mMaxChildWidth, child.getMeasuredWidth());
- mMaxChildHeight = Math.max(mMaxChildHeight, child.getMeasuredHeight());
- }
-
- // Measure again for each child to be exactly the same size.
-
- childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxChildWidth, MeasureSpec.EXACTLY);
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxChildHeight, MeasureSpec.EXACTLY);
-
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
-
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
-
- setMeasuredDimension(resolveSize(mMaxChildWidth, widthMeasureSpec),
- resolveSize(mMaxChildHeight, heightMeasureSpec));
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int width = r - l;
- int height = b - t;
-
- final int count = getChildCount();
-
- // Calculate the number of visible children.
- int visibleCount = 0;
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
- ++visibleCount;
- }
-
- if (visibleCount == 0) {
- return;
- }
-
- // Calculate what number of rows and columns will optimize for even horizontal and
- // vertical whitespace between items. Start with a 1 x N grid, then try 2 x N, and so on.
- int bestSpaceDifference = Integer.MAX_VALUE;
- int spaceDifference;
-
- // Horizontal and vertical space between items
- int hSpace = 0;
- int vSpace = 0;
-
- int cols = 1;
- int rows;
-
- while (true) {
- rows = (visibleCount - 1) / cols + 1;
-
- hSpace = ((width - mMaxChildWidth * cols) / (cols + 1));
- vSpace = ((height - mMaxChildHeight * rows) / (rows + 1));
-
- spaceDifference = Math.abs(vSpace - hSpace);
- if (rows * cols != visibleCount) {
- spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER;
- } else if (rows * mMaxChildHeight > height || cols * mMaxChildWidth > width) {
- spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER;
- }
-
- if (spaceDifference < bestSpaceDifference) {
- // Found a better whitespace squareness/ratio
- bestSpaceDifference = spaceDifference;
-
- // If we found a better whitespace squareness and there's only 1 row, this is
- // the best we can do.
- if (rows == 1) {
- break;
- }
- } else {
- // This is a worse whitespace ratio, use the previous value of cols and exit.
- --cols;
- rows = (visibleCount - 1) / cols + 1;
- hSpace = ((width - mMaxChildWidth * cols) / (cols + 1));
- vSpace = ((height - mMaxChildHeight * rows) / (rows + 1));
- break;
- }
-
- ++cols;
- }
-
- // Lay out children based on calculated best-fit number of rows and cols.
-
- // If we chose a layout that has negative horizontal or vertical space, force it to zero.
- hSpace = Math.max(0, hSpace);
- vSpace = Math.max(0, vSpace);
-
- // Re-use width/height variables to be child width/height.
- width = (width - hSpace * (cols + 1)) / cols;
- height = (height - vSpace * (rows + 1)) / rows;
-
- int left, top;
- int col, row;
- int visibleIndex = 0;
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.getVisibility() == GONE) {
- continue;
- }
-
- row = visibleIndex / cols;
- col = visibleIndex % cols;
-
- left = hSpace * (col + 1) + width * col;
- top = vSpace * (row + 1) + height * row;
-
- child.layout(left, top, (hSpace == 0 && col == cols - 1) ? r : (left + width),
- (vSpace == 0 && row == rows - 1) ? b : (top + height));
- ++visibleIndex;
- }
- }
-} \ No newline at end of file