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(), activityType.getText().toString(), description.getText().toString(),
myTracksProviderUtils, trackRecordingServiceConnection, newWeight); myTracksProviderUtils, trackRecordingServiceConnection, newWeight);
if (EulaUtils.hasShowEnableSync(TrackEditActivity.this)) { if (EulaUtils.showEnableSync(TrackEditActivity.this)) {
EulaUtils.setShowEnableSync(TrackEditActivity.this); EulaUtils.setShowEnableSync(TrackEditActivity.this);
if (PreferencesUtils.getBoolean(TrackEditActivity.this, R.string.drive_sync_key, if (PreferencesUtils.getBoolean(TrackEditActivity.this, R.string.drive_sync_key,
PreferencesUtils.DRIVE_SYNC_DEFAULT)) { PreferencesUtils.DRIVE_SYNC_DEFAULT)) {
@@ -651,7 +651,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
* Shows start up dialogs. * Shows start up dialogs.
*/ */
public void showStartupDialogs() { public void showStartupDialogs() {
if (!EulaUtils.hasAcceptEula(this)) { if (!EulaUtils.hasAcceptedEula(this)) {
Fragment fragment = getSupportFragmentManager() Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG); .findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
if (fragment == null) { if (fragment == null) {
@@ -672,7 +672,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
@Override @Override
public void onEulaDone() { public void onEulaDone() {
if (EulaUtils.hasAcceptEula(this)) { if (EulaUtils.hasAcceptedEula(this)) {
showStartupDialogs(); showStartupDialogs();
return; return;
} }
@@ -111,7 +111,7 @@ public class EulaDialogFragment extends AbstractMyTracksDialogFragment {
}).setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() { }).setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
EulaUtils.setAcceptEula(getActivity()); EulaUtils.setAcceptedEula(getActivity());
caller.onEulaDone(); caller.onEulaDone();
} }
}); });
@@ -30,39 +30,40 @@ public class EulaUtils {
private static final String EULA_PREFERENCE_FILE = "eula"; private static final String EULA_PREFERENCE_FILE = "eula";
// Accepting Google mobile terms of service // 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 static final String SHOW_ENABLE_SYNC_PREFERENCE_KEY = "showEnableSync";
private EulaUtils() {} 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);
}
/**
* Sets to true that eula is accepted.
* *
* @param context the context * @param context the context
*/ */
public static void setAcceptEula(Context context) { public static boolean hasAcceptedEula(Context context) {
setValue(context, ACCEPT_EULA_PREFERENCE_KEY, true); return getValue(context, ACCEPTED_EULA_PREFERENCE_KEY, false);
} }
/** /**
* Returns true if show enable sync is needed. * Sets to true accepted eula.
* *
* @param context the context * @param context the context
*/ */
public static boolean hasShowEnableSync(Context context) { public static void setAcceptedEula(Context context) {
setValue(context, ACCEPTED_EULA_PREFERENCE_KEY, true);
}
/**
* Returns true if should show enable sync.
*
* @param context the context
*/
public static boolean showEnableSync(Context context) {
return getValue(context, SHOW_ENABLE_SYNC_PREFERENCE_KEY, true); 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 * @param context the context
*/ */