Permalink
Browse files

front: Work in progress cheat ui redesign

  • Loading branch information...
fzurita committed Dec 31, 2015
1 parent 144134a commit 5eb530a09320015df9928819a4bf43eb6351668a
@@ -5,18 +5,25 @@
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
+
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
- android:background="#747273" />
+ android:background="#747273"
+ android:focusable="false"
+ android:focusableInTouchMode="false" />
+
<TextView
android:id="@+android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:padding="12dp"
android:textColor="?attr/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
-</LinearLayout>
+
+</LinearLayout>
View
@@ -183,7 +183,8 @@
<string name="screenCheats_summaryDisabled">Disabled</string>
<!-- Preference Categories -->
- <string name="categoryCheats_title">Cheat options (long-press for notes)</string>
+ <string name="categoryCheats_title1">Cheat Options</string>
+ <string name="categoryCheats_title2">Enable Cheats (long-press for notes)</string>
<string name="categoryGln64_title">Gln64 settings</string>
<string name="categoryRice_title">Rice settings</string>
<string name="categoryGlide64_title">Glide64 settings</string>
@@ -84,21 +84,24 @@
android:icon="@drawable/ic_key"
android:key="screenCheats"
android:title="@string/screenCheats_title" >
- <android.support.v7.preference.CheckBoxPreference
- android:defaultValue="false"
- android:key="playShowCheats"
- android:title="@string/playShowCheats_title" />
-
- <android.support.v7.preference.Preference
- android:key="actionCheatEditor"
- android:summary="@string/actionCheatEditor_summary"
- android:title="@string/actionCheatEditor_title" >
- </android.support.v7.preference.Preference>
+ <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
+ android:key="categoryCheatOptions"
+ android:selectable="true"
+ android:title="@string/categoryCheats_title1" >
+ <android.support.v7.preference.CheckBoxPreference
+ android:defaultValue="false"
+ android:key="playShowCheats"
+ android:title="@string/playShowCheats_title" />
+ <android.support.v7.preference.Preference
+ android:key="actionCheatEditor"
+ android:summary="@string/actionCheatEditor_summary"
+ android:title="@string/actionCheatEditor_title" >
+ </android.support.v7.preference.Preference>
+ </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
<paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryCheats"
- android:selectable="true"
- android:title="@string/categoryCheats_title" />
+ android:title="@string/categoryCheats_title2" />
</android.support.v7.preference.PreferenceScreen>
<android.support.v7.preference.Preference
@@ -112,7 +115,4 @@
android:summary="@string/actionResetGamePrefs_summary"
android:title="@string/actionResetGamePrefs_title" />
- <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
- </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
-
</android.support.v7.preference.PreferenceScreen>
@@ -219,7 +219,26 @@ protected void OnPreferenceScreenChange(String key)
@Override
public void onFragmentCreation(AppCompatPreferenceFragment currentFragment)
{
+ //TODO: DIdn't fix it
+ if(mPrefFrag != null)
+ {
+ View fragView = mPrefFrag.getView();
+
+ if(fragView != null)
+ {
+ fragView.setVisibility(View.GONE);
+ }
+ }
+
mPrefFrag = currentFragment;
+
+ View fragView = mPrefFrag.getView();
+
+ if(fragView != null)
+ {
+ fragView.setVisibility(View.VISIBLE);
+ }
+
OnPreferenceScreenChange(mPrefFrag.getTag());
}
@@ -6,10 +6,13 @@
import android.support.v7.appcompat.R;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
+import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnChildAttachStateChangeListener;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnKeyListener;
import android.view.ViewGroup;
public class AppCompatPreferenceFragment extends PreferenceFragmentCompat
@@ -131,27 +134,54 @@ public void onViewCreated(View view, Bundle savedInstanceState)
protected void onBindPreferences()
{
// Detect when a view is added to the preference fragment and request focus if it's the first view
- final RecyclerView view1 = getListView();
+ final RecyclerView recyclerView = getListView();
- final RecyclerView.Adapter<?> adapter = view1.getAdapter();
+ final RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
- view1.addOnChildAttachStateChangeListener(new OnChildAttachStateChangeListener()
+ recyclerView.addOnChildAttachStateChangeListener(new OnChildAttachStateChangeListener()
{
@Override
public void onChildViewAttachedToWindow(View childView)
{
+ final LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.getLayoutManager();
+
+ //Prevent scrolling past the top
+ childView.setOnKeyListener(new OnKeyListener() {
+
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event)
+ {
+ View focusedChild = layoutManager.getFocusedChild();
+ int selectedPos = recyclerView.getChildAdapterPosition(focusedChild);
+
+ if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ switch(keyCode) {
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ return !(selectedPos < adapter.getItemCount() - 1);
+ case KeyEvent.KEYCODE_DPAD_UP:
+ return selectedPos == 0;
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+ });
+
//Make sure all views are focusable
childView.setFocusable(true);
- //Get focus on the first item the first time it's displayed
- RecyclerView.ViewHolder holder = view1.findViewHolderForItemId(adapter.getItemId(0));
+ int firstItem = layoutManager.findFirstCompletelyVisibleItemPosition() + 1;
+
+ //Get focus on the first visible item the first time it's displayed
+ RecyclerView.ViewHolder holder = recyclerView.findViewHolderForItemId(adapter.getItemId(firstItem));
if(holder != null)
- {
+ {
if (!mHasFocusBeenSet)
{
mHasFocusBeenSet = true;
holder.itemView.requestFocus();
- holder.itemView.setNextFocusUpId(holder.itemView.getId());
}
}
}
@@ -1,5 +1,5 @@
/**
- * Mupen64PlusAE, an N64 emulator for the Android platform
+ * Mupen4PlusAE, an N64 emulator for the Android platform
*
* Copyright (C) 2013 Paul Lamb
*
@@ -28,49 +28,65 @@
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
-public final class ExpandablePreferenceCategory extends PreferenceGroup {
- private RecyclerView.Adapter mRootAdapter;
+public final class ExpandablePreferenceCategory extends PreferenceGroup
+{
+ private RecyclerView.Adapter<?> mRootAdapter;
+
/**
- * Do NOT use this constructor, use {@link PreferenceManager#createPreferenceScreen(Context)}.
+ * Do NOT use this constructor, use
+ * {@link PreferenceManager#createPreferenceScreen(Context)}.
+ *
* @hide-
*/
- public ExpandablePreferenceCategory(Context context, AttributeSet attrs) {
+ public ExpandablePreferenceCategory(Context context, AttributeSet attrs)
+ {
super(context, attrs, R.attr.preferenceScreenStyle);
}
+
/**
* Returns an adapter that can be attached to a {@link PreferenceFragment}
- * or {@link PreferenceFragmentCompat} to show the preferences contained in this
- * {@link PreferenceScreen}.
+ * or {@link PreferenceFragmentCompat} to show the preferences contained in
+ * this {@link PreferenceScreen}.
* <p>
- * This {@link PreferenceScreen} will NOT appear in the returned adapter, instead
- * it appears in the hierarchy above this {@link PreferenceScreen}.
+ * This {@link PreferenceScreen} will NOT appear in the returned adapter,
+ * instead it appears in the hierarchy above this {@link PreferenceScreen}.
*
* @return An adapter that manages the {@link Preference} contained in this
* {@link PreferenceScreen}.
*/
- public final RecyclerView.Adapter getAdapter() {
- if (mRootAdapter == null) {
+ public final RecyclerView.Adapter<?> getAdapter()
+ {
+ if (mRootAdapter == null)
+ {
mRootAdapter = onCreateAdapter();
}
return mRootAdapter;
}
+
/**
* Creates the root adapter.
*
- * @return An adapter that contains the preferences contained in this {@link PreferenceScreen}.
+ * @return An adapter that contains the preferences contained in this
+ * {@link PreferenceScreen}.
* @see #getAdapter()
*/
- protected RecyclerView.Adapter onCreateAdapter() {
+ protected RecyclerView.Adapter<?> onCreateAdapter()
+ {
return new PreferenceGroupAdapter(this);
}
+
@Override
- protected void onClick() {
- if (getIntent() != null || getFragment() != null || getPreferenceCount() == 0) {
+ protected void onClick()
+ {
+ if (getIntent() != null || getFragment() != null || getPreferenceCount() == 0)
+ {
return;
}
}
+
@Override
- protected boolean isOnSameScreenAsChildren() {
- return false;
+ protected boolean isOnSameScreenAsChildren()
+ {
+ return true;
}
}

0 comments on commit 5eb530a

Please sign in to comment.