forked from upstream-mirrors/OpenTracks
merge from main
This commit is contained in:
@@ -284,8 +284,8 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setEulaValue(MyTracks.this);
|
||||
Intent startIntent = new Intent(MyTracks.this, WelcomeActivity.class);
|
||||
startActivityForResult(startIntent, Constants.WELCOME);
|
||||
startActivityForResult(
|
||||
new Intent(MyTracks.this, WelcomeActivity.class), Constants.WELCOME);
|
||||
}
|
||||
})
|
||||
.setTitle(R.string.eula_title)
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
@@ -57,31 +56,31 @@ public class WelcomeActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
AlertDialog.Builder builder;
|
||||
switch (id) {
|
||||
case DIALOG_ABOUT_ID:
|
||||
LayoutInflater layoutInflator = LayoutInflater.from(this);
|
||||
View view = layoutInflator.inflate(R.layout.about, null);
|
||||
TextView aboutVersionTextView = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersionTextView.setText(SystemUtils.getMyTracksVersion(this));
|
||||
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(R.string.generic_ok, null);
|
||||
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
showDialog(DIALOG_EULA_ID);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
View view = getLayoutInflater().inflate(R.layout.about, null);
|
||||
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(this));
|
||||
|
||||
return new AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
showDialog(DIALOG_EULA_ID);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, null)
|
||||
.setTitle(R.string.my_tracks_app_name)
|
||||
.setView(view)
|
||||
.create();
|
||||
case DIALOG_EULA_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.eula_title);
|
||||
builder.setMessage(EulaUtils.getEulaMessage(this));
|
||||
builder.setPositiveButton(R.string.generic_ok, null);
|
||||
builder.setCancelable(true);
|
||||
return builder.create();
|
||||
return new AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setMessage(EulaUtils.getEulaMessage(this))
|
||||
.setPositiveButton(R.string.generic_ok, null)
|
||||
.setTitle(R.string.eula_title)
|
||||
.create();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,53 +25,42 @@ import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Utilities for EULA.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class EulaUtils {
|
||||
|
||||
private static final String EULA_PREFERENCE_FILE = "eula";
|
||||
|
||||
// Accepting Google mobile terms of service
|
||||
private static final String EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
||||
|
||||
// Google's mobile page
|
||||
private static final String HOST_NAME = "m.google.com";
|
||||
|
||||
private EulaUtils() {}
|
||||
|
||||
public static boolean getEulaValue(Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
return preferences.getBoolean(EULA_PREFERENCE_KEY, false);
|
||||
return sharedPreferences.getBoolean(EULA_PREFERENCE_KEY, false);
|
||||
}
|
||||
|
||||
public static void setEulaValue(Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
Editor editor = preferences.edit();
|
||||
Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(EULA_PREFERENCE_KEY, true);
|
||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
|
||||
public static String getEulaMessage(Context context) {
|
||||
String item1 = String.format(context.getString(R.string.eula_message_item1), HOST_NAME,
|
||||
HOST_NAME, HOST_NAME, HOST_NAME, HOST_NAME);
|
||||
String item3 = String.format(context.getString(R.string.eula_message_item3), HOST_NAME);
|
||||
String footer = String.format(context.getString(R.string.eula_message_footer), HOST_NAME);
|
||||
String copyright = "©" + Calendar.getInstance().get(Calendar.YEAR);
|
||||
return context.getString(R.string.eula_message_date)
|
||||
return context.getString(R.string.eula_date)
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_message_header)
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_message_body)
|
||||
+ "\n\n"
|
||||
+ "1. " + item1
|
||||
+ "\n\n"
|
||||
+ "2. " + context.getString(R.string.eula_message_item2)
|
||||
+ "\n\n"
|
||||
+ "3. " + item3
|
||||
+ "\n\n"
|
||||
+ "4. " + context.getString(R.string.eula_message_item4)
|
||||
+ "\n\n"
|
||||
+ footer
|
||||
+ "\n\n"
|
||||
+ copyright;
|
||||
+ context.getString(R.string.eula_body, HOST_NAME)
|
||||
+ "\n\n"
|
||||
+ context.getString(R.string.eula_footer, HOST_NAME)
|
||||
+ "\n\n"
|
||||
+ "©" + Calendar.getInstance().get(Calendar.YEAR);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user