diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-09 17:02:49 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-09 17:02:49 +0100 |
commit | 10715f7acee9620e8a27b62f1600ee4bcbae1ccd (patch) | |
tree | a0259c601e5b59047c3d09b738d0c943aa1ec189 | |
parent | 2162c85c125a2155f29ddcd436d36ff9a472c3d7 (diff) | |
download | open-keychain-10715f7acee9620e8a27b62f1600ee4bcbae1ccd.tar.gz open-keychain-10715f7acee9620e8a27b62f1600ee4bcbae1ccd.tar.bz2 open-keychain-10715f7acee9620e8a27b62f1600ee4bcbae1ccd.zip |
add experimental drawer navigation
24 files changed, 608 insertions, 35 deletions
diff --git a/OpenPGP-Keychain/libs/android-support-v4.jar b/OpenPGP-Keychain/libs/android-support-v4.jar Binary files differindex 99e063b33..9056828a0 100644 --- a/OpenPGP-Keychain/libs/android-support-v4.jar +++ b/OpenPGP-Keychain/libs/android-support-v4.jar diff --git a/OpenPGP-Keychain/res/drawable-hdpi/drawer_shadow.9.png b/OpenPGP-Keychain/res/drawable-hdpi/drawer_shadow.9.png Binary files differnew file mode 100644 index 000000000..224cc4ff4 --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-hdpi/drawer_shadow.9.png diff --git a/OpenPGP-Keychain/res/drawable-hdpi/ic_drawer.png b/OpenPGP-Keychain/res/drawable-hdpi/ic_drawer.png Binary files differnew file mode 100644 index 000000000..ff7b1def9 --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-hdpi/ic_drawer.png diff --git a/OpenPGP-Keychain/res/drawable-hdpi/ic_menu_filebrowser.png b/OpenPGP-Keychain/res/drawable-hdpi/ic_menu_filebrowser.png Binary files differdeleted file mode 100644 index 3db304fa8..000000000 --- a/OpenPGP-Keychain/res/drawable-hdpi/ic_menu_filebrowser.png +++ /dev/null diff --git a/OpenPGP-Keychain/res/drawable-mdpi/drawer_shadow.9.png b/OpenPGP-Keychain/res/drawable-mdpi/drawer_shadow.9.png Binary files differnew file mode 100644 index 000000000..3797f99c0 --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-mdpi/drawer_shadow.9.png diff --git a/OpenPGP-Keychain/res/drawable-mdpi/ic_drawer.png b/OpenPGP-Keychain/res/drawable-mdpi/ic_drawer.png Binary files differnew file mode 100644 index 000000000..fb681ba26 --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-mdpi/ic_drawer.png diff --git a/OpenPGP-Keychain/res/drawable-mdpi/ic_menu_filebrowser.png b/OpenPGP-Keychain/res/drawable-mdpi/ic_menu_filebrowser.png Binary files differdeleted file mode 100644 index fda13f1be..000000000 --- a/OpenPGP-Keychain/res/drawable-mdpi/ic_menu_filebrowser.png +++ /dev/null diff --git a/OpenPGP-Keychain/res/drawable-xhdpi/drawer_shadow.9.png b/OpenPGP-Keychain/res/drawable-xhdpi/drawer_shadow.9.png Binary files differnew file mode 100644 index 000000000..fa3d853e9 --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-xhdpi/drawer_shadow.9.png diff --git a/OpenPGP-Keychain/res/drawable-xhdpi/ic_drawer.png b/OpenPGP-Keychain/res/drawable-xhdpi/ic_drawer.png Binary files differnew file mode 100644 index 000000000..b9bc3d70f --- /dev/null +++ b/OpenPGP-Keychain/res/drawable-xhdpi/ic_drawer.png diff --git a/OpenPGP-Keychain/res/drawable-xhdpi/ic_menu_filebrowser.png b/OpenPGP-Keychain/res/drawable-xhdpi/ic_menu_filebrowser.png Binary files differdeleted file mode 100644 index d1324014d..000000000 --- a/OpenPGP-Keychain/res/drawable-xhdpi/ic_menu_filebrowser.png +++ /dev/null diff --git a/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml b/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml index a40444e0f..a88d7afd2 100644 --- a/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml +++ b/OpenPGP-Keychain/res/layout/api_app_settings_fragment.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" > @@ -41,12 +42,16 @@ android:layout_height="wrap_content" android:orientation="horizontal" > - <Button + <com.beardedhen.androidbootstrap.BootstrapButton android:id="@+id/api_app_settings_select_key_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:text="@string/api_settings_select_key" /> + android:layout_margin="4dp" + android:text="@string/api_settings_select_key" + bootstrapbutton:bb_icon_left="fa-key" + bootstrapbutton:bb_size="default" + bootstrapbutton:bb_type="default" /> <LinearLayout android:layout_width="match_parent" @@ -76,11 +81,16 @@ </LinearLayout> </LinearLayout> - <Button + <com.beardedhen.androidbootstrap.BootstrapButton android:id="@+id/api_app_settings_advanced_button" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/api_settings_show_advanced" /> + android:layout_gravity="center_vertical" + android:layout_margin="4dp" + android:text="@string/api_settings_show_advanced" + bootstrapbutton:bb_icon_left="fa-caret-up" + bootstrapbutton:bb_size="default" + bootstrapbutton:bb_type="default" /> <LinearLayout android:id="@+id/api_app_settings_advanced" diff --git a/OpenPGP-Keychain/res/layout/drawer_list_item.xml b/OpenPGP-Keychain/res/layout/drawer_list_item.xml new file mode 100644 index 000000000..d8e39399c --- /dev/null +++ b/OpenPGP-Keychain/res/layout/drawer_list_item.xml @@ -0,0 +1,36 @@ +<!-- + Copyright 2013 The Android Open Source Project + + 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. + --> + +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="@android:style/TextAppearance.Medium" + android:gravity="center_vertical" + android:padding="16dp" + android:textColor="#fff"/> +<!-- +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceListItemSmall" + android:gravity="center_vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:textColor="#fff" + android:background="?android:attr/activatedBackgroundIndicator" + android:minHeight="?android:attr/listPreferredItemHeightSmall"/> --> diff --git a/OpenPGP-Keychain/res/layout/fragment_planet.xml b/OpenPGP-Keychain/res/layout/fragment_planet.xml new file mode 100644 index 000000000..4fe5bbe61 --- /dev/null +++ b/OpenPGP-Keychain/res/layout/fragment_planet.xml @@ -0,0 +1,23 @@ +<!-- + Copyright 2013 The Android Open Source Project + + 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. + --> + +<ImageView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/image" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="#000000" + android:gravity="center" + android:padding="32dp" /> diff --git a/OpenPGP-Keychain/res/layout/key_list_public_activity.xml b/OpenPGP-Keychain/res/layout/key_list_public_activity.xml index 07ec253cc..704b3c8c9 100644 --- a/OpenPGP-Keychain/res/layout/key_list_public_activity.xml +++ b/OpenPGP-Keychain/res/layout/key_list_public_activity.xml @@ -1,14 +1,38 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. --> +<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/drawer_layout" android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" > + android:layout_height="match_parent" > - <fragment - android:id="@+id/key_list_public_fragment" - android:name="org.sufficientlysecure.keychain.ui.KeyListPublicFragment" + <FrameLayout android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="1" /> + android:layout_height="match_parent" > -</LinearLayout>
\ No newline at end of file + <fragment + android:id="@+id/key_list_public_fragment" + android:name="org.sufficientlysecure.keychain.ui.KeyListPublicFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </FrameLayout> + + <!-- + android:layout_gravity="start" tells DrawerLayout to treat + this as a sliding drawer on the left side for left-to-right + languages and on the right side for right-to-left languages. + The drawer is given a fixed width in dp and extends the full height of + the container. A solid background is used for contrast + with the content view. + --> + + <ListView + android:id="@+id/left_drawer" + android:layout_width="240dp" + android:layout_height="match_parent" + android:layout_gravity="start" + android:background="#111" + android:choiceMode="singleChoice" + android:divider="@android:color/transparent" + android:dividerHeight="0dp" /> + +</android.support.v4.widget.DrawerLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values-sw600dp/dimens.xml b/OpenPGP-Keychain/res/values-sw600dp/dimens.xml new file mode 100644 index 000000000..1ba777d65 --- /dev/null +++ b/OpenPGP-Keychain/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw600dp devices (e.g. 7" tablets) here. + --> + +</resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values-sw720dp-land/dimens.xml b/OpenPGP-Keychain/res/values-sw720dp-land/dimens.xml new file mode 100644 index 000000000..eee741a51 --- /dev/null +++ b/OpenPGP-Keychain/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ +<resources> + + <!-- + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + --> + <dimen name="activity_horizontal_margin">128dp</dimen> + +</resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values/dimens.xml b/OpenPGP-Keychain/res/values/dimens.xml new file mode 100644 index 000000000..a6dd14032 --- /dev/null +++ b/OpenPGP-Keychain/res/values/dimens.xml @@ -0,0 +1,7 @@ +<resources> + + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> + +</resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index b02d72bb8..e9ce05b77 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -19,7 +19,7 @@ <resources> <!-- title --> - <string name="title_manage_public_keys">Public Keys</string> + <string name="title_manage_public_keys">Contacts</string> <string name="title_manage_secret_keys">Secret Keys</string> <string name="title_select_recipients">Select Public Key</string> <string name="title_select_secret_key">Select Secret Key</string> @@ -301,7 +301,7 @@ <string name="compression_very_slow">very slow</string> <!-- Dashboard --> - <string name="dashboard_manage_keys">Manage Public Keys</string> + <string name="dashboard_manage_keys">Contacts</string> <string name="dashboard_my_keys">My Secret Keys</string> <string name="dashboard_encrypt">Encrypt</string> <string name="dashboard_decrypt">Decrypt</string> @@ -331,8 +331,8 @@ <!-- Remote API --> <string name="api_no_apps">No registered applications!</string> - <string name="api_settings_show_advanced">Show advanced settings…</string> - <string name="api_settings_hide_advanced">Hide advanced settings…</string> + <string name="api_settings_show_advanced">Show advanced settings</string> + <string name="api_settings_hide_advanced">Hide advanced settings</string> <string name="api_settings_no_key">No key selected</string> <string name="api_settings_select_key">Select key</string> <string name="api_settings_save">Save</string> @@ -369,4 +369,19 @@ <!-- Key view --> <string name="key_view_action_encrypt">Encrypt to this contact</string> + <!-- Navigation Drawer --> + <string-array name="drawer_array"> + <item>Contacts</item> + <item>Encrypt</item> + <item>Decrypt</item> + <item>Import Keys</item> + <item>My Keys</item> + <item>Settings</item> + <item>Registered Apps</item> + <item>Help</item> + </string-array> + + <string name="drawer_open">Open navigation drawer</string> + <string name="drawer_close">Close navigation drawer</string> + </resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java index e592f5d57..bb6e427a4 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java @@ -49,12 +49,13 @@ import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; +import com.beardedhen.androidbootstrap.BootstrapButton; + public class AppSettingsFragment extends Fragment { // model @@ -62,12 +63,12 @@ public class AppSettingsFragment extends Fragment { // view private LinearLayout mAdvancedSettingsContainer; - private Button mAdvancedSettingsButton; + private BootstrapButton mAdvancedSettingsButton; private TextView mAppNameView; private ImageView mAppIconView; private TextView mKeyUserId; private TextView mKeyUserIdRest; - private Button mSelectKeyButton; + private BootstrapButton mSelectKeyButton; private Spinner mEncryptionAlgorithm; private Spinner mHashAlgorithm; private Spinner mCompression; @@ -116,7 +117,8 @@ public class AppSettingsFragment extends Fragment { } private void initView(View view) { - mAdvancedSettingsButton = (Button) view.findViewById(R.id.api_app_settings_advanced_button); + mAdvancedSettingsButton = (BootstrapButton) view + .findViewById(R.id.api_app_settings_advanced_button); mAdvancedSettingsContainer = (LinearLayout) view .findViewById(R.id.api_app_settings_advanced); @@ -124,7 +126,8 @@ public class AppSettingsFragment extends Fragment { mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); mKeyUserId = (TextView) view.findViewById(R.id.api_app_settings_user_id); mKeyUserIdRest = (TextView) view.findViewById(R.id.api_app_settings_user_id_rest); - mSelectKeyButton = (Button) view.findViewById(R.id.api_app_settings_select_key_button); + mSelectKeyButton = (BootstrapButton) view + .findViewById(R.id.api_app_settings_select_key_button); mEncryptionAlgorithm = (Spinner) view .findViewById(R.id.api_app_settings_encryption_algorithm); mHashAlgorithm = (Spinner) view.findViewById(R.id.api_app_settings_hash_algorithm); @@ -204,11 +207,13 @@ public class AppSettingsFragment extends Fragment { if (mAdvancedSettingsContainer.getVisibility() == View.VISIBLE) { mAdvancedSettingsContainer.startAnimation(invisibleAnimation); mAdvancedSettingsContainer.setVisibility(View.GONE); - mAdvancedSettingsButton.setText(R.string.api_settings_show_advanced); + mAdvancedSettingsButton.setText(getString(R.string.api_settings_show_advanced)); + mAdvancedSettingsButton.setLeftIcon("fa-caret-up"); } else { mAdvancedSettingsContainer.startAnimation(visibleAnimation); mAdvancedSettingsContainer.setVisibility(View.VISIBLE); - mAdvancedSettingsButton.setText(R.string.api_settings_hide_advanced); + mAdvancedSettingsButton.setText(getString(R.string.api_settings_hide_advanced)); + mAdvancedSettingsButton.setLeftIcon("fa-caret-down"); } } }); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java new file mode 100644 index 000000000..e278af5e3 --- /dev/null +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -0,0 +1,444 @@ +/* + * + * from https://github.com/tobykurien/SherlockNavigationDrawer + * + * Copyright 2013 The Android Open Source Project + * + * 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; + +import org.sufficientlysecure.keychain.R; + +import android.content.Intent; +import android.content.res.Configuration; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.view.ActionProvider; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.SubMenu; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +import com.actionbarsherlock.app.SherlockFragmentActivity; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuItem; + +/** + * 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> + */ +public class DrawerActivity extends SherlockFragmentActivity { + private DrawerLayout mDrawerLayout; + private ListView mDrawerList; + private ActionBarDrawerToggle mDrawerToggle; + + private CharSequence mDrawerTitle; + private CharSequence mTitle; + private String[] mDrawerTitles; + + protected void setupDrawerNavigation(Bundle savedInstanceState) { + // mTitle = mDrawerTitle = getTitle(); + mDrawerTitles = getResources().getStringArray(R.array.drawer_array); + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerList = (ListView) findViewById(R.id.left_drawer); + + // set a custom shadow that overlays the main content when the drawer + // 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.setOnItemClickListener(new DrawerItemClickListener()); + + // enable ActionBar app icon to behave as action to toggle nav drawer + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + + // ActionBarDrawerToggle ties together the the proper interactions + // between the sliding drawer and the action bar app icon + mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ + mDrawerLayout, /* DrawerLayout object */ + R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ + R.string.drawer_open, /* "open drawer" description for accessibility */ + R.string.drawer_close /* "close drawer" description for accessibility */ + ) { + public void onDrawerClosed(View view) { + getSupportActionBar().setTitle(mTitle); + supportInvalidateOptionsMenu(); // creates call to + // onPrepareOptionsMenu() + } + + public void onDrawerOpened(View drawerView) { + getSupportActionBar().setTitle(mDrawerTitle); + supportInvalidateOptionsMenu(); // creates call to + // onPrepareOptionsMenu() + } + }; + mDrawerLayout.setDrawerListener(mDrawerToggle); + + if (savedInstanceState == null) { + selectItem(0); + } + } + + /* Called whenever we call invalidateOptionsMenu() */ + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + // If the nav drawer is open, hide action items related to the content + // view + boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); + // menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); + return super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(final MenuItem item) { + // The action bar home/up action should open or close the drawer. + // ActionBarDrawerToggle will take care of this. + if (mDrawerToggle.onOptionsItemSelected(getMenuItem(item))) { + return true; + } + + // Handle action buttons + 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); + // intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle()); + // // catch event that there's no activity to handle intent + // if (intent.resolveActivity(getPackageManager()) != null) { + // startActivity(intent); + // } else { + // Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); + // } + // return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private android.view.MenuItem getMenuItem(final MenuItem item) { + return new android.view.MenuItem() { + @Override + public int getItemId() { + return item.getItemId(); + } + + public boolean isEnabled() { + return true; + } + + @Override + public boolean collapseActionView() { + return false; + } + + @Override + public boolean expandActionView() { + return false; + } + + @Override + public ActionProvider getActionProvider() { + return null; + } + + @Override + public View getActionView() { + return null; + } + + @Override + public char getAlphabeticShortcut() { + return 0; + } + + @Override + public int getGroupId() { + return 0; + } + + @Override + public Drawable getIcon() { + return null; + } + + @Override + public Intent getIntent() { + return null; + } + + @Override + public ContextMenuInfo getMenuInfo() { + return null; + } + + @Override + public char getNumericShortcut() { + return 0; + } + + @Override + public int getOrder() { + return 0; + } + + @Override + public SubMenu getSubMenu() { + return null; + } + + @Override + public CharSequence getTitle() { + return null; + } + + @Override + public CharSequence getTitleCondensed() { + return null; + } + + @Override + public boolean hasSubMenu() { + return false; + } + + @Override + public boolean isActionViewExpanded() { + return false; + } + + @Override + public boolean isCheckable() { + return false; + } + + @Override + public boolean isChecked() { + return false; + } + + @Override + public boolean isVisible() { + return false; + } + + @Override + public android.view.MenuItem setActionProvider(ActionProvider actionProvider) { + return null; + } + + @Override + public android.view.MenuItem setActionView(View view) { + return null; + } + + @Override + public android.view.MenuItem setActionView(int resId) { + return null; + } + + @Override + public android.view.MenuItem setAlphabeticShortcut(char alphaChar) { + return null; + } + + @Override + public android.view.MenuItem setCheckable(boolean checkable) { + return null; + } + + @Override + public android.view.MenuItem setChecked(boolean checked) { + return null; + } + + @Override + public android.view.MenuItem setEnabled(boolean enabled) { + return null; + } + + @Override + public android.view.MenuItem setIcon(Drawable icon) { + return null; + } + + @Override + public android.view.MenuItem setIcon(int iconRes) { + return null; + } + + @Override + public android.view.MenuItem setIntent(Intent intent) { + return null; + } + + @Override + public android.view.MenuItem setNumericShortcut(char numericChar) { + return null; + } + + @Override + public android.view.MenuItem setOnActionExpandListener(OnActionExpandListener listener) { + return null; + } + + @Override + public android.view.MenuItem setOnMenuItemClickListener( + OnMenuItemClickListener menuItemClickListener) { + return null; + } + + @Override + public android.view.MenuItem setShortcut(char numericChar, char alphaChar) { + return null; + } + + @Override + public void setShowAsAction(int actionEnum) { + } + + @Override + public android.view.MenuItem setShowAsActionFlags(int actionEnum) { + return null; + } + + @Override + public android.view.MenuItem setTitle(CharSequence title) { + return null; + } + + @Override + public android.view.MenuItem setTitle(int title) { + return null; + } + + @Override + public android.view.MenuItem setTitleCondensed(CharSequence title) { + return null; + } + + @Override + public android.view.MenuItem setVisible(boolean visible) { + return null; + } + }; + } + + /* The click listner for ListView in the navigation drawer */ + private class DrawerItemClickListener implements ListView.OnItemClickListener { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + selectItem(position); + } + } + + 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); + // } + + /** + * When using the ActionBarDrawerToggle, you must call it during onPostCreate() and + * onConfigurationChanged()... + */ + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + // Sync the toggle state after onRestoreInstanceState has occurred. + mDrawerToggle.syncState(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + // Pass any configuration change to the drawer toggles + 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; + // } + // } +}
\ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java index 2760df97e..3766b1c42 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyActivity.java @@ -45,8 +45,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity; * TODO: get key type by looking at dataUri! * */ -public class KeyActivity extends SherlockFragmentActivity { - +public class KeyActivity extends DrawerActivity { protected FileDialogFragment mFileDialog; protected String mExportFilename; diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java index 023c8fd9d..476d3c96c 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicActivity.java @@ -35,8 +35,8 @@ public class KeyListPublicActivity extends KeyActivity { setContentView(R.layout.key_list_public_activity); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + // now setup navigation drawer in DrawerActivity... + setupDrawerNavigation(savedInstanceState); } @Override @@ -49,13 +49,6 @@ public class KeyListPublicActivity 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_public_import: Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class); startActivityForResult(intentImportFromFile, Id.request.import_from_qr_code); diff --git a/libraries/ActionBarSherlock/libs/android-support-v4.jar b/libraries/ActionBarSherlock/libs/android-support-v4.jar Binary files differindex 99e063b33..9056828a0 100644 --- a/libraries/ActionBarSherlock/libs/android-support-v4.jar +++ b/libraries/ActionBarSherlock/libs/android-support-v4.jar diff --git a/libraries/AndroidBootstrap/libs/android-support-v4.jar b/libraries/AndroidBootstrap/libs/android-support-v4.jar Binary files differindex 99e063b33..9056828a0 100644 --- a/libraries/AndroidBootstrap/libs/android-support-v4.jar +++ b/libraries/AndroidBootstrap/libs/android-support-v4.jar |