Merge pull request #9042 from Ebola16/FP

Android: Minor cleanup
This commit is contained in:
LC 2020-09-01 07:27:07 -04:00 committed by GitHub
commit fb32f1ab88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 233 additions and 244 deletions

View File

@ -30,7 +30,6 @@ public class AppLinkActivity extends FragmentActivity
private AppLinkHelper.PlayAction playAction; private AppLinkHelper.PlayAction playAction;
private DirectoryStateReceiver directoryStateReceiver; private DirectoryStateReceiver directoryStateReceiver;
private BroadcastReceiver gameFileCacheReceiver;
@Override @Override
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
@ -96,18 +95,17 @@ public class AppLinkActivity extends FragmentActivity
} }
}); });
gameFileCacheReceiver = BroadcastReceiver gameFileCacheReceiver = new BroadcastReceiver()
new BroadcastReceiver() {
{ @Override
@Override public void onReceive(Context context, Intent intent)
public void onReceive(Context context, Intent intent) {
{ if (DirectoryInitialization.areDolphinDirectoriesReady())
if (DirectoryInitialization.areDolphinDirectoriesReady()) {
{ tryPlay(playAction);
tryPlay(playAction); }
} }
} };
};
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.registerReceiver(directoryStateReceiver, directoryStateIntentFilter); broadcastManager.registerReceiver(directoryStateReceiver, directoryStateIntentFilter);

View File

