preferences and help into menu not drawer according to guidelines and google apps

This commit is contained in:
Dominik Schürmann
2014-01-09 23:51:23 +01:00
parent 37fd7dbbc7
commit 3abad09cb0
6 changed files with 247 additions and 22 deletions

View File

@@ -60,8 +60,10 @@ public class DrawerActivity extends SherlockFragmentActivity {
private static Class[] mItemsClass = new Class[] { KeyListPublicActivity.class,
EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class,
KeyListSecretActivity.class, PreferencesActivity.class,
RegisteredAppsListActivity.class, HelpActivity.class };
KeyListSecretActivity.class, RegisteredAppsListActivity.class };
private static final int MENU_ID_PREFERENCE = 222;
private static final int MENU_ID_HELP = 223;
protected void setupDrawerNavigation(Bundle savedInstanceState) {
mDrawerTitle = getString(R.string.app_name);
@@ -78,9 +80,7 @@ public class DrawerActivity extends SherlockFragmentActivity {
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)), };
new NavItem("fa-android", getString(R.string.nav_apps)) };
mDrawerList.setAdapter(new NavigationDrawerAdapter(this, R.layout.drawer_list_item,
mItemIconTexts));
@@ -119,6 +119,14 @@ public class DrawerActivity extends SherlockFragmentActivity {
// }
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(42, MENU_ID_PREFERENCE, 100, R.string.menu_preferences);
menu.add(42, MENU_ID_HELP, 101, R.string.menu_help);
return super.onCreateOptionsMenu(menu);
}
/* Called whenever we call invalidateOptionsMenu() */
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
@@ -137,7 +145,20 @@ public class DrawerActivity extends SherlockFragmentActivity {
return true;
}
return super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case MENU_ID_PREFERENCE: {
Intent intent = new Intent(this, PreferencesActivity.class);
startActivity(intent);
return true;
}
case MENU_ID_HELP: {
Intent intent = new Intent(this, HelpActivity.class);
startActivity(intent);
return true;
}
default:
return super.onOptionsItemSelected(item);
}
// Handle action buttons
// switch (item.getItemId()) {
@@ -365,7 +386,7 @@ public class DrawerActivity extends SherlockFragmentActivity {
};
}
/* The click listner for ListView in the navigation drawer */
/* The click listener for ListView in the navigation drawer */
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

View File

@@ -34,7 +34,7 @@ import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;
public class HelpActivity extends DrawerActivity {
public class HelpActivity extends SherlockFragmentActivity {
public static final String EXTRA_SELECTED_TAB = "selectedTab";
ViewPager mViewPager;
@@ -50,10 +50,11 @@ public class HelpActivity extends DrawerActivity {
mViewPager = (ViewPager) findViewById(R.id.pager);
setupDrawerNavigation(savedInstanceState);
ActionBar bar = getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mTabsAdapter = new TabsAdapter(this, mViewPager);
@@ -65,20 +66,20 @@ public class HelpActivity extends DrawerActivity {
Bundle startBundle = new Bundle();
startBundle.putInt(HelpFragmentHtml.ARG_HTML_FILE, R.raw.help_start);
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_start)),
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_start)),
HelpFragmentHtml.class, startBundle, (selectedTab == 0 ? true : false));
Bundle nfcBundle = new Bundle();
nfcBundle.putInt(HelpFragmentHtml.ARG_HTML_FILE, R.raw.help_nfc_beam);
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_nfc_beam)),
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_nfc_beam)),
HelpFragmentHtml.class, nfcBundle, (selectedTab == 1 ? true : false));
Bundle changelogBundle = new Bundle();
changelogBundle.putInt(HelpFragmentHtml.ARG_HTML_FILE, R.raw.help_changelog);
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_changelog)),
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_changelog)),
HelpFragmentHtml.class, changelogBundle, (selectedTab == 2 ? true : false));
mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.help_tab_about)),
mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_about)),
HelpFragmentAbout.class, null, (selectedTab == 3 ? true : false));
}

View File

@@ -51,8 +51,8 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(false);
addPreferencesFromResource(R.xml.preferences);
@@ -218,5 +218,4 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
}
}
}
}