Reformat Android code

This commit is contained in:
riking 2018-08-26 21:37:54 -07:00
parent ab76631a7f
commit 248ee12aed
102 changed files with 11134 additions and 10354 deletions

View File

@ -67,7 +67,8 @@ android {
defaultConfig { defaultConfig {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments "-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo" // , "-DENABLE_GENERIC=ON" arguments "-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
// , "-DENABLE_GENERIC=ON"
abiFilters "arm64-v8a", "x86_64" //, "armeabi-v7a", "x86" abiFilters "arm64-v8a", "x86_64" //, "armeabi-v7a", "x86"
} }
} }

View File

@ -11,13 +11,13 @@
android:name="android.software.leanback" android:name="android.software.leanback"
android:required="false"/> android:required="false"/>
<uses-feature android:glEsVersion="0x00030000" /> <uses-feature android:glEsVersion="0x00030000"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" /> <uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA"/>
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA"/>
<application <application
android:name=".DolphinApplication" android:name=".DolphinApplication"
@ -27,7 +27,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:isGame="true" android:isGame="true"
android:banner="@drawable/banner_tv"> android:banner="@drawable/banner_tv">
<meta-data android:name="android.max_aspect" android:value="2.1" /> <meta-data
android:name="android.max_aspect"
android:value="2.1"/>
<activity <activity
android:name=".ui.main.MainActivity" android:name=".ui.main.MainActivity"
@ -67,18 +69,18 @@
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/FilePickerTheme"> android:theme="@style/FilePickerTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.GET_CONTENT" /> <action android:name="android.intent.action.GET_CONTENT"/>
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".activities.AppLinkActivity" > <activity android:name=".activities.AppLinkActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT"/>
<data <data
android:host="@string/host" android:host="@string/host"
android:scheme="@string/scheme" /> android:scheme="@string/scheme"/>
</intent-filter> </intent-filter>
</activity> </activity>
@ -87,11 +89,11 @@
<service <service
android:name=".services.SyncChannelJobService" android:name=".services.SyncChannelJobService"
android:exported="false" android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" /> android:permission="android.permission.BIND_JOB_SERVICE"/>
<service <service
android:name=".services.SyncProgramsJobService" android:name=".services.SyncProgramsJobService"
android:exported="false" android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" /> android:permission="android.permission.BIND_JOB_SERVICE"/>
<provider <provider
android:name="android.support.v4.content.FileProvider" android:name="android.support.v4.content.FileProvider"
@ -100,7 +102,7 @@
android:grantUriPermissions="true"> android:grantUriPermissions="true">
<meta-data <meta-data
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/nnf_provider_paths" /> android:resource="@xml/nnf_provider_paths"/>
</provider> </provider>
</application> </application>

View File

@ -7,13 +7,7 @@
package org.dolphinemu.dolphinemu; package org.dolphinemu.dolphinemu;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.content.res.AssetManager;
import android.view.Surface; import android.view.Surface;
import android.widget.Toast;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.utils.Log; import org.dolphinemu.dolphinemu.utils.Log;
@ -218,7 +212,6 @@ public final class NativeLibrary
* @param Device The input descriptor of the gamepad. * @param Device The input descriptor of the gamepad.
* @param Button Key code identifying which button was pressed. * @param Button Key code identifying which button was pressed.
* @param Action Mask identifying which action is happening (button pressed down, or button released). * @param Action Mask identifying which action is happening (button pressed down, or button released).
*
* @return If we handled the button press. * @return If we handled the button press.
*/ */
public static native boolean onGamePadEvent(String Device, int Button, int Action); public static native boolean onGamePadEvent(String Device, int Button, int Action);
@ -245,10 +238,10 @@ public final class NativeLibrary
* @param Section The section key that the actual key is in. * @param Section The section key that the actual key is in.
* @param Key The key to get the value from. * @param Key The key to get the value from.
* @param Default The value to return in the event the given key doesn't exist. * @param Default The value to return in the event the given key doesn't exist.
*
* @return the value stored at the key, or a default value if it doesn't exist. * @return the value stored at the key, or a default value if it doesn't exist.
*/ */
public static native String GetConfig(String configFile, String Section, String Key, String Default); public static native String GetConfig(String configFile, String Section, String Key,
String Default);
/** /**
* Sets a value to a key in the given ini config file. * Sets a value to a key in the given ini config file.
@ -333,22 +326,32 @@ public final class NativeLibrary
// Surface Handling // Surface Handling
public static native void SurfaceChanged(Surface surf); public static native void SurfaceChanged(Surface surf);
public static native void SurfaceDestroyed(); public static native void SurfaceDestroyed();
/** Unpauses emulation from a paused state. */ /**
* Unpauses emulation from a paused state.
*/
public static native void UnPauseEmulation(); public static native void UnPauseEmulation();
/** Pauses emulation. */ /**
* Pauses emulation.
*/
public static native void PauseEmulation(); public static native void PauseEmulation();
/** Stops emulation. */ /**
* Stops emulation.
*/
public static native void StopEmulation(); public static native void StopEmulation();
/** Returns true if emulation is running (or is paused). */ /**
* Returns true if emulation is running (or is paused).
*/
public static native boolean IsRunning(); public static native boolean IsRunning();
/** /**
* Enables or disables CPU block profiling * Enables or disables CPU block profiling
*
* @param enable * @param enable
*/ */
public static native void SetProfiling(boolean enable); public static native void SetProfiling(boolean enable);
@ -358,7 +361,9 @@ public final class NativeLibrary
*/ */
public static native void WriteProfileResults(); public static native void WriteProfileResults();
/** Native EGL functions not exposed by Java bindings **/ /**
* Native EGL functions not exposed by Java bindings
**/
public static native void eglBindAPI(int api); public static native void eglBindAPI(int api);
/** /**
@ -367,7 +372,9 @@ public final class NativeLibrary
public static native void RefreshWiimotes(); public static native void RefreshWiimotes();
private static boolean alertResult = false; private static boolean alertResult = false;
public static boolean displayAlertMsg(final String caption, final String text, final boolean yesNo)
public static boolean displayAlertMsg(final String caption, final String text,
final boolean yesNo)
{ {
Log.error("[NativeLibrary] Alert: " + text); Log.error("[NativeLibrary] Alert: " + text);
final EmulationActivity emulationActivity = sEmulationActivity.get(); final EmulationActivity emulationActivity = sEmulationActivity.get();
@ -434,7 +441,9 @@ public final class NativeLibrary
{ {
lock.wait(); lock.wait();
} }
catch (Exception e) { } catch (Exception e)
{
}
} }
if (yesNo) if (yesNo)

View File

@ -69,16 +69,19 @@ public class AppLinkActivity extends FragmentActivity
directoryStateReceiver = directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState -> new DirectoryStateReceiver(directoryInitializationState ->
{ {
if (directoryInitializationState == DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED) if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{ {
play(playAction); play(playAction);
} }
else if (directoryInitializationState == DirectoryInitializationService.DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED) else if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
{ {
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT) Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show(); .show();
} }
else if (directoryInitializationState == DirectoryInitializationService.DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE) else if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
{ {
Toast.makeText(this, R.string.external_storage_not_mounted, Toast.LENGTH_SHORT) Toast.makeText(this, R.string.external_storage_not_mounted, Toast.LENGTH_SHORT)
.show(); .show();

View File

@ -21,7 +21,8 @@ public class CustomFilePickerActivity extends FilePickerActivity
{ {
AbstractFilePickerFragment<File> fragment = new CustomFilePickerFragment(); AbstractFilePickerFragment<File> fragment = new CustomFilePickerFragment();
// startPath is allowed to be null. In that case, default folder should be SD-card and not "/" // startPath is allowed to be null. In that case, default folder should be SD-card and not "/"
fragment.setArgs(startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(), fragment.setArgs(
startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(),
mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick); mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
return fragment; return fragment;
} }

View File

@ -95,7 +95,8 @@ public final class EmulationActivity extends AppCompatActivity
MENU_ACTION_SAVE_SLOT6, MENU_ACTION_LOAD_SLOT1, MENU_ACTION_LOAD_SLOT2, MENU_ACTION_SAVE_SLOT6, MENU_ACTION_LOAD_SLOT1, MENU_ACTION_LOAD_SLOT2,
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5, MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC}) MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC})
public @interface MenuAction { public @interface MenuAction
{
} }
public static final int MENU_ACTION_EDIT_CONTROLS_PLACEMENT = 0; public static final int MENU_ACTION_EDIT_CONTROLS_PLACEMENT = 0;
@ -126,18 +127,28 @@ public final class EmulationActivity extends AppCompatActivity
private static SparseIntArray buttonsActionsMap = new SparseIntArray(); private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_emulation_edit_layout, EmulationActivity.MENU_ACTION_EDIT_CONTROLS_PLACEMENT); static
buttonsActionsMap.append(R.id.menu_emulation_toggle_controls, EmulationActivity.MENU_ACTION_TOGGLE_CONTROLS); {
buttonsActionsMap.append(R.id.menu_emulation_adjust_scale, EmulationActivity.MENU_ACTION_ADJUST_SCALE); buttonsActionsMap.append(R.id.menu_emulation_edit_layout,
buttonsActionsMap.append(R.id.menu_emulation_choose_controller, EmulationActivity.MENU_ACTION_CHOOSE_CONTROLLER); EmulationActivity.MENU_ACTION_EDIT_CONTROLS_PLACEMENT);
buttonsActionsMap.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES); buttonsActionsMap.append(R.id.menu_emulation_toggle_controls,
buttonsActionsMap.append(R.id.menu_emulation_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT); EmulationActivity.MENU_ACTION_TOGGLE_CONTROLS);
buttonsActionsMap
.append(R.id.menu_emulation_adjust_scale, EmulationActivity.MENU_ACTION_ADJUST_SCALE);
buttonsActionsMap.append(R.id.menu_emulation_choose_controller,
EmulationActivity.MENU_ACTION_CHOOSE_CONTROLLER);
buttonsActionsMap
.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES);
buttonsActionsMap
.append(R.id.menu_emulation_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT);
buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE); buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE);
buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD); buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD);
buttonsActionsMap.append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT); buttonsActionsMap
buttonsActionsMap.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT); .append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT);
buttonsActionsMap
.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT);
buttonsActionsMap.append(R.id.menu_emulation_save_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1); buttonsActionsMap.append(R.id.menu_emulation_save_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1);
buttonsActionsMap.append(R.id.menu_emulation_save_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2); buttonsActionsMap.append(R.id.menu_emulation_save_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2);
buttonsActionsMap.append(R.id.menu_emulation_save_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3); buttonsActionsMap.append(R.id.menu_emulation_save_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3);
@ -150,10 +161,12 @@ public final class EmulationActivity extends AppCompatActivity
buttonsActionsMap.append(R.id.menu_emulation_load_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5); buttonsActionsMap.append(R.id.menu_emulation_load_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5);
buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC); buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center, EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER); buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center,
EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER);
} }
public static void launch(FragmentActivity activity, GameFile gameFile, int position, View sharedView) public static void launch(FragmentActivity activity, GameFile gameFile, int position,
View sharedView)
{ {
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
@ -225,7 +238,8 @@ public final class EmulationActivity extends AppCompatActivity
}); });
// Set these options now so that the SurfaceView the game renders into is the right size. // Set these options now so that the SurfaceView the game renders into is the right size.
enableFullscreenImmersive(); enableFullscreenImmersive();
Toast.makeText(this, getString(R.string.emulation_touch_button_help), Toast.LENGTH_LONG).show(); Toast.makeText(this, getString(R.string.emulation_touch_button_help), Toast.LENGTH_LONG)
.show();
} }
else else
{ {
@ -382,7 +396,8 @@ public final class EmulationActivity extends AppCompatActivity
BACKSTACK_NAME_MENU, FragmentManager.POP_BACK_STACK_INCLUSIVE); BACKSTACK_NAME_MENU, FragmentManager.POP_BACK_STACK_INCLUSIVE);
mMenuVisible = false; mMenuVisible = false;
if (!result) { if (!result)
{
// Removing the menu failed, so that means it wasn't visible. Add it. // Removing the menu failed, so that means it wasn't visible. Add it.
Fragment fragment = MenuFragment.newInstance(mSelectedTitle); Fragment fragment = MenuFragment.newInstance(mSelectedTitle);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
@ -398,7 +413,8 @@ public final class EmulationActivity extends AppCompatActivity
} }
} }
public void exitWithAnimation() { public void exitWithAnimation()
{
runOnUiThread(() -> runOnUiThread(() ->
{ {
Picasso.with(EmulationActivity.this) Picasso.with(EmulationActivity.this)
@ -408,14 +424,17 @@ public final class EmulationActivity extends AppCompatActivity
.load(mScreenPath) .load(mScreenPath)
.noFade() .noFade()
.noPlaceholder() .noPlaceholder()
.into(mImageView, new Callback() { .into(mImageView, new Callback()
{
@Override @Override
public void onSuccess() { public void onSuccess()
{
showScreenshot(); showScreenshot();
} }
@Override @Override
public void onError() { public void onError()
{
finish(); finish();
} }
}); });
@ -452,7 +471,8 @@ public final class EmulationActivity extends AppCompatActivity
} }
// Populate the checkbox value for joystick center on touch // Populate the checkbox value for joystick center on touch
menu.findItem(R.id.menu_emulation_joystick_rel_center).setChecked(mPreferences.getBoolean("joystickRelCenter", true)); menu.findItem(R.id.menu_emulation_joystick_rel_center)
.setChecked(mPreferences.getBoolean("joystickRelCenter", true));
return true; return true;
} }
@ -601,7 +621,7 @@ public final class EmulationActivity extends AppCompatActivity
case MENU_ACTION_EXIT: case MENU_ACTION_EXIT:
// ATV menu is built using a fragment, this will pop that fragment before emulation ends. // ATV menu is built using a fragment, this will pop that fragment before emulation ends.
if(TvUtil.isLeanback(getApplicationContext())) if (TvUtil.isLeanback(getApplicationContext()))
toggleMenu(); // Hide the menu (it will be showing since we just clicked it) toggleMenu(); // Hide the menu (it will be showing since we just clicked it)
mEmulationFragment.stopEmulation(); mEmulationFragment.stopEmulation();
exitWithAnimation(); exitWithAnimation();
@ -663,36 +683,53 @@ public final class EmulationActivity extends AppCompatActivity
return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action); return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action);
} }
private void toggleControls() { private void toggleControls()
{
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
boolean[] enabledButtons = new boolean[14]; boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_toggle_controls); builder.setTitle(R.string.emulation_toggle_controls);
if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0) { if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
for (int i = 0; i < enabledButtons.length; i++) { {
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true); enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
} }
builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons, builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleGc" + indexSelected, isChecked)); (dialog, indexSelected, isChecked) -> editor
} else if (mPreferences.getInt("wiiController", 3) == 4) { .putBoolean("buttonToggleGc" + indexSelected, isChecked));
for (int i = 0; i < enabledButtons.length; i++) { }
else if (mPreferences.getInt("wiiController", 3) == 4)
{
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true); enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true);
} }
builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons, builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleClassic" + indexSelected, isChecked)); (dialog, indexSelected, isChecked) -> editor
} else { .putBoolean("buttonToggleClassic" + indexSelected, isChecked));
for (int i = 0; i < enabledButtons.length; i++) { }
else
{
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true); enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true);
} }
if (mPreferences.getInt("wiiController", 3) == 3) { if (mPreferences.getInt("wiiController", 3) == 3)
{
builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons, builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleWii" + indexSelected, isChecked)); (dialog, indexSelected, isChecked) -> editor
} else { .putBoolean("buttonToggleWii" + indexSelected, isChecked));
}
else
{
builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons, builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor.putBoolean("buttonToggleWii" + indexSelected, isChecked)); (dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggleWii" + indexSelected, isChecked));
} }
} }
builder.setNeutralButton(getString(R.string.emulation_toggle_all), (dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility()); builder.setNeutralButton(getString(R.string.emulation_toggle_all),
(dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility());
builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) ->
{ {
editor.apply(); editor.apply();
@ -704,7 +741,8 @@ public final class EmulationActivity extends AppCompatActivity
alertDialog.show(); alertDialog.show();
} }
private void adjustScale() { private void adjustScale()
{
LayoutInflater inflater = LayoutInflater.from(this); LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_seekbar, null); View view = inflater.inflate(R.layout.dialog_seekbar, null);
@ -714,16 +752,20 @@ public final class EmulationActivity extends AppCompatActivity
seekbar.setMax(150); seekbar.setMax(150);
seekbar.setProgress(mPreferences.getInt("controlScale", 50)); seekbar.setProgress(mPreferences.getInt("controlScale", 50));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
public void onStartTrackingTouch(SeekBar seekBar) { {
public void onStartTrackingTouch(SeekBar seekBar)
{
// Do nothing // Do nothing
} }
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
value.setText(String.valueOf(progress + 50)); value.setText(String.valueOf(progress + 50));
} }
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar)
{
// Do nothing // Do nothing
} }
}); });
@ -747,11 +789,13 @@ public final class EmulationActivity extends AppCompatActivity
alertDialog.show(); alertDialog.show();
} }
private void chooseController() { private void chooseController()
{
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_choose_controller); builder.setTitle(R.string.emulation_choose_controller);
builder.setSingleChoiceItems(R.array.controllersEntries, mPreferences.getInt("wiiController", 3), builder.setSingleChoiceItems(R.array.controllersEntries,
mPreferences.getInt("wiiController", 3),
(dialog, indexSelected) -> (dialog, indexSelected) ->
{ {
editor.putInt("wiiController", indexSelected); editor.putInt("wiiController", indexSelected);
@ -765,7 +809,8 @@ public final class EmulationActivity extends AppCompatActivity
mEmulationFragment.refreshInputOverlay(); mEmulationFragment.refreshInputOverlay();
Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT)
.show();
}); });
AlertDialog alertDialog = builder.create(); AlertDialog alertDialog = builder.create();

View File

@ -12,10 +12,10 @@ import android.widget.Toast;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.PicassoUtils; import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
@ -152,9 +152,12 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Game Settings") builder.setTitle("Game Settings")
.setItems(R.array.gameSettingsMenus, new DialogInterface.OnClickListener() { .setItems(R.array.gameSettingsMenus, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which) { {
switch (which) { public void onClick(DialogInterface dialog, int which)
{
switch (which)
{
case 0: case 0:
SettingsActivity.launch(activity, MenuTag.CONFIG, gameId); SettingsActivity.launch(activity, MenuTag.CONFIG, gameId);
break; break;
@ -162,22 +165,27 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId); SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId);
break; break;
case 2: case 2:
String path = DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini"; String path =
DirectoryInitializationService.getUserDirectory() + "/GameSettings/" +
gameId + ".ini";
File gameSettingsFile = new File(path); File gameSettingsFile = new File(path);
if (gameSettingsFile.exists()) if (gameSettingsFile.exists())
{ {
if (gameSettingsFile.delete()) if (gameSettingsFile.delete())
{ {
Toast.makeText(view.getContext(), "Cleared settings for " + gameId, Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(), "Cleared settings for " + gameId,
Toast.LENGTH_SHORT).show();
} }
else else
{ {
Toast.makeText(view.getContext(), "Unable to clear settings for " + gameId, Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(), "Unable to clear settings for " + gameId,
Toast.LENGTH_SHORT).show();
} }
} }
else else
{ {
Toast.makeText(view.getContext(), "No game settings to delete", Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(), "No game settings to delete",
Toast.LENGTH_SHORT).show();
} }
break; break;
} }
@ -198,7 +206,8 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
} }
@Override @Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state)
{ {
outRect.left = space; outRect.left = space;
outRect.right = space; outRect.right = space;

View File

@ -14,11 +14,11 @@ import android.widget.ImageView;
import android.widget.Toast; import android.widget.Toast;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService; import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.PicassoUtils; import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder; import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
@ -80,7 +80,8 @@ public final class GameRowPresenter extends Presenter
Context context = holder.cardParent.getContext(); Context context = holder.cardParent.getContext();
Drawable background = ContextCompat.getDrawable(context, backgroundId); Drawable background = ContextCompat.getDrawable(context, backgroundId);
holder.cardParent.setInfoAreaBackground(background); holder.cardParent.setInfoAreaBackground(background);
holder.cardParent.setOnLongClickListener(new View.OnLongClickListener() { holder.cardParent.setOnLongClickListener(new View.OnLongClickListener()
{
@Override @Override
public boolean onLongClick(View view) public boolean onLongClick(View view)
{ {
@ -99,9 +100,12 @@ public final class GameRowPresenter extends Presenter
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Game Settings") builder.setTitle("Game Settings")
.setItems(R.array.gameSettingsMenus, new DialogInterface.OnClickListener() { .setItems(R.array.gameSettingsMenus, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which) { {
switch (which) { public void onClick(DialogInterface dialog, int which)
{
switch (which)
{
case 0: case 0:
SettingsActivity.launch(activity, MenuTag.CONFIG, gameId); SettingsActivity.launch(activity, MenuTag.CONFIG, gameId);
break; break;
@ -109,22 +113,27 @@ public final class GameRowPresenter extends Presenter
SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId); SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId);
break; break;
case 2: case 2:
String path = DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini"; String path = DirectoryInitializationService.getUserDirectory() +
"/GameSettings/" + gameId + ".ini";
File gameSettingsFile = new File(path); File gameSettingsFile = new File(path);
if (gameSettingsFile.exists()) if (gameSettingsFile.exists())
{ {
if (gameSettingsFile.delete()) if (gameSettingsFile.delete())
{ {
Toast.makeText(view.getContext(), "Cleared settings for " + gameId, Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(), "Cleared settings for " + gameId,
Toast.LENGTH_SHORT).show();
} }
else else
{ {
Toast.makeText(view.getContext(), "Unable to clear settings for " + gameId, Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(),
"Unable to clear settings for " + gameId, Toast.LENGTH_SHORT)
.show();
} }
} }
else else
{ {
Toast.makeText(view.getContext(), "No game settings to delete", Toast.LENGTH_SHORT).show(); Toast.makeText(view.getContext(), "No game settings to delete",
Toast.LENGTH_SHORT).show();
} }
break; break;
} }

View File

@ -2,9 +2,9 @@ package org.dolphinemu.dolphinemu.adapters;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;

View File

@ -5,14 +5,12 @@ import android.app.Dialog;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
@ -41,7 +39,8 @@ public final class GameDetailsDialog extends DialogFragment
GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH)); GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.dialog_game_details, null); ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater()
.inflate(R.layout.dialog_game_details, null);
final ImageView imageGameScreen = contents.findViewById(R.id.image_game_screen); final ImageView imageGameScreen = contents.findViewById(R.id.image_game_screen);
CircleImageView circleBanner = contents.findViewById(R.id.circle_banner); CircleImageView circleBanner = contents.findViewById(R.id.circle_banner);

View File

@ -192,15 +192,19 @@ public final class MotionAlertDialog extends AlertDialog
* @param motionRange MotionRange of the movement * @param motionRange MotionRange of the movement
* @param axisDir Either '-' or '+' * @param axisDir Either '-' or '+'
*/ */
private void saveMotionInput(InputDevice device, InputDevice.MotionRange motionRange, char axisDir) private void saveMotionInput(InputDevice device, InputDevice.MotionRange motionRange,
char axisDir)
{ {
String bindStr = "Device '" + device.getDescriptor() + "'-Axis " + motionRange.getAxis() + axisDir; String bindStr =
"Device '" + device.getDescriptor() + "'-Axis " + motionRange.getAxis() + axisDir;
String uiString = device.getName() + ": Axis " + motionRange.getAxis() + axisDir; String uiString = device.getName() + ": Axis " + motionRange.getAxis() + axisDir;
saveInput(bindStr, uiString); saveInput(bindStr, uiString);
} }
/** Save the input string to settings and SharedPreferences, then dismiss this Dialog. */ /**
* Save the input string to settings and SharedPreferences, then dismiss this Dialog.
*/
private void saveInput(String bind, String ui) private void saveInput(String bind, String ui)
{ {
setting.setValue(bind); setting.setValue(bind);

View File

@ -24,7 +24,6 @@ public abstract class Setting
} }
/** /**
*
* @return The identifier used to write this setting to the ini file. * @return The identifier used to write this setting to the ini file.
*/ */
public String getKey() public String getKey()
@ -33,7 +32,6 @@ public abstract class Setting
} }
/** /**
*
* @return The name of the header under which this Setting should be written in the ini file. * @return The name of the header under which this Setting should be written in the ini file.
*/ */
public String getSection() public String getSection()

