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.
This commit is contained in:
Mike Harris 2017-09-25 23:13:37 -07:00
parent ab90a3029d
commit 7db88e831e
9 changed files with 39 additions and 52 deletions

View File

@ -15,7 +15,6 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.FileAdapter; import org.dolphinemu.dolphinemu.adapters.FileAdapter;
import org.dolphinemu.dolphinemu.model.GameDatabase; 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 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 FileAdapter mAdapter;
private Toolbar mToolbar; private Toolbar mToolbar;

View File

@ -12,7 +12,6 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
@ -20,12 +19,12 @@ import de.hdodenhof.circleimageview.CircleImageView;
public final class GameDetailsDialog extends DialogFragment public final class GameDetailsDialog extends DialogFragment
{ {
public static final String ARGUMENT_GAME_TITLE = BuildConfig.APPLICATION_ID + ".game_title"; private static final String ARG_GAME_TITLE = "game_title";
public static final String ARGUMENT_GAME_DESCRIPTION = BuildConfig.APPLICATION_ID + ".game_description"; private static final String ARG_GAME_DESCRIPTION = "game_description";
public static final String ARGUMENT_GAME_COUNTRY = BuildConfig.APPLICATION_ID + ".game_country"; private static final String ARG_GAME_COUNTRY = "game_country";
public static final String ARGUMENT_GAME_DATE = BuildConfig.APPLICATION_ID + ".game_date"; private static final String ARG_GAME_DATE = "game_date";
public static final String ARGUMENT_GAME_PATH = BuildConfig.APPLICATION_ID + ".game_path"; private static final String ARG_GAME_PATH = "game_path";
public static final String ARGUMENT_GAME_SCREENSHOT_PATH = BuildConfig.APPLICATION_ID + ".game_screenshot_path"; private static final String ARG_GAME_SCREENSHOT_PATH = "game_screenshot_path";
// TODO Add all of this to the Loader in GameActivity.java // 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) 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(); GameDetailsDialog fragment = new GameDetailsDialog();
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putString(ARGUMENT_GAME_TITLE, title); arguments.putString(ARG_GAME_TITLE, title);
arguments.putString(ARGUMENT_GAME_DESCRIPTION, description); arguments.putString(ARG_GAME_DESCRIPTION, description);
arguments.putInt(ARGUMENT_GAME_COUNTRY, country); arguments.putInt(ARG_GAME_COUNTRY, country);
arguments.putString(ARGUMENT_GAME_DATE, company); arguments.putString(ARG_GAME_DATE, company);
arguments.putString(ARGUMENT_GAME_PATH, path); arguments.putString(ARG_GAME_PATH, path);
arguments.putString(ARGUMENT_GAME_SCREENSHOT_PATH, screenshotPath); arguments.putString(ARG_GAME_SCREENSHOT_PATH, screenshotPath);
fragment.setArguments(arguments); fragment.setArguments(arguments);
return fragment; return fragment;
@ -61,13 +60,13 @@ public final class GameDetailsDialog extends DialogFragment
FloatingActionButton buttonLaunch = (FloatingActionButton) contents.findViewById(R.id.button_launch); 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]; String country = getResources().getStringArray(R.array.countryNames)[countryIndex];
textTitle.setText(getArguments().getString(ARGUMENT_GAME_TITLE)); textTitle.setText(getArguments().getString(ARG_GAME_TITLE));
textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION)); textDescription.setText(getArguments().getString(ARG_GAME_DESCRIPTION));
textCountry.setText(country); textCountry.setText(country);
textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE)); textDate.setText(getArguments().getString(ARG_GAME_DATE));
buttonLaunch.setOnClickListener(new View.OnClickListener() 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. // Start the emulation activity and send the path of the clicked ROM to it.
EmulationActivity.launch(getActivity(), EmulationActivity.launch(getActivity(),
getArguments().getString(ARGUMENT_GAME_PATH), getArguments().getString(ARG_GAME_PATH),
getArguments().getString(ARGUMENT_GAME_TITLE), getArguments().getString(ARG_GAME_TITLE),
getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH), getArguments().getString(ARG_GAME_SCREENSHOT_PATH),
-1, -1,
imageGameScreen); imageGameScreen);
} }
@ -86,7 +85,7 @@ public final class GameDetailsDialog extends DialogFragment
// Fill in the view contents. // Fill in the view contents.
Picasso.with(imageGameScreen.getContext()) Picasso.with(imageGameScreen.getContext())
.load(getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH)) .load(getArguments().getString(ARG_GAME_SCREENSHOT_PATH))
.fit() .fit()
.centerCrop() .centerCrop()
.noFade() .noFade()

View File

