Moved settings button into navigation drawer

This commit is contained in:
daniel oeh 2014-12-04 21:31:01 +01:00
parent 6962d13974
commit 6bba71469f
15 changed files with 99 additions and 71 deletions

View File

@ -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

View File

@ -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;

View File

@ -72,15 +72,6 @@ public class PreferenceActivity extends ActionBarActivity {
preferenceController.onActivityResult(requestCode, resultCode, data);
}
@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);
@ -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:

View File

@ -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();
}
}

View File

@ -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();

View File

@ -1,14 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_list"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_layout"
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/nav_drawer_background"
android:choiceMode="singleChoice"
android:clipToPadding="false"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:paddingBottom="@dimen/list_vertical_padding"
android:paddingTop="@dimen/list_vertical_padding"
android:scrollbarStyle="outsideOverlay" />
android:orientation="vertical">
<ListView
android:id="@+id/nav_list"
android:layout_width="@dimen/drawer_width"
android:layout_height="0dp"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:clipToPadding="false"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:paddingBottom="@dimen/list_vertical_padding"
android:paddingTop="@dimen/list_vertical_padding"
android:scrollbarStyle="outsideOverlay" />
<View
android:layout_width="@dimen/drawer_width"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:background="@color/gray" />
<LinearLayout
android:id="@+id/nav_settings"
android:layout_width="@dimen/drawer_width"
android:layout_height="@dimen/listitem_iconwithtext_height"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/settings_label"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgvCover"
android:layout_width="@dimen/thumbnail_length_navlist"
android:layout_height="@dimen/thumbnail_length_navlist"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="@dimen/listitem_icon_leftpadding"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:contentDescription="@string/cover_label"
android:cropToPadding="true"
android:padding="8dp"
android:scaleType="centerCrop"
android:src="?attr/ic_settings" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_margin="16dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/settings_label"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_size_navdrawer" />
</LinearLayout>
</LinearLayout>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/show_preferences"
android:title="@string/settings_label"
android:menuCategory="system"
custom:showAsAction="collapseActionView"/>
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

View File

@ -35,6 +35,7 @@
<attr name="av_pause_big" format="reference"/>
<attr name="av_ff_big" format="reference"/>
<attr name="av_rew_big" format="reference"/>
<attr name="ic_settings" format="reference"/>
<!-- Used in itemdescription -->
<attr name="non_transparent_background" format="reference"/>

View File

@ -40,6 +40,7 @@
<item name="attr/av_pause_big">@drawable/ic_pause_grey600_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_grey600_36dp</item>
<item name="attr/av_rew_big">@drawable/ic_fast_rewind_grey600_36dp</item>
<item name="attr/ic_settings">@drawable/ic_settings_grey600_24dp</item>
</style>
<style name="Theme.AntennaPod.Dark" parent="@style/Theme.AppCompat">
@ -80,6 +81,7 @@
<item name="attr/av_pause_big">@drawable/ic_pause_white_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_white_36dp</item>
<item name="attr/av_rew_big">@drawable/ic_fast_rewind_white_36dp</item>
<item name="attr/ic_settings">@drawable/ic_settings_white_24dp</item>
</style>
<style name="Theme.AntennaPod.Light.NoTitle" parent="@style/Theme.AppCompat.Light.NoActionBar">
@ -122,6 +124,7 @@
<item name="attr/av_pause_big">@drawable/ic_pause_grey600_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_grey600_36dp</item>
<item name="attr/av_rew_big">@drawable/ic_fast_rewind_grey600_36dp</item>
<item name="attr/ic_settings">@drawable/ic_settings_grey600_24dp</item>
</style>
<style name="Theme.AntennaPod.Dark.NoTitle" parent="@style/Theme.AppCompat.NoActionBar">
@ -163,6 +166,7 @@
<item name="attr/av_pause_big">@drawable/ic_pause_white_36dp</item>
<item name="attr/av_ff_big">@drawable/ic_fast_forward_white_36dp</item>
<item name="attr/av_rew_big">@drawable/ic_fast_rewind_white_36dp</item>
<item name="attr/ic_settings">@drawable/ic_settings_white_24dp</item>
</style>
<style name="Theme.AntennaPod.VideoPlayer" parent="@style/Theme.AntennaPod.Dark">