[Android] MRL: use TextInputLayout instead of EditText

Jean-Baptiste Kempf git at videolan.org
Fri Jun 12 17:29:25 CEST 2015


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Jun 12 15:04:41 2015 +0200| [417d2dac2260bb679e727fa1759baf8e49714222] | committer: Geoffrey Métais

MRL: use TextInputLayout instead of EditText

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

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

 vlc-android/res/layout/mrl_panel.xml               |   20 ++++++++++++--------
 .../videolan/vlc/gui/network/MRLPanelFragment.java |   18 ++++++++++--------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/vlc-android/res/layout/mrl_panel.xml b/vlc-android/res/layout/mrl_panel.xml
index 529edf1..f9470b5 100644
--- a/vlc-android/res/layout/mrl_panel.xml
+++ b/vlc-android/res/layout/mrl_panel.xml
@@ -2,16 +2,20 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/mrl_root"
     android:layout_width="match_parent" android:layout_height="match_parent">
-    <EditText
-        android:id="@+id/mrl_edit"
+    <android.support.design.widget.TextInputLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_margin="10dp"
-        android:hint="@string/open_mrl_dialog_msg"
-        android:inputType="textUri"
-        android:maxLines="2"
-        android:imeOptions="actionGo"/>
+        android:id="@+id/mrl_edit">
+        <EditText
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentTop="true"
+            android:layout_margin="10dp"
+            android:hint="@string/open_mrl_dialog_msg"
+            android:inputType="textUri"
+            android:maxLines="2"
+            android:imeOptions="actionGo"/>
+    </android.support.design.widget.TextInputLayout>
     <android.support.v7.widget.RecyclerView
         android:id="@+id/mrl_list"
         android:layout_width="match_parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.java b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.java
index 2a16189..1a8ed6a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.java
@@ -25,6 +25,7 @@ import android.support.v4.app.Fragment;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.support.design.widget.TextInputLayout;
 import android.text.TextUtils;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -48,7 +49,7 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
     private MRLAdapter mAdapter;
     private RecyclerView.LayoutManager mLayoutManager;
     ArrayList<String> mHistory;
-    EditText mEditText;
+    TextInputLayout mEditText;
     View mRootView;
 
     public MRLPanelFragment(){}
@@ -62,9 +63,10 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
         ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.open_mrl_dialog_title);
         View v = inflater.inflate(R.layout.mrl_panel, container, false);
         mRootView = v.findViewById(R.id.mrl_root);
-        mEditText = (EditText) v.findViewById(R.id.mrl_edit);
-        mEditText.setOnKeyListener(this);
-        mEditText.setOnEditorActionListener(this);
+        mEditText = (TextInputLayout) v.findViewById(R.id.mrl_edit);
+        mEditText.getEditText().setOnKeyListener(this);
+        mEditText.getEditText().setOnEditorActionListener(this);
+        mEditText.setHint(getString(R.string.open_mrl_dialog_msg));
         mRecyclerView = (RecyclerView) v.findViewById(R.id.mrl_list);
         mLayoutManager = new LinearLayoutManager(getActivity());
         mRecyclerView.setLayoutManager(mLayoutManager);
@@ -97,12 +99,12 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
     }
 
     private boolean processUri() {
-        if (!TextUtils.isEmpty(mEditText.getText().toString())){
-            Util.openStream(getActivity(), mEditText.getText().toString().trim());
-            MediaDatabase.getInstance().addMrlhistoryItem(mEditText.getText().toString().trim());
+        if (!TextUtils.isEmpty(mEditText.getEditText().getText().toString())){
+            Util.openStream(getActivity(), mEditText.getEditText().getText().toString().trim());
+            MediaDatabase.getInstance().addMrlhistoryItem(mEditText.getEditText().getText().toString().trim());
             updateHistory();
             getActivity().supportInvalidateOptionsMenu();
-            mEditText.getText().clear();
+            mEditText.getEditText().getText().clear();
             return true;
         }
         return false;



More information about the Android mailing list