aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-30 14:00:45 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-30 14:00:45 -0800
commit6df08e25f5dc7715b2b61f34f2d46e19d766e98d (patch)
treead8df929ec3ae942d05e1969f0a26f0e33bbba9b
parente76d66e73b1a493eb513eead749d47656a6b9f18 (diff)
downloaddsub-6df08e25f5dc7715b2b61f34f2d46e19d766e98d.tar.gz
dsub-6df08e25f5dc7715b2b61f34f2d46e19d766e98d.tar.bz2
dsub-6df08e25f5dc7715b2b61f34f2d46e19d766e98d.zip
#181 Work around for tablet context menus
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SearchFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectArtistFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java9
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java13
8 files changed, 32 insertions, 32 deletions
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index 0d865fe8..a190369d 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -95,9 +95,6 @@ public class MainFragment extends SubsonicFragment {
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
int serverCount = Util.getServerCount(context);
int activeServer = Util.getActiveServer(context);
@@ -109,11 +106,13 @@ public class MainFragment extends SubsonicFragment {
}
menu.setGroupCheckable(MENU_GROUP_SERVER, true, true);
menu.setHeaderTitle(R.string.main_select_server);
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(android.view.MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java
index 0e084c69..95810db0 100644
--- a/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -151,9 +151,6 @@ public class SearchFragment extends SubsonicFragment {
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Object selectedItem = list.getItemAtPosition(info.position);
@@ -161,11 +158,13 @@ public class SearchFragment extends SubsonicFragment {
if(selectedItem instanceof MusicDirectory.Entry && !((MusicDirectory.Entry) selectedItem).isVideo() && !Util.isOffline(context)) {
menu.removeItem(R.id.song_menu_remove_playlist);
}
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index 81fc362b..fbe54cee 100644
--- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -110,9 +110,6 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Object entry = artistList.getItemAtPosition(info.position);
@@ -136,11 +133,13 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
}
menu.setGroupCheckable(MENU_GROUP_MUSIC_FOLDER, true, true);
}
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index c13776dd..9ea43395 100644
--- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -109,9 +109,6 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
MenuInflater inflater = context.getMenuInflater();
inflater.inflate(R.menu.select_bookmark_context, menu);
@@ -119,10 +116,6 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
- return false;
- }
-
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
Bookmark bookmark = bookmarks.get(info.position);
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 47e842c7..a8169a1e 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -238,9 +238,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
@@ -255,14 +252,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
menu.removeItem(R.id.song_menu_server_download);
}
}
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
-
+
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
Object selectedItem = entries.get(showHeader ? (info.position - 1) : info.position);
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index e6a49db1..93e54ce4 100644
--- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -95,9 +95,6 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
MenuInflater inflater = context.getMenuInflater();
if (Util.isOffline(context)) {
@@ -114,11 +111,13 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
menu.removeItem(R.id.playlist_menu_stop_sync);
}
}
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index 8b83a0c5..1ff51813 100644
--- a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -126,9 +126,6 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- if(!primaryFragment) {
- return;
- }
if(!Util.isOffline(context)) {
android.view.MenuInflater inflater = context.getMenuInflater();
@@ -142,11 +139,13 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
menu.removeItem(R.id.podcast_menu_stop_sync);
}
}
+
+ recreateContextMenu(menu);
}
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
- if(!primaryFragment) {
+ if(menuItem.getGroupId() != getSupportTag()) {
return false;
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index d8de9982..48157c34 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -33,6 +33,7 @@ import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.ContextMenu;
import android.view.GestureDetector;
+import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
@@ -203,6 +204,18 @@ public class SubsonicFragment extends Fragment {
}
}
+ protected void recreateContextMenu(ContextMenu menu) {
+ List<MenuItem> menuItems = new ArrayList<MenuItem>();
+ for(int i = 0; i < menu.size(); i++) {
+ menuItems.add(menu.getItem(i));
+ }
+ menu.clear();
+ for(int i = 0; i < menuItems.size(); i++) {
+ MenuItem item = menuItems.get(i);
+ menu.add(tag, item.getItemId(), Menu.NONE, item.getTitle());
+ }
+ }
+
public boolean onContextItemSelected(MenuItem menuItem, Object selectedItem) {
Artist artist = selectedItem instanceof Artist ? (Artist) selectedItem : null;
MusicDirectory.Entry entry = selectedItem instanceof MusicDirectory.Entry ? (MusicDirectory.Entry) selectedItem : null;