forked from upstream-mirrors/OpenTracks
Set default units to imperial if in US
This commit is contained in:
@@ -30,7 +30,6 @@ limitations under the License.
|
|||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:text="@string/track_list_empty_message"
|
android:text="@string/track_list_empty_message"
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/ListEmptyTextView" >
|
style="@style/ListEmptyTextView" >
|
||||||
</TextView>
|
</TextView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -29,7 +29,6 @@ limitations under the License.
|
|||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:text="@string/track_list_empty_message"
|
android:text="@string/track_list_empty_message"
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/ListEmptyTextView" >
|
style="@style/ListEmptyTextView" >
|
||||||
</TextView>
|
</TextView>
|
||||||
<include layout="@layout/track_controller" />
|
<include layout="@layout/track_controller" />
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity displaying a list of tracks.
|
* An activity displaying a list of tracks.
|
||||||
*
|
*
|
||||||
@@ -645,7 +647,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
* Shows start up dialogs.
|
* Shows start up dialogs.
|
||||||
*/
|
*/
|
||||||
public void showStartupDialogs() {
|
public void showStartupDialogs() {
|
||||||
if (!EulaUtils.getAcceptEula(this)) {
|
if (!EulaUtils.hasAcceptEula(this)) {
|
||||||
Fragment fragment = getSupportFragmentManager()
|
Fragment fragment = getSupportFragmentManager()
|
||||||
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
|
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
|
||||||
if (fragment == null) {
|
if (fragment == null) {
|
||||||
@@ -653,19 +655,20 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
if (!EulaUtils.hasDefaultUnits(this)) {
|
||||||
* Before the welcome sequence, the empty view is not visible so that it
|
String statsUnits = getString(
|
||||||
* doesn't show through.
|
Locale.US.equals(Locale.getDefault()) ? R.string.stats_units_imperial
|
||||||
*/
|
: R.string.stats_units_metric);
|
||||||
findViewById(R.id.track_list_empty_view).setVisibility(View.VISIBLE);
|
PreferencesUtils.setString(this, R.string.stats_units_key, statsUnits);
|
||||||
|
EulaUtils.setDefaultUnits(this);
|
||||||
|
}
|
||||||
checkGooglePlayServices();
|
checkGooglePlayServices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEulaDone() {
|
public void onEulaDone() {
|
||||||
if (EulaUtils.getAcceptEula(this)) {
|
if (EulaUtils.hasAcceptEula(this)) {
|
||||||
showStartupDialogs();
|
showStartupDialogs();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -692,7 +695,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showEnableSync() {
|
private void showEnableSync() {
|
||||||
if (EulaUtils.getShowEnableSync(this)) {
|
if (EulaUtils.hasShowEnableSync(this)) {
|
||||||
Fragment fragment = getSupportFragmentManager()
|
Fragment fragment = getSupportFragmentManager()
|
||||||
.findFragmentByTag(EnableSyncDialogFragment.ENABLE_SYNC_DIALOG_TAG);
|
.findFragmentByTag(EnableSyncDialogFragment.ENABLE_SYNC_DIALOG_TAG);
|
||||||
if (fragment == null) {
|
if (fragment == null) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.google.android.apps.mytracks.fragments;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -33,8 +32,6 @@ import android.text.util.Linkify;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DialogFragment to show EULA.
|
* A DialogFragment to show EULA.
|
||||||
*
|
*
|
||||||
@@ -120,10 +117,6 @@ public class EulaDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
EulaUtils.setAcceptEula(fragmentActivity);
|
EulaUtils.setAcceptEula(fragmentActivity);
|
||||||
String statsUnits = fragmentActivity.getString(
|
|
||||||
Locale.US.equals(Locale.getDefault()) ? R.string.stats_units_imperial
|
|
||||||
: R.string.stats_units_metric);
|
|
||||||
PreferencesUtils.setString(fragmentActivity, R.string.stats_units_key, statsUnits);
|
|
||||||
caller.onEulaDone();
|
caller.onEulaDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,22 +30,60 @@ public class EulaUtils {
|
|||||||
|
|
||||||
// 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 ACCEPT_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
||||||
|
private static final String DEFAULT_UNITS_PREFERENCE_KEY = "defaultUnits";
|
||||||
private static final String SHOW_ENABLE_SYNC_PREFERENCE_KEY = "showEnableSync";
|
private static final String SHOW_ENABLE_SYNC_PREFERENCE_KEY = "showEnableSync";
|
||||||
|
|
||||||
private EulaUtils() {}
|
private EulaUtils() {}
|
||||||
|
|
||||||
public static boolean getAcceptEula(Context context) {
|
/**
|
||||||
|
* Returns true if eula is accepted.
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
|
public static boolean hasAcceptEula(Context context) {
|
||||||
return getValue(context, ACCEPT_EULA_PREFERENCE_KEY, false);
|
return getValue(context, ACCEPT_EULA_PREFERENCE_KEY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets to true that eula is accepted.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
public static void setAcceptEula(Context context) {
|
public static void setAcceptEula(Context context) {
|
||||||
setValue(context, ACCEPT_EULA_PREFERENCE_KEY, true);
|
setValue(context, ACCEPT_EULA_PREFERENCE_KEY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getShowEnableSync(Context context) {
|
/**
|
||||||
|
* Returns true if the default units is initialized.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
|
public static boolean hasDefaultUnits(Context context) {
|
||||||
|
return getValue(context, DEFAULT_UNITS_PREFERENCE_KEY, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets to true that the default units is initialized.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
|
public static void setDefaultUnits(Context context) {
|
||||||
|
setValue(context, DEFAULT_UNITS_PREFERENCE_KEY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if show enable sync is needed.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
|
public static boolean hasShowEnableSync(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.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
*/
|
||||||
public static void setShowEnableSync(Context context) {
|
public static void setShowEnableSync(Context context) {
|
||||||
setValue(context, SHOW_ENABLE_SYNC_PREFERENCE_KEY, false);
|
setValue(context, SHOW_ENABLE_SYNC_PREFERENCE_KEY, false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user