[Android] Remove settings launcher from ListView #Material

Geoffrey Métais git at videolan.org
Wed Jan 14 16:54:38 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 14 16:49:04 2015 +0100| [42080b32c62005eff0e384466238005d0cb62308] | committer: Geoffrey Métais

Remove settings launcher from ListView #Material

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=42080b32c62005eff0e384466238005d0cb62308
---

 vlc-android/res/layout/sidebar.xml                 |   73 +++++++++++++++-----
 .../src/org/videolan/vlc/gui/MainActivity.java     |   23 ++++--
 .../src/org/videolan/vlc/gui/SidebarAdapter.java   |    2 +-
 3 files changed, 74 insertions(+), 24 deletions(-)

diff --git a/vlc-android/res/layout/sidebar.xml b/vlc-android/res/layout/sidebar.xml
index f1bf9b3..bb4e403 100644
--- a/vlc-android/res/layout/sidebar.xml
+++ b/vlc-android/res/layout/sidebar.xml
@@ -1,20 +1,59 @@
 <?xml version="1.0" encoding="utf-8"?>
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
-	<ListView
-	    android:id="@+id/sidelist"
-	    android:layout_height="match_parent"
-	    android:divider="?attr/background_menu_divider"
-	    android:dividerHeight="0.2dp"
-	    android:layout_width="208dp"
-	    android:paddingTop="?attr/actionBarSize"
-	    android:layout_gravity="start"
-	    android:cacheColorHint="#0000"
-	    android:fastScrollEnabled="true"
-	    android:background="?attr/background_menu"
-	    android:nextFocusForward="@id/sidelist"
-	    android:nextFocusUp="@id/sidelist"
-	    android:nextFocusDown="@id/sidelist"
-	    android:nextFocusLeft="@id/sidelist"
-	    android:nextFocusRight="@id/sidelist" >
-	</ListView>
+    <RelativeLayout
+        android:id="@+id/side_menu"
+        android:layout_width="208dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        android:background="?attr/background_menu">
+        <ListView
+            android:id="@+id/sidelist"
+            android:layout_width="208dp"
+            android:layout_height="match_parent"
+            android:divider="?attr/background_menu_divider"
+            android:dividerHeight="0.2dp"
+            android:paddingTop="?attr/actionBarSize"
+            android:cacheColorHint="#0000"
+            android:layout_above="@+id/sidebar_separator"
+            android:nextFocusForward="@id/sidelist"
+            android:nextFocusUp="@id/sidelist"
+            android:nextFocusDown="@id/sidelist"
+            android:nextFocusLeft="@id/sidelist"
+            android:nextFocusRight="@id/sidelist" >
+        </ListView>
+
+        <View
+            android:id="@+id/sidebar_separator"
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:layout_above="@+id/settings"
+            android:background="?attr/playlist_item_footer" />
+
+        <ImageView
+            android:id="@+id/settings_icon"
+            android:layout_width="32dp"
+            android:layout_height="32dp"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentBottom="true"
+            android:layout_margin="10dp"
+            android:clickable="true"
+            android:onClick="onClick"
+            android:src="@drawable/ic_menu_preferences"/>
+
+        <TextView
+            android:id="@+id/settings"
+            android:layout_width="match_parent"
+            android:layout_height="32dp"
+            android:layout_alignParentBottom="true"
+            android:layout_toRightOf="@+id/settings_icon"
+            android:gravity="left|center_vertical"
+            android:layout_marginTop="10dp"
+            android:layout_marginBottom="10dp"
+            android:clickable="true"
+            android:onClick="onClick"
+            android:text="@string/preferences"
+            android:textColor="?attr/list_menu"
+            android:textSize="16sp"
+            android:fontFamily="sans-serif"/>
+    </RelativeLayout>
 </merge>
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 594dd81..37424e5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -110,6 +110,7 @@ public class MainActivity extends ActionBarActivity {
     private DrawerLayout mRootContainer;
     private ListView mListView;
     private ActionBarDrawerToggle mDrawerToggle;
+    private View mSideMenu;
 
     private View mInfoLayout;
     private ProgressBar mInfoProgress;
@@ -207,6 +208,7 @@ public class MainActivity extends ActionBarActivity {
         mSlidingPane = (SlidingPaneLayout) v_main.findViewById(R.id.pane);
         mSlidingPane.setPanelSlideListener(mPanelSlideListener);
 
+        mSideMenu = v_main.findViewById(R.id.side_menu);
         mListView = (ListView)v_main.findViewById(R.id.sidelist);
         mListView.setFooterDividersEnabled(true);
         mSidebarAdapter = new SidebarAdapter(this);
@@ -250,7 +252,7 @@ public class MainActivity extends ActionBarActivity {
                 if(current == null || (entry != null && current.getTag().equals(entry.id))) { /* Already selected */
                     if (mFocusedPrior != 0)
                         findViewById(R.id.ml_menu_search).requestFocus();
-                    mRootContainer.closeDrawer(mListView);
+                    mRootContainer.closeDrawer(mSideMenu);
                     return;
                 }
 
@@ -287,7 +289,7 @@ public class MainActivity extends ActionBarActivity {
 
                     if (mFocusedPrior != 0)
                         findViewById(R.id.ml_menu_search).requestFocus();
-                    mRootContainer.closeDrawer(mListView);
+                    mRootContainer.closeDrawer(mSideMenu);
                 }else if (entry.attributeID == R.attr.ic_menu_preferences){
                     startActivityForResult(new Intent(mContext, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
                 }
@@ -311,7 +313,7 @@ public class MainActivity extends ActionBarActivity {
             mHandler.postDelayed(new Runnable() {
                 @Override
                 public void run() {
-                    mRootContainer.openDrawer(mListView);
+                    mRootContainer.openDrawer(mSideMenu);
                 }
             }, 500);
         }
@@ -448,11 +450,11 @@ public class MainActivity extends ActionBarActivity {
 
     @Override
     public void onBackPressed() {
-        if(mRootContainer.isDrawerOpen(mListView)) {
+        if(mRootContainer.isDrawerOpen(mSideMenu)) {
             /* Close the menu first */
             if (mFocusedPrior != 0)
                 findViewById(R.id.ml_menu_search).requestFocus();
-            mRootContainer.closeDrawer(mListView);
+            mRootContainer.closeDrawer(mSideMenu);
             return;
         }
 
@@ -689,7 +691,7 @@ public class MainActivity extends ActionBarActivity {
                 MediaDatabase.getInstance().clearSearchHistory();
                 break;
         }
-        mRootContainer.closeDrawer(mListView);
+        mRootContainer.closeDrawer(mSideMenu);
         return super.onOptionsItemSelected(item);
     }
 
@@ -1023,4 +1025,13 @@ public class MainActivity extends ActionBarActivity {
             }
         }
     }
+
+    public void onClick(View v){
+        switch (v.getId()){
+            case R.id.settings:
+            case R.id.settings_icon:
+                startActivityForResult(new Intent(mContext, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
+                break;
+        }
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java b/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
index fdaeaec..1610d8e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SidebarAdapter.java
@@ -86,7 +86,7 @@ public class SidebarAdapter extends BaseAdapter {
         for(SidebarEntry e : entries) {
             sidebarFragments.add(e.id);
         }
-        entries.add(new SidebarEntry(SidebarEntry.ID_PREFERENCES, R.string.preferences, R.attr.ic_menu_preferences, SidebarEntry.TYPE_ACTION));
+//        entries.add(new SidebarEntry(SidebarEntry.ID_PREFERENCES, R.string.preferences, R.attr.ic_menu_preferences, SidebarEntry.TYPE_ACTION));
     }
 
     public SidebarAdapter(Context context) {



More information about the Android mailing list