Skip to content

Commit

Permalink
Adjust some options trying to improve focusability of the main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
kingargyle committed Sep 12, 2017
1 parent 653aae2 commit a011836
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public class MainActivity extends SerenityDrawerLayoutActivity implements MainVi
actionBar.setDisplayShowCustomEnabled(true);

setContentView(R.layout.activity_plex_app_main);
initMenuDrawerViews();
DisplayUtils.overscanCompensation(this, getWindow().getDecorView());
bind(this);
initMenuDrawerViews();
createSideMenu();

initPreferences();
Expand Down Expand Up @@ -112,7 +113,6 @@ public class MainActivity extends SerenityDrawerLayoutActivity implements MainVi

@Override protected void onResume() {
super.onResume();
DisplayUtils.overscanCompensation(this, getWindow().getDecorView());
registerGDMReceiver();

// Start the auto-configuration service
Expand All @@ -121,6 +121,8 @@ public class MainActivity extends SerenityDrawerLayoutActivity implements MainVi
Intent recommendationIntent = new Intent(getApplicationContext(), OnDeckRecommendationIntentService.class);
startService(recommendationIntent);

drawerList.setVisibility(View.GONE);

mainMenuContainer.setFocusable(true);
mainMenuContainer.requestFocusFromTouch();
}
Expand All @@ -139,6 +141,7 @@ protected void registerGDMReceiver() {
}

@Override protected void createSideMenu() {
mainMenuContainer.setVisibility(View.VISIBLE);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.menudrawer_selector, R.string.drawer_open,
R.string.drawer_closed) {
@Override public void onDrawerOpened(View drawerView) {
Expand Down Expand Up @@ -166,15 +169,18 @@ protected void registerGDMReceiver() {
}

protected void populateMenuOptions() {
drawerList.setVisibility(View.GONE);
List<MenuDrawerItem> drawerMenuItem = new ArrayList<>();
drawerMenuItem.add(new MenuDrawerItemImpl(getResources().getString(R.string.options_main_about), R.drawable.ic_action_action_about));
drawerMenuItem.add(new MenuDrawerItemImpl(getResources().getString(R.string.options_main_clear_image_cache), R.drawable.ic_action_content_remove));
drawerMenuItem.add(new MenuDrawerItemImpl(getResources().getString(R.string.clear_queue), R.drawable.ic_action_content_remove));
drawerMenuItem.add(new MenuDrawerItemImpl(getResources().getString(R.string.options_main_about),
R.drawable.ic_action_action_about));
drawerMenuItem.add(new MenuDrawerItemImpl(getResources().getString(R.string.options_main_clear_image_cache),
R.drawable.ic_action_content_remove));
drawerMenuItem.add(
new MenuDrawerItemImpl(getResources().getString(R.string.clear_queue), R.drawable.ic_action_content_remove));

drawerList.setAdapter(new MenuDrawerAdapter(this, drawerMenuItem));
mainMenuContainer.requestFocusFromTouch();

drawerList.setOnItemClickListener(new MainMenuDrawerOnItemClickedListener(drawerLayout));
mainMenuContainer.requestFocusFromTouch();
}

protected void initPreferences() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ private void setupGallery() {
unbinder.unbind();
}

@Override public void onResume() {
super.onResume();
mainGallery.requestFocusFromTouch();
}

@Subscribe(threadMode = ThreadMode.MAIN) public void onMainMenuRetrievalResponse(MainMenuEvent event) {
menuItems = new MenuMediaContainer(event.getMediaContainer()).createMenuItems();
setupGallery();
mainGallery.setVisibility(View.VISIBLE);
mainGallery.requestFocus();
mainGallery.requestFocusFromTouch();
}

@Subscribe(threadMode = ThreadMode.MAIN) public void onMainMenuErrorResponse(ErrorMainMenuEvent event) {
Expand All @@ -127,6 +132,6 @@ private void setupGallery() {
Toast.makeText(getActivity(), "Unable to connect to Plex Library at " + plexFactory.baseURL(), Toast.LENGTH_LONG)
.show();

mainGallery.requestFocus();
mainGallery.requestFocusFromTouch();
}
}
2 changes: 2 additions & 0 deletions serenity-app/src/main/res/layout-large/item_mainmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
android:layout_height="wrap_content"
android:focusable="true"
android:clickable="true"

android:descendantFocusability="afterDescendants"
>

<TextView
Expand Down
18 changes: 10 additions & 8 deletions serenity-app/src/main/res/layout-large/main_menu_view.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<us.nineworlds.serenity.widgets.ReflectingLayout xmlns:android="http://schemas.android.com/apk/res/android"

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/relectionArea"
android:layout_width="fill_parent"
android:layout_height="90dp"
android:padding="5dp"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/content_panel_dark"
android:layout_centerInParent="true"
>

<net.ganin.darv.DpadAwareRecyclerView
android:id="@+id/mainGalleryMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:paddingLeft="5dp"
app:selectorVelocity="1000"
android:focusableInTouchMode="true"
app:smoothScrolling="true"
app:backgroundSelector="@drawable/main_menu_item_foreground_selector"
android:nextFocusUp="@+id/menu_button"
Expand All @@ -25,4 +26,5 @@
<requestFocus/>
</net.ganin.darv.DpadAwareRecyclerView>

</us.nineworlds.serenity.widgets.ReflectingLayout>

</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
android:paddingLeft="5dp"
android:drawableLeft="@drawable/ic_action_settings"
android:focusable="true"
android:visibility="gone"
android:gravity="center_vertical"
android:text="Settings"
android:textColor="@android:color/white"
Expand Down

0 comments on commit a011836

Please sign in to comment.