Skip to content

Commit

Permalink
front: Made preference activities navigational using a controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
fzurita committed Dec 27, 2015
1 parent 659c60f commit 144134a
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 22 deletions.
22 changes: 22 additions & 0 deletions res/layout/custom_preference_category.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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" />
<TextView
android:id="@+android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="12dp"
android:textColor="?attr/colorAccent"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
2 changes: 1 addition & 1 deletion res/values/styles.xml
Expand Up @@ -10,7 +10,7 @@
<item name="android:colorBackground">@android:color/black</item> <item name="android:colorBackground">@android:color/black</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style> </style>

<style name="Theme.Mupen64plusaeTheme" parent="Theme.AppCompat"> <style name="Theme.Mupen64plusaeTheme" parent="Theme.AppCompat">
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style> </style>
Expand Down
7 changes: 4 additions & 3 deletions res/xml/preferences_game.xml
Expand Up @@ -95,8 +95,9 @@
android:title="@string/actionCheatEditor_title" > android:title="@string/actionCheatEditor_title" >
</android.support.v7.preference.Preference> </android.support.v7.preference.Preference>


<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryCheats" android:key="categoryCheats"
android:selectable="true"
android:title="@string/categoryCheats_title" /> android:title="@string/categoryCheats_title" />
</android.support.v7.preference.PreferenceScreen> </android.support.v7.preference.PreferenceScreen>


Expand All @@ -111,7 +112,7 @@
android:summary="@string/actionResetGamePrefs_summary" android:summary="@string/actionResetGamePrefs_summary"
android:title="@string/actionResetGamePrefs_title" /> android:title="@string/actionResetGamePrefs_title" />


<android.support.v7.preference.PreferenceCategory> <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>


</android.support.v7.preference.PreferenceScreen> </android.support.v7.preference.PreferenceScreen>
42 changes: 24 additions & 18 deletions res/xml/preferences_global.xml
Expand Up @@ -41,30 +41,30 @@
To minimize app size, consider using Android's built-in resources when possible. To minimize app size, consider using Android's built-in resources when possible.
For example, consider icon resources in "@android:drawable/..." instead of custom For example, consider icon resources in "@android:drawable/..." instead of custom
resources in "@drawable/...". resources in "@drawable/...".
*********************************************************************************** ***********************************************************************************
--> -->
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mupen64="http://schemas.android.com/apk/res/org.mupen64plusae.v3.alpha" xmlns:mupen64="http://schemas.android.com/apk/res/org.mupen64plusae.v3.alpha"
android:key="screenRoot" > android:key="screenRoot" >


<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryLibrary" android:key="categoryLibrary"
android:selectable="true"
android:title="@string/categoryLibrary_title" > android:title="@string/categoryLibrary_title" >
<android.support.v7.preference.CheckBoxPreference <android.support.v7.preference.CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="showRecentlyPlayed" android:key="showRecentlyPlayed"
android:summary="@string/showRecentlyPlayed_summary" android:summary="@string/showRecentlyPlayed_summary"
android:title="@string/showRecentlyPlayed_title" /> android:title="@string/showRecentlyPlayed_title" />

<android.support.v7.preference.CheckBoxPreference <android.support.v7.preference.CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="showFullNames" android:key="showFullNames"
android:summary="@string/showFullNames_summary" android:summary="@string/showFullNames_summary"
android:title="@string/showFullNames_title" /> android:title="@string/showFullNames_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>

<paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
<android.support.v7.preference.PreferenceCategory
android:key="categoryDisplay" android:key="categoryDisplay"
android:selectable="true"
android:title="@string/categoryDisplay_title" > android:title="@string/categoryDisplay_title" >
<paulscode.android.mupen64plusae.preference.CompatListPreference <paulscode.android.mupen64plusae.preference.CompatListPreference
android:defaultValue="@string/displayOrientation_default" android:defaultValue="@string/displayOrientation_default"
Expand Down Expand Up @@ -100,6 +100,7 @@
android:key="displayFps" android:key="displayFps"
android:summary="@string/displayFps_summary" android:summary="@string/displayFps_summary"
android:title="@string/displayFps_title" /> android:title="@string/displayFps_title" />