View File

@ -35,9 +35,15 @@ public class Settings
static static
{ {
configFileSectionsMap.put(SettingsFile.FILE_NAME_DOLPHIN, Arrays.asList(SECTION_INI_CORE, SECTION_INI_INTERFACE, SECTION_BINDINGS, SECTION_ANALYTICS)); configFileSectionsMap.put(SettingsFile.FILE_NAME_DOLPHIN,
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX, Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS, SECTION_STEREOSCOPY)); Arrays.asList(SECTION_INI_CORE, SECTION_INI_INTERFACE, SECTION_BINDINGS,
configFileSectionsMap.put(SettingsFile.FILE_NAME_WIIMOTE, Arrays.asList(SECTION_WIIMOTE + 1, SECTION_WIIMOTE + 2, SECTION_WIIMOTE + 3, SECTION_WIIMOTE + 4)); SECTION_ANALYTICS));
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX,
Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS,
SECTION_STEREOSCOPY));
configFileSectionsMap.put(SettingsFile.FILE_NAME_WIIMOTE,
Arrays.asList(SECTION_WIIMOTE + 1, SECTION_WIIMOTE + 2, SECTION_WIIMOTE + 3,
SECTION_WIIMOTE + 4));
} }
/** /**
@ -108,7 +114,7 @@ public class Settings
for (Map.Entry<String, List<String>> entry : configFileSectionsMap.entrySet()) for (Map.Entry<String, List<String>> entry : configFileSectionsMap.entrySet())
{ {
String fileName = entry.getKey(); String fileName = entry.getKey();
if(filesToExclude == null || !filesToExclude.contains(fileName)) if (filesToExclude == null || !filesToExclude.contains(fileName))
{ {
sections.putAll(SettingsFile.readFile(fileName, view)); sections.putAll(SettingsFile.readFile(fileName, view));
} }

View File

@ -7,7 +7,8 @@ public final class CheckBoxSetting extends SettingsItem
{ {
private boolean mDefaultValue; private boolean mDefaultValue;
public CheckBoxSetting(String key, String section, int titleId, int descriptionId, boolean defaultValue, Setting setting) public CheckBoxSetting(String key, String section, int titleId, int descriptionId,
boolean defaultValue, Setting setting)
{ {
super(key, section, setting, titleId, descriptionId); super(key, section, setting, titleId, descriptionId);
mDefaultValue = defaultValue; mDefaultValue = defaultValue;

View File

@ -1,7 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
import org.dolphinemu.dolphinemu.features.settings.model.Setting; import org.dolphinemu.dolphinemu.features.settings.model.Setting;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
/** /**
* ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments. * ViewModel abstraction for an Item in the RecyclerView powering SettingsFragments.
@ -48,7 +48,6 @@ public abstract class SettingsItem
} }
/** /**
*
* @return The identifier for the backing Setting. * @return The identifier for the backing Setting.
*/ */
public String getKey() public String getKey()
@ -57,7 +56,6 @@ public abstract class SettingsItem
} }
/** /**
*
* @return The header under which the backing Setting belongs. * @return The header under which the backing Setting belongs.
*/ */
public String getSection() public String getSection()
@ -67,7 +65,6 @@ public abstract class SettingsItem
/** /**
*
* @return The backing Setting, possibly null. * @return The backing Setting, possibly null.
*/ */
public Setting getSetting() public Setting getSetting()
@ -87,7 +84,6 @@ public abstract class SettingsItem
} }
/** /**
*
* @return A resource ID for a text string representing this Setting's name. * @return A resource ID for a text string representing this Setting's name.
*/ */
public int getNameId() public int getNameId()

View File

@ -12,7 +12,8 @@ public final class SingleChoiceSetting extends SettingsItem
private int mValuesId; private int mValuesId;
private MenuTag menuTag; private MenuTag menuTag;
public SingleChoiceSetting(String key, String section, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting, MenuTag menuTag) public SingleChoiceSetting(String key, String section, int titleId, int descriptionId,
int choicesId, int valuesId, int defaultValue, Setting setting, MenuTag menuTag)
{ {
super(key, section, setting, titleId, descriptionId); super(key, section, setting, titleId, descriptionId);
mValuesId = valuesId; mValuesId = valuesId;
@ -21,7 +22,8 @@ public final class SingleChoiceSetting extends SettingsItem
this.menuTag = menuTag; this.menuTag = menuTag;
} }
public SingleChoiceSetting(String key, String section, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting) public SingleChoiceSetting(String key, String section, int titleId, int descriptionId,
int choicesId, int valuesId, int defaultValue, Setting setting)
{ {
this(key, section, titleId, descriptionId, choicesId, valuesId, defaultValue, setting, null); this(key, section, titleId, descriptionId, choicesId, valuesId, defaultValue, setting, null);
} }

View File

