[Libreoffice-commits] online.git: android/app
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue May 7 15:37:58 UTC 2019
android/app/build.gradle | 3 +
android/app/src/main/AndroidManifest.xml | 2
android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java | 6 +-
android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java | 18 +++---
android/app/src/main/res/values/strings.xml | 2
android/app/src/main/res/xml/libreoffice_preferences.xml | 28 +++++++---
6 files changed, 43 insertions(+), 16 deletions(-)
New commits:
commit d50ce4f86cfd8f2eb96a604e022dcc63b58a3f3c
Author: kaishu-sahu <kaishusahu101 at gmail.com>
AuthorDate: Tue Apr 23 17:44:52 2019 +0530
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue May 7 17:37:38 2019 +0200
android: replace PreferenceFragment with PreferenceFragmentCompat
PreferenceFragment is deprecated.
Also add debug info option in settings.
Change-Id: I0e55079bc82c85d6ad7ffeb86f821bf7ad07a792
Reviewed-on: https://gerrit.libreoffice.org/71151
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/android/app/build.gradle b/android/app/build.gradle
index ea3dd5288..eeaf61f61 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -61,6 +61,9 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation(name:'owncloud_android_lib', ext:'aar')
+
+ //before changing the version please see https://issuetracker.google.com/issues/111662669
+ implementation 'androidx.preference:preference:1.1.0-alpha01'
}
task copyUnpackAssets(type: Copy) {
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index cb302929c..e6df34af6 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -121,7 +121,7 @@
android:label="@string/title_activity_show_html"></activity>
<activity
android:name=".SettingsActivity"
- android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
+ android:theme="@style/Theme.AppCompat.Light"
android:label="@string/app_name_settings">
</activity>
</application>
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
index 72fa0b500..bc0236cf1 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
@@ -52,6 +52,7 @@ public class MainActivity extends AppCompatActivity {
private static final String ASSETS_EXTRACTED_PREFS_KEY = "ASSETS_EXTRACTED";
private static final int PERMISSION_READ_EXTERNAL_STORAGE = 777;
+ private static final String KEY_ENABLE_SHOW_DEBUG_INFO = "ENABLE_SHOW_DEBUG_INFO";
private static final String KEY_PROVIDER_ID = "providerID";
private static final String KEY_DOCUMENT_URI = "documentUri";
@@ -67,6 +68,7 @@ public class MainActivity extends AppCompatActivity {
private String urlToLoad;
private WebView mWebView;
+ private SharedPreferences sPrefs;
private boolean isDocEditable = false;
private boolean isDocDebuggable = BuildConfig.DEBUG;
@@ -129,7 +131,6 @@ public class MainActivity extends AppCompatActivity {
}
private void updatePreferences() {
- SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (sPrefs.getInt(ASSETS_EXTRACTED_PREFS_KEY, 0) != BuildConfig.VERSION_CODE) {
if (copyFromAssets(getAssets(), "unpack", getApplicationInfo().dataDir)) {
sPrefs.edit().putInt(ASSETS_EXTRACTED_PREFS_KEY, BuildConfig.VERSION_CODE).apply();
@@ -140,12 +141,15 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ sPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
updatePreferences();
setContentView(R.layout.activity_main);
AssetManager assetManager = getResources().getAssets();
+ isDocDebuggable = sPrefs.getBoolean(KEY_ENABLE_SHOW_DEBUG_INFO, false) && BuildConfig.DEBUG;
+
ApplicationInfo applicationInfo = getApplicationInfo();
String dataDir = applicationInfo.dataDir;
Log.i(TAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java
index e58fc8d4b..75cd9468c 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java
@@ -9,27 +9,31 @@
package org.libreoffice.androidapp;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceFragment;
-public class SettingsActivity extends Activity {
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.preference.PreferenceFragmentCompat;
+
+public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
- getFragmentManager().beginTransaction()
+ getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
- public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
+ public static class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
+
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.libreoffice_preferences);
+ if (!BuildConfig.DEBUG) {
+ findPreference("ENABLE_SHOW_DEBUG_INFO").setVisible(false);
+ }
}
@Override
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index deb16c914..41dc85ad6 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -27,6 +27,8 @@
<string name="pref_filter_summary">Set which file filter should be used by default.</string>
<string name="display_language">Display Language</string>
<string name="display_language_summary">Set the default display language</string>
+ <string name="pref_show_debug_info">Show Debug Info</string>
+ <string name="pref_show_debug_info_summary">Enable to show debug information in document viewer</string>
<string name="about_license">Show License</string>
<string name="about_notice">Show Notice</string>
diff --git a/android/app/src/main/res/xml/libreoffice_preferences.xml b/android/app/src/main/res/xml/libreoffice_preferences.xml
index eca0df51e..8090a98eb 100644
--- a/android/app/src/main/res/xml/libreoffice_preferences.xml
+++ b/android/app/src/main/res/xml/libreoffice_preferences.xml
@@ -1,29 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:title="@string/pref_category_explorer"
- android:key="PREF_CATEGORY_EXPLORER">
+ android:key="PREF_CATEGORY_EXPLORER"
+ app:iconSpaceReserved="false" >
<ListPreference
android:title="@string/pref_filter_title"
android:summary="@string/pref_filter_summary"
android:entries="@array/FilterTypeNames"
android:entryValues="@array/FilterTypeStringValues"
android:defaultValue="-1"
- android:key="FILTER_MODE"/>
+ android:key="FILTER_MODE"
+ app:iconSpaceReserved="false" />
<ListPreference
android:summary="@string/pref_sort_summary"
android:key="SORT_MODE"
android:title="@string/pref_sort_title"
android:entries="@array/SortModeNames"
android:defaultValue="0"
- android:entryValues="@array/SortModeStringValues"/>
+ android:entryValues="@array/SortModeStringValues"
+ app:iconSpaceReserved="false" />
<ListPreference
android:entries="@array/ViewModeNames"
android:entryValues="@array/ViewModeStringValues"
android:defaultValue="@integer/grid_view_integer"
android:title="@string/pref_file_explorer_title"
android:key="EXPLORER_VIEW_TYPE"
- android:summary="@string/pref_viewmode_summary" />
+ android:summary="@string/pref_viewmode_summary"
+ app:iconSpaceReserved="false" />
<ListPreference
android:title="@string/display_language"
@@ -32,13 +37,22 @@
android:entryValues="@array/SupportedLanguagesValues"
android:defaultValue="en"
android:key="DISPLAY_LANGUAGE"
- />
+ app:iconSpaceReserved="false" />
<CheckBoxPreference
android:title="@string/pref_show_hidden_files"
android:key="ENABLE_SHOW_HIDDEN_FILES"
android:summary="@string/pref_show_hidden_files_summary"
- android:defaultValue="false" />
+ android:defaultValue="false"
+ app:iconSpaceReserved="false" />
+
+ <CheckBoxPreference
+ android:title="@string/pref_show_debug_info"
+ android:key="ENABLE_SHOW_DEBUG_INFO"
+ android:summary="@string/pref_show_debug_info_summary"
+ android:defaultValue="false"
+ app:iconSpaceReserved="false" />
+
</PreferenceCategory>
</PreferenceScreen>
More information about the Libreoffice-commits
mailing list