<paulscode.android.mupen64plusae.preference.CompatListPreference <paulscode.android.mupen64plusae.preference.CompatListPreference
android:defaultValue="@string/videoHardwareType_default" android:defaultValue="@string/videoHardwareType_default"
android:entries="@array/videoHardwareType_entries" android:entries="@array/videoHardwareType_entries"
Expand All @@ -114,9 +115,10 @@
android:key="videoPolygonOffset" android:key="videoPolygonOffset"
android:summary="@string/videoPolygonOffset_summary" android:summary="@string/videoPolygonOffset_summary"
android:title="@string/videoPolygonOffset_title" /> android:title="@string/videoPolygonOffset_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryAudio" android:key="categoryAudio"
android:selectable="true"
android:title="@string/categoryAudio_title" > android:title="@string/categoryAudio_title" >
<paulscode.android.mupen64plusae.preference.CompatListPreference <paulscode.android.mupen64plusae.preference.CompatListPreference
android:defaultValue="@string/audioPlugin_default" android:defaultValue="@string/audioPlugin_default"
Expand All @@ -139,7 +141,7 @@
android:key="audioSLESBufferSize" android:key="audioSLESBufferSize"
android:summary="@string/selectedValue" android:summary="@string/selectedValue"
android:title="@string/audioSLESBufferSize_title" /> android:title="@string/audioSLESBufferSize_title" />
<paulscode.android.mupen64plusae.preference.CompatListPreference <paulscode.android.mupen64plusae.preference.CompatListPreference
android:defaultValue="@string/audioSLESBufferNbr_default" android:defaultValue="@string/audioSLESBufferNbr_default"
android:entries="@array/audioSLESBufferNbr_entries" android:entries="@array/audioSLESBufferNbr_entries"
android:entryValues="@array/audioSLESBufferNbr_values" android:entryValues="@array/audioSLESBufferNbr_values"
Expand All @@ -157,9 +159,10 @@
android:key="audioSwapChannels" android:key="audioSwapChannels"
android:summary="@string/audioSwapChannels_summary" android:summary="@string/audioSwapChannels_summary"
android:title="@string/audioSwapChannels_title" /> android:title="@string/audioSwapChannels_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryTouchscreen" android:key="categoryTouchscreen"
android:selectable="true"
android:title="@string/categoryTouchscreen_title" > android:title="@string/categoryTouchscreen_title" >
<paulscode.android.mupen64plusae.preference.SeekBarPreference <paulscode.android.mupen64plusae.preference.SeekBarPreference
android:defaultValue="100" android:defaultValue="100"
Expand All @@ -169,7 +172,6 @@
mupen64:minimumValue="50" mupen64:minimumValue="50"
mupen64:stepSize="1" mupen64:stepSize="1"
mupen64:units="%" /> mupen64:units="%" />

<paulscode.android.mupen64plusae.preference.SeekBarPreference <paulscode.android.mupen64plusae.preference.SeekBarPreference
android:defaultValue="100" android:defaultValue="100"
android:key="touchscreenTransparency" android:key="touchscreenTransparency"
Expand All @@ -191,9 +193,10 @@
android:key="touchscreenAutoHold" android:key="touchscreenAutoHold"
android:summary="@string/selectedValue" android:summary="@string/selectedValue"
android:title="@string/touchscreenAutoHold_title" /> android:title="@string/touchscreenAutoHold_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryInput" android:key="categoryInput"
android:selectable="true"
android:title="@string/categoryInput_title" > android:title="@string/categoryInput_title" >
<paulscode.android.mupen64plusae.preference.CompatListPreference <paulscode.android.mupen64plusae.preference.CompatListPreference
android:defaultValue="@string/navigationMode_default" android:defaultValue="@string/navigationMode_default"
Expand All @@ -202,6 +205,7 @@
android:key="navigationMode" android:key="navigationMode"
android:summary="@string/navigationMode_summary" android:summary="@string/navigationMode_summary"
android:title="@string/navigationMode_title" /> android:title="@string/navigationMode_title" />