@ -3,8 +3,8 @@ package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Setting; import org.dolphinemu.dolphinemu.features.settings.model.Setting;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.utils.Log;
public final class SliderSetting extends SettingsItem public final class SliderSetting extends SettingsItem
{ {
@ -13,7 +13,8 @@ public final class SliderSetting extends SettingsItem
private String mUnits; private String mUnits;
public SliderSetting(String key, String section, int titleId, int descriptionId, int max, String units, int defaultValue, Setting setting) public SliderSetting(String key, String section, int titleId, int descriptionId, int max,
String units, int defaultValue, Setting setting)
{ {
super(key, section, setting, titleId, descriptionId); super(key, section, setting, titleId, descriptionId);
mMax = max; mMax = max;

View File

@ -10,7 +10,8 @@ public class StringSingleChoiceSetting extends SettingsItem
private String[] mChoicesId; private String[] mChoicesId;
private String[] mValuesId; private String[] mValuesId;
public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId, String[] choicesId, String[] valuesId, String defaultValue, Setting setting) public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId,
String[] choicesId, String[] valuesId, String defaultValue, Setting setting)
{ {
super(key, section, setting, titleId, descriptionId); super(key, section, setting, titleId, descriptionId);
mValuesId = valuesId; mValuesId = valuesId;
@ -54,16 +55,20 @@ public class StringSingleChoiceSetting extends SettingsItem
} }
} }
public int getSelectValueIndex() { public int getSelectValueIndex()
{
String selectedValue = getSelectedValue(); String selectedValue = getSelectedValue();
for(int i=0;i<mValuesId.length;i++) { for (int i = 0; i < mValuesId.length; i++)
if(mValuesId[i].equals(selectedValue)) { {
if (mValuesId[i].equals(selectedValue))
{
return i; return i;
} }
} }
return -1; return -1;
} }
/** /**
* Write a value to the backing int. If that int was previously null, * Write a value to the backing int. If that int was previously null,
* initializes a new one and returns it, so it can be added to the Hashmap. * initializes a new one and returns it, so it can be added to the Hashmap.

View File

@ -7,7 +7,8 @@ public final class SubmenuSetting extends SettingsItem
{ {
private MenuTag mMenuKey; private MenuTag mMenuKey;
public SubmenuSetting(String key, Setting setting, int titleId, int descriptionId, MenuTag menuKey) public SubmenuSetting(String key, Setting setting, int titleId, int descriptionId,
MenuTag menuKey)
{ {
super(key, null, setting, titleId, descriptionId); super(key, null, setting, titleId, descriptionId);
mMenuKey = menuKey; mMenuKey = menuKey;

View File

@ -15,12 +15,9 @@ import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.SettingSection;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService; import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver; import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
import java.util.HashMap;
public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
{ {
private static final String ARG_MENU_TAG = "menu_tag"; private static final String ARG_MENU_TAG = "menu_tag";
@ -102,7 +99,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
@Override @Override
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack, String gameID) public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
String gameID)
{ {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
@ -120,7 +118,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
transaction.addToBackStack(null); transaction.addToBackStack(null);
mPresenter.addToStack(); mPresenter.addToStack();
} }
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras), FRAGMENT_TAG); transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras),
FRAGMENT_TAG);
transaction.commit(); transaction.commit();
} }
@ -137,7 +136,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
} }
@Override @Override
public void startDirectoryInitializationService(DirectoryStateReceiver receiver, IntentFilter filter) public void startDirectoryInitializationService(DirectoryStateReceiver receiver,
IntentFilter filter)
{ {
LocalBroadcastManager.getInstance(this).registerReceiver( LocalBroadcastManager.getInstance(this).registerReceiver(
receiver, receiver,
@ -197,7 +197,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
} }
@Override @Override
public void onSettingsFileLoaded(org.dolphinemu.dolphinemu.features.settings.model.Settings settings) public void onSettingsFileLoaded(
org.dolphinemu.dolphinemu.features.settings.model.Settings settings)
{ {
SettingsFragmentView fragment = getFragment(); SettingsFragmentView fragment = getFragment();

View File

@ -84,17 +84,20 @@ public final class SettingsActivityPresenter
directoryStateReceiver = directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState -> new DirectoryStateReceiver(directoryInitializationState ->
{ {
if (directoryInitializationState == DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED) if (directoryInitializationState ==
DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{ {
mView.hideLoading(); mView.hideLoading();
loadSettingsUI(); loadSettingsUI();
} }
else if (directoryInitializationState == DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED) else if (directoryInitializationState ==
DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
{ {
mView.showPermissionNeededHint(); mView.showPermissionNeededHint();
mView.hideLoading(); mView.hideLoading();
} }
else if (directoryInitializationState == DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE) else if (directoryInitializationState ==
DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
{ {
mView.showExternalStorageNotMountedHint(); mView.showExternalStorageNotMountedHint();
mView.hideLoading(); mView.hideLoading();

View File

@ -33,8 +33,8 @@ import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SettingViewHold
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SingleChoiceViewHolder; import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SingleChoiceViewHolder;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SliderViewHolder; import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SliderViewHolder;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHolder; import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHolder;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.utils.Log;
import java.util.ArrayList; import java.util.ArrayList;
@ -142,7 +142,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mView.putSetting(setting); mView.putSetting(setting);
} }
if (item.getKey().equals(SettingsFile.KEY_SKIP_EFB) || item.getKey().equals(SettingsFile.KEY_IGNORE_FORMAT)) if (item.getKey().equals(SettingsFile.KEY_SKIP_EFB) ||
item.getKey().equals(SettingsFile.KEY_IGNORE_FORMAT))
{ {
mView.putSetting(new BooleanSetting(item.getKey(), item.getSection(), !checked)); mView.putSetting(new BooleanSetting(item.getKey(), item.getSection(), !checked));
} }
@ -215,13 +216,16 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{ {
final MotionAlertDialog dialog = new MotionAlertDialog(mContext, item); final MotionAlertDialog dialog = new MotionAlertDialog(mContext, item);
dialog.setTitle(R.string.input_binding); dialog.setTitle(R.string.input_binding);
dialog.setMessage(String.format(mContext.getString(R.string.input_binding_description), mContext.getString(item.getNameId()))); dialog.setMessage(String.format(mContext.getString(R.string.input_binding_description),
mContext.getString(item.getNameId())));
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), this); dialog.setButton(AlertDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), this);
dialog.setButton(AlertDialog.BUTTON_NEUTRAL, mContext.getString(R.string.clear), (dialogInterface, i) -> dialog.setButton(AlertDialog.BUTTON_NEUTRAL, mContext.getString(R.string.clear),
(dialogInterface, i) ->
{ {
item.setValue(""); item.setValue("");
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(mContext);
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(item.getKey()); editor.remove(item.getKey());
editor.apply(); editor.apply();
@ -251,7 +255,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
int value = getValueForSingleChoiceSelection(scSetting, which); int value = getValueForSingleChoiceSelection(scSetting, which);
MenuTag menuTag = scSetting.getMenuTag(); MenuTag menuTag = scSetting.getMenuTag();
if(menuTag != null) if (menuTag != null)
{ {
if (menuTag.isGCPadMenu()) if (menuTag.isGCPadMenu())
{ {
@ -283,7 +287,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
} }
else if (scSetting.getKey().equals(SettingsFile.KEY_WIIMOTE_EXTENSION)) else if (scSetting.getKey().equals(SettingsFile.KEY_WIIMOTE_EXTENSION))
{ {
putExtensionSetting(which, Character.getNumericValue(scSetting.getSection().charAt(scSetting.getSection().length() - 1))); putExtensionSetting(which, Character.getNumericValue(
scSetting.getSection().charAt(scSetting.getSection().length() - 1)));
} }
} }
@ -411,19 +416,23 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
switch (which) switch (which)
{ {
case 0: case 0:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "OGL"); gfxBackend =
new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "OGL");
break; break;
case 1: case 1:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "Vulkan"); gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
"Vulkan");
break; break;
case 2: case 2:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "Software Renderer"); gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
"Software Renderer");
break; break;
case 3: case 3:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "Null"); gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
"Null");
break; break;
} }
@ -432,7 +441,9 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
private void putExtensionSetting(int which, int wiimoteNumber) private void putExtensionSetting(int which, int wiimoteNumber)
{ {
StringSetting extension = new StringSetting(SettingsFile.KEY_WIIMOTE_EXTENSION, Settings.SECTION_WIIMOTE + wiimoteNumber, mContext.getResources().getStringArray(R.array.wiimoteExtensionsEntries)[which]); StringSetting extension = new StringSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
Settings.SECTION_WIIMOTE + wiimoteNumber,
mContext.getResources().getStringArray(R.array.wiimoteExtensionsEntries)[which]);
mView.putSetting(extension); mView.putSetting(extension);
} }
} }

View File

@ -33,7 +33,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
SettingsFragment fragment = new SettingsFragment(); SettingsFragment fragment = new SettingsFragment();
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
if(extras != null) if (extras != null)
{ {
arguments.putAll(extras); arguments.putAll(extras);
} }
@ -85,7 +85,8 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState)
{ {
return inflater.inflate(R.layout.fragment_settings, container, false); return inflater.inflate(R.layout.fragment_settings, container, false);
} }
@ -118,13 +119,15 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
} }
@Override @Override
public void onSettingsFileLoaded(org.dolphinemu.dolphinemu.features.settings.model.Settings settings) public void onSettingsFileLoaded(
org.dolphinemu.dolphinemu.features.settings.model.Settings settings)
{ {
mPresenter.setSettings(settings); mPresenter.setSettings(settings);
} }
@Override @Override
public void passSettingsToActivity(org.dolphinemu.dolphinemu.features.settings.model.Settings settings) public void passSettingsToActivity(
org.dolphinemu.dolphinemu.features.settings.model.Settings settings)
{ {
if (mActivity != null) if (mActivity != null)
{ {

View File

@ -6,7 +6,8 @@ import android.view.View;
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
public abstract class SettingViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener public abstract class SettingViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener
{ {
private SettingsAdapter mAdapter; private SettingsAdapter mAdapter;

View File

@ -10,8 +10,8 @@ import org.dolphinemu.dolphinemu.features.settings.model.Setting;
import org.dolphinemu.dolphinemu.features.settings.model.SettingSection; import org.dolphinemu.dolphinemu.features.settings.model.SettingSection;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.BiMap; import org.dolphinemu.dolphinemu.utils.BiMap;
import org.dolphinemu.dolphinemu.utils.Log; import org.dolphinemu.dolphinemu.utils.Log;
@ -245,7 +245,9 @@ public final class SettingsFile
public static final String KEY_VIDEO_BACKEND_INDEX = "VideoBackendIndex"; public static final String KEY_VIDEO_BACKEND_INDEX = "VideoBackendIndex";
private static BiMap<String, String> sectionsMap = new BiMap<>(); private static BiMap<String, String> sectionsMap = new BiMap<>();
static {
static
{
sectionsMap.add("Hardware", "Video_Hardware"); sectionsMap.add("Hardware", "Video_Hardware");
sectionsMap.add("Settings", "Video_Settings"); sectionsMap.add("Settings", "Video_Settings");
sectionsMap.add("Enhancements", "Video_Enhancements"); sectionsMap.add("Enhancements", "Video_Enhancements");
@ -266,7 +268,8 @@ public final class SettingsFile
* @param ini The ini file to load the settings from * @param ini The ini file to load the settings from
* @param view The current view. * @param view The current view.
*/ */
static HashMap<String, SettingSection> readFile(final File ini, boolean isCustomGame, SettingsActivityView view) static HashMap<String, SettingSection> readFile(final File ini, boolean isCustomGame,
SettingsActivityView view)
{ {
HashMap<String, SettingSection> sections = new Settings.SettingsSectionMap(); HashMap<String, SettingSection> sections = new Settings.SettingsSectionMap();
@ -302,7 +305,7 @@ public final class SettingsFile
} }
catch (IOException e) catch (IOException e)
{ {
Log.error("[SettingsFile] Error reading from: " + ini.getAbsolutePath()+ e.getMessage()); Log.error("[SettingsFile] Error reading from: " + ini.getAbsolutePath() + e.getMessage());
if (view != null) if (view != null)
view.onSettingsFileNotFound(); view.onSettingsFileNotFound();
} }
@ -316,7 +319,7 @@ public final class SettingsFile
} }
catch (IOException e) catch (IOException e)
{ {
Log.error("[SettingsFile] Error closing: " + ini.getAbsolutePath()+ e.getMessage()); Log.error("[SettingsFile] Error closing: " + ini.getAbsolutePath() + e.getMessage());
} }
} }
} }
@ -324,7 +327,8 @@ public final class SettingsFile
return sections; return sections;
} }
public static HashMap<String, SettingSection> readFile(final String fileName, SettingsActivityView view) public static HashMap<String, SettingSection> readFile(final String fileName,
SettingsActivityView view)
{ {
HashMap<String, SettingSection> sections = readFile(getSettingsFile(fileName), false, view); HashMap<String, SettingSection> sections = readFile(getSettingsFile(fileName), false, view);
@ -344,17 +348,20 @@ public final class SettingsFile
* @param gameId the id of the game to load it's settings. * @param gameId the id of the game to load it's settings.
* @param view The current view. * @param view The current view.
*/ */
public static HashMap<String, SettingSection> readCustomGameSettings(final String gameId, SettingsActivityView view) public static HashMap<String, SettingSection> readCustomGameSettings(final String gameId,
SettingsActivityView view)
{ {
return readFile(getCustomGameSettingsFile(gameId), true, view); return readFile(getCustomGameSettingsFile(gameId), true, view);
} }
public static HashMap<String, SettingSection> readGenericGameSettings(final String gameId, SettingsActivityView view) public static HashMap<String, SettingSection> readGenericGameSettings(final String gameId,
SettingsActivityView view)
{ {
return readFile(getGenericGameSettingsFile(gameId), true, view); return readFile(getGenericGameSettingsFile(gameId), true, view);
} }
public static HashMap<String, SettingSection> readGenericGameSettingsForAllRegions(final String gameId, SettingsActivityView view) public static HashMap<String, SettingSection> readGenericGameSettingsForAllRegions(
final String gameId, SettingsActivityView view)
{ {
return readFile(getGenericGameSettingsForAllRegions(gameId), true, view); return readFile(getGenericGameSettingsForAllRegions(gameId), true, view);
} }
@ -368,7 +375,8 @@ public final class SettingsFile
* @param sections The HashMap containing the Settings we want to serialize. * @param sections The HashMap containing the Settings we want to serialize.
* @param view The current view. * @param view The current view.
*/ */
public static void saveFile(final String fileName, TreeMap<String, SettingSection> sections, SettingsActivityView view) public static void saveFile(final String fileName, TreeMap<String, SettingSection> sections,
SettingsActivityView view)
{ {
File ini = getSettingsFile(fileName); File ini = getSettingsFile(fileName);
@ -394,7 +402,8 @@ public final class SettingsFile
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
Log.error("[SettingsFile] Bad encoding; please file a bug report: " + fileName + ".ini: " + e.getMessage()); Log.error("[SettingsFile] Bad encoding; please file a bug report: " + fileName + ".ini: " +
e.getMessage());
if (view != null) if (view != null)
view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage()); view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage());
} }
@ -407,7 +416,8 @@ public final class SettingsFile
} }
} }
public static void saveCustomGameSettings(final String gameId, final HashMap<String, SettingSection> sections) public static void saveCustomGameSettings(final String gameId,
final HashMap<String, SettingSection> sections)
{ {
Set<String> sortedSections = new TreeSet<>(sections.keySet()); Set<String> sortedSections = new TreeSet<>(sections.keySet());
@ -421,7 +431,9 @@ public final class SettingsFile
for (String settingKey : sortedKeySet) for (String settingKey : sortedKeySet)
{ {
Setting setting = settings.get(settingKey); Setting setting = settings.get(settingKey);
NativeLibrary.SetUserSetting(gameId, mapSectionNameFromIni(section.getName()), setting.getKey(), setting.getValueAsString()); NativeLibrary
.SetUserSetting(gameId, mapSectionNameFromIni(section.getName()), setting.getKey(),
setting.getValueAsString());
} }
} }
} }
@ -449,24 +461,30 @@ public final class SettingsFile
@NonNull @NonNull
private static File getSettingsFile(String fileName) private static File getSettingsFile(String fileName)
{ {
return new File(DirectoryInitializationService.getUserDirectory() + "/Config/" + fileName + ".ini"); return new File(
DirectoryInitializationService.getUserDirectory() + "/Config/" + fileName + ".ini");
} }
private static File getGenericGameSettingsForAllRegions(String gameId) private static File getGenericGameSettingsForAllRegions(String gameId)
{ {
// Use the first 3 chars from the gameId to load the generic game settings for all regions // Use the first 3 chars from the gameId to load the generic game settings for all regions
gameId = gameId.substring(0, 3); gameId = gameId.substring(0, 3);
return new File(DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" + gameId + ".ini"); return new File(
DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" +
gameId + ".ini");
} }
private static File getGenericGameSettingsFile(String gameId) private static File getGenericGameSettingsFile(String gameId)
{ {
return new File(DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" + gameId + ".ini"); return new File(
DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" +
gameId + ".ini");
} }
private static File getCustomGameSettingsFile(String gameId) private static File getCustomGameSettingsFile(String gameId)
{ {
return new File(DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini"); return new File(
DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini");
} }
private static SettingSection sectionFromLine(String line, boolean isCustomGame) private static SettingSection sectionFromLine(String line, boolean isCustomGame)
@ -499,11 +517,14 @@ public final class SettingsFile
public static void firstAnalyticsAdd(boolean enabled) public static void firstAnalyticsAdd(boolean enabled)
{ {
HashMap<String, SettingSection> dolphinSections = readFile(SettingsFile.FILE_NAME_DOLPHIN, null); HashMap<String, SettingSection> dolphinSections =
readFile(SettingsFile.FILE_NAME_DOLPHIN, null);
SettingSection analyticsSection = dolphinSections.get(Settings.SECTION_ANALYTICS); SettingSection analyticsSection = dolphinSections.get(Settings.SECTION_ANALYTICS);
Setting analyticsEnabled = new StringSetting(KEY_ANALYTICS_ENABLED, Settings.SECTION_ANALYTICS, enabled ? "True" : "False"); Setting analyticsEnabled = new StringSetting(KEY_ANALYTICS_ENABLED, Settings.SECTION_ANALYTICS,
Setting analyticsFirstAsk = new StringSetting(KEY_ANALYTICS_PERMISSION_ASKED, Settings.SECTION_ANALYTICS, "True"); enabled ? "True" : "False");
Setting analyticsFirstAsk =
new StringSetting(KEY_ANALYTICS_PERMISSION_ASKED, Settings.SECTION_ANALYTICS, "True");
analyticsSection.putSetting(analyticsFirstAsk); analyticsSection.putSetting(analyticsFirstAsk);
analyticsSection.putSetting(analyticsEnabled); analyticsSection.putSetting(analyticsEnabled);

View File

@ -60,7 +60,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
if (context instanceof EmulationActivity) if (context instanceof EmulationActivity)
{ {
activity = (EmulationActivity)context; activity = (EmulationActivity) context;
NativeLibrary.setEmulationActivity((EmulationActivity) context); NativeLibrary.setEmulationActivity((EmulationActivity) context);
} }
else else
@ -157,25 +157,30 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
super.onDetach(); super.onDetach();
} }
private void setupDolphinDirectoriesThenStartEmulation() { private void setupDolphinDirectoriesThenStartEmulation()
{
IntentFilter statusIntentFilter = new IntentFilter( IntentFilter statusIntentFilter = new IntentFilter(
DirectoryInitializationService.BROADCAST_ACTION); DirectoryInitializationService.BROADCAST_ACTION);
directoryStateReceiver = directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState -> new DirectoryStateReceiver(directoryInitializationState ->
{ {
if (directoryInitializationState == DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED) if (directoryInitializationState ==
DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{ {
mEmulationState.run(activity.isActivityRecreated()); mEmulationState.run(activity.isActivityRecreated());
} }
else if (directoryInitializationState == DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED) else if (directoryInitializationState ==
DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
{ {
Toast.makeText(getContext(), R.string.write_permission_needed, Toast.LENGTH_SHORT) Toast.makeText(getContext(), R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show(); .show();
} }
else if (directoryInitializationState == DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE) else if (directoryInitializationState ==
DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
{ {
Toast.makeText(getContext(), R.string.external_storage_not_mounted, Toast.LENGTH_SHORT) Toast.makeText(getContext(), R.string.external_storage_not_mounted,
Toast.LENGTH_SHORT)
.show(); .show();
} }
}); });

View File

@ -18,13 +18,19 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
{ {
private static final String KEY_TITLE = "title"; private static final String KEY_TITLE = "title";
private static SparseIntArray buttonsActionsMap = new SparseIntArray(); private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_take_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT); static
{
buttonsActionsMap
.append(R.id.menu_take_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT);
buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE); buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE);
buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD); buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD);
buttonsActionsMap.append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT); buttonsActionsMap
buttonsActionsMap.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT); .append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT);
buttonsActionsMap.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES); buttonsActionsMap
.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT);
buttonsActionsMap
.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES);
buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC); buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
} }

View File

