From 315f47bf3047acbbc929a2a231eda8d8ca6a7804 Mon Sep 17 00:00:00 2001 From: Matthew Simmons Date: Fri, 7 Jan 2011 13:22:30 -0500 Subject: [PATCH] Add License button to the About dialog box. Add link to privacy policy to the About dialog box. --- MyTracks/res/layout/about.xml | 31 ++++++++++---- MyTracks/res/values/do_not_translate.xml | 1 + MyTracks/res/values/strings.xml | 3 +- .../google/android/apps/mytracks/Eula.java | 41 ++++++++++++------- .../android/apps/mytracks/MyTracks.java | 2 +- .../apps/mytracks/WelcomeActivity.java | 8 ++++ 6 files changed, 62 insertions(+), 24 deletions(-) diff --git a/MyTracks/res/layout/about.xml b/MyTracks/res/layout/about.xml index 753d860e8..0870154b7 100644 --- a/MyTracks/res/layout/about.xml +++ b/MyTracks/res/layout/about.xml @@ -41,8 +41,7 @@ limitations under the License. - + - + - + - + + + + + + + + diff --git a/MyTracks/res/values/do_not_translate.xml b/MyTracks/res/values/do_not_translate.xml index 32095d881..050778199 100644 --- a/MyTracks/res/values/do_not_translate.xml +++ b/MyTracks/res/values/do_not_translate.xml @@ -21,6 +21,7 @@ limitations under the License. mytracks@googlegroups.com mytracks.appspot.com + google.com/privacy Copyright 2009 Google Inc. Bartlomiej Niechwiej Dylan Casey diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index 487afee53..a838c30c1 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -104,6 +104,7 @@ limitations under the License. Error Success Waypoint + License (Start) @@ -378,8 +379,8 @@ limitations under the License. Help Team: Version: - Support Support: + Privacy: Send to... diff --git a/MyTracks/src/com/google/android/apps/mytracks/Eula.java b/MyTracks/src/com/google/android/apps/mytracks/Eula.java index 4471d93fc..933e3498e 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/Eula.java +++ b/MyTracks/src/com/google/android/apps/mytracks/Eula.java @@ -26,32 +26,31 @@ import android.content.Intent; import android.content.SharedPreferences; /** - * Displays an EULA ("End User License Agreement") that the user has to accept - * before using the application. Your application should call - * {@link Eula#showEula(android.app.Activity)} in the onCreate() method of the - * first activity. If the user accepts the EULA, it will never be shown again. - * If the user refuses, {@link android.app.Activity#finish()} is invoked on your - * activity. + * This class handles display of EULAs ("End User License Agreements") to the + * user. */ class Eula { private static final String PREFERENCE_EULA_ACCEPTED = "eula.accepted"; private static final String PREFERENCES_EULA = "eula"; + private Eula() {} + /** * Displays the EULA if necessary. This method should be called from the - * onCreate() method of your main Activity. + * onCreate() method of your main Activity. If the user accepts, the EULA + * will never be displayed again. If the user refuses, the activity will + * finish (exit). * * @param activity The Activity to finish if the user rejects the EULA */ - static void showEula(final Activity activity) { + static void showEulaRequireAcceptance(final Activity activity) { final SharedPreferences preferences = activity.getSharedPreferences(PREFERENCES_EULA, Activity.MODE_PRIVATE); if (preferences.getBoolean(PREFERENCE_EULA_ACCEPTED, false)) { return; } - final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(R.string.eula_title); + final AlertDialog.Builder builder = initDialog(activity); builder.setCancelable(true); builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() { @@ -73,10 +72,27 @@ class Eula { refuse(activity); } }); - builder.setMessage(ResourceUtils.readFile(activity, R.raw.eula)); builder.show(); } + /** + * Display the EULA to the user in an informational context. They won't be + * given the choice of accepting or declining the EULA -- we're simply + * displaying it for them to read. + */ + static void showEula(Activity activity) { + AlertDialog.Builder builder = initDialog(activity); + builder.setPositiveButton(R.string.ok, null); + builder.show(); + } + + private static AlertDialog.Builder initDialog(Activity activity) { + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.eula_title); + builder.setMessage(ResourceUtils.readFile(activity, R.raw.eula)); + return builder; + } + private static void accept(Activity activity, SharedPreferences preferences) { ApiFeatures.getInstance().getApiPlatformAdapter().applyPreferenceChanges( preferences.edit().putBoolean(PREFERENCE_EULA_ACCEPTED, true)); @@ -87,7 +103,4 @@ class Eula { private static void refuse(Activity activity) { activity.finish(); } - - private Eula() { - } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index c4ed31c11..6cd26c3b5 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -315,7 +315,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, } // This will show the eula until the user accepts or quits the app. - Eula.showEula(this); + Eula.showEulaRequireAcceptance(this); // Check if we got invoked via the VIEW intent: Intent intent = getIntent(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java index 42edd66f6..0ae23e2c7 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java @@ -19,6 +19,7 @@ import com.google.android.maps.mytracks.R; import android.app.Activity; import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -71,9 +72,16 @@ public class WelcomeActivity extends Activity { public void about() { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.about, null); + final Activity activity = this; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(view); builder.setPositiveButton(R.string.ok, null); + builder.setNeutralButton(R.string.license, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Eula.showEula(activity); + } + }); builder.setIcon(R.drawable.arrow_icon); AlertDialog dialog = builder.create(); dialog.show();