[Android] Show network protocole on folder icons

Geoffrey Métais git at videolan.org
Wed Dec 2 19:01:13 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec  2 19:00:47 2015 +0100| [088cf7b55ace97cc196be0d103de05c08d5439ce] | committer: Geoffrey Métais

Show network protocole on folder icons

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

 vlc-android/res/layout/directory_view_item.xml     |   11 +++++--
 .../vlc/gui/browser/BaseBrowserAdapter.java        |   21 ++++++++----
 .../vlc/gui/browser/FilePickerAdapter.java         |    4 ++-
 .../vlc/gui/browser/NetworkBrowserAdapter.java     |   34 --------------------
 .../vlc/gui/browser/NetworkBrowserFragment.java    |    2 +-
 5 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/vlc-android/res/layout/directory_view_item.xml b/vlc-android/res/layout/directory_view_item.xml
index 8f89747..a151af2 100644
--- a/vlc-android/res/layout/directory_view_item.xml
+++ b/vlc-android/res/layout/directory_view_item.xml
@@ -26,6 +26,9 @@
         <variable
             name="checked"
             type="boolean"/>
+        <variable
+            name="protocole"
+            type="String"/>
     </data>
     <LinearLayout
         android:id="@+id/layout_item"
@@ -50,15 +53,19 @@
             android:tag="@{position}"
             android:onClick="@{handler.onCheckBoxClick}"/>
 
-        <ImageView
+        <TextView
             android:id="@+id/dvi_icon"
             android:layout_width="@dimen/directory_browser_item_size"
             android:layout_height="@dimen/directory_browser_item_size"
             android:layout_gravity="center"
+            android:gravity="center"
             android:layout_marginLeft="15dp"
             android:contentDescription="@string/cover_art"
             android:visibility="@{type != 2 ? View.VISIBLE : View.GONE}"
-            android:src="@drawable/icon" />
+            android:background="@drawable/icon"
+            android:text="@{protocole}"
+            android:textSize="11sp"
+            android:textColor="@color/whitetransparent"/>
 
         <LinearLayout
             android:layout_width="0dp"
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 0a562a4..8a571ad 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -25,11 +25,12 @@ package org.videolan.vlc.gui.browser;
 import android.databinding.DataBindingUtil;
 import android.net.Uri;
 import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.CheckBox;
-import android.widget.ImageView;
+import android.widget.TextView;
 
 import org.videolan.libvlc.Media;
 import org.videolan.vlc.R;
@@ -108,9 +109,10 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
         vh.binding.setMedia(media);
         vh.binding.setHasContextMenu(hasContextMenu);
         vh.binding.setType(TYPE_MEDIA);
+        vh.binding.setProtocole(getProtocole(media));
         vh.binding.executePendingBindings();
 
-        vh.icon.setImageResource(getIconResId(media));
+        vh.icon.setBackgroundResource(getIconResId(media));
         if (hasContextMenu) {
             vh.itemView.setOnLongClickListener(this);
         }
@@ -123,16 +125,14 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
 
     public class MediaViewHolder extends RecyclerView.ViewHolder {
         public CheckBox checkBox;
-        public ImageView icon;
-        public ImageView more;
+        public TextView icon;
         DirectoryViewItemBinding binding;
 
         public MediaViewHolder(View v) {
             super(v);
             binding = DataBindingUtil.bind(v);
             checkBox = (CheckBox) v.findViewById(R.id.browser_checkbox);
-            icon = (ImageView) v.findViewById(R.id.dvi_icon);
-            more = (ImageView) v.findViewById(R.id.item_more);
+            icon = (TextView) v.findViewById(R.id.dvi_icon);
             v.findViewById(R.id.layout_item).setTag(R.id.layout_item, this);
         }
     }
@@ -294,6 +294,15 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
                 return R.drawable.ic_browser_unknown_normal;
         }
     }
+    protected String getProtocole(MediaWrapper media) {
+        if (media.getType() != MediaWrapper.TYPE_DIR)
+            return null;
+        String scheme = media.getUri().getScheme();
+        if (TextUtils.equals(scheme, "smb") || TextUtils.equals(scheme, "upnp"))
+            return scheme;
+        else
+            return null;
+    }
 
     public ClickHandler mClickHandler = new ClickHandler();
     public class ClickHandler {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
index 9fd42e6..adc5f5c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
@@ -49,7 +49,9 @@ public class FilePickerAdapter extends BaseBrowserAdapter {
         vh.binding.setMedia(media);
         vh.binding.setHasContextMenu(false);
         vh.binding.setType(TYPE_MEDIA);
-        vh.icon.setImageResource(getIconResId(media));
+        vh.binding.setProtocole(null);
+
+        vh.icon.setBackgroundResource(getIconResId(media));
     }
 
     //TODO update with different filter types in other cases than subtitles selection
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserAdapter.java
deleted file mode 100644
index e0a89c0..0000000
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserAdapter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * *************************************************************************
- *  NetworkBrowserAdapter.java
- * **************************************************************************
- *  Copyright © 2015 VLC authors and VideoLAN
- *  Author: Geoffrey Métais
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *  ***************************************************************************
- */
-
-package org.videolan.vlc.gui.browser;
-
-import org.videolan.vlc.R;
-
-public class NetworkBrowserAdapter extends BaseBrowserAdapter{
-
-    public NetworkBrowserAdapter(BaseBrowserFragment fragment){
-        super(fragment);
-        FOLDER_RES_ID = R.drawable.ic_menu_network;
-    }
-}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 6e474fc..07b3988 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -53,7 +53,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
     public NetworkBrowserFragment() {
         ROOT = "smb";
         mHandler = new BrowserFragmentHandler(this);
-        mAdapter = new NetworkBrowserAdapter(this);
+        mAdapter = new BaseBrowserAdapter(this);
     }
 
     @Override



More information about the Android mailing list