From 7db88e831eb1394dd3215ea2a4e518d596b90c96 Mon Sep 17 00:00:00 2001 From: Mike Harris Date: Mon, 25 Sep 2017 23:13:37 -0700 Subject: [PATCH] Remove prefix of tag, args and keys with packagename. Prefixing everything with a constant packagename is not needed for internal keys, and just adds complexity. Rename ARGUMENT_ prefix to ARG_ to match (most) of the rest of the codebase. Restrict visiblity of above as much as possible. --- .../activities/AddDirectoryActivity.java | 3 +- .../dolphinemu/dialogs/GameDetailsDialog.java | 41 +++++++++---------- .../fragments/EmulationFragment.java | 9 ++-- .../fragments/LoadStateFragment.java | 3 +- .../fragments/SaveStateFragment.java | 3 +- .../ui/platform/PlatformGamesFragment.java | 3 +- .../ui/settings/SettingsActivity.java | 13 +++--- .../settings/SettingsActivityPresenter.java | 9 ++-- .../ui/settings/SettingsFragment.java | 7 +--- 9 files changed, 39 insertions(+), 52 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java index 7751844bbb..45e1f87ca9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java @@ -15,7 +15,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.adapters.FileAdapter; import org.dolphinemu.dolphinemu.model.GameDatabase; @@ -28,7 +27,7 @@ import org.dolphinemu.dolphinemu.ui.main.MainPresenter; */ public class AddDirectoryActivity extends AppCompatActivity implements FileAdapter.FileClickListener { - public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path"; + private static final String KEY_CURRENT_PATH = "path"; private FileAdapter mAdapter; private Toolbar mToolbar; 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 5b351478d2..f67ac0c442 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 @@ -12,7 +12,6 @@ import android.widget.TextView; import com.squareup.picasso.Picasso; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; @@ -20,12 +19,12 @@ import de.hdodenhof.circleimageview.CircleImageView; public final class GameDetailsDialog extends DialogFragment { - public static final String ARGUMENT_GAME_TITLE = BuildConfig.APPLICATION_ID + ".game_title"; - public static final String ARGUMENT_GAME_DESCRIPTION = BuildConfig.APPLICATION_ID + ".game_description"; - public static final String ARGUMENT_GAME_COUNTRY = BuildConfig.APPLICATION_ID + ".game_country"; - public static final String ARGUMENT_GAME_DATE = BuildConfig.APPLICATION_ID + ".game_date"; - public static final String ARGUMENT_GAME_PATH = BuildConfig.APPLICATION_ID + ".game_path"; - public static final String ARGUMENT_GAME_SCREENSHOT_PATH = BuildConfig.APPLICATION_ID + ".game_screenshot_path"; + private static final String ARG_GAME_TITLE = "game_title"; + private static final String ARG_GAME_DESCRIPTION = "game_description"; + private static final String ARG_GAME_COUNTRY = "game_country"; + private static final String ARG_GAME_DATE = "game_date"; + private static final String ARG_GAME_PATH = "game_path"; + private static final String ARG_GAME_SCREENSHOT_PATH = "game_screenshot_path"; // TODO Add all of this to the Loader in GameActivity.java public static GameDetailsDialog newInstance(String title, String description, int country, String company, String path, String screenshotPath) @@ -33,12 +32,12 @@ public final class GameDetailsDialog extends DialogFragment GameDetailsDialog fragment = new GameDetailsDialog(); Bundle arguments = new Bundle(); - arguments.putString(ARGUMENT_GAME_TITLE, title); - arguments.putString(ARGUMENT_GAME_DESCRIPTION, description); - arguments.putInt(ARGUMENT_GAME_COUNTRY, country); - arguments.putString(ARGUMENT_GAME_DATE, company); - arguments.putString(ARGUMENT_GAME_PATH, path); - arguments.putString(ARGUMENT_GAME_SCREENSHOT_PATH, screenshotPath); + arguments.putString(ARG_GAME_TITLE, title); + arguments.putString(ARG_GAME_DESCRIPTION, description); + arguments.putInt(ARG_GAME_COUNTRY, country); + arguments.putString(ARG_GAME_DATE, company); + arguments.putString(ARG_GAME_PATH, path); + arguments.putString(ARG_GAME_SCREENSHOT_PATH, screenshotPath); fragment.setArguments(arguments); return fragment; @@ -61,13 +60,13 @@ public final class GameDetailsDialog extends DialogFragment FloatingActionButton buttonLaunch = (FloatingActionButton) contents.findViewById(R.id.button_launch); - int countryIndex = getArguments().getInt(ARGUMENT_GAME_COUNTRY); + int countryIndex = getArguments().getInt(ARG_GAME_COUNTRY); String country = getResources().getStringArray(R.array.countryNames)[countryIndex]; - textTitle.setText(getArguments().getString(ARGUMENT_GAME_TITLE)); - textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION)); + textTitle.setText(getArguments().getString(ARG_GAME_TITLE)); + textDescription.setText(getArguments().getString(ARG_GAME_DESCRIPTION)); textCountry.setText(country); - textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE)); + textDate.setText(getArguments().getString(ARG_GAME_DATE)); buttonLaunch.setOnClickListener(new View.OnClickListener() { @@ -76,9 +75,9 @@ public final class GameDetailsDialog extends DialogFragment { // Start the emulation activity and send the path of the clicked ROM to it. EmulationActivity.launch(getActivity(), - getArguments().getString(ARGUMENT_GAME_PATH), - getArguments().getString(ARGUMENT_GAME_TITLE), - getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH), + getArguments().getString(ARG_GAME_PATH), + getArguments().getString(ARG_GAME_TITLE), + getArguments().getString(ARG_GAME_SCREENSHOT_PATH), -1, imageGameScreen); } @@ -86,7 +85,7 @@ public final class GameDetailsDialog extends DialogFragment // Fill in the view contents. Picasso.with(imageGameScreen.getContext()) - .load(getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH)) + .load(getArguments().getString(ARG_GAME_SCREENSHOT_PATH)) .fit() .centerCrop() .noFade() 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 5bf1a7d677..94d411a78d 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 @@ -12,7 +12,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.overlay.InputOverlay; @@ -20,9 +19,9 @@ import org.dolphinemu.dolphinemu.utils.Log; public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback { - public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".emulation_fragment"; + public static final String FRAGMENT_TAG = "emulation_fragment"; - private static final String ARGUMENT_GAME_PATH = BuildConfig.APPLICATION_ID + ".game_path"; + private static final String ARG_GAME_PATH = "game_path"; private SharedPreferences mPreferences; @@ -40,7 +39,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C EmulationFragment fragment = new EmulationFragment(); Bundle arguments = new Bundle(); - arguments.putString(ARGUMENT_GAME_PATH, path); + arguments.putString(ARG_GAME_PATH, path); fragment.setArguments(arguments); return fragment; @@ -238,7 +237,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C Log.info("[EmulationFragment] Starting emulation: " + mSurface); // Start emulation using the provided Surface. - String path = getArguments().getString(ARGUMENT_GAME_PATH); + String path = getArguments().getString(ARG_GAME_PATH); NativeLibrary.Run(path); } }; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java index 894a4f76d3..41b24f929a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java @@ -10,13 +10,12 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.GridLayout; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; public final class LoadStateFragment extends Fragment implements View.OnClickListener { - public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".load_state"; + public static final String FRAGMENT_TAG = "load_state"; private static SparseIntArray buttonsActionsMap = new SparseIntArray(); static { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java index 1d04b03a59..b0ae7d9818 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java @@ -10,13 +10,12 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.GridLayout; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; public final class SaveStateFragment extends Fragment implements View.OnClickListener { - public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".save_state"; + public static final String FRAGMENT_TAG = "save_state"; private static SparseIntArray buttonsActionsMap = new SparseIntArray(); static { 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 563d110675..ec6d55db5f 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 @@ -10,13 +10,12 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.adapters.GameAdapter; public final class PlatformGamesFragment extends Fragment implements PlatformGamesView { - private static final String ARG_PLATFORM = BuildConfig.APPLICATION_ID + ".PLATFORM"; + private static final String ARG_PLATFORM = "platform"; private PlatformGamesPresenter mPresenter = new PlatformGamesPresenter(this); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivity.java index 5f320e86df..c5b12165ff 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivity.java @@ -10,7 +10,6 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.widget.Toast; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.settings.SettingSection; @@ -19,6 +18,8 @@ import java.util.HashMap; public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView { + private static final String ARG_FILE_NAME = "file_name"; + private static final String FRAGMENT_TAG = "settings"; private SettingsActivityPresenter mPresenter = new SettingsActivityPresenter(this); @Override @@ -29,7 +30,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting setContentView(R.layout.activity_settings); Intent launcher = getIntent(); - String filename = launcher.getStringExtra(ARGUMENT_FILE_NAME); + String filename = launcher.getStringExtra(ARG_FILE_NAME); mPresenter.onCreate(savedInstanceState, filename); } @@ -93,7 +94,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting transaction.addToBackStack(null); mPresenter.addToStack(); } - transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), SettingsFragment.FRAGMENT_TAG); + transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), FRAGMENT_TAG); transaction.commit(); } @@ -170,16 +171,14 @@ public final class SettingsActivity extends AppCompatActivity implements Setting private SettingsFragment getFragment() { - return (SettingsFragment) getFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG); + return (SettingsFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG); } - public static final String ARGUMENT_FILE_NAME = BuildConfig.APPLICATION_ID + ".file_name"; - public static void launch(Context context, String menuTag) { Intent settings = new Intent(context, SettingsActivity.class); - settings.putExtra(ARGUMENT_FILE_NAME, menuTag); + settings.putExtra(ARG_FILE_NAME, menuTag); context.startActivity(settings); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityPresenter.java index f78e37098b..9e68c00d20 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityPresenter.java @@ -2,9 +2,6 @@ package org.dolphinemu.dolphinemu.ui.settings; import android.os.Bundle; -import org.dolphinemu.dolphinemu.BuildConfig; -import org.dolphinemu.dolphinemu.DolphinApplication; -import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.settings.SettingSection; import org.dolphinemu.dolphinemu.utils.Log; @@ -15,7 +12,7 @@ import java.util.HashMap; public final class SettingsActivityPresenter { - private static final String SHOULD_SAVE = BuildConfig.APPLICATION_ID + ".should_save"; + private static final String KEY_SHOULD_SAVE = "should_save"; private SettingsActivityView mView; @@ -43,7 +40,7 @@ public final class SettingsActivityPresenter } else { - mShouldSave = savedInstanceState.getBoolean(SHOULD_SAVE); + mShouldSave = savedInstanceState.getBoolean(KEY_SHOULD_SAVE); } } @@ -106,7 +103,7 @@ public final class SettingsActivityPresenter public void saveState(Bundle outState) { - outState.putBoolean(SHOULD_SAVE, mShouldSave); + outState.putBoolean(KEY_SHOULD_SAVE, mShouldSave); } public void onGcPadSettingChanged(String key, int value) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragment.java index d8c3d7cc81..19433dc2a5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragment.java @@ -11,7 +11,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.settings.Setting; import org.dolphinemu.dolphinemu.model.settings.SettingSection; @@ -24,6 +23,8 @@ import java.util.HashMap; public final class SettingsFragment extends Fragment implements SettingsFragmentView { + private static final String ARGUMENT_MENU_TAG = "menu_tag"; + private SettingsFragmentPresenter mPresenter = new SettingsFragmentPresenter(this); private SettingsActivityView mActivity; @@ -174,10 +175,6 @@ public final class SettingsFragment extends Fragment implements SettingsFragment mActivity.onExtensionSettingChanged(key, value); } - public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".fragment.settings"; - - public static final String ARGUMENT_MENU_TAG = FRAGMENT_TAG + ".menu_tag"; - public static Fragment newInstance(String menuTag) { SettingsFragment fragment = new SettingsFragment();