<android.support.v7.preference.CheckBoxPreference <android.support.v7.preference.CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="inputVolumeMappable" android:key="inputVolumeMappable"
Expand All @@ -212,29 +216,31 @@
android:key="inputShareController" android:key="inputShareController"
android:summary="@string/inputShareController_summary" android:summary="@string/inputShareController_summary"
android:title="@string/inputShareController_title" /> android:title="@string/inputShareController_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>
<android.support.v7.preference.PreferenceCategory <paulscode.android.mupen64plusae.preference.CustomPreferenceCategory
android:key="categoryData" android:key="categoryData"
android:selectable="true"
android:title="@string/categoryData_title" > android:title="@string/categoryData_title" >
<paulscode.android.mupen64plusae.preference.PathPreference <paulscode.android.mupen64plusae.preference.PathPreference
android:defaultValue="@string/pathGameSaves_default" android:defaultValue="@string/pathGameSaves_default"
android:key="pathGameSaves" android:key="pathGameSaves"
android:title="@string/pathGameSaves_title" android:title="@string/pathGameSaves_title"
mupen64:selectionMode="0" /> mupen64:selectionMode="0" />

<paulscode.android.mupen64plusae.preference.SeekBarPreference <paulscode.android.mupen64plusae.preference.SeekBarPreference
android:defaultValue="4" android:defaultValue="4"
android:key="gameAutoSaves" android:key="gameAutoSaves"
android:title="@string/GameAutoSavesMax_title" android:title="@string/GameAutoSavesMax_title"
mupen64:minimumValue="1"
mupen64:maximumValue="10" mupen64:maximumValue="10"
mupen64:minimumValue="1"
mupen64:stepSize="1" mupen64:stepSize="1"
mupen64:units="" /> mupen64:units="" />


<android.support.v7.preference.Preference <android.support.v7.preference.Preference
android:key="actionReloadAssets" android:key="actionReloadAssets"
android:summary="@string/actionReloadAssets_summary" android:summary="@string/actionReloadAssets_summary"
android:title="@string/actionReloadAssets_title" /> android:title="@string/actionReloadAssets_title" />
</android.support.v7.preference.PreferenceCategory> </paulscode.android.mupen64plusae.preference.CustomPreferenceCategory>


<android.support.v7.preference.Preference <android.support.v7.preference.Preference
android:icon="@drawable/ic_undo" android:icon="@drawable/ic_undo"
Expand Down
@@ -0,0 +1,59 @@
/**
* Mupen64PlusAE, an N64 emulator for the Android platform
*
* Copyright (C) 2013 Paul Lamb
*
* This file is part of Mupen64PlusAE.
*
* Mupen64PlusAE is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Mupen64PlusAE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Mupen64PlusAE. If
* not, see <http://www.gnu.org/licenses/>.
*
* Authors: fzurita
*/
package paulscode.android.mupen64plusae.preference;

import org.mupen64plusae.v3.alpha.R;

import android.content.Context;
import android.support.v7.preference.PreferenceCategory;
import android.util.AttributeSet;

/**
* A type of {@link PreferenceCategory} that is focusable
*/

public class CustomPreferenceCategory extends PreferenceCategory
{
/**
* Constructor
*
* @param context The {@link Context} this CustomPreferenceCategory is being used in.
* @param attrs A collection of attributes, as found associated with a tag in an XML document.
*/
public CustomPreferenceCategory( Context context, AttributeSet attrs )
{
super( context, attrs);
setLayoutResource(R.layout.custom_preference_category);
setSelectable(true);
}

/**
* Constructor
*
* @param context The {@link Context} this CustomPreferenceCategory will be used in.
*/
public CustomPreferenceCategory( Context context )
{
super( context );
setLayoutResource(R.layout.custom_preference_category);
setSelectable(true);
}
}

0 comments on commit 144134a

Please sign in to comment.