Code cleanup of EulaUtils

This commit is contained in:
Jimmy Shih
2014-01-10 12:45:26 -08:00
parent 6ab9f0716b
commit 0743835893
4 changed files with 21 additions and 20 deletions
@@ -179,7 +179,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity implements Choos
activityType.getText().toString(), description.getText().toString(),
myTracksProviderUtils, trackRecordingServiceConnection, newWeight);
if (EulaUtils.hasShowEnableSync(TrackEditActivity.this)) {
if (EulaUtils.showEnableSync(TrackEditActivity.this)) {
EulaUtils.setShowEnableSync(TrackEditActivity.this);
if (PreferencesUtils.getBoolean(TrackEditActivity.this, R.string.drive_sync_key,
PreferencesUtils.DRIVE_SYNC_DEFAULT)) {
@@ -651,7 +651,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
* Shows start up dialogs.
*/
public void showStartupDialogs() {
if (!EulaUtils.hasAcceptEula(this)) {
if (!EulaUtils.hasAcceptedEula(this)) {
Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
if (fragment == null) {
@@ -672,7 +672,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
@Override
public void onEulaDone() {
if (EulaUtils.hasAcceptEula(this)) {
if (EulaUtils.hasAcceptedEula(this)) {
showStartupDialogs();
return;
}
@@ -111,7 +111,7 @@ public class EulaDialogFragment extends AbstractMyTracksDialogFragment {
}).setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
EulaUtils.setAcceptEula(getActivity());
EulaUtils.setAcceptedEula(getActivity());
caller.onEulaDone();
}
});
@@ -30,46 +30,47 @@ public class EulaUtils {
private static final String EULA_PREFERENCE_FILE = "eula";
// Accepting Google mobile terms of service
private static final String ACCEPT_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
private static final String ACCEPTED_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
private static final String SHOW_ENABLE_SYNC_PREFERENCE_KEY = "showEnableSync";
private EulaUtils() {}
/**
* Returns true if eula is accepted.
* Returns true if has accepted eula.
*
* @param context the context
*/
public static boolean hasAcceptEula(Context context) {
return getValue(context, ACCEPT_EULA_PREFERENCE_KEY, false);
public static boolean hasAcceptedEula(Context context) {
return getValue(context, ACCEPTED_EULA_PREFERENCE_KEY, false);
}
/**
* Sets to true that eula is accepted.
* Sets to true accepted eula.
*
* @param context the context
*/
public static void setAcceptEula(Context context) {
setValue(context, ACCEPT_EULA_PREFERENCE_KEY, true);
public static void setAcceptedEula(Context context) {
setValue(context, ACCEPTED_EULA_PREFERENCE_KEY, true);
}
/**
* Returns true if show enable sync is needed.
* Returns true if should show enable sync.
*
* @param context the context
* @param context the context
*/
public static boolean hasShowEnableSync(Context context) {
public static boolean showEnableSync(Context context) {
return getValue(context, SHOW_ENABLE_SYNC_PREFERENCE_KEY, true);
}
/**
* Sets to false that show enable sync is needed.
* Sets to false show enable sync.
*
* @param context the context
*/
public static void setShowEnableSync(Context context) {
setValue(context, SHOW_ENABLE_SYNC_PREFERENCE_KEY, false);
}
}
private static boolean getValue(Context context, String key, boolean defaultValue) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);