Android: Reformat Java sources

This commit is contained in:
Connor McLaughlin 2021-01-03 18:28:12 +10:00
parent 600e8d5dd0
commit fc3780815d
15 changed files with 105 additions and 91 deletions

View File

@ -72,13 +72,17 @@ public class AndroidHostInterface {
public static native int getControllerAxisCode(String controllerType, String axisName); public static native int getControllerAxisCode(String controllerType, String axisName);
public static native String[] getControllerButtonNames(String controllerType); public static native String[] getControllerButtonNames(String controllerType);
public static native String[] getControllerAxisNames(String controllerType); public static native String[] getControllerAxisNames(String controllerType);
public native void handleControllerButtonEvent(int controllerIndex, int buttonIndex, boolean pressed); public native void handleControllerButtonEvent(int controllerIndex, int buttonIndex, boolean pressed);
public native void handleControllerAxisEvent(int controllerIndex, int axisIndex, float value); public native void handleControllerAxisEvent(int controllerIndex, int axisIndex, float value);
public native String[] getInputProfileNames(); public native String[] getInputProfileNames();
public native boolean loadInputProfile(String name); public native boolean loadInputProfile(String name);
public native boolean saveInputProfile(String name); public native boolean saveInputProfile(String name);
public native HotkeyInfo[] getHotkeyInfoList(); public native HotkeyInfo[] getHotkeyInfoList();
@ -90,6 +94,7 @@ public class AndroidHostInterface {
public native GameListEntry getGameListEntry(String path); public native GameListEntry getGameListEntry(String path);
public native String getGameSettingValue(String path, String key); public native String getGameSettingValue(String path, String key);
public native void setGameSettingValue(String path, String key, String value); public native void setGameSettingValue(String path, String key, String value);
public native void resetSystem(); public native void resetSystem();

View File

@ -89,16 +89,21 @@ public class ControllerBindingPreference extends Preference {
public void onBindViewHolder(PreferenceViewHolder holder) { public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder); super.onBindViewHolder(holder);
ImageView iconView = ((ImageView)holder.findViewById(R.id.controller_binding_icon)); ImageView iconView = ((ImageView) holder.findViewById(R.id.controller_binding_icon));
TextView nameView = ((TextView)holder.findViewById(R.id.controller_binding_name)); TextView nameView = ((TextView) holder.findViewById(R.id.controller_binding_name));
mValueView = ((TextView)holder.findViewById(R.id.controller_binding_value)); mValueView = ((TextView) holder.findViewById(R.id.controller_binding_value));
int drawableId = R.drawable.ic_baseline_radio_button_checked_24; int drawableId = R.drawable.ic_baseline_radio_button_checked_24;
switch (mType) switch (mType) {
{ case BUTTON:
case BUTTON: drawableId = getIconForButton(mBindingName); break; drawableId = getIconForButton(mBindingName);
case AXIS: drawableId = getIconForAxis(mBindingName); break; break;
case HOTKEY: drawableId = getIconForHotkey(mBindingName); break; case AXIS:
drawableId = getIconForAxis(mBindingName);
break;
case HOTKEY:
drawableId = getIconForHotkey(mBindingName);
break;
} }
iconView.setImageDrawable(ContextCompat.getDrawable(getContext(), drawableId)); iconView.setImageDrawable(ContextCompat.getDrawable(getContext(), drawableId));

View File

@ -55,38 +55,38 @@ public class EmulationSurfaceView extends SurfaceView {
} }
} }
private static final int[] buttonKeyCodes = new int[] { private static final int[] buttonKeyCodes = new int[]{
KeyEvent.KEYCODE_BUTTON_A, // 0/Cross KeyEvent.KEYCODE_BUTTON_A, // 0/Cross
KeyEvent.KEYCODE_BUTTON_B, // 1/Circle KeyEvent.KEYCODE_BUTTON_B, // 1/Circle
KeyEvent.KEYCODE_BUTTON_X, // 2/Square KeyEvent.KEYCODE_BUTTON_X, // 2/Square
KeyEvent.KEYCODE_BUTTON_Y, // 3/Triangle KeyEvent.KEYCODE_BUTTON_Y, // 3/Triangle
KeyEvent.KEYCODE_BUTTON_SELECT, // 4/Select KeyEvent.KEYCODE_BUTTON_SELECT, // 4/Select
KeyEvent.KEYCODE_BUTTON_MODE, // 5/Analog KeyEvent.KEYCODE_BUTTON_MODE, // 5/Analog
KeyEvent.KEYCODE_BUTTON_START, // 6/Start KeyEvent.KEYCODE_BUTTON_START, // 6/Start
KeyEvent.KEYCODE_BUTTON_THUMBL, // 7/L3 KeyEvent.KEYCODE_BUTTON_THUMBL, // 7/L3
KeyEvent.KEYCODE_BUTTON_THUMBR, // 8/R3 KeyEvent.KEYCODE_BUTTON_THUMBR, // 8/R3
KeyEvent.KEYCODE_BUTTON_L1, // 9/L1 KeyEvent.KEYCODE_BUTTON_L1, // 9/L1
KeyEvent.KEYCODE_BUTTON_R1, // 10/R1 KeyEvent.KEYCODE_BUTTON_R1, // 10/R1
KeyEvent.KEYCODE_DPAD_UP, // 11/Up KeyEvent.KEYCODE_DPAD_UP, // 11/Up
KeyEvent.KEYCODE_DPAD_DOWN, // 12/Down KeyEvent.KEYCODE_DPAD_DOWN, // 12/Down
KeyEvent.KEYCODE_DPAD_LEFT, // 13/Left KeyEvent.KEYCODE_DPAD_LEFT, // 13/Left
KeyEvent.KEYCODE_DPAD_RIGHT, // 14/Right KeyEvent.KEYCODE_DPAD_RIGHT, // 14/Right
KeyEvent.KEYCODE_BUTTON_L2, // 15 KeyEvent.KEYCODE_BUTTON_L2, // 15
KeyEvent.KEYCODE_BUTTON_R2, // 16 KeyEvent.KEYCODE_BUTTON_R2, // 16
KeyEvent.KEYCODE_BUTTON_C, // 17 KeyEvent.KEYCODE_BUTTON_C, // 17
KeyEvent.KEYCODE_BUTTON_Z, // 18 KeyEvent.KEYCODE_BUTTON_Z, // 18
}; };
private static final int[] axisCodes = new int[] { private static final int[] axisCodes = new int[]{
MotionEvent.AXIS_X, // 0/LeftX MotionEvent.AXIS_X, // 0/LeftX
MotionEvent.AXIS_Y, // 1/LeftY MotionEvent.AXIS_Y, // 1/LeftY
MotionEvent.AXIS_Z, // 2/RightX MotionEvent.AXIS_Z, // 2/RightX
MotionEvent.AXIS_RZ, // 3/RightY MotionEvent.AXIS_RZ, // 3/RightY
MotionEvent.AXIS_LTRIGGER, // 4/L2 MotionEvent.AXIS_LTRIGGER, // 4/L2
MotionEvent.AXIS_RTRIGGER, // 5/R2 MotionEvent.AXIS_RTRIGGER, // 5/R2
MotionEvent.AXIS_RX, // 6 MotionEvent.AXIS_RX, // 6
MotionEvent.AXIS_RY, // 7 MotionEvent.AXIS_RY, // 7
MotionEvent.AXIS_HAT_X, // 8 MotionEvent.AXIS_HAT_X, // 8
MotionEvent.AXIS_HAT_Y, // 9 MotionEvent.AXIS_HAT_Y, // 9
}; };
public static int getButtonIndexForKeyCode(int keyCode) { public static int getButtonIndexForKeyCode(int keyCode) {

View File

@ -117,22 +117,22 @@ public class GamePropertiesActivity extends AppCompatActivity {
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
final PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getContext()); final PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getContext());
activity.createListGameSetting(ps, "CPUOverclock", R.string.settings_cpu_overclocking, R.array.settings_advanced_cpu_overclock_entries, R.array.settings_advanced_cpu_overclock_values); activity.createListGameSetting(ps, "CPUOverclock", R.string.settings_cpu_overclocking, R.array.settings_advanced_cpu_overclock_entries, R.array.settings_advanced_cpu_overclock_values);
activity.createListGameSetting(ps,"CDROMReadSpeedup", R.string.settings_cdrom_read_speedup, R.array.settings_cdrom_read_speedup_entries, R.array.settings_cdrom_read_speedup_values); activity.createListGameSetting(ps, "CDROMReadSpeedup", R.string.settings_cdrom_read_speedup, R.array.settings_cdrom_read_speedup_entries, R.array.settings_cdrom_read_speedup_values);
activity.createListGameSetting(ps, "DisplayAspectRatio", R.string.settings_aspect_ratio, R.array.settings_display_aspect_ratio_names, R.array.settings_display_aspect_ratio_values); activity.createListGameSetting(ps, "DisplayAspectRatio", R.string.settings_aspect_ratio, R.array.settings_display_aspect_ratio_names, R.array.settings_display_aspect_ratio_values);
activity.createListGameSetting(ps, "DisplayCropMode", R.string.settings_crop_mode,R.array.settings_display_crop_mode_entries,R.array.settings_display_crop_mode_values); activity.createListGameSetting(ps, "DisplayCropMode", R.string.settings_crop_mode, R.array.settings_display_crop_mode_entries, R.array.settings_display_crop_mode_values);
activity.createListGameSetting(ps,"GPUDownsampleMode", R.string.settings_downsample_mode, R.array.settings_downsample_mode_entries, R.array.settings_downsample_mode_values); activity.createListGameSetting(ps, "GPUDownsampleMode", R.string.settings_downsample_mode, R.array.settings_downsample_mode_entries, R.array.settings_downsample_mode_values);
activity.createBooleanGameSetting(ps, "DisplayLinearUpscaling", R.string.settings_linear_upscaling); activity.createBooleanGameSetting(ps, "DisplayLinearUpscaling", R.string.settings_linear_upscaling);
activity.createBooleanGameSetting(ps,"DisplayIntegerUpscaling",R.string.settings_integer_upscaling); activity.createBooleanGameSetting(ps, "DisplayIntegerUpscaling", R.string.settings_integer_upscaling);
activity.createBooleanGameSetting(ps,"DisplayForce4_3For24Bit",R.string.settings_force_4_3_for_24bit); activity.createBooleanGameSetting(ps, "DisplayForce4_3For24Bit", R.string.settings_force_4_3_for_24bit);
activity.createListGameSetting(ps, "GPUResolutionScale", R.string.settings_gpu_resolution_scale, R.array.settings_gpu_resolution_scale_entries, R.array.settings_gpu_resolution_scale_values); activity.createListGameSetting(ps, "GPUResolutionScale", R.string.settings_gpu_resolution_scale, R.array.settings_gpu_resolution_scale_entries, R.array.settings_gpu_resolution_scale_values);
activity.createListGameSetting(ps, "GPUMSAA", R.string.settings_msaa, R.array.settings_gpu_msaa_entries, R.array.settings_gpu_msaa_values); activity.createListGameSetting(ps, "GPUMSAA", R.string.settings_msaa, R.array.settings_gpu_msaa_entries, R.array.settings_gpu_msaa_values);
activity.createBooleanGameSetting(ps, "GPUTrueColor", R.string.settings_true_color); activity.createBooleanGameSetting(ps, "GPUTrueColor", R.string.settings_true_color);
activity.createBooleanGameSetting(ps,"GPUScaledDithering",R.string.settings_scaled_dithering); activity.createBooleanGameSetting(ps, "GPUScaledDithering", R.string.settings_scaled_dithering);
activity.createListGameSetting(ps, "GPUTextureFilter", R.string.settings_texture_filtering, R.array.settings_gpu_texture_filter_names, R.array.settings_gpu_texture_filter_values); activity.createListGameSetting(ps, "GPUTextureFilter", R.string.settings_texture_filtering, R.array.settings_gpu_texture_filter_names, R.array.settings_gpu_texture_filter_values);
activity.createBooleanGameSetting(ps,"GPUForceNTSCTimings",R.string.settings_force_ntsc_timings); activity.createBooleanGameSetting(ps, "GPUForceNTSCTimings", R.string.settings_force_ntsc_timings);
activity.createBooleanGameSetting(ps, "GPUWidescreenHack", R.string.settings_widescreen_hack); activity.createBooleanGameSetting(ps, "GPUWidescreenHack", R.string.settings_widescreen_hack);
activity.createBooleanGameSetting(ps, "GPUPGXP", R.string.settings_pgxp_geometry_correction); activity.createBooleanGameSetting(ps, "GPUPGXP", R.string.settings_pgxp_geometry_correction);
activity.createBooleanGameSetting(ps, "GPUPGXPDepthBuffer", R.string.settings_pgxp_depth_buffer); activity.createBooleanGameSetting(ps, "GPUPGXPDepthBuffer", R.string.settings_pgxp_depth_buffer);
@ -193,11 +193,16 @@ public class GamePropertiesActivity extends AppCompatActivity {
TabLayout tabLayout = view.findViewById(R.id.tab_layout); TabLayout tabLayout = view.findViewById(R.id.tab_layout);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> { new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch (position) switch (position) {
{ case 0:
case 0: tab.setText("Summary"); break; tab.setText("Summary");
case 1: tab.setText("Game Settings"); break; break;
case 2: tab.setText("Controller Settings"); break; case 1:
tab.setText("Game Settings");
break;
case 2:
tab.setText("Controller Settings");
break;
} }
}).attach(); }).attach();
} }
@ -214,8 +219,7 @@ public class GamePropertiesActivity extends AppCompatActivity {
@NonNull @NonNull
@Override @Override
public Fragment createFragment(int position) { public Fragment createFragment(int position) {
switch (position) switch (position) {
{
case 0: { // Summary case 0: { // Summary
ListFragment lf = new ListFragment(); ListFragment lf = new ListFragment();
lf.setListAdapter(activity.getPropertyListAdapter()); lf.setListAdapter(activity.getPropertyListAdapter());

View File

@ -9,7 +9,8 @@ public class PreferenceHelpers {
/** /**
* Clears all preferences in the specified section (starting with sectionName/). * Clears all preferences in the specified section (starting with sectionName/).
* We really don't want to have to do this with JNI... * We really don't want to have to do this with JNI...
* @param prefs Preferences object. *
* @param prefs Preferences object.
* @param sectionName Section to clear keys for. * @param sectionName Section to clear keys for.
*/ */
public static void clearSection(SharedPreferences prefs, String sectionName) { public static void clearSection(SharedPreferences prefs, String sectionName) {
@ -43,8 +44,7 @@ public class PreferenceHelpers {
return values; return values;
} }
public static boolean addToStringList(SharedPreferences prefs, String keyName, String valueToAdd) public static boolean addToStringList(SharedPreferences prefs, String keyName, String valueToAdd) {
{
Set<String> values = getStringSet(prefs, keyName); Set<String> values = getStringSet(prefs, keyName);
if (values == null) if (values == null)
values = new ArraySet<>(); values = new ArraySet<>();
@ -54,8 +54,7 @@ public class PreferenceHelpers {
return result; return result;
} }
public static boolean removeFromStringList(SharedPreferences prefs, String keyName, String valueToRemove) public static boolean removeFromStringList(SharedPreferences prefs, String keyName, String valueToRemove) {
{
Set<String> values = getStringSet(prefs, keyName); Set<String> values = getStringSet(prefs, keyName);
if (values == null) if (values == null)
return false; return false;

View File

@ -74,8 +74,8 @@ public class PropertyListAdapter extends BaseAdapter {
.inflate(R.layout.layout_game_property_entry, parent, false); .inflate(R.layout.layout_game_property_entry, parent, false);
} }
TextView titleView = (TextView)convertView.findViewById(R.id.property_title); TextView titleView = (TextView) convertView.findViewById(R.id.property_title);
TextView valueView = (TextView)convertView.findViewById(R.id.property_value); TextView valueView = (TextView) convertView.findViewById(R.id.property_value);
Item prop = mItems.get(position); Item prop = mItems.get(position);
titleView.setText(prop.title); titleView.setText(prop.title);
valueView.setText(prop.value); valueView.setText(prop.value);

View File

@ -4,13 +4,13 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,2l-5.5,9h11z"/> android:pathData="M12,2l-5.5,9h11z" />
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M17.5,17.5m-4.5,0a4.5,4.5 0,1 1,9 0a4.5,4.5 0,1 1,-9 0"/> android:pathData="M17.5,17.5m-4.5,0a4.5,4.5 0,1 1,9 0a4.5,4.5 0,1 1,-9 0" />
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M3,13.5h8v8H3z"/> android:pathData="M3,13.5h8v8H3z" />
</vector> </vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/> android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z" />
</vector> </vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M15,7.5V2H9v5.5l3,3 3,-3zM7.5,9H2v6h5.5l3,-3 -3,-3zM9,16.5V22h6v-5.5l-3,-3 -3,3zM16.5,9l-3,3 3,3H22V9h-5.5z"/> android:pathData="M15,7.5V2H9v5.5l3,3 3,-3zM7.5,9H2v6h5.5l3,-3 -3,-3zM9,16.5V22h6v-5.5l-3,-3 -3,3zM16.5,9l-3,3 3,3H22V9h-5.5z" />
</vector> </vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/> android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector> </vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/> android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector> </vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24" android:viewportHeight="24"
android:tint="?attr/colorControlNormal"> android:tint="?attr/colorControlNormal">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/> android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z" />
</vector> </vector>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView

View File

@ -16,5 +16,5 @@
<item <item
android:id="@+id/action_clear_bindings" android:id="@+id/action_clear_bindings"
android:title="Clear Bindings"/> android:title="Clear Bindings" />
</menu> </menu>

View File

@ -29,9 +29,10 @@
app:title="@string/settings_controller_mapping" app:title="@string/settings_controller_mapping"
app:summary="@string/settings_controller_mapping_summary" app:summary="@string/settings_controller_mapping_summary"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<intent android:action="android.intent.action.VIEW" <intent
android:targetClass="com.github.stenzek.duckstation.ControllerMappingActivity" android:action="android.intent.action.VIEW"
android:targetPackage="com.github.stenzek.duckstation" /> android:targetClass="com.github.stenzek.duckstation.ControllerMappingActivity"
android:targetPackage="com.github.stenzek.duckstation" />
</Preference> </Preference>
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:key="Controller1/ForceAnalogOnReset" app:key="Controller1/ForceAnalogOnReset"