Remove checks for opened drawer, now unneccessary

This commit is contained in:
Martin Fietz 2015-04-18 22:12:26 +02:00
parent 3bf2b109bb
commit 9c2f46e5e4
11 changed files with 77 additions and 126 deletions

View File

@ -46,7 +46,6 @@ import de.danoeh.antennapod.core.util.playback.PlaybackController;
import de.danoeh.antennapod.dialog.VariableSpeedDialog; import de.danoeh.antennapod.dialog.VariableSpeedDialog;
import de.danoeh.antennapod.fragment.CoverFragment; import de.danoeh.antennapod.fragment.CoverFragment;
import de.danoeh.antennapod.fragment.ItemDescriptionFragment; import de.danoeh.antennapod.fragment.ItemDescriptionFragment;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity; import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.danoeh.antennapod.preferences.PreferenceController; import de.danoeh.antennapod.preferences.PreferenceController;
@ -413,26 +412,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
butShowCover = (ImageButton) findViewById(R.id.butCover); butShowCover = (ImageButton) findViewById(R.id.butCover);
txtvTitle = (TextView) findViewById(R.id.txtvTitle); txtvTitle = (TextView) findViewById(R.id.txtvTitle);
/* drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) {
CharSequence currentTitle = getSupportActionBar().getTitle();
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
currentTitle = getSupportActionBar().getTitle();
getSupportActionBar().setTitle(R.string.app_name);
supportInvalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
getSupportActionBar().setTitle(currentTitle);
supportInvalidateOptionsMenu();
}
}; */
drawerToggle.setDrawerIndicatorEnabled(false); drawerToggle.setDrawerIndicatorEnabled(false);
drawerLayout.setDrawerListener(drawerToggle); drawerLayout.setDrawerListener(drawerToggle);
@ -638,20 +618,12 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
if (!MenuItemUtils.isActivityDrawerOpen(this)) { return super.onCreateOptionsMenu(menu);
return super.onCreateOptionsMenu(menu);
} else {
return false;
}
} }
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
if (!MenuItemUtils.isActivityDrawerOpen(this)) { return super.onPrepareOptionsMenu(menu);
return super.onPrepareOptionsMenu(menu);
} else {
return false;
}
} }
public interface AudioplayerContentFragment { public interface AudioplayerContentFragment {

View File

@ -113,28 +113,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
navList = (ListView) findViewById(R.id.nav_list); navList = (ListView) findViewById(R.id.nav_list);
navDrawer = findViewById(R.id.nav_layout); navDrawer = findViewById(R.id.nav_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) { drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close);
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
//currentTitle = getSupportActionBar().getTitle();
//getSupportActionBar().setTitle(drawerTitle);
//supportInvalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
//getSupportActionBar().setTitle(currentTitle);
//supportInvalidateOptionsMenu();
}
};
if (savedInstanceState != null) { if (savedInstanceState != null) {
int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0); int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0);
drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0); drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0);
} }
drawerLayout.setDrawerListener(drawerToggle); drawerLayout.setDrawerListener(drawerToggle);
final FragmentManager fm = getSupportFragmentManager(); final FragmentManager fm = getSupportFragmentManager();

View File

