diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-12-04 21:31:01 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-12-19 19:47:38 +0100 |
commit | 6bba71469f1eb4d26ba4966f8e1febbe275f1782 (patch) | |
tree | ffdc2ddf1dd273efebbd48977af7cbf54121a628 /app/src/main/java/de/danoeh | |
parent | 6962d139746347aff034e3a84eaecf3e98062160 (diff) | |
download | AntennaPod-6bba71469f1eb4d26ba4966f8e1febbe275f1782.zip |
Moved settings button into navigation drawer
Diffstat (limited to 'app/src/main/java/de/danoeh')
5 files changed, 32 insertions, 50 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index f124de947..897e10d76 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -48,6 +48,7 @@ import de.danoeh.antennapod.fragment.CoverFragment; import de.danoeh.antennapod.fragment.ItemDescriptionFragment; import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.NavDrawerActivity; +import de.danoeh.antennapod.preferences.PreferenceController; /** * Activity for playing audio files. @@ -68,6 +69,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc private DrawerLayout drawerLayout; private NavListAdapter navAdapter; private ListView navList; + private View navDrawer; private ActionBarDrawerToggle drawerToggle; private Fragment[] detachedFragments; @@ -426,6 +428,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc getSupportActionBar().setDisplayHomeAsUpEnabled(true); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navList = (ListView) findViewById(R.id.nav_list); + navDrawer = findViewById(R.id.nav_layout); butPlaybackSpeed = (Button) findViewById(R.id.butPlaybackSpeed); butNavChaptersShownotes = (ImageButton) findViewById(R.id.butNavChaptersShownotes); butShowCover = (ImageButton) findViewById(R.id.butCover); @@ -465,11 +468,19 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc intent.putExtra(MainActivity.EXTRA_NAV_INDEX, relPos); startActivity(intent); } - drawerLayout.closeDrawer(navList); + drawerLayout.closeDrawer(navDrawer); } }); drawerToggle.syncState(); + findViewById(R.id.nav_settings).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + drawerLayout.closeDrawer(navDrawer); + startActivity(new Intent(AudioplayerActivity.this, PreferenceController.getPreferenceActivity())); + } + }); + butNavChaptersShownotes.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -644,7 +655,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override public boolean isDrawerOpen() { - return drawerLayout != null && navList != null && drawerLayout.isDrawerOpen(navList); + return drawerLayout != null && navDrawer != null && drawerLayout.isDrawerOpen(navDrawer); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index df6ff1046..7d242dece 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -15,8 +15,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarDrawerToggle; import android.util.Log; -import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; @@ -71,6 +69,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity private ExternalPlayerFragment externalPlayerFragment; private DrawerLayout drawerLayout; + private View navDrawer; private ListView navList; private NavListAdapter navAdapter; @@ -90,8 +89,10 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity drawerTitle = currentTitle = getTitle(); + drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navList = (ListView) findViewById(R.id.nav_list); + navDrawer = findViewById(R.id.nav_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) { @Override @@ -134,6 +135,14 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity navList.setAdapter(navAdapter); navList.setOnItemClickListener(navListClickListener); + findViewById(R.id.nav_settings).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + drawerLayout.closeDrawer(navDrawer); + startActivity(new Intent(MainActivity.this, PreferenceController.getPreferenceActivity())); + } + }); + checkFirstLaunch(); } @@ -143,7 +152,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity new Handler().postDelayed(new Runnable() { @Override public void run() { - drawerLayout.openDrawer(navList); + drawerLayout.openDrawer(navDrawer); } }, 1500); @@ -158,7 +167,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity } public boolean isDrawerOpen() { - return drawerLayout != null && navList != null && drawerLayout.isDrawerOpen(navList); + return drawerLayout != null && navDrawer != null && drawerLayout.isDrawerOpen(navDrawer); } public List<Feed> getFeeds() { @@ -251,7 +260,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity selectedNavListIndex = position; navAdapter.notifyDataSetChanged(); } - drawerLayout.closeDrawer(navList); + drawerLayout.closeDrawer(navDrawer); } }; @@ -261,7 +270,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity drawerToggle.syncState(); if (savedInstanceState != null) { currentTitle = savedInstanceState.getString("title"); - if (!drawerLayout.isDrawerOpen(navList)) { + if (!drawerLayout.isDrawerOpen(navDrawer)) { getSupportActionBar().setTitle(currentTitle); } selectedNavListIndex = savedInstanceState.getInt("selectedNavIndex"); @@ -312,29 +321,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity public boolean onOptionsItemSelected(MenuItem item) { if (drawerToggle.onOptionsItemSelected(item)) { return true; - } - switch (item.getItemId()) { - case R.id.show_preferences: - startActivity(new Intent(this, PreferenceController.getPreferenceActivity())); - return true; - default: - return super.onOptionsItemSelected(item); + } else { + return super.onOptionsItemSelected(item); } } - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - return true; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.main, menu); - return true; - } private DBReader.NavDrawerData navDrawerData; private AsyncTask<Void, Void, DBReader.NavDrawerData> loadTask; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java index c40489374..3802de2a6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -73,15 +73,6 @@ public class PreferenceActivity extends ActionBarActivity { } @Override - public void onBackPressed() { - // The default back button behavior has to be overwritten because changing the theme clears the back stack - Intent destIntent = new Intent(this, MainActivity.class); - destIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(destIntent); - finish(); - } - - @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); return true; @@ -91,9 +82,6 @@ public class PreferenceActivity extends ActionBarActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - Intent destIntent = new Intent(this, MainActivity.class); - destIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(destIntent); finish(); return true; default: diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivityGingerbread.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivityGingerbread.java index c58593f77..633f8d66d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivityGingerbread.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivityGingerbread.java @@ -84,13 +84,4 @@ public class PreferenceActivityGingerbread extends android.preference.Preference ); return false; } - - @Override - public void onBackPressed() { - // The default back button behavior has to be overwritten because changing the theme clears the back stack - Intent destIntent = new Intent(this, MainActivity.class); - destIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(destIntent); - finish(); - } } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 41930a7f2..cbd5c0f29 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -24,6 +24,7 @@ import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.AboutActivity; import de.danoeh.antennapod.activity.DirectoryChooserActivity; +import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.activity.PreferenceActivityGingerbread; import de.danoeh.antennapod.asynctask.OpmlExportWorker; @@ -178,7 +179,7 @@ public class PreferenceController { @Override public boolean onPreferenceChange( Preference preference, Object newValue) { - Intent i = activity.getIntent(); + Intent i = new Intent(activity, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); activity.finish(); |