<p dir="ltr">retry</p>
<div class="gmail_quote">On Sep 6, 2014 4:42 PM, "Mik Amchislavsky" <<a href="mailto:hailmikhail@gmail.com">hailmikhail@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Focus support.</div><div>    </div><div>Menu-opening automation for Overflow and Sliding menus.</div><div>Menu-closing automation for Overflow menus.</div><div>Temporary solution to avoid focus of invisible items.</div><div><div><br></div><div>index 362f2f7..71605f4 100644</div><div>--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java</div><div>+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java</div><div>@@ -93,6 +93,8 @@ import android.widget.TextView;</div><div> </div><div> import com.slidingmenu.lib.SlidingMenu;</div><div> </div><div>+import android.view.KeyEvent;</div><div>+</div><div> public class MainActivity extends ActionBarActivity {</div><div>     public final static String TAG = "VLC/MainActivity";</div><div> </div><div>@@ -133,7 +135,8 @@ public class MainActivity extends ActionBarActivity {</div><div>     private boolean mScanNeeded = true;</div><div> </div><div>     private Handler mHandler = new MainActivityHandler(this);</div><div><br></div><div>+<span style="white-space:pre-wrap">    </span>private int mFocusedPrior = 0;</div><div>+<span style="white-space:pre-wrap">  </span></div><div>     @Override</div><div>     protected void onCreate(Bundle savedInstanceState) {</div><div>         if (!LibVlcUtil.hasCompatibleCPU(this)) {</div><div>@@ -580,6 +583,18 @@ public class MainActivity extends ActionBarActivity {</div><div>         // Enable the clear search history function for the search fragment.</div><div>         if (mCurrentFragment != null && mCurrentFragment.equals("search"))</div><div>             menu.findItem(R.id.search_clear_history).setVisible(true);</div><div>+</div><div>+<span style="white-space:pre-wrap">               </span>/* Focus support. Provide menu-closing automation for Overlflow</div><div>+<span style="white-space:pre-wrap">         </span> * and Sortby menues</div><div>+<span style="white-space:pre-wrap">            </span> */</div><div>+<span style="white-space:pre-wrap">             </span>if (mFocusedPrior != R.id.ml_menu_refresh) {</div><div>+<span style="white-space:pre-wrap">                    </span>menu.findItem(R.id.ml_close_options).setVisible(false);</div><div>+<span style="white-space:pre-wrap">                 </span>menu.findItem(R.id.ml_close_sortby).setVisible(false);</div><div>+<span style="white-space:pre-wrap">          </span>} else {</div><div>+<span style="white-space:pre-wrap">                        </span>menu.findItem(R.id.ml_close_options).setVisible(true);</div><div>+<span style="white-space:pre-wrap">                  </span>menu.findItem(R.id.ml_close_sortby).setVisible(true);</div><div>+<span style="white-space:pre-wrap">           </span>}</div><div>+</div><div>         return true;</div><div>     }</div><div> </div><div>@@ -673,6 +688,13 @@ public class MainActivity extends ActionBarActivity {</div><div>             case R.id.search_clear_history:</div><div>                 MediaDatabase.getInstance().clearSearchHistory();</div><div>                 break;</div><div>+            /* Focus support. Menu-closing automation                </div><div>+             */</div><div>+<span style="white-space:pre-wrap">                 </span>case R.id.ml_close_options:</div><div>+<span style="white-space:pre-wrap">                     </span>case R.id.ml_close_sortby:                         </div><div>+<span style="white-space:pre-wrap">                                </span>closeOptionsMenu();</div><div>+<span style="white-space:pre-wrap">                             </span>findViewById(R.id.ml_menu_refresh).requestFocus();</div><div>+<span style="white-space:pre-wrap">                              </span>break;               </div><div>         }</div><div>         return super.onOptionsItemSelected(item);</div><div>     }</div><div>@@ -691,6 +713,83 @@ public class MainActivity extends ActionBarActivity {</div><div>         }</div><div>     }</div><div> </div><div>+<span style="white-space:pre-wrap">       </span>/* Focus support. Start. */<span style="white-space:pre-wrap">     </span></div><div>+<span style="white-space:pre-wrap">        </span></div><div>+<span style="white-space:pre-wrap">        </span>// onKeyDown will not occur while moving within a list</div><div>+<span style="white-space:pre-wrap">  </span>@Override</div><div>+<span style="white-space:pre-wrap">       </span>public boolean onKeyDown(int keyCode, KeyEvent event) {</div><div>+<span style="white-space:pre-wrap">         </span>mFocusedPrior = getCurrentFocus().getId();</div><div>+<span style="white-space:pre-wrap">              </span>return super .onKeyDown(keyCode, event);</div><div>+<span style="white-space:pre-wrap">        </span>}</div><div>+</div><div>+<span style="white-space:pre-wrap">       </span>@Override</div><div>+<span style="white-space:pre-wrap">       </span>public boolean onKeyUp(int keyCode, KeyEvent event) {</div><div>+<span style="white-space:pre-wrap">           </span>int id = getCurrentFocus().getId();<span style="white-space:pre-wrap">     </span></div><div>+</div><div>+<span style="white-space:pre-wrap">                </span>/* Menu-opening automation for Overlflow and Sliding</div><div>+<span style="white-space:pre-wrap">            </span> * menus.</div><div>+<span style="white-space:pre-wrap">               </span> * </div><div>+<span style="white-space:pre-wrap">            </span> * R.id of -1 matches Overflow and App Icon. The two may be</div><div>+<span style="white-space:pre-wrap">             </span> * distinguished by the prior ID. Overflow menu resides next to</div><div>+<span style="white-space:pre-wrap">         </span> * ml_menu_refresh.</div><div>+<span style="white-space:pre-wrap">             </span> */</div><div>+<span style="white-space:pre-wrap">             </span>if  (id == -1) {</div><div>+<span style="white-space:pre-wrap">                       </span>if (mFocusedPrior == R.id.ml_menu_refresh) {</div><div>+<span style="white-space:pre-wrap">                            </span>openOptionsMenu();</div><div>+<span style="white-space:pre-wrap">                      </span>} else {</div><div>+<span style="white-space:pre-wrap">                                </span>if (mMenu.isMenuShowing() == false) {</div><div>+<span style="white-space:pre-wrap">                                   </span>mMenu.showMenu();</div><div>+<span style="white-space:pre-wrap">                                       </span>View myView = mMenu.getMenu();</div><div>+<span style="white-space:pre-wrap">                                  </span>myView.scrollTo(0,0);</div><div>+<span style="white-space:pre-wrap">                                   </span>myView.requestFocus();</div><div>+<span style="white-space:pre-wrap">                          </span>}</div><div>+<span style="white-space:pre-wrap">                       </span>}</div><div>+<span style="white-space:pre-wrap">                       </span>return true;</div><div>+<span style="white-space:pre-wrap">            </span>}</div><div>+</div><div>+<span style="white-space:pre-wrap">               </span>/* Menu-closing automation.</div><div>+<span style="white-space:pre-wrap">             </span> * </div><div>+<span style="white-space:pre-wrap">            </span> * While navigating a single list, onKeyDown doesn't fire but,</div><div>+<span style="white-space:pre-wrap">              </span> * onKeyUp continues to occur. In the event mFocusedPrior equals</div><div>+<span style="white-space:pre-wrap">                </span> * R.id.list, the user navigated from one list to another.</div><div>+<span style="white-space:pre-wrap">              </span> */</div><div>+<span style="white-space:pre-wrap">             </span>if (((mFocusedPrior == android.R.id.list) ||</div><div>+<span style="white-space:pre-wrap">            </span>     (id != android.R.id.list)) &&</div><div>+<span style="white-space:pre-wrap">            </span>    (mFocusedPrior != -1) &&</div><div>+<span style="white-space:pre-wrap">          </span>    (mFocusedPrior != ml_menu_search) &&</div><div>+<span style="white-space:pre-wrap">              </span>    (mMenu.isMenuShowing())) {</div><div>+<span style="white-space:pre-wrap">                        </span>mMenu.showContent();</div><div>+<span style="white-space:pre-wrap">                    </span>return true;</div><div>+<span style="white-space:pre-wrap">            </span>}</div><div>+</div><div>+<span style="white-space:pre-wrap">               </span>/* Scope reduction.</div><div>+<span style="white-space:pre-wrap">             </span> * </div><div>+<span style="white-space:pre-wrap">            </span> * Through hard codign, the following will force focus to a</div><div>+<span style="white-space:pre-wrap">             </span> * visible control in the event focus reaches an invisible</div><div>+<span style="white-space:pre-wrap">              </span> * control.</div><div>+<span style="white-space:pre-wrap">             </span> * </div><div>+<span style="white-space:pre-wrap">            </span> * In the future, focusable property must be managed in</div><div>+<span style="white-space:pre-wrap">         </span> * tandem with the visible property.</div><div>+<span style="white-space:pre-wrap">            </span> */</div><div>+<span style="white-space:pre-wrap">             </span>if ((id == R.id.play_pause) ||</div><div>+<span style="white-space:pre-wrap">                  </span>(id == R.id.repeat) ||</div><div>+<span style="white-space:pre-wrap">                  </span>(id == R.id.shuffle) ||</div><div>+<span style="white-space:pre-wrap">                 </span>(id == R.id.header_play_pause) ||</div><div>+<span style="white-space:pre-wrap">                       </span>(id == R.id.timeline) ||</div><div>+<span style="white-space:pre-wrap">                        </span>(id == R.id.next)) {</div><div>+</div><div>+<span style="white-space:pre-wrap">                    </span>if (mSlidingPane.getState() == mSlidingPane.STATE_OPENED_ENTIRELY)</div><div>+<span style="white-space:pre-wrap">                              </span>findViewById(R.id.ml_menu_search).requestFocus();</div><div>+<span style="white-space:pre-wrap">                       </span>else</div><div>+<span style="white-space:pre-wrap">                            </span>findViewById(R.id.play_pause).requestFocus();</div><div>+</div><div>+<span style="white-space:pre-wrap">                   </span>return true;</div><div>+<span style="white-space:pre-wrap">            </span>}</div><div>+<span style="white-space:pre-wrap">               </span></div><div>+<span style="white-space:pre-wrap">                </span>return  super .onKeyUp(keyCode, event);</div><div>+<span style="white-space:pre-wrap">        </span>}</div><div>+<span style="white-space:pre-wrap">       </span>/* Focus support. End. */</div><div>+</div><div>     private void reloadPreferences() {</div><div>         SharedPreferences sharedPrefs = getSharedPreferences("MainActivity", MODE_PRIVATE);</div><div>         mCurrentFragment = sharedPrefs.getString("fragment", "video");</div><div><br></div><div>index 856e35a..7a9938a 100644</div><div>--- a/vlc-android/res/menu-v10/media_library.xml</div><div>+++ b/vlc-android/res/menu-v10/media_library.xml</div><div>@@ -23,6 +23,10 @@</div><div>             <item</div><div>                 android:id="@+id/ml_menu_sortby_length"</div><div>                 android:title="@string/sortby_length" /></div><div>+<span style="white-space:pre-wrap">                      </span><item</div><div>+<span style="white-space:pre-wrap">                                </span>android:id="@+id/ml_close_sortby"</div><div>+<span style="white-space:pre-wrap">                             </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">                         </span>android:title="@string/exit_menu" /></div><div>         </menu></div><div>     </item></div><div>     <item</div><div>@@ -52,4 +56,8 @@</div><div>         android:visible="false"</div><div>         android:icon="@android:drawable/ic_menu_close_clear_cancel"</div><div>         android:id="@+id/search_clear_history" /></div><div>+<span style="white-space:pre-wrap">       </span><item</div><div>+<span style="white-space:pre-wrap">                </span>android:id="@+id/ml_close_options"</div><div>+<span style="white-space:pre-wrap">            </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">         </span>android:title="@string/exit_menu" /></div><div> </menu></div><div><br></div><div>index 2c434b0..02b4959 100644</div><div>--- a/vlc-android/res/menu-v13/media_library.xml</div><div>+++ b/vlc-android/res/menu-v13/media_library.xml</div><div>@@ -23,6 +23,10 @@</div><div>             <item</div><div>                 android:id="@+id/ml_menu_sortby_length"</div><div>                 android:title="@string/sortby_length" /></div><div>+<span style="white-space:pre-wrap">                  </span><item</div><div>+<span style="white-space:pre-wrap">                                </span>android:id="@+id/ml_close_sortby"</div><div>+<span style="white-space:pre-wrap">                             </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">                         </span>android:title="@string/exit_menu" />                </div><div>         </menu></div><div>     </item></div><div>     <item</div><div>@@ -52,4 +56,8 @@</div><div>         android:visible="false"</div><div>         android:icon="@android:drawable/ic_menu_close_clear_cancel"</div><div>         android:id="@+id/search_clear_history" /></div><div>+<span style="white-space:pre-wrap">       </span><item</div><div>+<span style="white-space:pre-wrap">                </span>android:id="@+id/ml_close_options"</div><div>+<span style="white-space:pre-wrap">            </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">         </span>android:title="@string/exit_menu" />        </div><div> </menu></div><div><br></div><div>index 856e35a..7a9938a 100644</div><div>--- a/vlc-android/res/menu-v7/media_library.xml</div><div>+++ b/vlc-android/res/menu-v7/media_library.xml</div><div>@@ -23,6 +23,10 @@</div><div>             <item</div><div>                 android:id="@+id/ml_menu_sortby_length"</div><div>                 android:title="@string/sortby_length" /></div><div>+<span style="white-space:pre-wrap">                        </span><item</div><div>+<span style="white-space:pre-wrap">                                </span>android:id="@+id/ml_close_sortby"</div><div>+<span style="white-space:pre-wrap">                             </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">                         </span>android:title="@string/exit_menu" /></div><div>         </menu></div><div>     </item></div><div>     <item</div><div>@@ -52,4 +56,8 @@</div><div>         android:visible="false"</div><div>         android:icon="@android:drawable/ic_menu_close_clear_cancel"</div><div>         android:id="@+id/search_clear_history" /></div><div>+<span style="white-space:pre-wrap">       </span><item</div><div>+<span style="white-space:pre-wrap">                </span>android:id="@+id/ml_close_options"</div><div>+<span style="white-space:pre-wrap">            </span>android:icon="@drawable/dots"</div><div>+<span style="white-space:pre-wrap">         </span>android:title="@string/exit_menu" /></div><div> </menu></div><div><br></div><div>index d9a2a11..4d1d7dc 100644</div><div>--- a/vlc-android/res/values/strings.xml</div><div>+++ b/vlc-android/res/values/strings.xml</div><div>@@ -106,6 +106,7 @@</div><div>     <string name="thumbnail">Thumbnail</string></div><div>     <string name="unseekable_stream">Unseekable stream</string></div><div>     <string name="refresh">Refresh</string></div><div>+<span style="white-space:pre-wrap">        </span><string name="exit_menu">Return</string></div><div>     <string name="track_audio">Audio track</string></div><div>     <string name="track_video">Video track</string></div><div>     <string name="track_text">Subtitles track</string></div></div><div><br></div></div>
</blockquote></div>