OSDN Git Service

b/2293262 Add About section to Calendar Settings
authorMichael Chan <mchan@android.com>
Tue, 2 Mar 2010 06:22:48 +0000 (22:22 -0800)
committerMichael Chan <mchan@android.com>
Wed, 3 Mar 2010 01:21:16 +0000 (17:21 -0800)
Change-Id: I5f797b67bd4887b37949905d151a2409949090fc

res/values/strings.xml
res/xml/preferences.xml
src/com/android/calendar/CalendarPreferenceActivity.java

index 32ea73e..0275c75 100644 (file)
     <!-- Default value for the number of reminder minutes -->
     <string name="preferences_default_reminder_default">10</string>
 
+    <!-- This is the title of a section in the Settings screen for "About" this application -->
+    <string name="preferences_about_title">About</string>
+    <!-- Build version of the application -->
+    <string name="preferences_build_version">Build version</string>
 </resources>
index 061170e..d62f7d4 100644 (file)
@@ -21,7 +21,7 @@
             android:defaultValue="false"
             android:title="@string/preferences_hide_declined_title" />
     </PreferenceCategory>
-    
+
     <PreferenceCategory android:title="@string/preferences_alerts_title">
         <ListPreference
             android:key="preferences_alerts_type"
             android:entries="@array/preferences_alert_type_labels"
             android:entryValues="@array/preferences_alert_type_values"
             android:dialogTitle="@string/preferences_alerts_type_dialog" />
-        
+
         <RingtonePreference
             android:layout="?android:attr/preferenceLayoutChild"
             android:key="preferences_alerts_ringtone"
             android:title="@string/preferences_alerts_ringtone_title"
             android:ringtoneType="notification"
             android:defaultValue="content://settings/system/notification_sound" />
-        
+
         <CheckBoxPreference
             android:layout="?android:attr/preferenceLayoutChild"
             android:key="preferences_alerts_vibrate"
             android:defaultValue="false"
             android:title="@string/preferences_alerts_vibrate_title" />
-        
+
         <ListPreference
             android:key="preferences_default_reminder"
             android:defaultValue="@string/preferences_default_reminder_default"
             android:entryValues="@array/preferences_default_reminder_values"
             android:dialogTitle="@string/preferences_default_reminder_dialog" />
     </PreferenceCategory>
+
+    <PreferenceCategory
+        android:title="@string/preferences_about_title">
+        <Preference
+            android:key="build_version"
+            android:title="@string/preferences_build_version" />
+    </PreferenceCategory>
+
 </PreferenceScreen>
index 3b1dd27..917887b 100644 (file)
@@ -19,6 +19,8 @@ package com.android.calendar;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
 import android.preference.CheckBoxPreference;
 import android.preference.ListPreference;
@@ -28,6 +30,8 @@ import android.preference.PreferenceScreen;
 import android.preference.RingtonePreference;
 
 public class CalendarPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
+    private static final String BUILD_VERSION = "build_version";
+
     // The name of the shared preferences file. This name must be maintained for historical
     // reasons, as it's what PreferenceManager assigned the first time the file was created.
     private static final String SHARED_PREFS_NAME = "com.android.calendar_preferences";
@@ -75,7 +79,7 @@ public class CalendarPreferenceActivity extends PreferenceActivity implements On
         // Make sure to always use the same preferences file regardless of the package name
         // we're running under
         getPreferenceManager().setSharedPreferencesName(SHARED_PREFS_NAME);
-        
+
         // Load the preferences from an XML resource
         addPreferencesFromResource(R.xml.preferences);
 
@@ -85,6 +89,13 @@ public class CalendarPreferenceActivity extends PreferenceActivity implements On
         mVibrate = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS_VIBRATE);
         mRingtone = (RingtonePreference) preferenceScreen.findPreference(KEY_ALERTS_RINGTONE);
 
+        try {
+            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+            findPreference(BUILD_VERSION).setSummary(packageInfo.versionName);
+        } catch (NameNotFoundException e) {
+            findPreference(BUILD_VERSION).setSummary("?");
+        }
+
         updateChildPreferences();
     }