@ -67,7 +67,6 @@ public final class EmulationActivity extends AppCompatActivity
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
private MotionListener mMotionListener; private MotionListener mMotionListener;
private ControllerMappingHelper mControllerMappingHelper;
private Settings mSettings; private Settings mSettings;
@ -317,7 +316,6 @@ public final class EmulationActivity extends AppCompatActivity
sIsGameCubeGame = Platform.fromNativeInt(mPlatform) == Platform.GAMECUBE; sIsGameCubeGame = Platform.fromNativeInt(mPlatform) == Platform.GAMECUBE;
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen"); mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
mMotionListener = new MotionListener(this); mMotionListener = new MotionListener(this);
mControllerMappingHelper = new ControllerMappingHelper();
int themeId; int themeId;
if (mDeviceHasTouchScreen) if (mDeviceHasTouchScreen)
@ -445,19 +443,17 @@ public final class EmulationActivity extends AppCompatActivity
protected void onActivityResult(int requestCode, int resultCode, Intent result) protected void onActivityResult(int requestCode, int resultCode, Intent result)
{ {
super.onActivityResult(requestCode, resultCode, result); super.onActivityResult(requestCode, resultCode, result);
switch (requestCode) if (requestCode == REQUEST_CHANGE_DISC)
{ {
case REQUEST_CHANGE_DISC: // If the user picked a file, as opposed to just backing out.
// If the user picked a file, as opposed to just backing out. if (resultCode == MainActivity.RESULT_OK)
if (resultCode == MainActivity.RESULT_OK) {
String newDiscPath = FileBrowserHelper.getSelectedPath(result);
if (!TextUtils.isEmpty(newDiscPath))
{ {
String newDiscPath = FileBrowserHelper.getSelectedPath(result); NativeLibrary.ChangeDisc(newDiscPath);
if (!TextUtils.isEmpty(newDiscPath))
{
NativeLibrary.ChangeDisc(newDiscPath);
}
} }
break; }
} }
} }
@ -1041,14 +1037,14 @@ public final class EmulationActivity extends AppCompatActivity
private void setIRSensitivity() private void setIRSensitivity()
{ {
int ir_pitch = Integer.valueOf( int ir_pitch = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15")); mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
LayoutInflater inflater = LayoutInflater.from(this); LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null); View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
TextView text_slider_value_pitch = (TextView) view.findViewById(R.id.text_ir_pitch); TextView text_slider_value_pitch = view.findViewById(R.id.text_ir_pitch);
TextView units = (TextView) view.findViewById(R.id.text_ir_pitch_units); TextView units = view.findViewById(R.id.text_ir_pitch_units);
SeekBar seekbar_pitch = view.findViewById(R.id.seekbar_pitch); SeekBar seekbar_pitch = view.findViewById(R.id.seekbar_pitch);
text_slider_value_pitch.setText(String.valueOf(ir_pitch)); text_slider_value_pitch.setText(String.valueOf(ir_pitch));
@ -1074,11 +1070,11 @@ public final class EmulationActivity extends AppCompatActivity
} }
}); });
int ir_yaw = Integer.valueOf( int ir_yaw = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15")); mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw); TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw);
TextView units_yaw = (TextView) view.findViewById(R.id.text_ir_yaw_units); TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units);
SeekBar seekbar_yaw = view.findViewById(R.id.seekbar_width); SeekBar seekbar_yaw = view.findViewById(R.id.seekbar_width);
text_slider_value_yaw.setText(String.valueOf(ir_yaw)); text_slider_value_yaw.setText(String.valueOf(ir_yaw));
@ -1105,14 +1101,12 @@ public final class EmulationActivity extends AppCompatActivity
}); });
int ir_vertical_offset = Integer.valueOf( int ir_vertical_offset = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId, mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
"10")); "10"));
TextView text_slider_value_vertical_offset = TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset);
(TextView) view.findViewById(R.id.text_ir_vertical_offset); TextView units_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset_units);
TextView units_vertical_offset =
(TextView) view.findViewById(R.id.text_ir_vertical_offset_units);
SeekBar seekbar_vertical_offset = view.findViewById(R.id.seekbar_vertical_offset); SeekBar seekbar_vertical_offset = view.findViewById(R.id.seekbar_vertical_offset);
text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset)); text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset));
@ -1176,9 +1170,7 @@ public final class EmulationActivity extends AppCompatActivity
new AlertDialog.Builder(this, R.style.DolphinDialogBase) new AlertDialog.Builder(this, R.style.DolphinDialogBase)
.setTitle(getString(R.string.emulation_touch_overlay_reset)) .setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> .setPositiveButton(R.string.yes, (dialogInterface, i) ->
{ mEmulationFragment.resetInputOverlay())
mEmulationFragment.resetInputOverlay();
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> .setNegativeButton(R.string.cancel, (dialogInterface, i) ->
{ {
}) })
@ -1210,7 +1202,7 @@ public final class EmulationActivity extends AppCompatActivity
{ {
int axis = range.getAxis(); int axis = range.getAxis();
float origValue = event.getAxisValue(axis); float origValue = event.getAxisValue(axis);
float value = mControllerMappingHelper.scaleAxis(input, axis, origValue); float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
// If the input is still in the "flat" area, that means it's really zero. // If the input is still in the "flat" area, that means it's really zero.
// This is used to compensate for imprecision in joysticks. // This is used to compensate for imprecision in joysticks.
if (Math.abs(value) > range.getFlat()) if (Math.abs(value) > range.getFlat())

View File

@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.adapters;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
@ -28,10 +29,11 @@ public class PlatformPagerAdapter extends FragmentPagerAdapter
public PlatformPagerAdapter(FragmentManager fm, Context context) public PlatformPagerAdapter(FragmentManager fm, Context context)
{ {
super(fm); super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
mContext = context; mContext = context;
} }
@NonNull
@Override @Override
public Fragment getItem(int position) public Fragment getItem(int position)
{ {

View File

@ -73,7 +73,7 @@ public final class GameDetailsDialog extends DialogFragment
textCountry.setText(country); textCountry.setText(country);
textCompany.setText(gameFile.getCompany()); textCompany.setText(gameFile.getCompany());
textGameId.setText(gameFile.getGameId()); textGameId.setText(gameFile.getGameId());
textRevision.setText(Integer.toString(gameFile.getRevision())); textRevision.setText(String.valueOf(gameFile.getRevision()));
if (!gameFile.shouldShowFileFormatDetails()) if (!gameFile.shouldShowFileFormatDetails())
{ {

View File

@ -44,20 +44,17 @@ public final class MotionAlertDialog extends AlertDialog
public boolean onKeyEvent(int keyCode, KeyEvent event) public boolean onKeyEvent(int keyCode, KeyEvent event)
{ {
Log.debug("[MotionAlertDialog] Received key event: " + event.getAction()); Log.debug("[MotionAlertDialog] Received key event: " + event.getAction());
switch (event.getAction()) if (event.getAction() == KeyEvent.ACTION_UP)
{ {
case KeyEvent.ACTION_UP: if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode)) {
{ setting.onKeyInput(event);
setting.onKeyInput(event); dismiss();
dismiss(); }
} // Even if we ignore the key, we still consume it. Thus return true regardless.
// Even if we ignore the key, we still consume it. Thus return true regardless. return true;
return true;
default:
return false;
} }
return false;
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.ui; package org.dolphinemu.dolphinemu.features.settings.ui;
import androidx.annotation.NonNull;
public enum MenuTag public enum MenuTag
{ {
CONFIG("config"), CONFIG("config"),
@ -46,6 +48,7 @@ public enum MenuTag
this.subType = subtype; this.subType = subtype;
} }
@NonNull
@Override @Override
public String toString() public String toString()
{ {

View File

@ -143,11 +143,10 @@ public final class SettingsActivityPresenter
public boolean handleOptionsItem(int itemId) public boolean handleOptionsItem(int itemId)
{ {
switch (itemId) if (itemId == R.id.menu_save_exit)
{ {
case R.id.menu_save_exit: mView.finish();
mView.finish(); return true;
return true;
} }
return false; return false;

View File

@ -2,8 +2,6 @@ package org.dolphinemu.dolphinemu.features.settings.ui;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -45,7 +43,6 @@ import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHold
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.Log;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.util.ArrayList; import java.util.ArrayList;
@ -97,7 +94,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
case SettingsItem.TYPE_SLIDER: case SettingsItem.TYPE_SLIDER:
view = inflater.inflate(R.layout.list_item_setting, parent, false); view = inflater.inflate(R.layout.list_item_setting, parent, false);
return new SliderViewHolder(view, this); return new SliderViewHolder(view, this, mContext);
case SettingsItem.TYPE_SUBMENU: case SettingsItem.TYPE_SUBMENU:
view = inflater.inflate(R.layout.list_item_setting_submenu, parent, false); view = inflater.inflate(R.layout.list_item_setting_submenu, parent, false);
@ -120,8 +117,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
return new ConfirmRunnableViewHolder(view, this, mContext, mView); return new ConfirmRunnableViewHolder(view, this, mContext, mView);
default: default:
Log.error("[SettingsAdapter] Invalid view type: " + viewType); throw new IllegalArgumentException("Invalid view type: " + viewType);
return null;
} }
} }
@ -243,13 +239,13 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
builder.setPositiveButton(R.string.ok, this); builder.setPositiveButton(R.string.ok, this);
mDialog = builder.show(); mDialog = builder.show();
mTextSliderValue = (TextView) view.findViewById(R.id.text_value); mTextSliderValue = view.findViewById(R.id.text_value);
mTextSliderValue.setText(String.valueOf(mSeekbarProgress)); mTextSliderValue.setText(String.valueOf(mSeekbarProgress));
TextView units = (TextView) view.findViewById(R.id.text_units); TextView units = view.findViewById(R.id.text_units);
units.setText(item.getUnits()); units.setText(item.getUnits());
SeekBar seekbar = (SeekBar) view.findViewById(R.id.seekbar); SeekBar seekbar = view.findViewById(R.id.seekbar);
seekbar.setMax(item.getMax()); seekbar.setMax(item.getMax());
seekbar.setProgress(mSeekbarProgress); seekbar.setProgress(mSeekbarProgress);
@ -273,21 +269,13 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mContext.getString(item.getNameId()))); 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), dialog.setButton(AlertDialog.BUTTON_NEUTRAL, mContext.getString(R.string.clear),
(dialogInterface, i) -> (dialogInterface, i) -> item.clearValue());
{
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(mContext);
item.clearValue();
});
dialog.setOnDismissListener(dialog1 -> dialog.setOnDismissListener(dialog1 ->
{ {
StringSetting setting = new StringSetting(item.getKey(), item.getSection(), item.getValue()); StringSetting setting = new StringSetting(item.getKey(), item.getSection(), item.getValue());
notifyItemChanged(position); notifyItemChanged(position);
if (setting != null) mView.putSetting(setting);
{
mView.putSetting(setting);
}
mView.onSettingChanged(item.getKey()); mView.onSettingChanged(item.getKey());
}); });

View File

@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.features.settings.ui;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -84,7 +85,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
} }
@Override @Override
public void onAttach(Context context) public void onAttach(@NonNull Context context)
{ {
super.onAttach(context); super.onAttach(context);
@ -115,7 +116,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
} }
@Override @Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{ {
Bundle args = getArguments(); Bundle args = getArguments();
MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG); MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG);

View File

@ -59,8 +59,8 @@ public final class SettingsFragmentPresenter
public void onCreate(MenuTag menuTag, String gameId, Bundle extras) public void onCreate(MenuTag menuTag, String gameId, Bundle extras)
{ {
mGameID = gameId; mGameID = gameId;
this.mMenuTag = menuTag; this.mMenuTag = menuTag;
if (menuTag.isGCPadMenu() || menuTag.isWiimoteExtensionMenu()) if (menuTag.isGCPadMenu() || menuTag.isWiimoteExtensionMenu())
{ {
mControllerNumber = menuTag.getSubType(); mControllerNumber = menuTag.getSubType();
@ -70,10 +70,6 @@ public final class SettingsFragmentPresenter
{ {
mControllerNumber = menuTag.getSubType(); mControllerNumber = menuTag.getSubType();
} }
else
{
mMenuTag = menuTag;
}
} }
public void onViewCreated(MenuTag menuTag, Settings settings) public void onViewCreated(MenuTag menuTag, Settings settings)

View File

@ -9,8 +9,6 @@ import android.widget.FrameLayout;
*/ */
public final class SettingsFrameLayout extends FrameLayout public final class SettingsFrameLayout extends FrameLayout
{ {
private float mVisibleness = 1.0f;
public SettingsFrameLayout(Context context) public SettingsFrameLayout(Context context)
{ {
super(context); super(context);
@ -44,7 +42,7 @@ public final class SettingsFrameLayout extends FrameLayout
public float getVisibleness() public float getVisibleness()
{ {
return mVisibleness; return 1.0f;
} }
public void setVisibleness(float visibleness) public void setVisibleness(float visibleness)

View File

@ -28,9 +28,9 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
mCheckbox = (CheckBox) root.findViewById(R.id.checkbox); mCheckbox = root.findViewById(R.id.checkbox);
} }
@Override @Override

View File

@ -35,8 +35,8 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
} }
@Override @Override
@ -78,9 +78,7 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder
mView.getActivity().finish(); mView.getActivity().finish();
}) })
.setNegativeButton("No", (dialog, whichButton) -> .setNegativeButton("No", (dialog, whichButton) ->
{ dialog.dismiss());
dialog.dismiss();
});
builder.show(); builder.show();
} }

View File

@ -8,7 +8,6 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker; import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
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;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
public final class FilePickerViewHolder extends SettingViewHolder public final class FilePickerViewHolder extends SettingViewHolder
@ -27,8 +26,8 @@ public final class FilePickerViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
} }
@Override @Override

View File

@ -20,7 +20,7 @@ public final class HeaderViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mHeaderName = (TextView) root.findViewById(R.id.text_header_name); mHeaderName = root.findViewById(R.id.text_header_name);
} }
@Override @Override
@ -34,4 +34,4 @@ public final class HeaderViewHolder extends SettingViewHolder
{ {
// no-op // no-op
} }
} }

View File

@ -30,8 +30,8 @@ public class RumbleBindingViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
} }
@Override @Override

View File

@ -26,8 +26,8 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.content.Context;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -10,21 +11,25 @@ import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
public final class SliderViewHolder extends SettingViewHolder public final class SliderViewHolder extends SettingViewHolder
{ {
private Context mContext;
private SliderSetting mItem; private SliderSetting mItem;
private TextView mTextSettingName; private TextView mTextSettingName;
private TextView mTextSettingDescription; private TextView mTextSettingDescription;
public SliderViewHolder(View itemView, SettingsAdapter adapter) public SliderViewHolder(View itemView, SettingsAdapter adapter, Context context)
{ {
super(itemView, adapter); super(itemView, adapter);
mContext = context;
} }
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); mTextSettingDescription = root.findViewById(R.id.text_setting_description);
} }
@Override @Override
@ -40,7 +45,9 @@ public final class SliderViewHolder extends SettingViewHolder
} }
else else
{ {
mTextSettingDescription.setText(mItem.getSelectedValue() + mItem.getUnits()); mTextSettingDescription.setText(mContext
.getString(R.string.slider_setting_value, mItem.getSelectedValue(),
mItem.getUnits()));
} }
} }

View File

@ -22,7 +22,7 @@ public final class SubmenuViewHolder extends SettingViewHolder
@Override @Override
protected void findViews(View root) protected void findViews(View root)
{ {
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingName = root.findViewById(R.id.text_setting_name);
} }
@Override @Override

View File

@ -432,10 +432,8 @@ public final class SettingsFile
{ {
File ini = getSettingsFile(fileName); File ini = getSettingsFile(fileName);
PrintWriter writer = null; try (PrintWriter writer = new PrintWriter(ini, "UTF-8"))
try
{ {
writer = new PrintWriter(ini, "UTF-8");
Set<String> keySet = sections.keySet(); Set<String> keySet = sections.keySet();
Set<String> sortedKeySet = new TreeSet<>(keySet); Set<String> sortedKeySet = new TreeSet<>(keySet);
@ -459,13 +457,6 @@ public final class SettingsFile
if (view != null) if (view != null)
view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage()); view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage());
} }
finally
{
if (writer != null)
{
writer.close();
}
}
} }
public static void saveCustomGameSettings(final String gameId, public static void saveCustomGameSettings(final String gameId,
@ -534,14 +525,14 @@ public final class SettingsFile
DirectoryInitialization.copyFile(defautlWiiProfilePath, wiiConfigPath); DirectoryInitialization.copyFile(defautlWiiProfilePath, wiiConfigPath);
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, "Device", NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, "Device",
"Android/" + (Integer.valueOf(padId) + 4) + "/Touchscreen"); "Android/" + (Integer.parseInt(padId) + 4) + "/Touchscreen");
} }
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, value); NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, value);
// Enable the profile // Enable the profile
NativeLibrary.SetUserSetting(gameId, Settings.SECTION_CONTROLS, NativeLibrary.SetUserSetting(gameId, Settings.SECTION_CONTROLS,
KEY_WIIMOTE_PROFILE + (Integer.valueOf(padId) + 1), profile); KEY_WIIMOTE_PROFILE + (Integer.parseInt(padId) + 1), profile);
} }
private static String mapSectionNameFromIni(String generalSectionName) private static String mapSectionNameFromIni(String generalSectionName)

View File

@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@ -54,7 +55,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
} }
@Override @Override
public void onAttach(Context context) public void onAttach(@NonNull Context context)
{ {
super.onAttach(context); super.onAttach(context);
@ -213,7 +214,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
} }
@Override @Override
public void surfaceCreated(SurfaceHolder holder) public void surfaceCreated(@NonNull SurfaceHolder holder)
{ {
// We purposely don't do anything here. // We purposely don't do anything here.
// All work is done in surfaceChanged, which we are guaranteed to get even for surface creation. // All work is done in surfaceChanged, which we are guaranteed to get even for surface creation.
@ -227,7 +228,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
} }
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) public void surfaceDestroyed(@NonNull SurfaceHolder holder)
{ {
mEmulationState.clearSurface(); mEmulationState.clearSurface();
} }
@ -447,7 +448,10 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
try try
{ {
File file = new File(path); File file = new File(path);
file.delete(); if (!file.delete())
{
Log.error("[EmulationFragment] Failed to delete " + file.getAbsolutePath());
}
} }
catch (Exception ignored) catch (Exception ignored)
{ {

View File

@ -2,7 +2,6 @@ package org.dolphinemu.dolphinemu.fragments;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import android.util.SparseIntArray; import android.util.SparseIntArray;
@ -58,13 +57,12 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
return fragment; return fragment;
} }
@Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
View rootView = inflater.inflate(R.layout.fragment_ingame_menu, container, false); View rootView = inflater.inflate(R.layout.fragment_ingame_menu, container, false);
LinearLayout options = (LinearLayout) rootView.findViewById(R.id.layout_options); LinearLayout options = rootView.findViewById(R.id.layout_options);
mPauseEmulation = options.findViewById(R.id.menu_pause_emulation); mPauseEmulation = options.findViewById(R.id.menu_pause_emulation);
mUnpauseEmulation = options.findViewById(R.id.menu_unpause_emulation); mUnpauseEmulation = options.findViewById(R.id.menu_unpause_emulation);

View File

@ -80,13 +80,12 @@ public final class SaveLoadStateFragment extends Fragment implements View.OnClic
mSaveOrLoad = (SaveOrLoad) getArguments().getSerializable(KEY_SAVEORLOAD); mSaveOrLoad = (SaveOrLoad) getArguments().getSerializable(KEY_SAVEORLOAD);
} }
@Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
View rootView = inflater.inflate(R.layout.fragment_saveload_state, container, false); View rootView = inflater.inflate(R.layout.fragment_saveload_state, container, false);
GridLayout grid = (GridLayout) rootView.findViewById(R.id.grid_state_slots); GridLayout grid = rootView.findViewById(R.id.grid_state_slots);
for (int childIndex = 0; childIndex < grid.getChildCount(); childIndex++) for (int childIndex = 0; childIndex < grid.getChildCount(); childIndex++)
{ {
Button button = (Button) grid.getChildAt(childIndex); Button button = (Button) grid.getChildAt(childIndex);

View File

@ -1,7 +1,6 @@
package org.dolphinemu.dolphinemu.model; package org.dolphinemu.dolphinemu.model;
import android.content.Context; import android.content.Context;
import android.os.Environment;
public class GameFile public class GameFile
{ {

View File

@ -33,6 +33,12 @@ public class GameFileCache
{ {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET); Set<String> folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET);
if (folderPaths == null)
{
return;
}
Set<String> newFolderPaths = new HashSet<>(folderPaths); Set<String> newFolderPaths = new HashSet<>(folderPaths);
newFolderPaths.add(path); newFolderPaths.add(path);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
@ -44,6 +50,12 @@ public class GameFileCache
{ {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET); Set<String> folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET);
if (folderPaths == null)
{
return;
}
Set<String> newFolderPaths = new HashSet<>(); Set<String> newFolderPaths = new HashSet<>();
for (String folderPath : folderPaths) for (String folderPath : folderPaths)
{ {
@ -78,7 +90,13 @@ public class GameFileCache
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> folderPathsSet = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET); Set<String> folderPathsSet = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET);
String[] folderPaths = folderPathsSet.toArray(new String[folderPathsSet.size()]);
if (folderPathsSet == null)
{
return false;
}
String[] folderPaths = folderPathsSet.toArray(new String[0]);
boolean cacheChanged = update(folderPaths, recursiveScan); boolean cacheChanged = update(folderPaths, recursiveScan);
cacheChanged |= updateAdditionalMetadata(); cacheChanged |= updateAdditionalMetadata();

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2013 Dolphin Emulator Project * Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -1075,14 +1075,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Decide inner scale based on joystick ID // Decide inner scale based on joystick ID
float innerScale; float innerScale;
switch (joystick) if (joystick == ButtonType.STICK_C)
{ {
case ButtonType.STICK_C: innerScale = 1.833f;
innerScale = 1.833f; }
break; else
default: {
innerScale = 1.375f; innerScale = 1.375f;
break;
} }
// Now set the bounds for the InputOverlayDrawableJoystick. // Now set the bounds for the InputOverlayDrawableJoystick.

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2013 Dolphin Emulator Project * Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -70,7 +70,7 @@ public final class InputOverlayDrawableButton
return mTrackId; return mTrackId;
} }
public boolean onConfigureTouch(MotionEvent event) public void onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int) event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
@ -89,9 +89,7 @@ public final class InputOverlayDrawableButton
mPreviousTouchX = fingerPositionX; mPreviousTouchX = fingerPositionX;
mPreviousTouchY = fingerPositionY; mPreviousTouchY = fingerPositionY;
break; break;
} }
return true;
} }
public void setPosition(int x, int y) public void setPosition(int x, int y)

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2016 Dolphin Emulator Project * Copyright 2016 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -148,7 +148,7 @@ public final class InputOverlayDrawableDpad
return mTrackId; return mTrackId;
} }
public boolean onConfigureTouch(MotionEvent event) public void onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int) event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
@ -167,9 +167,7 @@ public final class InputOverlayDrawableDpad
mPreviousTouchX = fingerPositionX; mPreviousTouchX = fingerPositionX;
mPreviousTouchY = fingerPositionY; mPreviousTouchY = fingerPositionY;
break; break;
} }
return true;
} }
public void setPosition(int x, int y) public void setPosition(int x, int y)

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2013 Dolphin Emulator Project * Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -165,7 +165,7 @@ public final class InputOverlayDrawableJoystick
return pressed; return pressed;
} }
public boolean onConfigureTouch(MotionEvent event) public void onConfigureTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
int fingerPositionX = (int) event.getX(pointerIndex); int fingerPositionX = (int) event.getX(pointerIndex);
@ -195,7 +195,6 @@ public final class InputOverlayDrawableJoystick
mPreviousTouchY = fingerPositionY; mPreviousTouchY = fingerPositionY;
break; break;
} }
return true;
} }

View File

@ -49,8 +49,8 @@ public class InputOverlayPointer
Integer x = outMetrics.widthPixels; Integer x = outMetrics.widthPixels;
// Adjusting for device's black bars. // Adjusting for device's black bars.
Float deviceAR = (float) x / y; float deviceAR = (float) x / y;
Float gameAR = NativeLibrary.GetGameAspectRatio(); float gameAR = NativeLibrary.GetGameAspectRatio();
aspectAdjusted = gameAR / deviceAR; aspectAdjusted = gameAR / deviceAR;
if (gameAR <= deviceAR) // Black bars on left/right if (gameAR <= deviceAR) // Black bars on left/right
@ -73,7 +73,7 @@ public class InputOverlayPointer
} }
} }
public boolean onTouch(MotionEvent event) public void onTouch(MotionEvent event)
{ {
int pointerIndex = event.getActionIndex(); int pointerIndex = event.getActionIndex();
@ -92,7 +92,7 @@ public class InputOverlayPointer
} }
if (trackId == -1) if (trackId == -1)
return false; return;
int x = (int) event.getX(event.findPointerIndex(trackId)); int x = (int) event.getX(event.findPointerIndex(trackId));
int y = (int) event.getY(event.findPointerIndex(trackId)); int y = (int) event.getY(event.findPointerIndex(trackId));
@ -106,7 +106,6 @@ public class InputOverlayPointer
axes[0] = ((y * aspectAdjusted) - maxHeight) / maxHeight; axes[0] = ((y * aspectAdjusted) - maxHeight) / maxHeight;
axes[1] = (x - maxWidth) / maxWidth; axes[1] = (x - maxWidth) / maxWidth;
} }
return false;
} }
private void touchPress() private void touchPress()

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2013 Dolphin Emulator Project * Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.

View File

@ -53,7 +53,7 @@ public class CustomTitleView extends LinearLayout implements TitleViewAdapter.Pr
{ {
super(context, attrs, defStyle); super(context, attrs, defStyle);
View root = LayoutInflater.from(context).inflate(R.layout.tv_title, this); View root = LayoutInflater.from(context).inflate(R.layout.tv_title, this);
mTitleView = (TextView) root.findViewById(R.id.title); mTitleView = root.findViewById(R.id.title);
mBadgeView = root.findViewById(R.id.badge); mBadgeView = root.findViewById(R.id.badge);
} }

View File

@ -109,6 +109,10 @@ public final class MainActivity extends AppCompatActivity implements MainView
protected void onStop() protected void onStop()
{ {
super.onStop(); super.onStop();
if (isChangingConfigurations())
{
skipRescanningLibrary();
}
StartupHandler.setSessionTime(this); StartupHandler.setSessionTime(this);
} }
@ -174,36 +178,34 @@ public final class MainActivity extends AppCompatActivity implements MainView
protected void onActivityResult(int requestCode, int resultCode, Intent result) protected void onActivityResult(int requestCode, int resultCode, Intent result)
{ {
super.onActivityResult(requestCode, resultCode, result); super.onActivityResult(requestCode, resultCode, result);
switch (requestCode)
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{ {
case MainPresenter.REQUEST_DIRECTORY: switch (requestCode)
// If the user picked a file, as opposed to just backing out. {
if (resultCode == MainActivity.RESULT_OK) case MainPresenter.REQUEST_DIRECTORY:
{
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result)); mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
} break;
break;
case MainPresenter.REQUEST_GAME_FILE: case MainPresenter.REQUEST_GAME_FILE:
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result)); EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
} break;
break;
case MainPresenter.REQUEST_WAD_FILE: case MainPresenter.REQUEST_WAD_FILE:
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result)); mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
} break;
break; }
}
else
{
skipRescanningLibrary();
} }
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults)
{ {
if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION) if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION)
{ {

View File

@ -43,8 +43,6 @@ public final class TvMainActivity extends FragmentActivity implements MainView
private BrowseSupportFragment mBrowseFragment; private BrowseSupportFragment mBrowseFragment;
private ArrayObjectAdapter mRowsAdapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {
@ -95,6 +93,10 @@ public final class TvMainActivity extends FragmentActivity implements MainView
protected void onStop() protected void onStop()
{ {
super.onStop(); super.onStop();
if (isChangingConfigurations())
{
skipRescanningLibrary();
}
StartupHandler.setSessionTime(this); StartupHandler.setSessionTime(this);
} }
@ -187,31 +189,28 @@ public final class TvMainActivity extends FragmentActivity implements MainView
protected void onActivityResult(int requestCode, int resultCode, Intent result) protected void onActivityResult(int requestCode, int resultCode, Intent result)
{ {
super.onActivityResult(requestCode, resultCode, result); super.onActivityResult(requestCode, resultCode, result);
switch (requestCode)
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{ {
case MainPresenter.REQUEST_DIRECTORY: switch (requestCode)
// If the user picked a file, as opposed to just backing out. {
if (resultCode == MainActivity.RESULT_OK) case MainPresenter.REQUEST_DIRECTORY:
{
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result)); mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
} break;
break;
case MainPresenter.REQUEST_GAME_FILE: case MainPresenter.REQUEST_GAME_FILE:
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result)); EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
} break;
break;
case MainPresenter.REQUEST_WAD_FILE: case MainPresenter.REQUEST_WAD_FILE:
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result)); mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
} break;
break; }
}
else
{
skipRescanningLibrary();
} }
} }
@ -219,29 +218,28 @@ public final class TvMainActivity extends FragmentActivity implements MainView
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) @NonNull int[] grantResults)
{ {
switch (requestCode) if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION)
{ {
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION: if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
{ DirectoryInitialization.start(this);
DirectoryInitialization.start(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(); }
} }
break; else
default: {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
break;
} }
} }
private void buildRowsAdapter() private void buildRowsAdapter()
{ {
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
if (PermissionsHandler.hasWriteAccess(this)) if (PermissionsHandler.hasWriteAccess(this))
{ {
@ -255,13 +253,13 @@ public final class TvMainActivity extends FragmentActivity implements MainView
// Add row to the adapter only if it is not empty. // Add row to the adapter only if it is not empty.
if (row != null) if (row != null)
{ {
mRowsAdapter.add(row); rowsAdapter.add(row);
} }
} }
mRowsAdapter.add(buildSettingsRow()); rowsAdapter.add(buildSettingsRow());
mBrowseFragment.setAdapter(mRowsAdapter); mBrowseFragment.setAdapter(rowsAdapter);
} }
private ListRow buildGamesRow(Platform platform, Collection<GameFile> gameFiles) private ListRow buildGamesRow(Platform platform, Collection<GameFile> gameFiles)

View File

@ -2,7 +2,7 @@ package org.dolphinemu.dolphinemu.ui.platform;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -50,7 +50,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) public void onViewCreated(@NonNull View view, Bundle savedInstanceState)
{ {
int columns = getResources().getInteger(R.integer.game_grid_columns); int columns = getResources().getInteger(R.integer.game_grid_columns);
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), columns); RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), columns);
@ -88,6 +88,6 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
private void findViews(View root) private void findViews(View root)
{ {
mRecyclerView = (RecyclerView) root.findViewById(R.id.grid_games); mRecyclerView = root.findViewById(R.id.grid_games);
} }
} }

View File

@ -80,7 +80,7 @@ public class AppLinkHelper
private static long extractLong(Uri uri, int index) private static long extractLong(Uri uri, int index)
{ {
return Long.valueOf(extract(uri, index)); return Long.parseLong(extract(uri, index));
} }
private static String extract(Uri uri, int index) private static String extract(Uri uri, int index)

View File

@ -6,8 +6,8 @@ import java.util.Map;
public class BiMap<K, V> public class BiMap<K, V>
{ {
private Map<K, V> forward = new HashMap<K, V>(); private Map<K, V> forward = new HashMap<>();
private Map<V, K> backward = new HashMap<V, K>(); private Map<V, K> backward = new HashMap<>();
public synchronized void add(K key, V value) public synchronized void add(K key, V value)
{ {
@ -24,4 +24,4 @@ public class BiMap<K, V>
{ {
return backward.get(key); return backward.get(key);
} }
} }

View File

@ -8,10 +8,9 @@ import java.io.FileOutputStream;
public final class CoverHelper public final class CoverHelper
{ {
private static String baseUrl = "https://art.gametdb.com/wii/cover/%s/%s.png";
public static String buildGameTDBUrl(GameFile game, String region) public static String buildGameTDBUrl(GameFile game, String region)
{ {
String baseUrl = "https://art.gametdb.com/wii/cover/%s/%s.png";
return String.format(baseUrl, region, game.getGameTdbId()); return String.format(baseUrl, region, game.getGameTdbId());
} }

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2014 Dolphin Emulator Project * Copyright 2014 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -267,12 +267,23 @@ public final class DirectoryInitialization
try try
{ {
String[] assetList = context.getAssets().list(assetFolder);
if (assetList == null)
{
return;
}
boolean createdFolder = false; boolean createdFolder = false;
for (String file : context.getAssets().list(assetFolder)) for (String file : assetList)
{ {
if (!createdFolder) if (!createdFolder)
{ {
outputFolder.mkdir(); if (!outputFolder.mkdir())
{
Log.error("[DirectoryInitialization] Failed to create folder " +
outputFolder.getAbsolutePath());
}
createdFolder = true; createdFolder = true;
} }
copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file), copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file),
@ -317,7 +328,10 @@ public final class DirectoryInitialization
File wiiPath = new File(directory); File wiiPath = new File(directory);
if (!wiiPath.isDirectory()) if (!wiiPath.isDirectory())
{ {
wiiPath.mkdirs(); if (!wiiPath.mkdirs())
{
Log.error("[DirectoryInitialization] Failed to create folder " + wiiPath.getAbsolutePath());
}
} }
} }

View File

@ -1,4 +1,4 @@
/** /*
* Copyright 2013 Dolphin Emulator Project * Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+ * Licensed under GPLv2+
* Refer to the license.txt file included. * Refer to the license.txt file included.
@ -223,14 +223,14 @@ public final class EGLHelper
} }
// Detects the specific kind of GL modes that are supported // Detects the specific kind of GL modes that are supported
private boolean detect() private void detect()
{ {
// Get total number of configs available. // Get total number of configs available.
int[] numConfigs = new int[1]; int[] numConfigs = new int[1];
if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs)) if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs))
{ {
Log.error("[EGLHelper] Error retrieving number of EGL configs available."); Log.error("[EGLHelper] Error retrieving number of EGL configs available.");
return false; return;
} }
// Now get all the configurations // Now get all the configurations
@ -238,7 +238,7 @@ public final class EGLHelper
if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs)) if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs))
{ {
Log.error("[EGLHelper] Error retrieving all EGL configs."); Log.error("[EGLHelper] Error retrieving all EGL configs.");
return false; return;
} }
for (EGLConfig mEGLConfig : mEGLConfigs) for (EGLConfig mEGLConfig : mEGLConfigs)
@ -258,8 +258,6 @@ public final class EGLHelper
supportGLES3 = true; supportGLES3 = true;
} }
} }
return true;
} }
// Creates the context and surface. // Creates the context and surface.

View File

@ -77,7 +77,7 @@ public final class StartupHandler
if (currentTime > (lastOpen + SESSION_TIMEOUT)) if (currentTime > (lastOpen + SESSION_TIMEOUT))
{ {
new AfterDirectoryInitializationRunner().run(context, new AfterDirectoryInitializationRunner().run(context,
() -> NativeLibrary.ReportStartToAnalytics()); NativeLibrary::ReportStartToAnalytics);
} }
} }
} }

View File

@ -123,11 +123,10 @@ public class TvUtil
throws Resources.NotFoundException throws Resources.NotFoundException
{ {
Resources res = context.getResources(); Resources res = context.getResources();
Uri resUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + res.getResourcePackageName(resId) "://" + res.getResourcePackageName(resId)
+ '/' + res.getResourceTypeName(resId) + '/' + res.getResourceTypeName(resId)
+ '/' + res.getResourceEntryName(resId)); + '/' + res.getResourceEntryName(resId));
return resUri;
} }
/** /**
@ -255,9 +254,7 @@ public class TvUtil
*/ */
public static List<HomeScreenChannel> createUniversalSubscriptions() public static List<HomeScreenChannel> createUniversalSubscriptions()
{ {
//Leaving the subs local variable in case more channels are created other than platforms. return new ArrayList<>(createPlatformSubscriptions());
List<HomeScreenChannel> subs = new ArrayList<>(createPlatformSubscriptions());
return subs;
} }
private static List<HomeScreenChannel> createPlatformSubscriptions() private static List<HomeScreenChannel> createPlatformSubscriptions()

View File

@ -391,6 +391,7 @@
<string name="pitch">Total Pitch</string> <string name="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string> <string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string> <string name="vertical_offset">Vertical Offset</string>
<string name="slider_setting_value">%1$d%2$s</string>
<string name="disc_number">Disc %1$d</string> <string name="disc_number">Disc %1$d</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string> <string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>