[Libreoffice-commits] online.git: android/app
mert (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 28 12:13:00 UTC 2020
android/app/build.gradle | 2
android/app/src/main/AndroidManifest.xml | 2
android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java | 70 +++++++++-
android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java | 14 +-
android/app/src/main/res/drawable/ic_folder_black_24dp.xml | 3
android/app/src/main/res/layout/activity_document_browser.xml | 21 +--
android/app/src/main/res/layout/file_explorer_grid_item.xml | 3
android/app/src/main/res/layout/file_list_item.xml | 4
android/app/src/main/res/layout/theme_selection.xml | 44 ++++++
android/app/src/main/res/values/strings.xml | 7 +
android/app/src/main/res/values/themes.xml | 7 -
android/app/src/main/res/xml/libreoffice_preferences.xml | 13 +
12 files changed, 167 insertions(+), 23 deletions(-)
New commits:
commit 5c023938a366f44bbe922214fb8727146d18e127
Author: mert <mert.tumer at collabora.com>
AuthorDate: Wed May 6 15:15:32 2020 +0300
Commit: Mert Tumer <mert.tumer at collabora.com>
CommitDate: Mon Sep 28 14:12:41 2020 +0200
android: enable Dark Theme for Dark Mode changes
Change-Id: I631d31558ae9afac9585d12d66237bc04a761555
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93563
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Mert Tumer <mert.tumer at collabora.com>
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 627ac6ca9..aa8f5ca16 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -67,7 +67,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 4e8723706..7777a3262 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -32,7 +32,7 @@
<!-- Document Browser Activity -->
<activity
android:name=".ui.LibreOfficeUIActivity"
- android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
+ android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|uiMode"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
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 c51d098af..701ae8350 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/SettingsActivity.java
@@ -11,29 +11,97 @@ package org.libreoffice.androidapp;
import android.content.SharedPreferences;
import android.os.Bundle;
-
+import android.view.View;
+import android.widget.RadioGroup;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
+import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+import org.libreoffice.androidapp.ui.LibreOfficeUIActivity;
public class SettingsActivity extends AppCompatActivity {
+
+ private static SharedPreferences prefs;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
+ setTheme(R.style.LibreOfficeTheme_Base);
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
+ prefs = getSharedPreferences(LibreOfficeUIActivity.EXPLORER_PREFS_KEY, MODE_PRIVATE);
}
public static class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
+ int dayNightMode;
+ int selectedThemeBtnId;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.libreoffice_preferences);
if (!BuildConfig.DEBUG) {
findPreference("ENABLE_SHOW_DEBUG_INFO").setVisible(false);
}
+ Preference themePreference = findPreference("THEME_SELECTION");
+
+ dayNightMode = AppCompatDelegate.getDefaultNightMode();
+ selectedThemeBtnId = R.id.radioBtn_default;
+ switch (dayNightMode) {
+ case AppCompatDelegate.MODE_NIGHT_YES:
+ themePreference.setSummary(R.string.theme_dark);
+ selectedThemeBtnId = R.id.radioBtn_dark;
+ break;
+ case AppCompatDelegate.MODE_NIGHT_NO:
+ themePreference.setSummary(R.string.theme_light);
+ selectedThemeBtnId = R.id.radioBtn_light;
+ break;
+ case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM:
+ themePreference.setSummary(R.string.theme_system_default);
+ selectedThemeBtnId = R.id.radioBtn_default;
+ break;
+ }
+
+ themePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ View view = getLayoutInflater().inflate(R.layout.theme_selection, null);
+ RadioGroup group = (RadioGroup) view.findViewById(R.id.radioGrp_theme);
+ group.check(selectedThemeBtnId);
+
+ group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup radioGroup, int i) {
+ switch (i) {
+ case R.id.radioBtn_dark:
+ dayNightMode = AppCompatDelegate.MODE_NIGHT_YES;
+ break;
+ case R.id.radioBtn_light:
+ dayNightMode = AppCompatDelegate.MODE_NIGHT_NO;
+ break;
+ case R.id.radioBtn_default:
+ dayNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
+ break;
+ }
+ AppCompatDelegate.setDefaultNightMode(dayNightMode);
+ prefs.edit().putInt(LibreOfficeUIActivity.NIGHT_MODE_KEY, dayNightMode).commit();
+ getActivity().recreate();
+
+ }
+ });
+
+ AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
+ dialog.setView(view);
+ dialog.setTitle(getString(R.string.choose_theme));
+ dialog.setCancelable(true);
+ dialog.setNegativeButton(getString(R.string.cancel_label), null);
+ dialog.show();
+ return false;
+ }
+ });
}
@Override
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index a36aaaa6c..c83fb3155 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -81,6 +81,7 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -99,7 +100,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
private int filterMode = FileUtilities.ALL;
private int sortMode;
private boolean showHiddenFiles;
-
// dynamic permissions IDs
private static final int PERMISSION_WRITE_EXTERNAL_STORAGE = 0;
@@ -121,6 +121,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
public static final String NEW_FILE_PATH_KEY = "NEW_FILE_PATH_KEY";
public static final String NEW_DOC_TYPE_KEY = "NEW_DOC_TYPE_KEY";
+ public static final String NIGHT_MODE_KEY = "NIGHT_MODE";
public static final String GRID_VIEW = "0";
public static final String LIST_VIEW = "1";
@@ -157,15 +158,16 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
@Override
public void onCreate(Bundle savedInstanceState) {
+ PreferenceManager.setDefaultValues(this, R.xml.documentprovider_preferences, false);
+ readPreferences();
+ int mode = prefs.getInt(NIGHT_MODE_KEY, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
+ AppCompatDelegate.setDefaultNightMode(mode);
super.onCreate(savedInstanceState);
// initialize document provider factory
//DocumentProviderFactory.initialize(this);
//documentProviderFactory = DocumentProviderFactory.getInstance();
- PreferenceManager.setDefaultValues(this, R.xml.documentprovider_preferences, false);
- readPreferences();
-
SettingsListenerModel.getInstance().setListener(this);
// Register the LOActivity events broadcast receiver
@@ -174,6 +176,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
// init UI and populate with contents from the provider
createUI();
+
fabOpenAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_open);
fabCloseAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_close);
}
@@ -867,6 +870,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
/** Uploading back when we return from the LOActivity. */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case LO_ACTIVITY_REQUEST_CODE: {
// TODO probably kill this, we don't need to do anything here any more
@@ -896,7 +900,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
Uri uri = data.getData();
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- String extension = (requestCode == CREATE_DOCUMENT_REQUEST_CODE)? "odt": ((requestCode == CREATE_SPREADSHEET_REQUEST_CODE)? "ods": "odp");
+ String extension = (requestCode == CREATE_DOCUMENT_REQUEST_CODE) ? "odt" : ((requestCode == CREATE_SPREADSHEET_REQUEST_CODE) ? "ods" : "odp");
createNewFile(uri, extension);
open(uri);
diff --git a/android/app/src/main/res/drawable/ic_folder_black_24dp.xml b/android/app/src/main/res/drawable/ic_folder_black_24dp.xml
index 1a9a16fb1..3bd99ad87 100644
--- a/android/app/src/main/res/drawable/ic_folder_black_24dp.xml
+++ b/android/app/src/main/res/drawable/ic_folder_black_24dp.xml
@@ -1,5 +1,6 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
- android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:tint="?android:attr/colorControlNormal">
<path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
</vector>
diff --git a/android/app/src/main/res/layout/activity_document_browser.xml b/android/app/src/main/res/layout/activity_document_browser.xml
index 4ab69a188..90584e2e3 100644
--- a/android/app/src/main/res/layout/activity_document_browser.xml
+++ b/android/app/src/main/res/layout/activity_document_browser.xml
@@ -15,6 +15,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
+ android:theme="@style/LibreOfficeTheme.Base"
+ style="@style/LibreOfficeTheme.Base"
android:focusableInTouchMode="true"
android:focusable="true">
@@ -23,6 +25,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/overview_coordinator_layout"
android:layout_width="match_parent"
+ android:background="?android:attr/colorBackground"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
@@ -33,10 +36,9 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@color/toolbar_background"
android:elevation="3dp"
- app:theme="@style/LibreOfficeTheme.Toolbar"
- app:popupTheme="@style/LibreOfficeTheme"
+ app:theme="@style/LibreOfficeTheme.Base"
+ app:popupTheme="@style/LibreOfficeTheme.Base"
app:layout_scrollFlags="enterAlways|scroll" />
</com.google.android.material.appbar.AppBarLayout>
@@ -72,6 +74,7 @@
android:layout_width="96dp"
android:layout_height="match_parent"
android:layout_weight="1"
+ android:tint="?android:attr/colorControlNormal"
android:scaleType="centerInside"
app:srcCompat="@drawable/ic_list_black_24dp" />
</LinearLayout>
@@ -167,7 +170,7 @@
android:layout_marginBottom="@dimen/new_doc_fab_tweak_bottom"
android:clickable="true"
android:focusable="true"
- app:backgroundTint="@color/background_normal"
+ app:backgroundTint="?android:attr/colorPrimary"
app:fabSize="mini"
app:srcCompat="@drawable/writer"
app:useCompatPadding="true" />
@@ -200,7 +203,7 @@
android:layout_marginBottom="@dimen/new_doc_fab_tweak_bottom"
android:clickable="true"
android:focusable="true"
- app:backgroundTint="@color/background_normal"
+ app:backgroundTint="?android:attr/colorPrimary"
app:fabSize="mini"
app:srcCompat="@drawable/impress"
app:useCompatPadding="true" />
@@ -233,7 +236,7 @@
android:layout_marginBottom="@dimen/new_doc_fab_tweak_bottom"
android:clickable="true"
android:focusable="true"
- app:backgroundTint="@color/background_normal"
+ app:backgroundTint="?android:attr/colorPrimary"
app:fabSize="mini"
app:srcCompat="@drawable/calc"
app:useCompatPadding="true" />
@@ -251,9 +254,9 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
- android:background="@color/background_normal"
- android:theme="@style/LibreOfficeTheme.NavigationView"
+ android:theme="@style/LibreOfficeTheme.Base"
app:headerLayout="@layout/navigation_header"
- app:menu="@menu/navigation_menu" />
+ app:menu="@menu/navigation_menu"/>
+
</androidx.drawerlayout.widget.DrawerLayout>
diff --git a/android/app/src/main/res/layout/file_explorer_grid_item.xml b/android/app/src/main/res/layout/file_explorer_grid_item.xml
index 631168050..d67676ab9 100644
--- a/android/app/src/main/res/layout/file_explorer_grid_item.xml
+++ b/android/app/src/main/res/layout/file_explorer_grid_item.xml
@@ -41,7 +41,7 @@
android:gravity="center_vertical"
android:maxLines="2"
android:textAlignment="center"
- android:textColor="@android:color/secondary_text_light"
+ android:textColor="?android:attr/textColorPrimary"
android:textSize="15sp"
android:textStyle="bold"
tools:text="file or dirname" />
@@ -53,6 +53,7 @@
android:layout_gravity="center"
android:contentDescription="@string/file_actions_icon_desc"
android:scaleType="fitStart"
+ android:tint="?android:attr/textColorPrimary"
app:srcCompat="@drawable/ic_more_vert_black_24dp" />
</LinearLayout>
diff --git a/android/app/src/main/res/layout/file_list_item.xml b/android/app/src/main/res/layout/file_list_item.xml
index d128d913c..28c2abe6f 100644
--- a/android/app/src/main/res/layout/file_list_item.xml
+++ b/android/app/src/main/res/layout/file_list_item.xml
@@ -33,6 +33,7 @@
android:id="@+id/file_item_name"
tools:text="file or dirname"
style="@style/ListItemText"
+ android:textColor="?android:attr/textColorPrimary"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="2"
@@ -46,6 +47,7 @@
android:layout_height="match_parent"
android:layout_marginEnd="4dp"
android:textAlignment="textEnd"
+ android:textColor="?android:attr/textColorPrimary"
tools:text="0" />
<TextView
@@ -53,6 +55,7 @@
style="@style/ListItemText"
android:layout_width="30dp"
android:layout_height="match_parent"
+ android:textColor="?android:attr/textColorPrimary"
tools:text="B" />
<ImageView
@@ -61,6 +64,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/file_actions_icon_desc"
+ android:tint="?android:attr/textColorPrimary"
app:srcCompat="@drawable/ic_more_vert_black_24dp" />
<!--TextView
android:id="@+id/file_item_date"
diff --git a/android/app/src/main/res/layout/theme_selection.xml b/android/app/src/main/res/layout/theme_selection.xml
new file mode 100644
index 000000000..80ff1bd8f
--- /dev/null
+++ b/android/app/src/main/res/layout/theme_selection.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/LibreOfficeTheme.Base">
+
+ <RadioGroup
+ android:id="@+id/radioGrp_theme"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="26sp"
+ android:paddingTop="16sp">
+
+ <RadioButton
+ android:id="@+id/radioBtn_dark"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="15sp"
+ android:paddingLeft="15sp"
+ android:fontFamily="sans-serif"
+ android:text="@string/theme_dark"
+ android:textSize="18sp" />
+
+ <RadioButton
+ android:id="@+id/radioBtn_light"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="15sp"
+ android:paddingLeft="15sp"
+ android:fontFamily="sans-serif"
+ android:text="@string/theme_light"
+ android:textSize="18sp" />
+
+ <RadioButton
+ android:id="@+id/radioBtn_default"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+
+ android:paddingLeft="15sp"
+ android:fontFamily="sans-serif"
+ android:text="@string/theme_system_default"
+ android:textSize="18sp" />
+ </RadioGroup>
+</LinearLayout>
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index fa8c6f037..9cf1fcb5c 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -145,4 +145,11 @@
<string name="bmp_null">Bmp is null!</string>
<string name="directory_not_saved">Directory not saved.</string>
<string name="title_activity_show_html">About</string>
+
+ <!-- Theme settings -->
+ <string name="theme">Theme</string>
+ <string name="choose_theme">Choose theme</string>
+ <string name="theme_system_default">System default</string>
+ <string name="theme_dark">Dark</string>
+ <string name="theme_light">Light</string>
</resources>
diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml
index 8576f9c22..9e922a820 100644
--- a/android/app/src/main/res/values/themes.xml
+++ b/android/app/src/main/res/values/themes.xml
@@ -2,8 +2,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="LibreOfficeTheme" parent="LibreOfficeTheme.Base"/>
- <style name="LibreOfficeTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
- </style>
+ <style name="LibreOfficeTheme.Base" parent="Theme.AppCompat.DayNight.NoActionBar"/>
<style name="ListItemText">
<item name="android:gravity">center_vertical</item>
@@ -11,7 +10,7 @@
<item name="android:textSize">14sp</item>
</style>
- <style name="LibreOfficeTheme.Toolbar" parent="Theme.AppCompat.Light.NoActionBar">
+ <style name="LibreOfficeTheme.Toolbar" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/toolbar_background</item>
</style>
@@ -27,6 +26,6 @@
<item name="android:textStyle">bold</item>
<item name="android:typeface">normal</item>
<item name="android:padding">5dp</item>
- <item name="android:background">@drawable/label_background</item>
+ <item name="android:background">?android:attr/colorPrimary</item>
</style>
</resources>
diff --git a/android/app/src/main/res/xml/libreoffice_preferences.xml b/android/app/src/main/res/xml/libreoffice_preferences.xml
index f8a3b14f5..dac169fb5 100644
--- a/android/app/src/main/res/xml/libreoffice_preferences.xml
+++ b/android/app/src/main/res/xml/libreoffice_preferences.xml
@@ -31,6 +31,19 @@
</PreferenceCategory-->
+ <PreferenceCategory
+ android:title="@string/theme"
+ android:key="PREF_CATEGORY_THEME"
+ app:iconSpaceReserved="false" >
+
+ <Preference
+ android:title="@string/choose_theme"
+ android:key="THEME_SELECTION"
+ android:summary="@string/theme_system_default"
+ app:iconSpaceReserved="false"/>
+
+ </PreferenceCategory>
+
<PreferenceCategory
android:title="@string/pref_category_editor"
android:key="PREF_CATEGORY_EDITOR"
More information about the Libreoffice-commits
mailing list