From 85ddb8fc867e697e07f111d5e38faa98536ac807 Mon Sep 17 00:00:00 2001 From: Ryan Meredith Date: Mon, 31 Aug 2020 11:23:59 -0400 Subject: [PATCH] Android: Minor cleanup 2 --- .../activities/AppLinkActivity.java | 24 ++++++++--------- .../activities/EmulationActivity.java | 14 +++++----- .../adapters/PlatformPagerAdapter.java | 4 ++- .../dolphinemu/dialogs/GameDetailsDialog.java | 2 +- .../features/settings/ui/MenuTag.java | 3 +++ .../features/settings/ui/SettingsAdapter.java | 26 +++++-------------- .../settings/ui/SettingsFragment.java | 5 ++-- .../ui/SettingsFragmentPresenter.java | 6 +---- .../settings/ui/SettingsFrameLayout.java | 4 +-- .../viewholder/CheckBoxSettingViewHolder.java | 6 ++--- .../viewholder/ConfirmRunnableViewHolder.java | 8 +++--- .../ui/viewholder/FilePickerViewHolder.java | 4 +-- .../ui/viewholder/HeaderViewHolder.java | 4 +-- .../viewholder/RumbleBindingViewHolder.java | 4 +-- .../ui/viewholder/SingleChoiceViewHolder.java | 4 +-- .../ui/viewholder/SliderViewHolder.java | 15 ++++++++--- .../ui/viewholder/SubmenuViewHolder.java | 2 +- .../fragments/EmulationFragment.java | 12 ++++++--- .../dolphinemu/fragments/MenuFragment.java | 4 +-- .../fragments/SaveLoadStateFragment.java | 3 +-- .../dolphinemu/dolphinemu/model/GameFile.java | 1 - .../dolphinemu/model/GameFileCache.java | 20 +++++++++++++- .../overlay/InputOverlayPointer.java | 9 +++---- .../dolphinemu/ui/main/CustomTitleView.java | 2 +- .../ui/platform/PlatformGamesFragment.java | 6 ++--- .../dolphinemu/dolphinemu/utils/BiMap.java | 6 ++--- .../dolphinemu/utils/CoverHelper.java | 3 +-- .../dolphinemu/utils/StartupHandler.java | 2 +- .../dolphinemu/dolphinemu/utils/TvUtil.java | 7 ++--- .../app/src/main/res/values/strings.xml | 1 + 30 files changed, 107 insertions(+), 104 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java index 976658c9cc..582296c89b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java @@ -30,7 +30,6 @@ public class AppLinkActivity extends FragmentActivity private AppLinkHelper.PlayAction playAction; private DirectoryStateReceiver directoryStateReceiver; - private BroadcastReceiver gameFileCacheReceiver; @Override protected void onCreate(Bundle savedInstanceState) @@ -96,18 +95,17 @@ public class AppLinkActivity extends FragmentActivity } }); - gameFileCacheReceiver = - new BroadcastReceiver() - { - @Override - public void onReceive(Context context, Intent intent) - { - if (DirectoryInitialization.areDolphinDirectoriesReady()) - { - tryPlay(playAction); - } - } - }; + BroadcastReceiver gameFileCacheReceiver = new BroadcastReceiver() + { + @Override + public void onReceive(Context context, Intent intent) + { + if (DirectoryInitialization.areDolphinDirectoriesReady()) + { + tryPlay(playAction); + } + } + }; LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); broadcastManager.registerReceiver(directoryStateReceiver, directoryStateIntentFilter); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 5a0536665f..1faa1bff43 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -1043,8 +1043,8 @@ public final class EmulationActivity extends AppCompatActivity LayoutInflater inflater = LayoutInflater.from(this); View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null); - TextView text_slider_value_pitch = (TextView) view.findViewById(R.id.text_ir_pitch); - TextView units = (TextView) view.findViewById(R.id.text_ir_pitch_units); + TextView text_slider_value_pitch = view.findViewById(R.id.text_ir_pitch); + TextView units = view.findViewById(R.id.text_ir_pitch_units); SeekBar seekbar_pitch = view.findViewById(R.id.seekbar_pitch); text_slider_value_pitch.setText(String.valueOf(ir_pitch)); @@ -1073,8 +1073,8 @@ public final class EmulationActivity extends AppCompatActivity int ir_yaw = Integer.parseInt( mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15")); - TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw); - TextView units_yaw = (TextView) view.findViewById(R.id.text_ir_yaw_units); + TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw); + TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units); SeekBar seekbar_yaw = view.findViewById(R.id.seekbar_width); text_slider_value_yaw.setText(String.valueOf(ir_yaw)); @@ -1105,10 +1105,8 @@ public final class EmulationActivity extends AppCompatActivity mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId, "10")); - TextView text_slider_value_vertical_offset = - (TextView) view.findViewById(R.id.text_ir_vertical_offset); - TextView units_vertical_offset = - (TextView) view.findViewById(R.id.text_ir_vertical_offset_units); + TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset); + TextView units_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset_units); SeekBar seekbar_vertical_offset = view.findViewById(R.id.seekbar_vertical_offset); text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset)); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java index e1141bf8be..1b04098dc4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/PlatformPagerAdapter.java @@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.adapters; import android.content.Context; import android.graphics.drawable.Drawable; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -28,10 +29,11 @@ public class PlatformPagerAdapter extends FragmentPagerAdapter public PlatformPagerAdapter(FragmentManager fm, Context context) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); mContext = context; } + @NonNull @Override public Fragment getItem(int position) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index a0597390e5..17d04a6138 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -73,7 +73,7 @@ public final class GameDetailsDialog extends DialogFragment textCountry.setText(country); textCompany.setText(gameFile.getCompany()); textGameId.setText(gameFile.getGameId()); - textRevision.setText(Integer.toString(gameFile.getRevision())); + textRevision.setText(String.valueOf(gameFile.getRevision())); if (!gameFile.shouldShowFileFormatDetails()) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java index aa6f9a48f4..8422f2903b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java @@ -1,5 +1,7 @@ package org.dolphinemu.dolphinemu.features.settings.ui; +import androidx.annotation.NonNull; + public enum MenuTag { CONFIG("config"), @@ -46,6 +48,7 @@ public enum MenuTag this.subType = subtype; } + @NonNull @Override public String toString() { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java index 1f2a7ab9dd..701cb7219a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java @@ -2,8 +2,6 @@ package org.dolphinemu.dolphinemu.features.settings.ui; import android.content.Context; import android.content.DialogInterface; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import androidx.appcompat.app.AlertDialog; 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.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; -import org.dolphinemu.dolphinemu.utils.Log; import java.security.InvalidParameterException; import java.util.ArrayList; @@ -97,7 +94,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter - { - SharedPreferences preferences = - PreferenceManager.getDefaultSharedPreferences(mContext); - item.clearValue(); - }); + (dialogInterface, i) -> item.clearValue()); dialog.setOnDismissListener(dialog1 -> { StringSetting setting = new StringSetting(item.getKey(), item.getSection(), item.getValue()); notifyItemChanged(position); - if (setting != null) - { - mView.putSetting(setting); - } + mView.putSetting(setting); mView.onSettingChanged(item.getKey()); }); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java index 28fae8ac3d..16510aa929 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java @@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.features.settings.ui; import android.content.Context; import android.os.Bundle; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; @@ -84,7 +85,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment } @Override - public void onAttach(Context context) + public void onAttach(@NonNull Context context) { super.onAttach(context); @@ -115,7 +116,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { Bundle args = getArguments(); MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index e10da3b396..8c6d656fba 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -59,8 +59,8 @@ public final class SettingsFragmentPresenter public void onCreate(MenuTag menuTag, String gameId, Bundle extras) { mGameID = gameId; - this.mMenuTag = menuTag; + if (menuTag.isGCPadMenu() || menuTag.isWiimoteExtensionMenu()) { mControllerNumber = menuTag.getSubType(); @@ -70,10 +70,6 @@ public final class SettingsFragmentPresenter { mControllerNumber = menuTag.getSubType(); } - else - { - mMenuTag = menuTag; - } } public void onViewCreated(MenuTag menuTag, Settings settings) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFrameLayout.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFrameLayout.java index a3da929734..eb917a9d05 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFrameLayout.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFrameLayout.java @@ -9,8 +9,6 @@ import android.widget.FrameLayout; */ public final class SettingsFrameLayout extends FrameLayout { - private float mVisibleness = 1.0f; - public SettingsFrameLayout(Context context) { super(context); @@ -44,7 +42,7 @@ public final class SettingsFrameLayout extends FrameLayout public float getVisibleness() { - return mVisibleness; + return 1.0f; } public void setVisibleness(float visibleness) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java index 1e5ed6cf15..0e0414bdaa 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java @@ -28,9 +28,9 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); - mCheckbox = (CheckBox) root.findViewById(R.id.checkbox); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); + mCheckbox = root.findViewById(R.id.checkbox); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/ConfirmRunnableViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/ConfirmRunnableViewHolder.java index 2f1cc9a9af..07b700ec8e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/ConfirmRunnableViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/ConfirmRunnableViewHolder.java @@ -35,8 +35,8 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); } @Override @@ -78,9 +78,7 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder mView.getActivity().finish(); }) .setNegativeButton("No", (dialog, whichButton) -> - { - dialog.dismiss(); - }); + dialog.dismiss()); builder.show(); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java index d4e112d43e..681828dc94 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java @@ -26,8 +26,8 @@ public final class FilePickerViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java index d9966f31b8..6ece671bf4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java @@ -20,7 +20,7 @@ public final class HeaderViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mHeaderName = (TextView) root.findViewById(R.id.text_header_name); + mHeaderName = root.findViewById(R.id.text_header_name); } @Override @@ -34,4 +34,4 @@ public final class HeaderViewHolder extends SettingViewHolder { // no-op } -} \ No newline at end of file +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java index dd86a52bc0..a5b8d9c944 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java @@ -30,8 +30,8 @@ public class RumbleBindingViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java index 78db2c09ff..ed75d8928c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java @@ -26,8 +26,8 @@ public final class SingleChoiceViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java index b40311dcea..4e2967374a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java @@ -1,5 +1,6 @@ package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; +import android.content.Context; import android.view.View; import android.widget.TextView; @@ -10,21 +11,25 @@ import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; public final class SliderViewHolder extends SettingViewHolder { + private Context mContext; + private SliderSetting mItem; private TextView mTextSettingName; private TextView mTextSettingDescription; - public SliderViewHolder(View itemView, SettingsAdapter adapter) + public SliderViewHolder(View itemView, SettingsAdapter adapter, Context context) { super(itemView, adapter); + + mContext = context; } @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); - mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); + mTextSettingName = root.findViewById(R.id.text_setting_name); + mTextSettingDescription = root.findViewById(R.id.text_setting_description); } @Override @@ -40,7 +45,9 @@ public final class SliderViewHolder extends SettingViewHolder } else { - mTextSettingDescription.setText(mItem.getSelectedValue() + mItem.getUnits()); + mTextSettingDescription.setText(mContext + .getString(R.string.slider_setting_value, mItem.getSelectedValue(), + mItem.getUnits())); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java index 746e2e6900..0560f3818f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java @@ -22,7 +22,7 @@ public final class SubmenuViewHolder extends SettingViewHolder @Override protected void findViews(View root) { - mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); + mTextSettingName = root.findViewById(R.id.text_setting_name); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index 7382826f6d..174a7e0bc6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -6,6 +6,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -54,7 +55,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C } @Override - public void onAttach(Context context) + public void onAttach(@NonNull Context context) { super.onAttach(context); @@ -213,7 +214,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C } @Override - public void surfaceCreated(SurfaceHolder holder) + public void surfaceCreated(@NonNull SurfaceHolder holder) { // We purposely don't do anything here. // 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 - public void surfaceDestroyed(SurfaceHolder holder) + public void surfaceDestroyed(@NonNull SurfaceHolder holder) { mEmulationState.clearSurface(); } @@ -447,7 +448,10 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C try { File file = new File(path); - file.delete(); + if (!file.delete()) + { + Log.error("[EmulationFragment] Failed to delete " + file.getAbsolutePath()); + } } catch (Exception ignored) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java index d9ec3ba2d7..bef1d7f7a8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java @@ -2,7 +2,6 @@ package org.dolphinemu.dolphinemu.fragments; import android.os.Bundle; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import android.util.SparseIntArray; @@ -58,13 +57,12 @@ public final class MenuFragment extends Fragment implements View.OnClickListener return fragment; } - @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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); mUnpauseEmulation = options.findViewById(R.id.menu_unpause_emulation); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveLoadStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveLoadStateFragment.java index 026b95d1e1..5a275a0c4f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveLoadStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveLoadStateFragment.java @@ -80,13 +80,12 @@ public final class SaveLoadStateFragment extends Fragment implements View.OnClic mSaveOrLoad = (SaveOrLoad) getArguments().getSerializable(KEY_SAVEORLOAD); } - @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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++) { Button button = (Button) grid.getChildAt(childIndex); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java index 70ae2371b2..dd1dd2898e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java @@ -1,7 +1,6 @@ package org.dolphinemu.dolphinemu.model; import android.content.Context; -import android.os.Environment; public class GameFile { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java index ec574ffaa4..4e38297efa 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java @@ -33,6 +33,12 @@ public class GameFileCache { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Set folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET); + + if (folderPaths == null) + { + return; + } + Set newFolderPaths = new HashSet<>(folderPaths); newFolderPaths.add(path); SharedPreferences.Editor editor = preferences.edit(); @@ -44,6 +50,12 @@ public class GameFileCache { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Set folderPaths = preferences.getStringSet(GAME_FOLDER_PATHS_PREFERENCE, EMPTY_SET); + + if (folderPaths == null) + { + return; + } + Set newFolderPaths = new HashSet<>(); for (String folderPath : folderPaths) { @@ -78,7 +90,13 @@ public class GameFileCache SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Set 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); cacheChanged |= updateAdditionalMetadata(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayPointer.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayPointer.java index 18ce190f15..c56853cf88 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayPointer.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayPointer.java @@ -49,8 +49,8 @@ public class InputOverlayPointer Integer x = outMetrics.widthPixels; // Adjusting for device's black bars. - Float deviceAR = (float) x / y; - Float gameAR = NativeLibrary.GetGameAspectRatio(); + float deviceAR = (float) x / y; + float gameAR = NativeLibrary.GetGameAspectRatio(); aspectAdjusted = gameAR / deviceAR; 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(); @@ -92,7 +92,7 @@ public class InputOverlayPointer } if (trackId == -1) - return false; + return; int x = (int) event.getX(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[1] = (x - maxWidth) / maxWidth; } - return false; } private void touchPress() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java index aefc4c3ad3..68ee3ccd8e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java @@ -53,7 +53,7 @@ public class CustomTitleView extends LinearLayout implements TitleViewAdapter.Pr { super(context, attrs, defStyle); 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); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java index 5ae9456677..b833bef823 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java @@ -2,7 +2,7 @@ package org.dolphinemu.dolphinemu.ui.platform; import android.os.Bundle; -import androidx.annotation.Nullable; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -50,7 +50,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam } @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); RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), columns); @@ -88,6 +88,6 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam private void findViews(View root) { - mRecyclerView = (RecyclerView) root.findViewById(R.id.grid_games); + mRecyclerView = root.findViewById(R.id.grid_games); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/BiMap.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/BiMap.java index 7394d67c90..5397cbf567 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/BiMap.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/BiMap.java @@ -6,8 +6,8 @@ import java.util.Map; public class BiMap { - private Map forward = new HashMap(); - private Map backward = new HashMap(); + private Map forward = new HashMap<>(); + private Map backward = new HashMap<>(); public synchronized void add(K key, V value) { @@ -24,4 +24,4 @@ public class BiMap { return backward.get(key); } -} \ No newline at end of file +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoverHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoverHelper.java index 08b232f4d9..35da6f3281 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoverHelper.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoverHelper.java @@ -8,10 +8,9 @@ import java.io.FileOutputStream; 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) { + String baseUrl = "https://art.gametdb.com/wii/cover/%s/%s.png"; return String.format(baseUrl, region, game.getGameTdbId()); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java index 68f3ff3a49..e09a200985 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java @@ -77,7 +77,7 @@ public final class StartupHandler if (currentTime > (lastOpen + SESSION_TIMEOUT)) { new AfterDirectoryInitializationRunner().run(context, - () -> NativeLibrary.ReportStartToAnalytics()); + NativeLibrary::ReportStartToAnalytics); } } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/TvUtil.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/TvUtil.java index c789293748..90e6006168 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/TvUtil.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/TvUtil.java @@ -123,11 +123,10 @@ public class TvUtil throws Resources.NotFoundException { Resources res = context.getResources(); - Uri resUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + + return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + res.getResourcePackageName(resId) + '/' + res.getResourceTypeName(resId) + '/' + res.getResourceEntryName(resId)); - return resUri; } /** @@ -255,9 +254,7 @@ public class TvUtil */ public static List createUniversalSubscriptions() { - //Leaving the subs local variable in case more channels are created other than platforms. - List subs = new ArrayList<>(createPlatformSubscriptions()); - return subs; + return new ArrayList<>(createPlatformSubscriptions()); } private static List createPlatformSubscriptions() diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index e72828590a..63bdc58fe8 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -395,6 +395,7 @@ Total Pitch Total Yaw Vertical Offset + %1$d%2$s Disc %1$d GameCube Controller 1 is set to \"None\"