@ -22,23 +22,41 @@ public final class SaveLoadStateFragment extends Fragment implements View.OnClic
private static final String KEY_SAVEORLOAD = "saveorload"; private static final String KEY_SAVEORLOAD = "saveorload";
private static SparseIntArray saveButtonsActionsMap = new SparseIntArray(); private static SparseIntArray saveButtonsActionsMap = new SparseIntArray();
static {
saveButtonsActionsMap.append(R.id.loadsave_state_button_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1); static
saveButtonsActionsMap.append(R.id.loadsave_state_button_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2); {
saveButtonsActionsMap.append(R.id.loadsave_state_button_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3); saveButtonsActionsMap
saveButtonsActionsMap.append(R.id.loadsave_state_button_4, EmulationActivity.MENU_ACTION_SAVE_SLOT4); .append(R.id.loadsave_state_button_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1);
saveButtonsActionsMap.append(R.id.loadsave_state_button_5, EmulationActivity.MENU_ACTION_SAVE_SLOT5); saveButtonsActionsMap
saveButtonsActionsMap.append(R.id.loadsave_state_button_6, EmulationActivity.MENU_ACTION_SAVE_SLOT6); .append(R.id.loadsave_state_button_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2);
saveButtonsActionsMap
.append(R.id.loadsave_state_button_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3);
saveButtonsActionsMap
.append(R.id.loadsave_state_button_4, EmulationActivity.MENU_ACTION_SAVE_SLOT4);
saveButtonsActionsMap
.append(R.id.loadsave_state_button_5, EmulationActivity.MENU_ACTION_SAVE_SLOT5);
saveButtonsActionsMap
.append(R.id.loadsave_state_button_6, EmulationActivity.MENU_ACTION_SAVE_SLOT6);
} }
private static SparseIntArray loadButtonsActionsMap = new SparseIntArray(); private static SparseIntArray loadButtonsActionsMap = new SparseIntArray();
static {
loadButtonsActionsMap.append(R.id.loadsave_state_button_1, EmulationActivity.MENU_ACTION_LOAD_SLOT1); static
loadButtonsActionsMap.append(R.id.loadsave_state_button_2, EmulationActivity.MENU_ACTION_LOAD_SLOT2); {
loadButtonsActionsMap.append(R.id.loadsave_state_button_3, EmulationActivity.MENU_ACTION_LOAD_SLOT3); loadButtonsActionsMap
loadButtonsActionsMap.append(R.id.loadsave_state_button_4, EmulationActivity.MENU_ACTION_LOAD_SLOT4); .append(R.id.loadsave_state_button_1, EmulationActivity.MENU_ACTION_LOAD_SLOT1);
loadButtonsActionsMap.append(R.id.loadsave_state_button_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5); loadButtonsActionsMap
loadButtonsActionsMap.append(R.id.loadsave_state_button_6, EmulationActivity.MENU_ACTION_LOAD_SLOT6); .append(R.id.loadsave_state_button_2, EmulationActivity.MENU_ACTION_LOAD_SLOT2);
loadButtonsActionsMap
.append(R.id.loadsave_state_button_3, EmulationActivity.MENU_ACTION_LOAD_SLOT3);
loadButtonsActionsMap
.append(R.id.loadsave_state_button_4, EmulationActivity.MENU_ACTION_LOAD_SLOT4);
loadButtonsActionsMap
.append(R.id.loadsave_state_button_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5);
loadButtonsActionsMap
.append(R.id.loadsave_state_button_6, EmulationActivity.MENU_ACTION_LOAD_SLOT6);
} }
private SaveOrLoad mSaveOrLoad; private SaveOrLoad mSaveOrLoad;
public static SaveLoadStateFragment newInstance(SaveOrLoad saveOrLoad) public static SaveLoadStateFragment newInstance(SaveOrLoad saveOrLoad)
@ -84,7 +102,7 @@ public final class SaveLoadStateFragment extends Fragment implements View.OnClic
public void onClick(View button) public void onClick(View button)
{ {
int action = 0; int action = 0;
switch(mSaveOrLoad) switch (mSaveOrLoad)
{ {
case SAVE: case SAVE:
action = saveButtonsActionsMap.get(button.getId(), -1); action = saveButtonsActionsMap.get(button.getId(), -1);

View File

@ -1,11 +1,7 @@
package org.dolphinemu.dolphinemu.model; package org.dolphinemu.dolphinemu.model;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment; import android.os.Environment;
import org.dolphinemu.dolphinemu.utils.CoverHelper;
public class GameFile public class GameFile
{ {
private long mPointer; // Do not rename or move without editing the native code private long mPointer; // Do not rename or move without editing the native code
@ -19,15 +15,25 @@ public class GameFile
public native void finalize(); public native void finalize();
public native int getPlatform(); public native int getPlatform();
public native String getTitle(); public native String getTitle();
public native String getDescription(); public native String getDescription();
public native String getCompany(); public native String getCompany();
public native int getCountry(); public native int getCountry();
public native int getRegion(); public native int getRegion();
public native String getPath(); public native String getPath();
public native String getGameId(); public native String getGameId();
public native int[] getBanner(); public native int[] getBanner();
public native int getBannerWidth(); public native int getBannerWidth();
public native int getBannerHeight(); public native int getBannerHeight();
public String getCoverPath() public String getCoverPath()

View File

@ -61,6 +61,7 @@ public class GameFileCache
/** /**
* Scans through the file system and updates the cache to match. * Scans through the file system and updates the cache to match.
*
* @return true if the cache was modified * @return true if the cache was modified
*/ */
public boolean scanLibrary(Context context) public boolean scanLibrary(Context context)
@ -81,9 +82,14 @@ public class GameFileCache
} }
public native GameFile[] getAllGames(); public native GameFile[] getAllGames();
public native GameFile addOrGet(String gamePath); public native GameFile addOrGet(String gamePath);
private native boolean update(String[] folderPaths); private native boolean update(String[] folderPaths);
private native boolean updateAdditionalMetadata(); private native boolean updateAdditionalMetadata();
public native boolean load(); public native boolean load();
private native boolean save(); private native boolean save();
} }

View File

@ -56,7 +56,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param context The current {@link Context} * @param context The current {@link Context}
* @param bitmap The {@link Bitmap} to scale. * @param bitmap The {@link Bitmap} to scale.
* @param scale The scale factor for the bitmap. * @param scale The scale factor for the bitmap.
*
* @return The scaled {@link Bitmap} * @return The scaled {@link Bitmap}
*/ */
public static Bitmap resizeBitmap(Context context, Bitmap bitmap, float scale) public static Bitmap resizeBitmap(Context context, Bitmap bitmap, float scale)
@ -67,8 +66,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
int minDimension = Math.min(dm.widthPixels, dm.heightPixels); int minDimension = Math.min(dm.widthPixels, dm.heightPixels);
return Bitmap.createScaledBitmap(bitmap, return Bitmap.createScaledBitmap(bitmap,
(int)(minDimension * scale), (int) (minDimension * scale),
(int)(minDimension * scale), (int) (minDimension * scale),
true); true);
} }
@ -83,7 +82,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
super(context, attrs); super(context, attrs);
mPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); mPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
if(!mPreferences.getBoolean("OverlayInit", false)) if (!mPreferences.getBoolean("OverlayInit", false))
defaultOverlay(); defaultOverlay();
// Load the controls. // Load the controls.
refreshControls(); refreshControls();
@ -113,7 +112,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
dpad.draw(canvas); dpad.draw(canvas);
} }
for (InputOverlayDrawableJoystick joystick: overlayJoysticks) for (InputOverlayDrawableJoystick joystick : overlayJoysticks)
{ {
joystick.draw(canvas); joystick.draw(canvas);
} }
@ -137,11 +136,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
// If a pointer enters the bounds of a button, press that button. // If a pointer enters the bounds of a button, press that button.
if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) if (button.getBounds()
.contains((int) event.getX(pointerIndex), (int) event.getY(pointerIndex)))
{ {
button.setPressedState(true); button.setPressedState(true);
button.setTrackId(event.getPointerId(pointerIndex)); button.setTrackId(event.getPointerId(pointerIndex));
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.PRESSED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(),
ButtonState.PRESSED);
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
@ -150,7 +151,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
if (button.getTrackId() == event.getPointerId(pointerIndex)) if (button.getTrackId() == event.getPointerId(pointerIndex))
{ {
button.setPressedState(false); button.setPressedState(false);
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(),
ButtonState.RELEASED);
} }
break; break;
} }
@ -167,25 +169,28 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Up, Down, Left, Right // Up, Down, Left, Right
boolean[] pressed = {false, false, false, false}; boolean[] pressed = {false, false, false, false};
// If a pointer enters the bounds of a button, press that button. // If a pointer enters the bounds of a button, press that button.
if (dpad.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) if (dpad.getBounds()
.contains((int) event.getX(pointerIndex), (int) event.getY(pointerIndex)))
{ {
if (dpad.getBounds().top + (dpad.getHeight() / 3) > (int)event.getY(pointerIndex)) if (dpad.getBounds().top + (dpad.getHeight() / 3) > (int) event.getY(pointerIndex))
pressed[0] = true; pressed[0] = true;
if (dpad.getBounds().bottom - (dpad.getHeight() / 3) < (int)event.getY(pointerIndex)) if (dpad.getBounds().bottom - (dpad.getHeight() / 3) < (int) event.getY(pointerIndex))
pressed[1] = true; pressed[1] = true;
if (dpad.getBounds().left + (dpad.getWidth() / 3) > (int)event.getX(pointerIndex)) if (dpad.getBounds().left + (dpad.getWidth() / 3) > (int) event.getX(pointerIndex))
pressed[2] = true; pressed[2] = true;
if (dpad.getBounds().right - (dpad.getWidth() / 3) < (int)event.getX(pointerIndex)) if (dpad.getBounds().right - (dpad.getWidth() / 3) < (int) event.getX(pointerIndex))
pressed[3] = true; pressed[3] = true;
// Release the buttons first, then press // Release the buttons first, then press
for(int i = 0; i < pressed.length; i++) for (int i = 0; i < pressed.length; i++)
if (!pressed[i]) if (!pressed[i])
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i), ButtonState.RELEASED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i),
ButtonState.RELEASED);
// Press buttons // Press buttons
for(int i = 0; i < pressed.length; i++) for (int i = 0; i < pressed.length; i++)
if (pressed[i]) if (pressed[i])
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i), ButtonState.PRESSED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i),
ButtonState.PRESSED);
setDpadState(dpad, pressed[0], pressed[1], pressed[2], pressed[3]); setDpadState(dpad, pressed[0], pressed[1], pressed[2], pressed[3]);
dpad.setTrackId(event.getPointerId(pointerIndex)); dpad.setTrackId(event.getPointerId(pointerIndex));
@ -196,10 +201,11 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// If a pointer ends, release the buttons. // If a pointer ends, release the buttons.
if (dpad.getTrackId() == event.getPointerId(pointerIndex)) if (dpad.getTrackId() == event.getPointerId(pointerIndex))
{ {
for(int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
dpad.setState(InputOverlayDrawableDpad.STATE_DEFAULT); dpad.setState(InputOverlayDrawableDpad.STATE_DEFAULT);
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i), ButtonState.RELEASED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i),
ButtonState.RELEASED);
} }
} }
break; break;
@ -226,8 +232,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
public boolean onTouchWhileEditing(MotionEvent event) public boolean onTouchWhileEditing(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int)event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
int fingerPositionY = (int)event.getY(pointerIndex); int fingerPositionY = (int) event.getY(pointerIndex);
// Maybe combine Button and Joystick as subclasses of the same parent? // Maybe combine Button and Joystick as subclasses of the same parent?
// Or maybe create an interface like IMoveableHUDControl? // Or maybe create an interface like IMoveableHUDControl?
@ -240,7 +246,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
// If no button is being moved now, remember the currently touched button to move. // If no button is being moved now, remember the currently touched button to move.
if (mButtonBeingConfigured == null && button.getBounds().contains(fingerPositionX, fingerPositionY)) if (mButtonBeingConfigured == null &&
button.getBounds().contains(fingerPositionX, fingerPositionY))
{ {
mButtonBeingConfigured = button; mButtonBeingConfigured = button;
mButtonBeingConfigured.onConfigureTouch(event); mButtonBeingConfigured.onConfigureTouch(event);
@ -260,7 +267,9 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
if (mButtonBeingConfigured == button) if (mButtonBeingConfigured == button)
{ {
// Persist button position by saving new place. // Persist button position by saving new place.
saveControlPosition(mButtonBeingConfigured.getId(), mButtonBeingConfigured.getBounds().left, mButtonBeingConfigured.getBounds().top); saveControlPosition(mButtonBeingConfigured.getId(),
mButtonBeingConfigured.getBounds().left,
mButtonBeingConfigured.getBounds().top);
mButtonBeingConfigured = null; mButtonBeingConfigured = null;
} }
break; break;
@ -275,7 +284,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
// If no button is being moved now, remember the currently touched button to move. // If no button is being moved now, remember the currently touched button to move.
if (mButtonBeingConfigured == null && dpad.getBounds().contains(fingerPositionX, fingerPositionY)) if (mButtonBeingConfigured == null &&
dpad.getBounds().contains(fingerPositionX, fingerPositionY))
{ {
mDpadBeingConfigured = dpad; mDpadBeingConfigured = dpad;
mDpadBeingConfigured.onConfigureTouch(event); mDpadBeingConfigured.onConfigureTouch(event);
@ -295,7 +305,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
if (mDpadBeingConfigured == dpad) if (mDpadBeingConfigured == dpad)
{ {
// Persist button position by saving new place. // Persist button position by saving new place.
saveControlPosition(mDpadBeingConfigured.getId(0), mDpadBeingConfigured.getBounds().left, mDpadBeingConfigured.getBounds().top); saveControlPosition(mDpadBeingConfigured.getId(0),
mDpadBeingConfigured.getBounds().left, mDpadBeingConfigured.getBounds().top);
mDpadBeingConfigured = null; mDpadBeingConfigured = null;
} }
break; break;
@ -308,7 +319,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
if (mJoystickBeingConfigured == null && joystick.getBounds().contains(fingerPositionX, fingerPositionY)) if (mJoystickBeingConfigured == null &&
joystick.getBounds().contains(fingerPositionX, fingerPositionY))
{ {
mJoystickBeingConfigured = joystick; mJoystickBeingConfigured = joystick;
mJoystickBeingConfigured.onConfigureTouch(event); mJoystickBeingConfigured.onConfigureTouch(event);
@ -325,7 +337,9 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
if (mJoystickBeingConfigured != null) if (mJoystickBeingConfigured != null)
{ {
saveControlPosition(mJoystickBeingConfigured.getId(), mJoystickBeingConfigured.getBounds().left, mJoystickBeingConfigured.getBounds().top); saveControlPosition(mJoystickBeingConfigured.getId(),
mJoystickBeingConfigured.getBounds().left,
mJoystickBeingConfigured.getBounds().top);
mJoystickBeingConfigured = null; mJoystickBeingConfigured = null;
} }
break; break;
@ -335,7 +349,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
return true; return true;
} }
private void setDpadState(InputOverlayDrawableDpad dpad, boolean up, boolean down, boolean left, boolean right) private void setDpadState(InputOverlayDrawableDpad dpad, boolean up, boolean down, boolean left,
boolean right)
{ {
if (up) if (up)
{ {
@ -369,40 +384,49 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
if (mPreferences.getBoolean("buttonToggleGc0", true)) if (mPreferences.getBoolean("buttonToggleGc0", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a, R.drawable.gcpad_a_pressed, ButtonType.BUTTON_A)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a,
R.drawable.gcpad_a_pressed, ButtonType.BUTTON_A));
} }
if (mPreferences.getBoolean("buttonToggleGc1", true)) if (mPreferences.getBoolean("buttonToggleGc1", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b, R.drawable.gcpad_b_pressed, ButtonType.BUTTON_B)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b,
R.drawable.gcpad_b_pressed, ButtonType.BUTTON_B));
} }
if (mPreferences.getBoolean("buttonToggleGc2", true)) if (mPreferences.getBoolean("buttonToggleGc2", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x, R.drawable.gcpad_x_pressed, ButtonType.BUTTON_X)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x,
R.drawable.gcpad_x_pressed, ButtonType.BUTTON_X));
} }
if (mPreferences.getBoolean("buttonToggleGc3", true)) if (mPreferences.getBoolean("buttonToggleGc3", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y, R.drawable.gcpad_y_pressed, ButtonType.BUTTON_Y)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y,
R.drawable.gcpad_y_pressed, ButtonType.BUTTON_Y));
} }
if (mPreferences.getBoolean("buttonToggleGc4", true)) if (mPreferences.getBoolean("buttonToggleGc4", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z, R.drawable.gcpad_z_pressed, ButtonType.BUTTON_Z)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z,
R.drawable.gcpad_z_pressed, ButtonType.BUTTON_Z));
} }
if (mPreferences.getBoolean("buttonToggleGc5", true)) if (mPreferences.getBoolean("buttonToggleGc5", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start, R.drawable.gcpad_start_pressed, ButtonType.BUTTON_START)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start,
R.drawable.gcpad_start_pressed, ButtonType.BUTTON_START));
} }
if (mPreferences.getBoolean("buttonToggleGc6", true)) if (mPreferences.getBoolean("buttonToggleGc6", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l, R.drawable.gcpad_l_pressed, ButtonType.TRIGGER_L)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l,
R.drawable.gcpad_l_pressed, ButtonType.TRIGGER_L));
} }
if (mPreferences.getBoolean("buttonToggleGc7", true)) if (mPreferences.getBoolean("buttonToggleGc7", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r, R.drawable.gcpad_r_pressed, ButtonType.TRIGGER_R)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r,
R.drawable.gcpad_r_pressed, ButtonType.TRIGGER_R));
} }
if (mPreferences.getBoolean("buttonToggleGc8", true)) if (mPreferences.getBoolean("buttonToggleGc8", true))
{ {
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction, R.drawable.gcwii_dpad_pressed_two_directions, R.drawable.gcwii_dpad_pressed_one_direction,
R.drawable.gcwii_dpad_pressed_two_directions,
ButtonType.BUTTON_UP, ButtonType.BUTTON_DOWN, ButtonType.BUTTON_UP, ButtonType.BUTTON_DOWN,
ButtonType.BUTTON_LEFT, ButtonType.BUTTON_RIGHT)); ButtonType.BUTTON_LEFT, ButtonType.BUTTON_RIGHT));
} }
@ -422,45 +446,54 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
if (mPreferences.getBoolean("buttonToggleWii0", true)) if (mPreferences.getBoolean("buttonToggleWii0", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a, R.drawable.wiimote_a_pressed, ButtonType.WIIMOTE_BUTTON_A)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a,
R.drawable.wiimote_a_pressed, ButtonType.WIIMOTE_BUTTON_A));
} }
if (mPreferences.getBoolean("buttonToggleWii1", true)) if (mPreferences.getBoolean("buttonToggleWii1", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b, R.drawable.wiimote_b_pressed, ButtonType.WIIMOTE_BUTTON_B)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b,
R.drawable.wiimote_b_pressed, ButtonType.WIIMOTE_BUTTON_B));
} }
if (mPreferences.getBoolean("buttonToggleWii2", true)) if (mPreferences.getBoolean("buttonToggleWii2", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one, R.drawable.wiimote_one_pressed, ButtonType.WIIMOTE_BUTTON_1)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one,
R.drawable.wiimote_one_pressed, ButtonType.WIIMOTE_BUTTON_1));
} }
if (mPreferences.getBoolean("buttonToggleWii3", true)) if (mPreferences.getBoolean("buttonToggleWii3", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two, R.drawable.wiimote_two_pressed, ButtonType.WIIMOTE_BUTTON_2)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two,
R.drawable.wiimote_two_pressed, ButtonType.WIIMOTE_BUTTON_2));
} }
if (mPreferences.getBoolean("buttonToggleWii4", true)) if (mPreferences.getBoolean("buttonToggleWii4", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus, R.drawable.wiimote_plus_pressed, ButtonType.WIIMOTE_BUTTON_PLUS)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.WIIMOTE_BUTTON_PLUS));
} }
if (mPreferences.getBoolean("buttonToggleWii5", true)) if (mPreferences.getBoolean("buttonToggleWii5", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus, R.drawable.wiimote_minus_pressed, ButtonType.WIIMOTE_BUTTON_MINUS)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.WIIMOTE_BUTTON_MINUS));
} }
if (mPreferences.getBoolean("buttonToggleWii6", true)) if (mPreferences.getBoolean("buttonToggleWii6", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home, R.drawable.wiimote_home_pressed, ButtonType.WIIMOTE_BUTTON_HOME)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.WIIMOTE_BUTTON_HOME));
} }
if (mPreferences.getBoolean("buttonToggleWii7", true)) if (mPreferences.getBoolean("buttonToggleWii7", true))
{ {
if (mPreferences.getInt("wiiController", 3) == 2) if (mPreferences.getInt("wiiController", 3) == 2)
{ {
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction, R.drawable.gcwii_dpad_pressed_two_directions, R.drawable.gcwii_dpad_pressed_one_direction,
R.drawable.gcwii_dpad_pressed_two_directions,
ButtonType.WIIMOTE_RIGHT, ButtonType.WIIMOTE_LEFT, ButtonType.WIIMOTE_RIGHT, ButtonType.WIIMOTE_LEFT,
ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN)); ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN));
} }
else else
{ {
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction, R.drawable.gcwii_dpad_pressed_two_directions, R.drawable.gcwii_dpad_pressed_one_direction,
R.drawable.gcwii_dpad_pressed_two_directions,
ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN, ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN,
ButtonType.WIIMOTE_LEFT, ButtonType.WIIMOTE_RIGHT)); ButtonType.WIIMOTE_LEFT, ButtonType.WIIMOTE_RIGHT));
} }
@ -471,16 +504,19 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
if (mPreferences.getBoolean("buttonToggleWii8", true)) if (mPreferences.getBoolean("buttonToggleWii8", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c, R.drawable.nunchuk_c_pressed, ButtonType.NUNCHUK_BUTTON_C)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c,
R.drawable.nunchuk_c_pressed, ButtonType.NUNCHUK_BUTTON_C));
} }
if (mPreferences.getBoolean("buttonToggleWii9", true)) if (mPreferences.getBoolean("buttonToggleWii9", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z, R.drawable.nunchuk_z_pressed, ButtonType.NUNCHUK_BUTTON_Z)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z,
R.drawable.nunchuk_z_pressed, ButtonType.NUNCHUK_BUTTON_Z));
} }
if (mPreferences.getBoolean("buttonToggleWii10", true)) if (mPreferences.getBoolean("buttonToggleWii10", true))
{ {
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.NUNCHUK_STICK)); R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
ButtonType.NUNCHUK_STICK));
} }
} }
@ -488,64 +524,78 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
if (mPreferences.getBoolean("buttonToggleClassic0", true)) if (mPreferences.getBoolean("buttonToggleClassic0", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_a, R.drawable.classic_a_pressed, ButtonType.CLASSIC_BUTTON_A)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_a,
R.drawable.classic_a_pressed, ButtonType.CLASSIC_BUTTON_A));
} }
if (mPreferences.getBoolean("buttonToggleClassic1", true)) if (mPreferences.getBoolean("buttonToggleClassic1", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_b, R.drawable.classic_b_pressed, ButtonType.CLASSIC_BUTTON_B)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_b,
R.drawable.classic_b_pressed, ButtonType.CLASSIC_BUTTON_B));
} }
if (mPreferences.getBoolean("buttonToggleClassic2", true)) if (mPreferences.getBoolean("buttonToggleClassic2", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_x, R.drawable.classic_x_pressed, ButtonType.CLASSIC_BUTTON_X)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_x,
R.drawable.classic_x_pressed, ButtonType.CLASSIC_BUTTON_X));
} }
if (mPreferences.getBoolean("buttonToggleClassic3", true)) if (mPreferences.getBoolean("buttonToggleClassic3", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_y, R.drawable.classic_y_pressed, ButtonType.CLASSIC_BUTTON_Y)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_y,
R.drawable.classic_y_pressed, ButtonType.CLASSIC_BUTTON_Y));
} }
if (mPreferences.getBoolean("buttonToggleClassic4", true)) if (mPreferences.getBoolean("buttonToggleClassic4", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus, R.drawable.wiimote_plus_pressed, ButtonType.CLASSIC_BUTTON_PLUS)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.CLASSIC_BUTTON_PLUS));
} }
if (mPreferences.getBoolean("buttonToggleClassic5", true)) if (mPreferences.getBoolean("buttonToggleClassic5", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus, R.drawable.wiimote_minus_pressed, ButtonType.CLASSIC_BUTTON_MINUS)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.CLASSIC_BUTTON_MINUS));
} }
if (mPreferences.getBoolean("buttonToggleClassic6", true)) if (mPreferences.getBoolean("buttonToggleClassic6", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home, R.drawable.wiimote_home_pressed, ButtonType.CLASSIC_BUTTON_HOME)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.CLASSIC_BUTTON_HOME));
} }
if (mPreferences.getBoolean("buttonToggleClassic7", true)) if (mPreferences.getBoolean("buttonToggleClassic7", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_l, R.drawable.classic_l_pressed, ButtonType.CLASSIC_TRIGGER_L)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_l,
R.drawable.classic_l_pressed, ButtonType.CLASSIC_TRIGGER_L));
} }
if (mPreferences.getBoolean("buttonToggleClassic8", true)) if (mPreferences.getBoolean("buttonToggleClassic8", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_r, R.drawable.classic_r_pressed, ButtonType.CLASSIC_TRIGGER_R)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_r,
R.drawable.classic_r_pressed, ButtonType.CLASSIC_TRIGGER_R));
} }
if (mPreferences.getBoolean("buttonToggleClassic9", true)) if (mPreferences.getBoolean("buttonToggleClassic9", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zl, R.drawable.classic_zl_pressed, ButtonType.CLASSIC_BUTTON_ZL)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zl,
R.drawable.classic_zl_pressed, ButtonType.CLASSIC_BUTTON_ZL));
} }
if (mPreferences.getBoolean("buttonToggleClassic10", true)) if (mPreferences.getBoolean("buttonToggleClassic10", true))
{ {
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zr, R.drawable.classic_zr_pressed, ButtonType.CLASSIC_BUTTON_ZR)); overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zr,
R.drawable.classic_zr_pressed, ButtonType.CLASSIC_BUTTON_ZR));
} }
if (mPreferences.getBoolean("buttonToggleClassic11", true)) if (mPreferences.getBoolean("buttonToggleClassic11", true))
{ {
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction, R.drawable.gcwii_dpad_pressed_two_directions, R.drawable.gcwii_dpad_pressed_one_direction,
R.drawable.gcwii_dpad_pressed_two_directions,
ButtonType.CLASSIC_DPAD_UP, ButtonType.CLASSIC_DPAD_DOWN, ButtonType.CLASSIC_DPAD_UP, ButtonType.CLASSIC_DPAD_DOWN,
ButtonType.CLASSIC_DPAD_LEFT, ButtonType.CLASSIC_DPAD_RIGHT)); ButtonType.CLASSIC_DPAD_LEFT, ButtonType.CLASSIC_DPAD_RIGHT));
} }
if (mPreferences.getBoolean("buttonToggleClassic12", true)) if (mPreferences.getBoolean("buttonToggleClassic12", true))
{ {
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.CLASSIC_STICK_LEFT)); R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
ButtonType.CLASSIC_STICK_LEFT));
} }
if (mPreferences.getBoolean("buttonToggleClassic13", true)) if (mPreferences.getBoolean("buttonToggleClassic13", true))
{ {
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.CLASSIC_STICK_RIGHT)); R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
ButtonType.CLASSIC_STICK_RIGHT));
} }
} }
@ -581,8 +631,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{ {
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor sPrefsEditor = sPrefs.edit(); SharedPreferences.Editor sPrefsEditor = sPrefs.edit();
sPrefsEditor.putFloat(sharedPrefsId+"-X", x); sPrefsEditor.putFloat(sharedPrefsId + "-X", x);
sPrefsEditor.putFloat(sharedPrefsId+"-Y", y); sPrefsEditor.putFloat(sharedPrefsId + "-Y", y);
sPrefsEditor.apply(); sPrefsEditor.apply();
} }
@ -614,11 +664,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param defaultResId The resource ID of the {@link Drawable} to get the {@link Bitmap} of (Default State). * @param defaultResId The resource ID of the {@link Drawable} to get the {@link Bitmap} of (Default State).
* @param pressedResId The resource ID of the {@link Drawable} to get the {@link Bitmap} of (Pressed State). * @param pressedResId The resource ID of the {@link Drawable} to get the {@link Bitmap} of (Pressed State).
* @param buttonId Identifier for determining what type of button the initialized InputOverlayDrawableButton represents. * @param buttonId Identifier for determining what type of button the initialized InputOverlayDrawableButton represents.
*
* @return An {@link InputOverlayDrawableButton} with the correct drawing bounds set. * @return An {@link InputOverlayDrawableButton} with the correct drawing bounds set.
*
*/ */
private static InputOverlayDrawableButton initializeOverlayButton(Context context, int defaultResId, int pressedResId, int buttonId) private static InputOverlayDrawableButton initializeOverlayButton(Context context,
int defaultResId, int pressedResId, int buttonId)
{ {
// Resources handle for fetching the initial Drawable resource. // Resources handle for fetching the initial Drawable resource.
final Resources res = context.getResources(); final Resources res = context.getResources();
@ -675,9 +724,12 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
scale /= 100; scale /= 100;
// Initialize the InputOverlayDrawableButton. // Initialize the InputOverlayDrawableButton.
final Bitmap defaultStateBitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, defaultResId), scale); final Bitmap defaultStateBitmap =
final Bitmap pressedStateBitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, pressedResId), scale); resizeBitmap(context, BitmapFactory.decodeResource(res, defaultResId), scale);
final InputOverlayDrawableButton overlayDrawable = new InputOverlayDrawableButton(res, defaultStateBitmap, pressedStateBitmap, buttonId); final Bitmap pressedStateBitmap =
resizeBitmap(context, BitmapFactory.decodeResource(res, pressedResId), scale);
final InputOverlayDrawableButton overlayDrawable =
new InputOverlayDrawableButton(res, defaultStateBitmap, pressedStateBitmap, buttonId);
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
// These were set in the input overlay configuration menu. // These were set in the input overlay configuration menu.
@ -708,7 +760,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param buttonDown Identifier for the down button. * @param buttonDown Identifier for the down button.
* @param buttonLeft Identifier for the left button. * @param buttonLeft Identifier for the left button.
* @param buttonRight Identifier for the right button. * @param buttonRight Identifier for the right button.
*
* @return the initialized {@link InputOverlayDrawableDpad} * @return the initialized {@link InputOverlayDrawableDpad}
*/ */
private static InputOverlayDrawableDpad initializeOverlayDpad(Context context, private static InputOverlayDrawableDpad initializeOverlayDpad(Context context,
@ -746,10 +797,16 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
scale /= 100; scale /= 100;
// Initialize the InputOverlayDrawableDpad. // Initialize the InputOverlayDrawableDpad.
final Bitmap defaultStateBitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, defaultResId), scale); final Bitmap defaultStateBitmap =
final Bitmap pressedOneDirectionStateBitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, pressedOneDirectionResId), scale); resizeBitmap(context, BitmapFactory.decodeResource(res, defaultResId), scale);
final Bitmap pressedTwoDirectionsStateBitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, pressedTwoDirectionsResId), scale); final Bitmap pressedOneDirectionStateBitmap =
final InputOverlayDrawableDpad overlayDrawable = new InputOverlayDrawableDpad(res, defaultStateBitmap, resizeBitmap(context, BitmapFactory.decodeResource(res, pressedOneDirectionResId),
scale);
final Bitmap pressedTwoDirectionsStateBitmap =
resizeBitmap(context, BitmapFactory.decodeResource(res, pressedTwoDirectionsResId),
scale);
final InputOverlayDrawableDpad overlayDrawable =
new InputOverlayDrawableDpad(res, defaultStateBitmap,
pressedOneDirectionStateBitmap, pressedTwoDirectionsStateBitmap, pressedOneDirectionStateBitmap, pressedTwoDirectionsStateBitmap,
buttonUp, buttonDown, buttonLeft, buttonRight); buttonUp, buttonDown, buttonLeft, buttonRight);
@ -779,10 +836,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param defaultResInner Resource ID for the default inner image of the joystick (the one you actually move around). * @param defaultResInner Resource ID for the default inner image of the joystick (the one you actually move around).
* @param pressedResInner Resource ID for the pressed inner image of the joystick. * @param pressedResInner Resource ID for the pressed inner image of the joystick.
* @param joystick Identifier for which joystick this is. * @param joystick Identifier for which joystick this is.
*
* @return the initialized {@link InputOverlayDrawableJoystick}. * @return the initialized {@link InputOverlayDrawableJoystick}.
*/ */
private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context, int resOuter, int defaultResInner, int pressedResInner, int joystick) private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context,
int resOuter, int defaultResInner, int pressedResInner, int joystick)
{ {
// Resources handle for fetching the initial Drawable resource. // Resources handle for fetching the initial Drawable resource.
final Resources res = context.getResources(); final Resources res = context.getResources();
@ -796,7 +853,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
scale /= 100; scale /= 100;
// Initialize the InputOverlayDrawableJoystick. // Initialize the InputOverlayDrawableJoystick.
final Bitmap bitmapOuter = resizeBitmap(context, BitmapFactory.decodeResource(res, resOuter), scale); final Bitmap bitmapOuter =
resizeBitmap(context, BitmapFactory.decodeResource(res, resOuter), scale);
final Bitmap bitmapInnerDefault = BitmapFactory.decodeResource(res, defaultResInner); final Bitmap bitmapInnerDefault = BitmapFactory.decodeResource(res, defaultResInner);
final Bitmap bitmapInnerPressed = BitmapFactory.decodeResource(res, pressedResInner); final Bitmap bitmapInnerPressed = BitmapFactory.decodeResource(res, pressedResInner);
@ -893,28 +951,50 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Each value is a percent from max X/Y stored as an int. Have to bring that value down // Each value is a percent from max X/Y stored as an int. Have to bring that value down
// to a decimal before multiplying by MAX X/Y. // to a decimal before multiplying by MAX X/Y.
sPrefsEditor.putFloat(ButtonType.BUTTON_A + "-X", (((float)res.getInteger(R.integer.BUTTON_A_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_A + "-X",
sPrefsEditor.putFloat(ButtonType.BUTTON_A + "-Y", (((float)res.getInteger(R.integer.BUTTON_A_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_A_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.BUTTON_B + "-X", (((float)res.getInteger(R.integer.BUTTON_B_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_A + "-Y",
sPrefsEditor.putFloat(ButtonType.BUTTON_B + "-Y", (((float)res.getInteger(R.integer.BUTTON_B_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_A_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.BUTTON_X + "-X", (((float)res.getInteger(R.integer.BUTTON_X_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_B + "-X",
sPrefsEditor.putFloat(ButtonType.BUTTON_X + "-Y", (((float)res.getInteger(R.integer.BUTTON_X_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_B_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.BUTTON_Y + "-X", (((float)res.getInteger(R.integer.BUTTON_Y_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_B + "-Y",
sPrefsEditor.putFloat(ButtonType.BUTTON_Y + "-Y", (((float)res.getInteger(R.integer.BUTTON_Y_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_B_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.BUTTON_Z + "-X", (((float)res.getInteger(R.integer.BUTTON_Z_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_X + "-X",
sPrefsEditor.putFloat(ButtonType.BUTTON_Z + "-Y", (((float)res.getInteger(R.integer.BUTTON_Z_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_X_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.BUTTON_UP + "-X", (((float)res.getInteger(R.integer.BUTTON_UP_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_X + "-Y",
sPrefsEditor.putFloat(ButtonType.BUTTON_UP + "-Y", (((float)res.getInteger(R.integer.BUTTON_UP_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_X_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.TRIGGER_L + "-X", (((float)res.getInteger(R.integer.TRIGGER_L_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_Y + "-X",
sPrefsEditor.putFloat(ButtonType.TRIGGER_L + "-Y", (((float)res.getInteger(R.integer.TRIGGER_L_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_Y_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.TRIGGER_R + "-X", (((float)res.getInteger(R.integer.TRIGGER_R_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_Y + "-Y",
sPrefsEditor.putFloat(ButtonType.TRIGGER_R + "-Y", (((float)res.getInteger(R.integer.TRIGGER_R_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_Y_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.BUTTON_START + "-X", (((float)res.getInteger(R.integer.BUTTON_START_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_Z + "-X",
sPrefsEditor.putFloat(ButtonType.BUTTON_START + "-Y", (((float)res.getInteger(R.integer.BUTTON_START_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_Z_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.STICK_C + "-X", (((float)res.getInteger(R.integer.STICK_C_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_Z + "-Y",
sPrefsEditor.putFloat(ButtonType.STICK_C + "-Y", (((float)res.getInteger(R.integer.STICK_C_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_Z_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.STICK_MAIN + "-X", (((float)res.getInteger(R.integer.STICK_MAIN_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.BUTTON_UP + "-X",
sPrefsEditor.putFloat(ButtonType.STICK_MAIN + "-Y", (((float)res.getInteger(R.integer.STICK_MAIN_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.BUTTON_UP_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.BUTTON_UP + "-Y",
(((float) res.getInteger(R.integer.BUTTON_UP_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.TRIGGER_L + "-X",
(((float) res.getInteger(R.integer.TRIGGER_L_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.TRIGGER_L + "-Y",
(((float) res.getInteger(R.integer.TRIGGER_L_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.TRIGGER_R + "-X",
(((float) res.getInteger(R.integer.TRIGGER_R_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.TRIGGER_R + "-Y",
(((float) res.getInteger(R.integer.TRIGGER_R_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.BUTTON_START + "-X",
(((float) res.getInteger(R.integer.BUTTON_START_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.BUTTON_START + "-Y",
(((float) res.getInteger(R.integer.BUTTON_START_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.STICK_C + "-X",
(((float) res.getInteger(R.integer.STICK_C_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.STICK_C + "-Y",
(((float) res.getInteger(R.integer.STICK_C_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.STICK_MAIN + "-X",
(((float) res.getInteger(R.integer.STICK_MAIN_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.STICK_MAIN + "-Y",
(((float) res.getInteger(R.integer.STICK_MAIN_Y) / 1000) * maxY));
// We want to commit right away, otherwise the overlay could load before this is saved. // We want to commit right away, otherwise the overlay could load before this is saved.
sPrefsEditor.commit(); sPrefsEditor.commit();
@ -941,35 +1021,60 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Each value is a percent from max X/Y stored as an int. Have to bring that value down // Each value is a percent from max X/Y stored as an int. Have to bring that value down
// to a decimal before multiplying by MAX X/Y. // to a decimal before multiplying by MAX X/Y.
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_A + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_A_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_A + "-X",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_A + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_A_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_A_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_B + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_B_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_A + "-Y",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_B + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_B_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_A_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_1 + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_1_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_B + "-X",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_1 + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_1_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_B_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_2 + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_2_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_B + "-Y",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_2 + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_2_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_B_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_Z + "-X", (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_Z_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_1 + "-X",
sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_Z + "-Y", (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_Z_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_1_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_C + "-X", (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_C_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_1 + "-Y",
sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_C + "-Y", (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_C_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_1_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_MINUS + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_MINUS_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_2 + "-X",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_MINUS + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_MINUS_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_2_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_PLUS + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_PLUS_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_2 + "-Y",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_PLUS + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_PLUS_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_2_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_UP + "-X", (((float) res.getInteger(R.integer.WIIMOTE_UP_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_Z + "-X",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_UP + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_UP_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_Z_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_HOME + "-X", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_HOME_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_Z + "-Y",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_HOME + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_BUTTON_HOME_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_Z_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_STICK + "-X", (((float) res.getInteger(R.integer.NUNCHUK_STICK_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_C + "-X",
sPrefsEditor.putFloat(ButtonType.NUNCHUK_STICK + "-Y", (((float) res.getInteger(R.integer.NUNCHUK_STICK_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.NUNCHUK_BUTTON_C_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_BUTTON_C + "-Y",
(((float) res.getInteger(R.integer.NUNCHUK_BUTTON_C_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_MINUS + "-X",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_MINUS_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_MINUS + "-Y",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_MINUS_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_PLUS + "-X",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_PLUS_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_PLUS + "-Y",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_PLUS_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_UP + "-X",
(((float) res.getInteger(R.integer.WIIMOTE_UP_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_UP + "-Y",
(((float) res.getInteger(R.integer.WIIMOTE_UP_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_HOME + "-X",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_HOME_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_BUTTON_HOME + "-Y",
(((float) res.getInteger(R.integer.WIIMOTE_BUTTON_HOME_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_STICK + "-X",
(((float) res.getInteger(R.integer.NUNCHUK_STICK_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.NUNCHUK_STICK + "-Y",
(((float) res.getInteger(R.integer.NUNCHUK_STICK_Y) / 1000) * maxY));
// Horizontal dpad // Horizontal dpad
sPrefsEditor.putFloat(ButtonType.WIIMOTE_RIGHT + "-X", (((float) res.getInteger(R.integer.WIIMOTE_RIGHT_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.WIIMOTE_RIGHT + "-X",
sPrefsEditor.putFloat(ButtonType.WIIMOTE_RIGHT + "-Y", (((float) res.getInteger(R.integer.WIIMOTE_RIGHT_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.WIIMOTE_RIGHT_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.WIIMOTE_RIGHT + "-Y",
(((float) res.getInteger(R.integer.WIIMOTE_RIGHT_Y) / 1000) * maxY));
// We want to commit right away, otherwise the overlay could load before this is saved. // We want to commit right away, otherwise the overlay could load before this is saved.
sPrefsEditor.commit(); sPrefsEditor.commit();
} }
private void wiiClassicDefaultOverlay() private void wiiClassicDefaultOverlay()
{ {
SharedPreferences.Editor sPrefsEditor = mPreferences.edit(); SharedPreferences.Editor sPrefsEditor = mPreferences.edit();
@ -991,34 +1096,62 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Each value is a percent from max X/Y stored as an int. Have to bring that value down // Each value is a percent from max X/Y stored as an int. Have to bring that value down
// to a decimal before multiplying by MAX X/Y. // to a decimal before multiplying by MAX X/Y.
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_A + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_A_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_A + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_A + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_A_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_A_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_B + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_B_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_A + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_B + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_B_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_A_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_X + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_X_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_B + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_X + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_X_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_B_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_Y + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_Y_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_B + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_Y + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_Y_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_B_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_MINUS + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_MINUS_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_X + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_MINUS + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_MINUS_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_X_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_PLUS + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_PLUS_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_X + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_PLUS + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_PLUS_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_X_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_HOME + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_HOME_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_Y + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_HOME + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_HOME_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_Y_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZL + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_ZL_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_Y + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZL + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_ZL_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_Y_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZR + "-X", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_ZR_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_MINUS + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZR + "-Y", (((float)res.getInteger(R.integer.CLASSIC_BUTTON_ZR_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_MINUS_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_DPAD_UP + "-X", (((float)res.getInteger(R.integer.CLASSIC_DPAD_UP_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_MINUS + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_DPAD_UP + "-Y", (((float)res.getInteger(R.integer.CLASSIC_DPAD_UP_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_MINUS_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_LEFT + "-X", (((float)res.getInteger(R.integer.CLASSIC_STICK_LEFT_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_PLUS + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_LEFT + "-Y", (((float)res.getInteger(R.integer.CLASSIC_STICK_LEFT_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_PLUS_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_RIGHT + "-X", (((float)res.getInteger(R.integer.CLASSIC_STICK_RIGHT_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_PLUS + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_RIGHT + "-Y", (((float)res.getInteger(R.integer.CLASSIC_STICK_RIGHT_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_PLUS_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_L + "-X", (((float)res.getInteger(R.integer.CLASSIC_TRIGGER_L_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_HOME + "-X",
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_L + "-Y", (((float)res.getInteger(R.integer.CLASSIC_TRIGGER_L_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_HOME_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_R + "-X", (((float)res.getInteger(R.integer.CLASSIC_TRIGGER_R_X) / 1000) * maxX)); sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_HOME + "-Y",
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_R + "-Y", (((float)res.getInteger(R.integer.CLASSIC_TRIGGER_R_Y) / 1000) * maxY)); (((float) res.getInteger(R.integer.CLASSIC_BUTTON_HOME_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZL + "-X",
(((float) res.getInteger(R.integer.CLASSIC_BUTTON_ZL_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZL + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_BUTTON_ZL_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZR + "-X",
(((float) res.getInteger(R.integer.CLASSIC_BUTTON_ZR_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_BUTTON_ZR + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_BUTTON_ZR_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_DPAD_UP + "-X",
(((float) res.getInteger(R.integer.CLASSIC_DPAD_UP_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_DPAD_UP + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_DPAD_UP_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_LEFT + "-X",
(((float) res.getInteger(R.integer.CLASSIC_STICK_LEFT_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_LEFT + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_STICK_LEFT_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_RIGHT + "-X",
(((float) res.getInteger(R.integer.CLASSIC_STICK_RIGHT_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_STICK_RIGHT + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_STICK_RIGHT_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_L + "-X",
(((float) res.getInteger(R.integer.CLASSIC_TRIGGER_L_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_L + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_TRIGGER_L_Y) / 1000) * maxY));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_R + "-X",
(((float) res.getInteger(R.integer.CLASSIC_TRIGGER_R_X) / 1000) * maxX));
sPrefsEditor.putFloat(ButtonType.CLASSIC_TRIGGER_R + "-Y",
(((float) res.getInteger(R.integer.CLASSIC_TRIGGER_R_Y) / 1000) * maxY));
// We want to commit right away, otherwise the overlay could load before this is saved. // We want to commit right away, otherwise the overlay could load before this is saved.
sPrefsEditor.commit(); sPrefsEditor.commit();

View File

@ -38,7 +38,8 @@ public final class InputOverlayDrawableButton
* @param pressedStateBitmap {@link Bitmap} to use with the pressed state Drawable. * @param pressedStateBitmap {@link Bitmap} to use with the pressed state Drawable.
* @param buttonType Identifier for this type of button. * @param buttonType Identifier for this type of button.
*/ */
public InputOverlayDrawableButton(Resources res, Bitmap defaultStateBitmap, Bitmap pressedStateBitmap, int buttonType) public InputOverlayDrawableButton(Resources res, Bitmap defaultStateBitmap,
Bitmap pressedStateBitmap, int buttonType)
{ {
mDefaultStateBitmap = new BitmapDrawable(res, defaultStateBitmap); mDefaultStateBitmap = new BitmapDrawable(res, defaultStateBitmap);
mPressedStateBitmap = new BitmapDrawable(res, pressedStateBitmap); mPressedStateBitmap = new BitmapDrawable(res, pressedStateBitmap);
@ -71,8 +72,8 @@ public final class InputOverlayDrawableButton
public boolean onConfigureTouch(MotionEvent event) public boolean onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int)event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
int fingerPositionY = (int)event.getY(pointerIndex); int fingerPositionY = (int) event.getY(pointerIndex);
switch (event.getAction()) switch (event.getAction())
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@ -82,7 +83,8 @@ public final class InputOverlayDrawableButton
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
mControlPositionX += fingerPositionX - mPreviousTouchX; mControlPositionX += fingerPositionX - mPreviousTouchX;
mControlPositionY += fingerPositionY - mPreviousTouchY; mControlPositionY += fingerPositionY - mPreviousTouchY;
setBounds(mControlPositionX, mControlPositionY, getWidth() + mControlPositionX, getHeight() + mControlPositionY); setBounds(mControlPositionX, mControlPositionY, getWidth() + mControlPositionX,
getHeight() + mControlPositionY);
mPreviousTouchX = fingerPositionX; mPreviousTouchX = fingerPositionX;
mPreviousTouchY = fingerPositionY; mPreviousTouchY = fingerPositionY;
break; break;

View File

@ -75,9 +75,10 @@ public final class InputOverlayDrawableDpad
public void draw(Canvas canvas) public void draw(Canvas canvas)
{ {
int px = mControlPositionX + (getWidth()/2); int px = mControlPositionX + (getWidth() / 2);
int py = mControlPositionY + (getHeight()/2); int py = mControlPositionY + (getHeight() / 2);
switch (mPressState) { switch (mPressState)
{
case STATE_DEFAULT: case STATE_DEFAULT:
mDefaultStateBitmap.draw(canvas); mDefaultStateBitmap.draw(canvas);
break; break;
@ -149,8 +150,8 @@ public final class InputOverlayDrawableDpad
public boolean onConfigureTouch(MotionEvent event) public boolean onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int)event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
int fingerPositionY = (int)event.getY(pointerIndex); int fingerPositionY = (int) event.getY(pointerIndex);
switch (event.getAction()) switch (event.getAction())
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@ -160,7 +161,8 @@ public final class InputOverlayDrawableDpad
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
mControlPositionX += fingerPositionX - mPreviousTouchX; mControlPositionX += fingerPositionX - mPreviousTouchX;
mControlPositionY += fingerPositionY - mPreviousTouchY; mControlPositionY += fingerPositionY - mPreviousTouchY;
setBounds(mControlPositionX, mControlPositionY, getWidth() + mControlPositionX, getHeight() + mControlPositionY); setBounds(mControlPositionX, mControlPositionY, getWidth() + mControlPositionX,
getHeight() + mControlPositionY);
mPreviousTouchX = fingerPositionX; mPreviousTouchX = fingerPositionX;
mPreviousTouchY = fingerPositionY; mPreviousTouchY = fingerPositionY;
break; break;
@ -187,15 +189,18 @@ public final class InputOverlayDrawableDpad
return mDefaultStateBitmap.getBounds(); return mDefaultStateBitmap.getBounds();
} }
public int getWidth() { public int getWidth()
{
return mWidth; return mWidth;
} }
public int getHeight() { public int getHeight()
{
return mHeight; return mHeight;
} }
public void setState(int pressState) { public void setState(int pressState)
{
mPressState = pressState; mPressState = pressState;
} }
} }

View File

@ -6,7 +6,6 @@
package org.dolphinemu.dolphinemu.overlay; package org.dolphinemu.dolphinemu.overlay;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -100,18 +99,19 @@ public final class InputOverlayDrawableJoystick
boolean reCenter = mPreferences.getBoolean("joystickRelCenter", true); boolean reCenter = mPreferences.getBoolean("joystickRelCenter", true);
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
switch(event.getAction() & MotionEvent.ACTION_MASK) switch (event.getAction() & MotionEvent.ACTION_MASK)
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
if (getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) if (getBounds().contains((int) event.getX(pointerIndex), (int) event.getY(pointerIndex)))
{ {
mPressedState = true; mPressedState = true;
mOuterBitmap.setAlpha(0); mOuterBitmap.setAlpha(0);
mBoundsBoxBitmap.setAlpha(255); mBoundsBoxBitmap.setAlpha(255);
if (reCenter) if (reCenter)
{ {
getVirtBounds().offset((int)event.getX(pointerIndex) - getVirtBounds().centerX(), (int)event.getY(pointerIndex) - getVirtBounds().centerY()); getVirtBounds().offset((int) event.getX(pointerIndex) - getVirtBounds().centerX(),
(int) event.getY(pointerIndex) - getVirtBounds().centerY());
} }
mBoundsBoxBitmap.setBounds(getVirtBounds()); mBoundsBoxBitmap.setBounds(getVirtBounds());
trackId = event.getPointerId(pointerIndex); trackId = event.getPointerId(pointerIndex);
@ -125,8 +125,10 @@ public final class InputOverlayDrawableJoystick
axises[0] = axises[1] = 0.0f; axises[0] = axises[1] = 0.0f;
mOuterBitmap.setAlpha(255); mOuterBitmap.setAlpha(255);
mBoundsBoxBitmap.setAlpha(0); mBoundsBoxBitmap.setAlpha(0);
setVirtBounds(new Rect(mOrigBounds.left, mOrigBounds.top, mOrigBounds.right, mOrigBounds.bottom)); setVirtBounds(new Rect(mOrigBounds.left, mOrigBounds.top, mOrigBounds.right,
setBounds(new Rect(mOrigBounds.left, mOrigBounds.top, mOrigBounds.right, mOrigBounds.bottom)); mOrigBounds.bottom));
setBounds(new Rect(mOrigBounds.left, mOrigBounds.top, mOrigBounds.right,
mOrigBounds.bottom));
SetInnerBounds(); SetInnerBounds();
trackId = -1; trackId = -1;
} }
@ -161,8 +163,8 @@ public final class InputOverlayDrawableJoystick
public boolean onConfigureTouch(MotionEvent event) public boolean onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int)event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
int fingerPositionY = (int)event.getY(pointerIndex); int fingerPositionY = (int) event.getY(pointerIndex);
switch (event.getAction()) switch (event.getAction())
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@ -209,8 +211,8 @@ public final class InputOverlayDrawableJoystick
private void SetInnerBounds() private void SetInnerBounds()
{ {
int X = getVirtBounds().centerX() + (int)((axises[1]) * (getVirtBounds().width() / 2)); int X = getVirtBounds().centerX() + (int) ((axises[1]) * (getVirtBounds().width() / 2));
int Y = getVirtBounds().centerY() + (int)((axises[0]) * (getVirtBounds().height() / 2)); int Y = getVirtBounds().centerY() + (int) ((axises[0]) * (getVirtBounds().height() / 2));
if (X > getVirtBounds().centerX() + (getVirtBounds().width() / 2)) if (X > getVirtBounds().centerX() + (getVirtBounds().width() / 2))
X = getVirtBounds().centerX() + (getVirtBounds().width() / 2); X = getVirtBounds().centerX() + (getVirtBounds().width() / 2);
@ -248,11 +250,20 @@ public final class InputOverlayDrawableJoystick
return mOuterBitmap.getBounds(); return mOuterBitmap.getBounds();
} }
private void setVirtBounds(Rect bounds) { mVirtBounds = bounds; } private void setVirtBounds(Rect bounds)
{
mVirtBounds = bounds;
}
private void setOrigBounds(Rect bounds) { mOrigBounds = bounds; } private void setOrigBounds(Rect bounds)
{
mOrigBounds = bounds;
}
private Rect getVirtBounds() { return mVirtBounds; } private Rect getVirtBounds()
{
return mVirtBounds;
}
public int getWidth() public int getWidth()
{ {

View File

@ -32,7 +32,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/ */
public final class DirectoryInitializationService extends IntentService public final class DirectoryInitializationService extends IntentService
{ {
public static final String BROADCAST_ACTION = "org.dolphinemu.dolphinemu.DIRECTORY_INITIALIZATION"; public static final String BROADCAST_ACTION =
"org.dolphinemu.dolphinemu.DIRECTORY_INITIALIZATION";
public static final String EXTRA_STATE = "directoryState"; public static final String EXTRA_STATE = "directoryState";
private static volatile DirectoryInitializationState directoryState = null; private static volatile DirectoryInitializationState directoryState = null;
@ -147,7 +148,7 @@ public final class DirectoryInitializationService extends IntentService
// TODO: Redo the Android controller system so that we don't have to extract these INIs. // TODO: Redo the Android controller system so that we don't have to extract these INIs.
String configDirectory = NativeLibrary.GetUserDirectory() + File.separator + "Config"; String configDirectory = NativeLibrary.GetUserDirectory() + File.separator + "Config";
copyAsset("GCPadNew.ini", new File(configDirectory, "GCPadNew.ini"), true); copyAsset("GCPadNew.ini", new File(configDirectory, "GCPadNew.ini"), true);
copyAsset("WiimoteNew.ini", new File(configDirectory,"WiimoteNew.ini"), false); copyAsset("WiimoteNew.ini", new File(configDirectory, "WiimoteNew.ini"), false);
} }
private static void deleteDirectoryRecursively(File file) private static void deleteDirectoryRecursively(File file)
@ -173,7 +174,8 @@ public final class DirectoryInitializationService extends IntentService
} }
else if (isDolphinDirectoryInitializationRunning.get()) else if (isDolphinDirectoryInitializationRunning.get())
{ {
throw new IllegalStateException("DirectoryInitializationService has to finish running first!"); throw new IllegalStateException(
"DirectoryInitializationService has to finish running first!");
} }
return userPath; return userPath;
@ -187,7 +189,8 @@ public final class DirectoryInitializationService extends IntentService
} }
else if (isDolphinDirectoryInitializationRunning.get()) else if (isDolphinDirectoryInitializationRunning.get())
{ {
throw new IllegalStateException("DirectoryInitializationService has to finish running first!"); throw new IllegalStateException(
"DirectoryInitializationService has to finish running first!");
} }
return internalPath; return internalPath;
@ -218,13 +221,15 @@ public final class DirectoryInitializationService extends IntentService
} }
catch (IOException e) catch (IOException e)
{ {
Log.error("[DirectoryInitializationService] Failed to copy asset file: " + asset + e.getMessage()); Log.error("[DirectoryInitializationService] Failed to copy asset file: " + asset +
e.getMessage());
} }
} }
private void copyAssetFolder(String assetFolder, File outputFolder, Boolean overwrite) private void copyAssetFolder(String assetFolder, File outputFolder, Boolean overwrite)
{ {
Log.verbose("[DirectoryInitializationService] Copying Folder " + assetFolder + " to " + outputFolder); Log.verbose("[DirectoryInitializationService] Copying Folder " + assetFolder + " to " +
outputFolder);
try try
{ {
@ -236,13 +241,15 @@ public final class DirectoryInitializationService extends IntentService
outputFolder.mkdir(); outputFolder.mkdir();
createdFolder = true; createdFolder = true;
} }
copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file), overwrite); copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file),
overwrite);
copyAsset(assetFolder + File.separator + file, new File(outputFolder, file), overwrite); copyAsset(assetFolder + File.separator + file, new File(outputFolder, file), overwrite);
} }
} }
catch (IOException e) catch (IOException e)
{ {
Log.error("[DirectoryInitializationService] Failed to copy asset folder: " + assetFolder + e.getMessage()); Log.error("[DirectoryInitializationService] Failed to copy asset folder: " + assetFolder +
e.getMessage());
} }
} }
@ -258,5 +265,6 @@ public final class DirectoryInitializationService extends IntentService
} }
private static native void CreateUserDirectories(); private static native void CreateUserDirectories();
private static native void SetSysDirectory(String path); private static native void SetSysDirectory(String path);
} }

View File

@ -158,7 +158,8 @@ public class SyncChannelJobService extends JobService
+ " from TV Provider."); + " from TV Provider.");
return channel.getId(); return channel.getId();
} }
} while (cursor.moveToNext()); }
while (cursor.moveToNext());
} }
return -1L; return -1L;
} }

View File

@ -2,9 +2,7 @@ package org.dolphinemu.dolphinemu.services;
import android.app.job.JobParameters; import android.app.job.JobParameters;
import android.app.job.JobService; import android.app.job.JobService;
import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.PersistableBundle; import android.os.PersistableBundle;

View File

@ -5,10 +5,15 @@ import android.content.Intent;
public final class USBPermService extends IntentService public final class USBPermService extends IntentService
{ {
public USBPermService() { super("USBPermService"); } public USBPermService()
{
super("USBPermService");
}
// Needed when extending IntentService. // Needed when extending IntentService.
// We don't care about the results of the intent handler for this. // We don't care about the results of the intent handler for this.
@Override @Override
protected void onHandleIntent(Intent intent) {} protected void onHandleIntent(Intent intent)
{
}
} }

View File

@ -11,11 +11,13 @@ import android.widget.TextView;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
public class CustomTitleView extends LinearLayout implements TitleViewAdapter.Provider { public class CustomTitleView extends LinearLayout implements TitleViewAdapter.Provider
{
private final TextView mTitleView; private final TextView mTitleView;
private final View mBadgeView; private final View mBadgeView;
private final TitleViewAdapter mTitleViewAdapter = new TitleViewAdapter() { private final TitleViewAdapter mTitleViewAdapter = new TitleViewAdapter()
{
@Override @Override
public View getSearchAffordanceView() public View getSearchAffordanceView()
{ {

View File

@ -17,12 +17,12 @@ import android.widget.Toast;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter; import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService; import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.services.GameFileCacheService; import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView; import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler; import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
import org.dolphinemu.dolphinemu.utils.StartupHandler; import org.dolphinemu.dolphinemu.utils.StartupHandler;
@ -181,10 +181,13 @@ public final class MainActivity extends AppCompatActivity implements MainView
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
switch (requestCode) { {
switch (requestCode)
{
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION: case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
DirectoryInitializationService.startService(this); DirectoryInitializationService.startService(this);
PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter( PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(
getSupportFragmentManager(), this); getSupportFragmentManager(), this);
@ -193,7 +196,9 @@ public final class MainActivity extends AppCompatActivity implements MainView
mTabLayout.setupWithViewPager(mViewPager); mTabLayout.setupWithViewPager(mViewPager);
mViewPager.setVisibility(View.VISIBLE); mViewPager.setVisibility(View.VISIBLE);
GameFileCacheService.startLoad(this); GameFileCacheService.startLoad(this);
} else { }
else
{
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT) Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show(); .show();
} }

View File

@ -8,9 +8,9 @@ import android.support.v4.content.LocalBroadcastManager;
import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.model.GameFileCache; import org.dolphinemu.dolphinemu.model.GameFileCache;
import org.dolphinemu.dolphinemu.services.GameFileCacheService; import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
public final class MainPresenter public final class MainPresenter
{ {

View File

@ -18,13 +18,13 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.adapters.GameRowPresenter; import org.dolphinemu.dolphinemu.adapters.GameRowPresenter;
import org.dolphinemu.dolphinemu.adapters.SettingsRowPresenter; import org.dolphinemu.dolphinemu.adapters.SettingsRowPresenter;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.model.TvSettingsItem; import org.dolphinemu.dolphinemu.model.TvSettingsItem;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService; import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.services.GameFileCacheService; import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler; import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
import org.dolphinemu.dolphinemu.utils.StartupHandler; import org.dolphinemu.dolphinemu.utils.StartupHandler;
@ -88,7 +88,8 @@ public final class TvMainActivity extends FragmentActivity implements MainView
StartupHandler.setSessionTime(this); StartupHandler.setSessionTime(this);
} }
void setupUI() { void setupUI()
{
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getSupportFragmentManager();
mBrowseFragment = new BrowseSupportFragment(); mBrowseFragment = new BrowseSupportFragment();
fragmentManager fragmentManager
@ -122,6 +123,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
} }
}); });
} }
/** /**
* MainView * MainView
*/ */
@ -186,13 +188,18 @@ public final class TvMainActivity extends FragmentActivity implements MainView
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
switch (requestCode) { {
switch (requestCode)
{
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION: case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
DirectoryInitializationService.startService(this); DirectoryInitializationService.startService(this);
GameFileCacheService.startLoad(this); GameFileCacheService.startLoad(this);
} else { }
else
{
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT) Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show(); .show();
} }
@ -276,7 +283,8 @@ public final class TvMainActivity extends FragmentActivity implements MainView
R.string.grid_menu_refresh)); R.string.grid_menu_refresh));
// Create a header for this row. // Create a header for this row.
HeaderItem header = new HeaderItem(R.string.preferences_settings, getString(R.string.preferences_settings)); HeaderItem header =
new HeaderItem(R.string.preferences_settings, getString(R.string.preferences_settings));
return new ListRow(header, rowItems); return new ListRow(header, rowItems);
} }

View File

@ -1,6 +1,8 @@
package org.dolphinemu.dolphinemu.ui.platform; package org.dolphinemu.dolphinemu.ui.platform;
/** Enum to represent platform (eg GameCube, Wii). */ /**
* Enum to represent platform (eg GameCube, Wii).
*/
public enum Platform public enum Platform
{ {
GAMECUBE(0, "GameCube Games"), GAMECUBE(0, "GameCube Games"),

View File

@ -11,11 +11,8 @@ import android.view.ViewGroup;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.GameAdapter; import org.dolphinemu.dolphinemu.adapters.GameAdapter;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService; import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import java.util.List;
public final class PlatformGamesFragment extends Fragment implements PlatformGamesView public final class PlatformGamesFragment extends Fragment implements PlatformGamesView
{ {
private static final String ARG_PLATFORM = "platform"; private static final String ARG_PLATFORM = "platform";

View File

@ -1,9 +1,5 @@
package org.dolphinemu.dolphinemu.ui.platform; package org.dolphinemu.dolphinemu.ui.platform;
import org.dolphinemu.dolphinemu.model.GameFile;
import java.util.List;
/** /**
* Abstraction for a screen representing a single platform's games. * Abstraction for a screen representing a single platform's games.
*/ */

View File

@ -20,8 +20,10 @@ public class Analytics
{ {
private static DirectoryStateReceiver directoryStateReceiver; private static DirectoryStateReceiver directoryStateReceiver;
private static final String analyticsAsked = Settings.SECTION_ANALYTICS + "_" + SettingsFile.KEY_ANALYTICS_PERMISSION_ASKED; private static final String analyticsAsked =
private static final String analyticsEnabled = Settings.SECTION_ANALYTICS + "_" + SettingsFile.KEY_ANALYTICS_ENABLED; Settings.SECTION_ANALYTICS + "_" + SettingsFile.KEY_ANALYTICS_PERMISSION_ASKED;
private static final String analyticsEnabled =
Settings.SECTION_ANALYTICS + "_" + SettingsFile.KEY_ANALYTICS_ENABLED;
private static final String DEVICE_MANUFACTURER = "DEVICE_MANUFACTURER"; private static final String DEVICE_MANUFACTURER = "DEVICE_MANUFACTURER";
private static final String DEVICE_OS = "DEVICE_OS"; private static final String DEVICE_OS = "DEVICE_OS";
@ -43,7 +45,8 @@ public class Analytics
directoryStateReceiver = new DirectoryStateReceiver(directoryInitializationState -> directoryStateReceiver = new DirectoryStateReceiver(directoryInitializationState ->
{ {
if (directoryInitializationState == DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED) if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{ {
LocalBroadcastManager.getInstance(context).unregisterReceiver(directoryStateReceiver); LocalBroadcastManager.getInstance(context).unregisterReceiver(directoryStateReceiver);
directoryStateReceiver = null; directoryStateReceiver = null;

View File

@ -4,13 +4,18 @@ import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
/** Some controllers have incorrect mappings. This class has special-case fixes for them. */ /**
* Some controllers have incorrect mappings. This class has special-case fixes for them.
*/
public class ControllerMappingHelper public class ControllerMappingHelper
{ {
/** Some controllers report extra button presses that can be ignored. */ /**
* Some controllers report extra button presses that can be ignored.
*/
public static boolean shouldKeyBeIgnored(InputDevice inputDevice, int keyCode) public static boolean shouldKeyBeIgnored(InputDevice inputDevice, int keyCode)
{ {
if (isDualShock4(inputDevice)) { if (isDualShock4(inputDevice))
{
// The two analog triggers generate analog motion events as well as a keycode. // The two analog triggers generate analog motion events as well as a keycode.
// We always prefer to use the analog values, so throw away the button press // We always prefer to use the analog values, so throw away the button press
// Even though the triggers are L/R2, without mappings they generate L/R1 events. // Even though the triggers are L/R2, without mappings they generate L/R1 events.
@ -19,7 +24,9 @@ public class ControllerMappingHelper
return false; return false;
} }
/** Scale an axis to be zero-centered with a proper range. */ /**
* Scale an axis to be zero-centered with a proper range.
*/
public static float scaleAxis(InputDevice inputDevice, int axis, float value) public static float scaleAxis(InputDevice inputDevice, int axis, float value)
{ {
if (isDualShock4(inputDevice)) if (isDualShock4(inputDevice))

View File

@ -3,7 +3,6 @@ package org.dolphinemu.dolphinemu.utils;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -14,15 +13,15 @@ public final class CoverHelper
public static String buildGameTDBUrl(GameFile game, String region) public static String buildGameTDBUrl(GameFile game, String region)
{ {
String gameId = game.getGameId(); String gameId = game.getGameId();
if(game.getPlatform() == 2) // WiiWare if (game.getPlatform() == 2) // WiiWare
gameId = gameId.substring(0,4); gameId = gameId.substring(0, 4);
return String.format(baseUrl, region, gameId); return String.format(baseUrl, region, gameId);
} }
public static String getRegion(GameFile game) public static String getRegion(GameFile game)
{ {
String region; String region;
switch(game.getRegion()) switch (game.getRegion())
{ {
case 0: // NTSC_J case 0: // NTSC_J
region = "JA"; region = "JA";

View File

@ -9,16 +9,20 @@ import org.dolphinemu.dolphinemu.services.DirectoryInitializationService.Directo
import rx.functions.Action1; import rx.functions.Action1;
public class DirectoryStateReceiver extends BroadcastReceiver { public class DirectoryStateReceiver extends BroadcastReceiver
{
Action1<DirectoryInitializationState> callback; Action1<DirectoryInitializationState> callback;
public DirectoryStateReceiver(Action1<DirectoryInitializationState> callback) {
public DirectoryStateReceiver(Action1<DirectoryInitializationState> callback)
{
this.callback = callback; this.callback = callback;
} }
@Override @Override
public void onReceive(Context context, Intent intent) public void onReceive(Context context, Intent intent)
{ {
DirectoryInitializationState state = (DirectoryInitializationState) intent.getSerializableExtra(DirectoryInitializationService.EXTRA_STATE); DirectoryInitializationState state = (DirectoryInitializationState) intent
.getSerializableExtra(DirectoryInitializationService.EXTRA_STATE);
callback.call(state); callback.call(state);
} }
} }

View File

@ -120,7 +120,7 @@ public final class EGLHelper
*/ */
public String[] getEGLInfo() public String[] getEGLInfo()
{ {
return new String[] { return new String[]{
mGL.glGetString(GL10.GL_VENDOR), mGL.glGetString(GL10.GL_VENDOR),
mGL.glGetString(GL10.GL_VERSION), mGL.glGetString(GL10.GL_VERSION),
mGL.glGetString(GL10.GL_RENDERER), mGL.glGetString(GL10.GL_RENDERER),
@ -244,7 +244,8 @@ public final class EGLHelper
for (EGLConfig mEGLConfig : mEGLConfigs) for (EGLConfig mEGLConfig : mEGLConfigs)
{ {
int[] attribVal = new int[1]; int[] attribVal = new int[1];
boolean ret = mEGL.eglGetConfigAttrib(mDisplay, mEGLConfig, EGL10.EGL_RENDERABLE_TYPE, attribVal); boolean ret =
mEGL.eglGetConfigAttrib(mDisplay, mEGLConfig, EGL10.EGL_RENDERABLE_TYPE, attribVal);
if (ret) if (ret)
{ {
if ((attribVal[0] & EGL_OPENGL_BIT) != 0) if ((attribVal[0] & EGL_OPENGL_BIT) != 0)
@ -303,7 +304,8 @@ public final class EGLHelper
else else
NativeLibrary.eglBindAPI(EGL_OPENGL_ES_API); NativeLibrary.eglBindAPI(EGL_OPENGL_ES_API);
mEGLContext = mEGL.eglCreateContext(mDisplay, mEGLConfigs[0], EGL10.EGL_NO_CONTEXT, ctx_attribs); mEGLContext =
mEGL.eglCreateContext(mDisplay, mEGLConfigs[0], EGL10.EGL_NO_CONTEXT, ctx_attribs);
mEGLSurface = mEGL.eglCreatePbufferSurface(mDisplay, mEGLConfigs[0], attribs); mEGLSurface = mEGL.eglCreatePbufferSurface(mDisplay, mEGLConfigs[0], attribs);
mEGL.eglMakeCurrent(mDisplay, mEGLSurface, mEGLSurface, mEGLContext); mEGL.eglMakeCurrent(mDisplay, mEGLSurface, mEGLSurface, mEGLContext);
mGL = (GL10) mEGLContext.getGL(); mGL = (GL10) mEGLContext.getGL();
@ -321,7 +323,6 @@ public final class EGLHelper
* </ul> * </ul>
* *
* @param glEnum A symbolic constant within {@link GL10}. * @param glEnum A symbolic constant within {@link GL10}.
*
* @return the string information represented by {@code glEnum}. * @return the string information represented by {@code glEnum}.
*/ */
public String glGetString(int glEnum) public String glGetString(int glEnum)
@ -343,7 +344,6 @@ public final class EGLHelper
* *
* @param glEnum A symbolic GL constant * @param glEnum A symbolic GL constant
* @param index The index of the string to return. * @param index The index of the string to return.
*
* @return the string information represented by {@code glEnum} and {@code index}. * @return the string information represented by {@code glEnum} and {@code index}.
*/ */
public String glGetStringi(int glEnum, int index) public String glGetStringi(int glEnum, int index)
@ -378,7 +378,6 @@ public final class EGLHelper
* Simplified call to {@link GL10#glGetIntegerv(int, int[], int) * Simplified call to {@link GL10#glGetIntegerv(int, int[], int)
* *
* @param glEnum A symbolic GL constant. * @param glEnum A symbolic GL constant.
*
* @return the integer information represented by {@code glEnum}. * @return the integer information represented by {@code glEnum}.
*/ */
public int glGetInteger(int glEnum) public int glGetInteger(int glEnum)

View File

@ -24,7 +24,8 @@ public final class FileBrowserHelper
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR); i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath()); i.putExtra(FilePickerActivity.EXTRA_START_PATH,
Environment.getExternalStorageDirectory().getPath());
activity.startActivityForResult(i, MainPresenter.REQUEST_ADD_DIRECTORY); activity.startActivityForResult(i, MainPresenter.REQUEST_ADD_DIRECTORY);
} }
@ -36,7 +37,8 @@ public final class FileBrowserHelper
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE); i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
i.putExtra(FilePickerActivity.EXTRA_START_PATH, Environment.getExternalStorageDirectory().getPath()); i.putExtra(FilePickerActivity.EXTRA_START_PATH,
Environment.getExternalStorageDirectory().getPath());
activity.startActivityForResult(i, requestCode); activity.startActivityForResult(i, requestCode);
} }

View File

@ -19,7 +19,8 @@ import org.dolphinemu.dolphinemu.services.USBPermService;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class Java_GCAdapter { public class Java_GCAdapter
{
public static UsbManager manager; public static UsbManager manager;
static byte[] controller_payload = new byte[37]; static byte[] controller_payload = new byte[37];
@ -61,7 +62,11 @@ public class Java_GCAdapter {
{ {
usb_con.close(); usb_con.close();
} }
public static int GetFD() { return usb_con.getFileDescriptor(); }
public static int GetFD()
{
return usb_con.getFileDescriptor();
}
public static boolean QueryAdapter() public static boolean QueryAdapter()
{ {
@ -82,15 +87,17 @@ public class Java_GCAdapter {
public static void InitAdapter() public static void InitAdapter()
{ {
byte[] init = { 0x13 }; byte[] init = {0x13};
usb_con.bulkTransfer(usb_in, init, init.length, 0); usb_con.bulkTransfer(usb_in, init, init.length, 0);
} }
public static int Input() { public static int Input()
{
return usb_con.bulkTransfer(usb_in, controller_payload, controller_payload.length, 16); return usb_con.bulkTransfer(usb_in, controller_payload, controller_payload.length, 16);
} }
public static int Output(byte[] rumble) { public static int Output(byte[] rumble)
{
return usb_con.bulkTransfer(usb_out, rumble, 5, 16); return usb_con.bulkTransfer(usb_out, rumble, 5, 16);
} }
@ -137,7 +144,9 @@ public class Java_GCAdapter {
final Activity emulationActivity = NativeLibrary.sEmulationActivity.get(); final Activity emulationActivity = NativeLibrary.sEmulationActivity.get();
if (emulationActivity != null) if (emulationActivity != null)
{ {
emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity, "GameCube Adapter couldn't be opened. Please re-plug the device.", Toast.LENGTH_LONG).show()); emulationActivity.runOnUiThread(() -> Toast.makeText(emulationActivity,
"GameCube Adapter couldn't be opened. Please re-plug the device.",
Toast.LENGTH_LONG).show());
} }
else else
{ {

View File

@ -41,7 +41,8 @@ public class Java_WiimoteAdapter
for (Map.Entry<String, UsbDevice> pair : devices.entrySet()) for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
{ {
UsbDevice dev = pair.getValue(); UsbDevice dev = pair.getValue();
if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID) if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID &&
dev.getVendorId() == NINTENDO_VENDOR_ID)
{ {
if (!manager.hasPermission(dev)) if (!manager.hasPermission(dev))
{ {
@ -67,7 +68,8 @@ public class Java_WiimoteAdapter
for (Map.Entry<String, UsbDevice> pair : devices.entrySet()) for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
{ {
UsbDevice dev = pair.getValue(); UsbDevice dev = pair.getValue();
if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID) if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID &&
dev.getVendorId() == NINTENDO_VENDOR_ID)
{ {
if (manager.hasPermission(dev)) if (manager.hasPermission(dev))
return true; return true;
@ -122,7 +124,8 @@ public class Java_WiimoteAdapter
for (Map.Entry<String, UsbDevice> pair : devices.entrySet()) for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
{ {
UsbDevice dev = pair.getValue(); UsbDevice dev = pair.getValue();
if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID) if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID &&
dev.getVendorId() == NINTENDO_VENDOR_ID)
{ {
if (manager.hasPermission(dev)) if (manager.hasPermission(dev))
{ {

View File

@ -14,26 +14,31 @@ import org.dolphinemu.dolphinemu.R;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
public class PermissionsHandler { public class PermissionsHandler
{
public static final int REQUEST_CODE_WRITE_PERMISSION = 500; public static final int REQUEST_CODE_WRITE_PERMISSION = 500;
@TargetApi(Build.VERSION_CODES.M) @TargetApi(Build.VERSION_CODES.M)
public static boolean checkWritePermission(final FragmentActivity activity) { public static boolean checkWritePermission(final FragmentActivity activity)
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
{
return true; return true;
} }
int hasWritePermission = ContextCompat.checkSelfPermission(activity, WRITE_EXTERNAL_STORAGE); int hasWritePermission = ContextCompat.checkSelfPermission(activity, WRITE_EXTERNAL_STORAGE);
if (hasWritePermission != PackageManager.PERMISSION_GRANTED) { if (hasWritePermission != PackageManager.PERMISSION_GRANTED)
if (activity.shouldShowRequestPermissionRationale(WRITE_EXTERNAL_STORAGE)) { {
if (activity.shouldShowRequestPermissionRationale(WRITE_EXTERNAL_STORAGE))
{
showMessageOKCancel(activity, activity.getString(R.string.write_permission_needed), showMessageOKCancel(activity, activity.getString(R.string.write_permission_needed),
(dialog, which) -> activity.requestPermissions(new String[] {WRITE_EXTERNAL_STORAGE}, (dialog, which) -> activity.requestPermissions(new String[]{WRITE_EXTERNAL_STORAGE},
REQUEST_CODE_WRITE_PERMISSION)); REQUEST_CODE_WRITE_PERMISSION));
return false; return false;
} }
activity.requestPermissions(new String[] {WRITE_EXTERNAL_STORAGE}, activity.requestPermissions(new String[]{WRITE_EXTERNAL_STORAGE},
REQUEST_CODE_WRITE_PERMISSION); REQUEST_CODE_WRITE_PERMISSION);
return false; return false;
} }
@ -41,8 +46,10 @@ public class PermissionsHandler {
return true; return true;
} }
public static boolean hasWriteAccess(Context context) { public static boolean hasWriteAccess(Context context)
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
int hasWritePermission = ContextCompat.checkSelfPermission(context, WRITE_EXTERNAL_STORAGE); int hasWritePermission = ContextCompat.checkSelfPermission(context, WRITE_EXTERNAL_STORAGE);
return hasWritePermission == PackageManager.PERMISSION_GRANTED; return hasWritePermission == PackageManager.PERMISSION_GRANTED;
} }
@ -50,12 +57,15 @@ public class PermissionsHandler {
return true; return true;
} }
private static void showMessageOKCancel(final FragmentActivity activity, String message, DialogInterface.OnClickListener okListener) { private static void showMessageOKCancel(final FragmentActivity activity, String message,
DialogInterface.OnClickListener okListener)
{
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setMessage(message) .setMessage(message)
.setPositiveButton(android.R.string.ok, okListener) .setPositiveButton(android.R.string.ok, okListener)
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> .setNegativeButton(android.R.string.cancel, (dialogInterface, i) ->
Toast.makeText(activity, R.string.write_permission_needed, Toast.LENGTH_SHORT).show()) Toast.makeText(activity, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show())
.create() .create()
.show(); .show();
} }

View File

@ -12,7 +12,8 @@ import org.dolphinemu.dolphinemu.model.GameFile;
import java.io.File; import java.io.File;
public class PicassoUtils { public class PicassoUtils
{
public static void loadGameBanner(ImageView imageView, GameFile gameFile) public static void loadGameBanner(ImageView imageView, GameFile gameFile)
{ {
File cover = new File(gameFile.getCustomCoverPath()); File cover = new File(gameFile.getCustomCoverPath());
@ -59,6 +60,7 @@ public class PicassoUtils {
CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(), CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(),
gameFile.getCoverPath()); gameFile.getCoverPath());
} }
@Override @Override
public void onError() // Second pass using US region public void onError() // Second pass using US region
{ {
@ -74,9 +76,11 @@ public class PicassoUtils {
@Override @Override
public void onSuccess() public void onSuccess()
{ {
CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(), CoverHelper.saveCover(
((BitmapDrawable) imageView.getDrawable()).getBitmap(),
gameFile.getCoverPath()); gameFile.getCoverPath());
} }
@Override @Override
public void onError() // Third and last pass using EN region public void onError() // Third and last pass using EN region
{ {
@ -92,9 +96,12 @@ public class PicassoUtils {
@Override @Override
public void onSuccess() public void onSuccess()
{ {
CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(), CoverHelper.saveCover(
((BitmapDrawable) imageView.getDrawable())
.getBitmap(),
gameFile.getCoverPath()); gameFile.getCoverPath());
} }
@Override @Override
public void onError() public void onError()
{ {

View File

@ -17,7 +17,6 @@ import android.graphics.drawable.VectorDrawable;
import android.media.tv.TvContract; import android.media.tv.TvContract;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.support.annotation.AnyRes; import android.support.annotation.AnyRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -25,7 +24,6 @@ import android.support.media.tv.Channel;
import android.support.media.tv.TvContractCompat; import android.support.media.tv.TvContractCompat;
import android.util.Log; import android.util.Log;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.model.HomeScreenChannel; import org.dolphinemu.dolphinemu.model.HomeScreenChannel;
import org.dolphinemu.dolphinemu.services.SyncChannelJobService; import org.dolphinemu.dolphinemu.services.SyncChannelJobService;
@ -33,7 +31,6 @@ import org.dolphinemu.dolphinemu.services.SyncProgramsJobService;
import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.ui.platform.Platform;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -84,7 +81,8 @@ public class TvUtil
do do
{ {
channels.add(Channel.fromCursor(cursor)); channels.add(Channel.fromCursor(cursor));
} while (cursor.moveToNext()); }
while (cursor.moveToNext());
} }
return channels; return channels;
} }
@ -164,7 +162,7 @@ public class TvUtil
try try
{ {
File cover = new File(game.getCustomCoverPath()); File cover = new File(game.getCustomCoverPath());
if(cover.exists()) if (cover.exists())
{ {
contentUri = getUriForFile(context, getFileProvider(context), cover); contentUri = getUriForFile(context, getFileProvider(context), cover);
} }
@ -269,8 +267,9 @@ public class TvUtil
} }
return subs; return subs;
} }
public static Boolean isLeanback(Context context) public static Boolean isLeanback(Context context)
{ {
return(context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)); return (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK));
} }
} }

View File

@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:state_selected="true" android:state_selected="true"
android:drawable="@color/dolphin_accent_gamecube" /> android:drawable="@color/dolphin_accent_gamecube"/>
<item <item
android:drawable="@color/tv_card_unselected" /> android:drawable="@color/tv_card_unselected"/>
</selector> </selector>

View File

@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:state_selected="true" android:state_selected="true"
android:drawable="@color/dolphin_accent_wii" /> android:drawable="@color/dolphin_accent_wii"/>
<item <item
android:drawable="@color/tv_card_unselected" /> android:drawable="@color/tv_card_unselected"/>
</selector> </selector>

View File

@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:state_selected="true" android:state_selected="true"
android:drawable="@color/dolphin_accent_wiiware" /> android:drawable="@color/dolphin_accent_wiiware"/>
<item <item
android:drawable="@color/tv_card_unselected" /> android:drawable="@color/tv_card_unselected"/>
</selector> </selector>

View File

@ -1,17 +1,13 @@
# Project-wide Gradle settings. # Project-wide Gradle settings.
# IDE (e.g. Android Studio) users: # IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override* # Gradle settings configured through the IDE *will override*
# any settings specified in this file. # any settings specified in this file.
# For more details on how to configure your build environment visit # For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m # Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects