OSDN Git Service

Eleven: Change order of overflow menu
authorlinus_lee <llee@cyngn.com>
Tue, 14 Oct 2014 02:09:31 +0000 (19:09 -0700)
committerlinus_lee <llee@cyngn.com>
Thu, 20 Nov 2014 20:51:32 +0000 (12:51 -0800)
https://cyanogen.atlassian.net/browse/MUSIC-116
https://cyanogen.atlassian.net/browse/MUSIC-128

This fix could be better longer-term by potentially switching to enums,
but given time constraints and the impact of this bug, this solution is sufficient

Change-Id: I880e8aa5d3ffc6e60865dfcd755146d0dba961f8

res/menu/album_sort_by.xml
res/menu/artist_sort_by.xml
res/menu/clear_list.xml
res/menu/new_playlist.xml
res/menu/song_sort_by.xml
src/com/cyngn/eleven/menu/FragmentMenuItems.java
src/com/cyngn/eleven/ui/fragments/PlaylistDetailFragment.java
src/com/cyngn/eleven/utils/PopupMenuHelper.java

index 1d9207a..2c96b13 100644 (file)
@@ -19,7 +19,7 @@
     <item
         android:id="@+id/menu_sort_by"
         android:showAsAction="never"
-        android:orderInCategory="120"
+        android:orderInCategory="200"
         android:title="@string/menu_sort_by">
         <menu>
             <item
index 1350f8d..06e23a9 100644 (file)
@@ -19,7 +19,7 @@
     <item
         android:id="@+id/menu_sort_by"
         android:showAsAction="never"
-        android:orderInCategory="120"
+        android:orderInCategory="200"
         android:title="@string/menu_sort_by">
         <menu>
             <item
index 020df38..a600280 100644 (file)
@@ -19,7 +19,7 @@
     <item
         android:id="@+id/clear_list"
         android:showAsAction="never"
-        android:orderInCategory="110"
+        android:orderInCategory="150"
         android:title="@string/menu_clear_list"/>
 
 </menu>
\ No newline at end of file
index 3e5886c..7e7e606 100644 (file)
@@ -19,7 +19,7 @@
     <item
         android:id="@+id/menu_new_playlist"
         android:showAsAction="never"
-        android:orderInCategory="100"
+        android:orderInCategory="130"
         android:title="@string/new_playlist"/>
 
 </menu>
\ No newline at end of file
index ea1044c..d09ae77 100644 (file)
@@ -19,7 +19,7 @@
     <item
         android:id="@+id/menu_sort_by"
         android:showAsAction="never"
-        android:orderInCategory="120"
+        android:orderInCategory="200"
         android:title="@string/menu_sort_by">
         <menu>
             <item
index 18570e9..014ed82 100644 (file)
@@ -13,55 +13,26 @@ package com.cyngn.eleven.menu;
 
 /**
  * Several of the context menu items used in Apollo are reused. This class helps
- * keep things tidy.
- * 
- * @author Andrew Neal (andrewdneal@gmail.com)
+ * keep things tidy. The integer values of the items are used both as the menu IDs
+ * _and_ to determine the sort order of the items.
  */
-public class FragmentMenuItems {
-
-    /* Removes a single album from the recents pages */
-    public static final int REMOVE_FROM_RECENT = 0;
-
-    /* Used to play the selected artist, album, song, playlist, or genre */
-    public static final int PLAY_SELECTION = 1;
-
-    /* Used to add to the qeueue */
-    public static final int ADD_TO_QUEUE = 2;
-
-    /* Used to add to a playlist */
-    public static final int ADD_TO_PLAYLIST = 3;
-
-    /* Used to create a new playlist */
-    public static final int NEW_PLAYLIST = 5;
-
-    /* Used to rename a playlist */
-    public static final int RENAME_PLAYLIST = 6;
-
-    /* Used to add to a current playlist */
-    public static final int PLAYLIST_SELECTED = 7;
-
-    /* Used to show more content by an artist */
-    public static final int MORE_BY_ARTIST = 8;
-
-    /* Used to delete track(s) */
-    public static final int DELETE = 9;
-
-    /* Used to fetch an artist image */
-    public static final int FETCH_ARTIST_IMAGE = 10;
-
-    /* Used to fetch album art */
-    public static final int FETCH_ALBUM_ART = 11;
-
-    /* Used to set a track as a ringtone */
-    public static final int USE_AS_RINGTONE = 12;
-
-    /* Used to remove a track from a playlist */
-    public static final int REMOVE_FROM_PLAYLIST = 14;
-
-    /* Used to remove a track from the queue */
-    public static final int REMOVE_FROM_QUEUE = 15;
-
-    /* Used to queue a track to be played next */
-    public static final int PLAY_NEXT = 16;
-
-}
+public interface FragmentMenuItems {
+    int PLAY_SELECTION      =  10; // play the selected song, album, etc.
+    int PLAY_NEXT           =  20; // queue a track to be played next
+    //  SHUFFLE             =  30  // defined in res/menu
+    int ADD_TO_QUEUE        =  40; // add to end of current queue
+    int ADD_TO_PLAYLIST     =  50; // append to a playlist
+    int REMOVE_FROM_QUEUE   =  60; // remove track from play queue
+    int REMOVE_FROM_PLAYLIST=  70; // remove track from playlist
+    int REMOVE_FROM_RECENT  =  80; // remove track from recently played list
+    int RENAME_PLAYLIST     =  90; // change name of playlist
+    int MORE_BY_ARTIST      = 100; // jump to artist detail page
+    int USE_AS_RINGTONE     = 110; // set track as ringtone
+    int DELETE              = 120; // delete track from device
+    int NEW_PLAYLIST        = 130; // create new playlist - also in res/menu!
+    int PLAYLIST_SELECTED   = 140; // this is used for existing playlists
+
+    // not currently in use
+    int FETCH_ARTIST_IMAGE  = 200;
+    int FETCH_ALBUM_ART     = 210;
+}
\ No newline at end of file
index 3a3d849..4870aff 100644 (file)
@@ -134,6 +134,7 @@ public class PlaylistDetailFragment extends FadingBarFragment implements
                 super.updateMenuIds(type, set);
 
                 set.add(FragmentMenuItems.REMOVE_FROM_PLAYLIST);
+                set.remove(FragmentMenuItems.DELETE);
             }
 
             @Override
index faddd31..46e1536 100644 (file)
@@ -225,25 +225,6 @@ public abstract class PopupMenuHelper implements PopupMenu.OnMenuItemClickListen
         return null;
     }
 
-    // FIXME: after merging http://gerrit.cyngn.com/#/c/4056/ remove this
-    // method and change the FragmentMenuItem IDs to so they can also double
-    // as the order values - changing addToMenu below as well
-    private int getMenuItemOrder(int menuId) {
-        switch(menuId) {
-            case FragmentMenuItems.PLAY_SELECTION: return 10;
-            case FragmentMenuItems.PLAY_NEXT: return 20;
-            // order 30 is reserved for SHUFFLE items
-            case FragmentMenuItems.ADD_TO_QUEUE: return 40;
-            case FragmentMenuItems.ADD_TO_PLAYLIST: return 50;
-            case FragmentMenuItems.REMOVE_FROM_QUEUE: return 60;
-            case FragmentMenuItems.RENAME_PLAYLIST: return 70;
-            case FragmentMenuItems.MORE_BY_ARTIST: return 80;
-            case FragmentMenuItems.USE_AS_RINGTONE: return 90;
-            case FragmentMenuItems.DELETE: return 100;
-            default: return 110;
-        }
-    }
-
     /**
      * Allows containing classes to add/remove ids to the menu
      * @param type the pop up menu type
@@ -309,7 +290,7 @@ public abstract class PopupMenuHelper implements PopupMenu.OnMenuItemClickListen
      * Simple helper function for adding an item to the menu
      */
     public void addToMenu(final Menu menu, final int id, final int resourceId) {
-        menu.add(getGroupId(), id, getMenuItemOrder(id), mActivity.getString(resourceId));
+        menu.add(getGroupId(), id, id /*as order*/, mActivity.getString(resourceId));
     }
 
     @Override