OSDN Git Service

Settings: fix 'CyanogenMod legal' link
authorRoman Birg <roman@cyngn.com>
Thu, 16 Apr 2015 23:54:23 +0000 (16:54 -0700)
committerAbhisek Devkota <ciwrl@cyanogenmod.com>
Mon, 15 Feb 2016 19:53:56 +0000 (11:53 -0800)
No more WebViews in priv-apps, so open it up in the browser.

CYNGNOS-1895

Change-Id: I263ccc0509e275d17512528deb606341d58e7a0d
Signed-off-by: Roman Birg <roman@cyngn.com>
res/values/cm_strings.xml
res/xml/about_legal.xml
src/com/android/settings/LegalSettings.java

index 7693a28..8338653 100644 (file)
 
     <string name="interruptions_ignore_while_media_title">Prevent audio ducking</string>
     <string name="interruptions_ignore_while_media_summary">Do not reduce media playback volume when a notification arrives</string>
+
+    <!-- CM Legal -->
+    <string name="cmlicense_title">CyanogenMod legal</string>
 </resources>
index 5d1d442..815913b 100644 (file)
         <intent android:action="android.settings.LICENSE" />
     </PreferenceScreen>
 
+    <!-- CM License information -->
+    <PreferenceScreen
+        android:key="cmlicense"
+        android:title="@string/cmlicense_title" />
+
     <!-- Terms and conditions -->
     <PreferenceScreen
         android:key="terms"
index cd91d20..a28fae5 100644 (file)
@@ -22,9 +22,14 @@ import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.net.Uri;
 import android.os.Bundle;
+import android.os.SystemProperties;
+import android.preference.Preference;
 import android.preference.PreferenceGroup;
+import android.preference.PreferenceScreen;
 import android.provider.SearchIndexableResource;
+import android.util.Log;
 
 import com.android.internal.logging.MetricsLogger;
 import com.android.settings.search.BaseSearchIndexProvider;
@@ -36,10 +41,13 @@ import java.util.List;
 
 public class LegalSettings extends SettingsPreferenceFragment implements Indexable {
 
+    private static final String LOG_TAG = "LegalSettings";
     private static final String KEY_TERMS = "terms";
     private static final String KEY_LICENSE = "license";
     private static final String KEY_COPYRIGHT = "copyright";
     private static final String KEY_WEBVIEW_LICENSE = "webview_license";
+    private static final String PROPERTY_CMLICENSE_URL = "ro.cmlegal.url";
+    private static final String KEY_CM_LICENSE = "cmlicense";
 
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -59,6 +67,22 @@ public class LegalSettings extends SettingsPreferenceFragment implements Indexab
     }
 
     @Override
+    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+        if (preference.getKey().equals(KEY_CM_LICENSE)) {
+            String userCMLicenseUrl = SystemProperties.get(PROPERTY_CMLICENSE_URL);
+            final Intent intent = new Intent(Intent.ACTION_VIEW);
+            intent.addCategory(Intent.CATEGORY_DEFAULT);
+            intent.setData(Uri.parse(userCMLicenseUrl));
+            try {
+                startActivity(intent);
+            } catch (Exception e) {
+                Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
+            }
+        }
+        return super.onPreferenceTreeClick(preferenceScreen, preference);
+    }
+
+    @Override
     protected int getMetricsCategory() {
         return MetricsLogger.ABOUT_LEGAL_SETTINGS;
     }