[Android] Keyboard navigation in advanced options

Geoffrey Métais git at videolan.org
Mon Jan 12 16:56:20 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 12 16:55:53 2015 +0100| [b8cdfe5a212217207fe305291dc916be924ba638] | committer: Geoffrey Métais

Keyboard navigation in advanced options

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

 vlc-android/res/layout/fragment_advanced_options.xml |   17 ++++++++++++-----
 .../org/videolan/vlc/gui/video/AdvOptionsDialog.java |   18 ++++++++++++++++++
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/vlc-android/res/layout/fragment_advanced_options.xml b/vlc-android/res/layout/fragment_advanced_options.xml
index a164fde..49ac33d 100644
--- a/vlc-android/res/layout/fragment_advanced_options.xml
+++ b/vlc-android/res/layout/fragment_advanced_options.xml
@@ -42,7 +42,9 @@
         android:layout_toRightOf="@+id/playback_speed_title"
         android:layout_toLeftOf="@+id/playback_speed_reset"
         android:progressDrawable="@drawable/po_seekbar"
-        android:thumb="@drawable/seekbar_thumb"/>
+        android:splitTrack="false"
+        android:thumb="@drawable/seekbar_thumb"
+        android:focusable="true"/>
 
         <TextView
             android:id="@+id/seek_beginning"
@@ -73,7 +75,8 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
-        android:text="1x"/>
+        android:text="1x"
+        android:focusable="true" />
     <!-- Sleep Timer-->
     <ImageView
         android:id="@+id/sleep_timer_icon"
@@ -101,7 +104,8 @@
         android:layout_toRightOf="@+id/sleep_timer_title"
         android:layout_alignLeft="@+id/seek_beginning"
         android:text="none_set"
-        android:clickable="true"/>
+        android:clickable="true"
+        android:focusable="true"/>
     <TextView
         android:id="@+id/sleep_timer_cancel"
         android:layout_width="wrap_content"
@@ -112,7 +116,8 @@
         android:layout_marginTop="10dp"
         android:layout_toRightOf="@+id/sleep_timer_value"
         android:text="@string/sleep_cancel"
-        android:clickable="true"/>
+        android:clickable="true"
+        android:focusable="true"/>
     <!-- Jump to position -->
     <ImageView
         android:id="@+id/jump_icon"
@@ -130,6 +135,8 @@
         android:layout_below="@+id/playback_speed_value"
         android:layout_marginTop="10dp"
         android:layout_alignRight="@+id/playback_speed_reset"
-        android:text="@string/jump_to_time" />
+        android:text="@string/jump_to_time"
+        android:clickable="true"
+        android:focusable="true"/>
 
 </RelativeLayout>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
index da7a0bc..812f269 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
@@ -28,6 +28,8 @@ import android.app.TimePickerDialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
@@ -72,7 +74,9 @@ public class AdvOptionsDialog extends DialogFragment{
 
     private ImageView mJumpIcon;
     private TextView mJumpTitle;
+
     private static AdvOptionsDialog sInstance;
+    private int mTextColor;
 
     public AdvOptionsDialog() {}
 
@@ -113,9 +117,14 @@ public class AdvOptionsDialog extends DialogFragment{
         mJumpIcon.setOnClickListener(mJumpListener);
         mJumpTitle.setOnClickListener(mJumpListener);
 
+        mReset.setOnFocusChangeListener(mFocusListener);
+        mSleepTime.setOnFocusChangeListener(mFocusListener);
+        mSleepCancel.setOnFocusChangeListener(mFocusListener);
+        mJumpTitle.setOnFocusChangeListener(mFocusListener);
 
         getDialog().setCancelable(true);
         mHandler.sendEmptyMessage(TOGGLE_CANCEL);
+        mTextColor = mSleepTitle.getCurrentTextColor();
         return root;
     }
 
@@ -161,6 +170,15 @@ public class AdvOptionsDialog extends DialogFragment{
         }
     };
 
+    View.OnFocusChangeListener mFocusListener = new View.OnFocusChangeListener() {
+        @Override
+        public void onFocusChange(View v, boolean hasFocus) {
+            if (v instanceof TextView)
+                ((TextView) v).setTextColor(v.hasFocus() ?
+                        sInstance.getResources().getColor(R.color.darkorange) : mTextColor);
+        }
+    };
+
     private void showTimePicker(int action) {
         DialogFragment newFragment = new TimePickerDialogFragment();
         Bundle args = new Bundle();



More information about the Android mailing list