tobiaskaminsky 7 лет назад
Родитель
Сommit
90dc587300

+ 43 - 0
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -556,6 +556,49 @@ public class Preferences extends PreferenceActivity
             pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
         }
 
+        // source code
+        boolean sourcecodeEnabled = getResources().getBoolean(R.bool.sourcecode_enabled);
+        Preference sourcecodePreference = findPreference("sourcecode");
+        if (sourcecodePreference != null) {
+            String sourcecodeUrl = getString(R.string.sourcecode_url);
+
+            if (sourcecodeEnabled && !sourcecodeUrl.isEmpty()) {
+                sourcecodePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        Uri uriUrl = Uri.parse(sourcecodeUrl);
+                        Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
+                        startActivity(intent);
+                        return true;
+                    }
+                });
+            } else {
+                preferenceCategoryAbout.removePreference(sourcecodePreference);
+            }
+        }
+
+        // license
+        boolean licenseEnabled = getResources().getBoolean(R.bool.license_enabled);
+        Preference licensePreference = findPreference("license");
+        if (licensePreference != null) {
+            String licenseUrl = getString(R.string.license_url);
+
+            if (licenseEnabled && !licenseUrl.isEmpty()) {
+                licensePreference.setSummary(R.string.prefs_gpl_v2);
+                licensePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        Uri uriUrl = Uri.parse(licenseUrl);
+                        Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
+                        startActivity(intent);
+                        return true;
+                    }
+                });
+            } else {
+                preferenceCategoryAbout.removePreference(licensePreference);
+            }
+        }
+
         // privacy
         boolean privacyEnabled = getResources().getBoolean(R.bool.privacy_enabled);
         Preference privacyPreference = findPreference("privacy");

+ 4 - 0
src/main/res/values/setup.xml

@@ -98,6 +98,10 @@
     <bool name="recommend_enabled">true</bool>
     <bool name="feedback_enabled">true</bool>
     <bool name="logger_enabled">false</bool>
+    <bool name="sourcecode_enabled">true</bool>
+    <string name="sourcecode_url" translatable="false">https://github.com/nextcloud/android</string>
+    <bool name="license_enabled">true</bool>
+    <string name="license_url" translatable="false">https://www.gnu.org/licenses/gpl-2.0.html</string>
     <string name="url_imprint"></string>
     <string name="mail_feedback">"mailto:android@nextcloud.com"</string>
     <string name="url_app_download">"https://play.google.com/store/apps/details?id=com.nextcloud.client"</string>

+ 3 - 0
src/main/res/values/strings.xml

@@ -703,4 +703,7 @@
 
     <string name="common_warning" translatable="false">Warning</string>
     <string name="corrupt_account_info" translatable="false">Accounts have been corrupted in case you have been using a release candidate of 2.0.0 between RC1 and RC5.\n\nWe are sorry to tell you that you need to remove the Nextcloud accounts from your device and need to re-login again completely in order to get fully working login-sessions on this device!</string>
+    <string name="prefs_sourcecode">Get source code</string>
+    <string name="prefs_license">License</string>
+    <string name="prefs_gpl_v2" translatable="false">GNU General Public License, version 2</string>
 </resources>

+ 8 - 0
src/main/res/xml/preferences.xml

@@ -72,6 +72,14 @@
 			android:title="@string/privacy"
 			android:id="@+id/privacy"
 			android:key="privacy"/>
+		<Preference
+			android:title="@string/prefs_sourcecode"
+			android:id="@+id/sourcecode"
+			android:key="sourcecode"/>
+		<Preference
+			android:title="@string/prefs_license"
+			android:id="@+id/license"
+			android:key="license"/>
 		<Preference android:title="@string/about_title" android:id="@+id/about_app" android:key="about_app" />
 	</PreferenceCategory>