@ -12,7 +12,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.overlay.InputOverlay; 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 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; private SharedPreferences mPreferences;
@ -40,7 +39,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
EmulationFragment fragment = new EmulationFragment(); EmulationFragment fragment = new EmulationFragment();
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putString(ARGUMENT_GAME_PATH, path); arguments.putString(ARG_GAME_PATH, path);
fragment.setArguments(arguments); fragment.setArguments(arguments);
return fragment; return fragment;
@ -238,7 +237,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
Log.info("[EmulationFragment] Starting emulation: " + mSurface); Log.info("[EmulationFragment] Starting emulation: " + mSurface);
// Start emulation using the provided Surface. // Start emulation using the provided Surface.
String path = getArguments().getString(ARGUMENT_GAME_PATH); String path = getArguments().getString(ARG_GAME_PATH);
NativeLibrary.Run(path); NativeLibrary.Run(path);
} }
}; };

View File

@ -10,13 +10,12 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.GridLayout; import android.widget.GridLayout;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
public final class LoadStateFragment extends Fragment implements View.OnClickListener 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(); private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static { static {

View File

@ -10,13 +10,12 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.GridLayout; import android.widget.GridLayout;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
public final class SaveStateFragment extends Fragment implements View.OnClickListener 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(); private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static { static {

View File

@ -10,13 +10,12 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.GameAdapter; import org.dolphinemu.dolphinemu.adapters.GameAdapter;
public final class PlatformGamesFragment extends Fragment implements PlatformGamesView 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); private PlatformGamesPresenter mPresenter = new PlatformGamesPresenter(this);

View File

@ -10,7 +10,6 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.settings.SettingSection; import org.dolphinemu.dolphinemu.model.settings.SettingSection;
@ -19,6 +18,8 @@ import java.util.HashMap;
public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
{ {
private static final String ARG_FILE_NAME = "file_name";
private static final String FRAGMENT_TAG = "settings";
private SettingsActivityPresenter mPresenter = new SettingsActivityPresenter(this); private SettingsActivityPresenter mPresenter = new SettingsActivityPresenter(this);
@Override @Override
@ -29,7 +30,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
setContentView(R.layout.activity_settings); setContentView(R.layout.activity_settings);
Intent launcher = getIntent(); Intent launcher = getIntent();
String filename = launcher.getStringExtra(ARGUMENT_FILE_NAME); String filename = launcher.getStringExtra(ARG_FILE_NAME);
mPresenter.onCreate(savedInstanceState, filename); mPresenter.onCreate(savedInstanceState, filename);
} }
@ -93,7 +94,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
transaction.addToBackStack(null); transaction.addToBackStack(null);
mPresenter.addToStack(); mPresenter.addToStack();
} }
transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), SettingsFragment.FRAGMENT_TAG); transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag), FRAGMENT_TAG);
transaction.commit(); transaction.commit();
} }
@ -170,16 +171,14 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
private SettingsFragment getFragment() 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) public static void launch(Context context, String menuTag)
{ {
Intent settings = new Intent(context, SettingsActivity.class); Intent settings = new Intent(context, SettingsActivity.class);
settings.putExtra(ARGUMENT_FILE_NAME, menuTag); settings.putExtra(ARG_FILE_NAME, menuTag);
context.startActivity(settings); context.startActivity(settings);
} }

View File

@ -2,9 +2,6 @@ package org.dolphinemu.dolphinemu.ui.settings;
import android.os.Bundle; 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.R;
import org.dolphinemu.dolphinemu.model.settings.SettingSection; import org.dolphinemu.dolphinemu.model.settings.SettingSection;
import org.dolphinemu.dolphinemu.utils.Log; import org.dolphinemu.dolphinemu.utils.Log;
@ -15,7 +12,7 @@ import java.util.HashMap;
public final class SettingsActivityPresenter 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; private SettingsActivityView mView;
@ -43,7 +40,7 @@ public final class SettingsActivityPresenter
} }
else 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) public void saveState(Bundle outState)
{ {
outState.putBoolean(SHOULD_SAVE, mShouldSave); outState.putBoolean(KEY_SHOULD_SAVE, mShouldSave);
} }
public void onGcPadSettingChanged(String key, int value) public void onGcPadSettingChanged(String key, int value)

View File

@ -11,7 +11,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.settings.Setting; import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.model.settings.SettingSection; import org.dolphinemu.dolphinemu.model.settings.SettingSection;
@ -24,6 +23,8 @@ import java.util.HashMap;
public final class SettingsFragment extends Fragment implements SettingsFragmentView public final class SettingsFragment extends Fragment implements SettingsFragmentView
{ {
private static final String ARGUMENT_MENU_TAG = "menu_tag";
private SettingsFragmentPresenter mPresenter = new SettingsFragmentPresenter(this); private SettingsFragmentPresenter mPresenter = new SettingsFragmentPresenter(this);
private SettingsActivityView mActivity; private SettingsActivityView mActivity;
@ -174,10 +175,6 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
mActivity.onExtensionSettingChanged(key, value); 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) public static Fragment newInstance(String menuTag)
{ {
SettingsFragment fragment = new SettingsFragment(); SettingsFragment fragment = new SettingsFragment();