@ -194,7 +194,7 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
inflater.inflate(R.menu.new_episodes, menu); inflater.inflate(R.menu.new_episodes, menu);
final SearchView sv = new SearchView(getActivity()); final SearchView sv = new SearchView(getActivity());
@ -220,7 +220,7 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
MenuItem menuItem = menu.findItem(R.id.mark_all_read_item); MenuItem menuItem = menu.findItem(R.id.mark_all_read_item);
if (menuItem != null) { if (menuItem != null) {
menuItem.setVisible(unreadItems != null && !unreadItems.isEmpty()); menuItem.setVisible(unreadItems != null && !unreadItems.isEmpty());

View File

@ -20,8 +20,6 @@ import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.service.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.DownloadStatus;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/** /**
* Shows the download log * Shows the download log
@ -119,7 +117,7 @@ public class DownloadLogFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);
MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard}); TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard});
@ -131,8 +129,11 @@ public class DownloadLogFragment extends ListFragment {
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
menu.findItem(R.id.clear_history_item).setVisible(downloadLog != null && !downloadLog.isEmpty()); MenuItem menuItem = menu.findItem(R.id.clear_history_item);
if(menuItem != null) {
menuItem.setVisible(downloadLog != null && !downloadLog.isEmpty());
}
} }
} }

View File

@ -180,7 +180,7 @@ public class ItemlistFragment extends ListFragment {
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
FeedMenuHandler.onCreateOptionsMenu(inflater, menu); FeedMenuHandler.onCreateOptionsMenu(inflater, menu);
final SearchView sv = new SearchView(getActivity()); final SearchView sv = new SearchView(getActivity());
@ -207,7 +207,7 @@ public class ItemlistFragment extends ListFragment {
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
FeedMenuHandler.onPrepareOptionsMenu(menu, feed); FeedMenuHandler.onPrepareOptionsMenu(menu, feed);
} }
} }

View File

@ -32,8 +32,6 @@ import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
public class PlaybackHistoryFragment extends ListFragment { public class PlaybackHistoryFragment extends ListFragment {
@ -141,7 +139,7 @@ public class PlaybackHistoryFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);
MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard}); TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard});
@ -153,7 +151,7 @@ public class PlaybackHistoryFragment extends ListFragment {
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
MenuItem menuItem = menu.findItem(R.id.clear_history_item); MenuItem menuItem = menu.findItem(R.id.clear_history_item);
if (menuItem != null) { if (menuItem != null) {
menuItem.setVisible(playbackHistory != null && !playbackHistory.isEmpty()); menuItem.setVisible(playbackHistory != null && !playbackHistory.isEmpty());

View File

@ -202,7 +202,7 @@ public class QueueFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
inflater.inflate(R.menu.queue, menu); inflater.inflate(R.menu.queue, menu);
final SearchView sv = new SearchView(getActivity()); final SearchView sv = new SearchView(getActivity());

View File

@ -25,8 +25,6 @@ import de.danoeh.antennapod.core.feed.FeedComponent;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.SearchResult; import de.danoeh.antennapod.core.feed.SearchResult;
import de.danoeh.antennapod.core.storage.FeedSearcher; import de.danoeh.antennapod.core.storage.FeedSearcher;
import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/** /**
* Performs a search operation on all feeds or one specific feed and displays the search result. * Performs a search operation on all feeds or one specific feed and displays the search result.
@ -134,7 +132,7 @@ public class SearchFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { if (itemsLoaded) {
MenuItem item = menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label); MenuItem item = menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
final SearchView sv = new SearchView(getActivity()); final SearchView sv = new SearchView(getActivity());

View File

@ -6,8 +6,18 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log; import android.util.Log;
import android.view.*; import android.view.LayoutInflater;
import android.widget.*; import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.List;
import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
@ -19,9 +29,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast;
import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
import java.util.List;
/** /**
* Displays a list of GPodnetPodcast-Objects in a GridView * Displays a list of GPodnetPodcast-Objects in a GridView
@ -43,24 +50,22 @@ public abstract class PodcastListFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { final android.support.v7.widget.SearchView sv = new android.support.v7.widget.SearchView(getActivity());
final android.support.v7.widget.SearchView sv = new android.support.v7.widget.SearchView(getActivity()); MenuItemUtils.addSearchItem(menu, sv);
MenuItemUtils.addSearchItem(menu, sv); sv.setQueryHint(getString(R.string.gpodnet_search_hint));
sv.setQueryHint(getString(R.string.gpodnet_search_hint)); sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() { @Override
@Override public boolean onQueryTextSubmit(String s) {
public boolean onQueryTextSubmit(String s) { sv.clearFocus();
sv.clearFocus(); ((MainActivity) getActivity()).loadChildFragment(SearchListFragment.newInstance(s));
((MainActivity) getActivity()).loadChildFragment(SearchListFragment.newInstance(s)); return true;
return true; }
}
@Override @Override
public boolean onQueryTextChange(String s) { public boolean onQueryTextChange(String s) {
return false; return false;
} }
}); });
}
} }
@Override @Override

View File

@ -14,7 +14,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast;
import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
/** /**
* Performs a search on the gpodder.net directory and displays the results. * Performs a search on the gpodder.net directory and displays the results.
@ -46,24 +45,22 @@ public class SearchListFragment extends PodcastListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
final SearchView sv = new SearchView(getActivity()); final SearchView sv = new SearchView(getActivity());
if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { MenuItemUtils.addSearchItem(menu, sv);
MenuItemUtils.addSearchItem(menu, sv); sv.setQueryHint(getString(R.string.gpodnet_search_hint));
sv.setQueryHint(getString(R.string.gpodnet_search_hint)); sv.setQuery(query, false);
sv.setQuery(query, false); sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override
@Override public boolean onQueryTextSubmit(String s) {
public boolean onQueryTextSubmit(String s) { sv.clearFocus();
sv.clearFocus(); changeQuery(s);
changeQuery(s); return true;
return true; }
}
@Override @Override
public boolean onQueryTextChange(String s) { public boolean onQueryTextChange(String s) {
return false; return false;
} }
}); });
}
} }
@Override @Override

View File

@ -21,7 +21,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService;
import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag;
import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.menuhandler.NavDrawerActivity;
public class TagListFragment extends ListFragment { public class TagListFragment extends ListFragment {
private static final String TAG = "TagListFragment"; private static final String TAG = "TagListFragment";
@ -36,27 +35,25 @@ public class TagListFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { final SearchView sv = new SearchView(getActivity());
final SearchView sv = new SearchView(getActivity()); MenuItemUtils.addSearchItem(menu, sv);
MenuItemUtils.addSearchItem(menu, sv); sv.setQueryHint(getString(R.string.gpodnet_search_hint));
sv.setQueryHint(getString(R.string.gpodnet_search_hint)); sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override
@Override public boolean onQueryTextSubmit(String s) {
public boolean onQueryTextSubmit(String s) { Activity activity = getActivity();
Activity activity = getActivity(); if (activity != null) {
if (activity != null) { sv.clearFocus();
sv.clearFocus(); ((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s));
((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s));
}
return true;
} }
return true;
}
@Override @Override
public boolean onQueryTextChange(String s) { public boolean onQueryTextChange(String s) {
return false; return false;
} }
}); });
}
} }
@Override @Override