[Android] Nicer 'save playlist' dialog

Geoffrey Métais git at videolan.org
Wed Dec 30 17:08:48 CET 2015


vlc-android | branch: 1.7.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 30 01:23:23 2015 +0100| [058fece6a2e53a3f16675cdef1f49977e1564492] | committer: Jean-Baptiste Kempf

Nicer 'save playlist' dialog

Modified-by: Alexandre Perraud
(cherry picked from commit 173bcdb3966f8a1cef96ccc89cc5b90b24abeaca)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> https://code.videolan.org/videolan/vlc-android/commit/058fece6a2e53a3f16675cdef1f49977e1564492
---

 vlc-android/res/layout/dialog_playlist.xml         | 23 ++++++++++++++++++----
 .../vlc/gui/dialogs/SavePlaylistDialog.java        | 12 ++++++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/vlc-android/res/layout/dialog_playlist.xml b/vlc-android/res/layout/dialog_playlist.xml
index 17e3cdc..ee01dda 100644
--- a/vlc-android/res/layout/dialog_playlist.xml
+++ b/vlc-android/res/layout/dialog_playlist.xml
@@ -1,18 +1,22 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent" android:layout_height="match_parent">
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="@dimen/half_default_margin">
 
+    <!--TODO : textColorHint doesn't work -->
     <android.support.design.widget.TextInputLayout
         android:id="@+id/dialog_playlist_name"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:hint="@string/playlist_name_hint">
+        android:layout_marginTop="@dimen/half_default_margin">
         <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
             android:hint="@string/playlist_name_hint"
+            android:textColorHint="?attr/font_default"
             android:inputType="text"
             android:imeOptions="actionSend"/>
     </android.support.design.widget.TextInputLayout>
@@ -20,6 +24,7 @@
         android:id="@+id/dialog_list_container"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/half_default_margin"
         android:layout_below="@+id/dialog_playlist_name">
         <ListView
             android:id="@android:id/list"
@@ -32,10 +37,20 @@
             android:text="@string/noplaylist"/>
     </FrameLayout>
     <Button
+        android:id="@+id/dialog_playlist_cancel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@android:string/cancel"
+        android:layout_below="@id/dialog_list_container"
+        android:layout_toLeftOf="@+id/dialog_playlist_save"
+        tools:targetApi="11"
+        style="?android:attr/borderlessButtonStyle"/>
+    <Button
         android:id="@+id/dialog_playlist_save"
-        android:layout_width="match_parent"
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="@string/playlist_save"
+        android:layout_alignParentRight="true"
+        android:text="@android:string/ok"
         android:layout_below="@id/dialog_list_container"
         tools:targetApi="11"
         style="?android:attr/borderlessButtonStyle"/>
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
index 78e9639..c8ef247 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
@@ -60,6 +60,7 @@ public class SavePlaylistDialog extends DialogFragment implements AdapterView.On
     ListView mListView;
     TextView mEmptyView;
     Button mSaveButton;
+    Button mCancelButton;
     AudioBrowserListAdapter mAdapter;
     ArrayList<MediaWrapper> mTracks;
 
@@ -76,7 +77,9 @@ public class SavePlaylistDialog extends DialogFragment implements AdapterView.On
     @NonNull
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        return new AppCompatDialog(getActivity(), getTheme());
+        AppCompatDialog dialog = new AppCompatDialog(getActivity(), getTheme());
+        dialog.setTitle(R.string.playlist_save);
+        return dialog;
 
     }
 
@@ -86,12 +89,19 @@ public class SavePlaylistDialog extends DialogFragment implements AdapterView.On
 
         mListView = (ListView) view.findViewById(android.R.id.list);
         mSaveButton = (Button) view.findViewById(R.id.dialog_playlist_save);
+        mCancelButton = (Button) view.findViewById(R.id.dialog_playlist_cancel);
         mEmptyView = (TextView) view.findViewById(android.R.id.empty);
         TextInputLayout mLayout = (TextInputLayout)view.findViewById(R.id.dialog_playlist_name);
         mLayout.setHint(getString(R.string.playlist_name_hint));
         mEditText = mLayout.getEditText();
         mListView.setOnItemClickListener(this);
         mSaveButton.setOnClickListener(this);
+        mCancelButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                dismiss();
+            }
+        });
 
         mEditText.setOnEditorActionListener(this);
         mListView.setEmptyView(mEmptyView);



More information about the Android mailing list