mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
Various updates to theming settings & fixes
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
a4efa5a746
commit
925ac6724e
@ -63,6 +63,14 @@ android {
|
||||
disable "ValidController"
|
||||
disable "ValidControllerChangeHandler"
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [
|
||||
parcelerStacktrace: "true"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
@ -134,9 +142,9 @@ configurations.all {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha07'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha08'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
||||
implementation 'com.github.vanniktech:Emoji:0.6.0'
|
||||
implementation group: 'androidx.emoji', name: 'emoji-bundled', version: '1.0.0'
|
||||
implementation 'org.michaelevans.colorart:library:0.0.3'
|
||||
@ -236,11 +244,3 @@ dependencies {
|
||||
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0'
|
||||
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.6'
|
||||
}
|
||||
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs +=
|
||||
['-Adagger.floatingBindsMethods=enabled',
|
||||
'-AparcelerStacktrace',]
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class MagicIncomingTextMessageViewHolder
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
|
||||
int bg_bubble_color = appPreferences.isDarkThemeEnabled() ?
|
||||
int bg_bubble_color = DisplayUtils.isDarkModeActive(context) ?
|
||||
resources.getColor(R.color.bg_message_list_incoming_bubble_dark2) :
|
||||
resources.getColor(R.color.bg_message_list_incoming_bubble);
|
||||
|
||||
|
@ -135,7 +135,6 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM
|
||||
image.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(message.getImageUrl()));
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
} else {
|
||||
|
@ -44,6 +44,9 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
||||
@Inject
|
||||
AppPreferences appPreferences;
|
||||
|
||||
@Inject
|
||||
Context context;
|
||||
|
||||
public MagicSystemMessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
@ -59,7 +62,7 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
||||
int mentionYouColor;
|
||||
int mentionOthersColor;
|
||||
|
||||
if(appPreferences.isDarkThemeEnabled()) {
|
||||
if(DisplayUtils.isDarkModeActive(context)) {
|
||||
normalColor = resources.getColor(R.color.bg_system_bubble_dark);
|
||||
mentionYouColor = resources.getColor(R.color.fg_mention_you_dark);
|
||||
mentionOthersColor = resources.getColor(R.color.fg_mention_others_dark);
|
||||
|
@ -145,7 +145,7 @@ public class NextcloudTalkApplication extends MultiDexApplication implements Lif
|
||||
|
||||
componentApplication.inject(this);
|
||||
|
||||
setAppTheme(appPreferences.isDarkThemeEnabled());
|
||||
setAppTheme(appPreferences.getTheme());
|
||||
super.onCreate();
|
||||
|
||||
ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this)
|
||||
@ -200,11 +200,21 @@ public class NextcloudTalkApplication extends MultiDexApplication implements Lif
|
||||
//endregion
|
||||
|
||||
//region Setters
|
||||
public static void setAppTheme(Boolean darkTheme) {
|
||||
if (darkTheme) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
public static void setAppTheme(String theme) {
|
||||
switch (theme) {
|
||||
case "night_no":
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
break;
|
||||
case "night_yes":
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
break;
|
||||
case "battery_saver":
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
|
||||
break;
|
||||
default:
|
||||
// will be "follow_system" only for now
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
@ -61,7 +61,7 @@ import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.preferencestorage.DatabaseStorageModule;
|
||||
import com.nextcloud.talk.utils.preferences.preferencestorage.DatabaseStorageModule;
|
||||
import com.yarolegovich.lovelydialog.LovelySaveStateHandler;
|
||||
import com.yarolegovich.lovelydialog.LovelyStandardDialog;
|
||||
import com.yarolegovich.mp.*;
|
||||
|
@ -136,9 +136,6 @@ public class SettingsController extends BaseController {
|
||||
@BindView(R.id.settings_screen_lock_timeout)
|
||||
MaterialChoicePreference screenLockTimeoutChoicePreference;
|
||||
|
||||
@BindView(R.id.settings_theme)
|
||||
MaterialSwitchPreference themeSwitchPreference;
|
||||
|
||||
@BindView(R.id.message_text)
|
||||
TextView messageText;
|
||||
@Inject
|
||||
@ -159,7 +156,7 @@ public class SettingsController extends BaseController {
|
||||
private OnPreferenceValueChangedListener<Boolean> screenSecurityChangeListener;
|
||||
private OnPreferenceValueChangedListener<Boolean> screenLockChangeListener;
|
||||
private OnPreferenceValueChangedListener<String> screenLockTimeoutChangeListener;
|
||||
private OnPreferenceValueChangedListener<Boolean> themeChangeListener;
|
||||
private OnPreferenceValueChangedListener<String> themeChangeListener;
|
||||
|
||||
private Disposable profileQueryDisposable;
|
||||
private Disposable dbQueryDisposable;
|
||||
@ -607,7 +604,6 @@ public class SettingsController extends BaseController {
|
||||
messageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
((Checkable) themeSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.isDarkThemeEnabled());
|
||||
}
|
||||
|
||||
private void loadAvatarImage() {
|
||||
@ -782,11 +778,10 @@ public class SettingsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
private class ThemeChangeListener implements OnPreferenceValueChangedListener<Boolean> {
|
||||
private class ThemeChangeListener implements OnPreferenceValueChangedListener<String> {
|
||||
@Override
|
||||
public void onChanged(Boolean newValue) {
|
||||
public void onChanged(String newValue) {
|
||||
NextcloudTalkApplication.setAppTheme(newValue);
|
||||
getActivity().recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,4 +382,16 @@ public class DisplayUtils {
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public static boolean isDarkModeActive(Context context) {
|
||||
int currentNightMode =
|
||||
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
switch (currentNightMode) {
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
return false;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,16 +266,20 @@ public interface AppPreferences {
|
||||
void unregisterScreenLockTimeoutListener(OnPreferenceValueChangedListener<String> listener);
|
||||
|
||||
@KeyByResource(R.string.nc_settings_theme_key)
|
||||
@DefaultValue(R.bool.value_false)
|
||||
boolean isDarkThemeEnabled();
|
||||
@DefaultValue(R.string.nc_default_theme)
|
||||
String getTheme();
|
||||
|
||||
@KeyByResource(R.string.nc_settings_theme_key)
|
||||
@RemoveMethod
|
||||
void removeTheme();
|
||||
|
||||
@KeyByResource(R.string.nc_settings_theme_key)
|
||||
@RegisterChangeListenerMethod
|
||||
void registerThemeChangeListener(OnPreferenceValueChangedListener<Boolean> listener);
|
||||
void registerThemeChangeListener(OnPreferenceValueChangedListener<String> listener);
|
||||
|
||||
@KeyByResource(R.string.nc_settings_theme_key)
|
||||
@UnregisterChangeListenerMethod
|
||||
void unregisterThemeChangeListener(OnPreferenceValueChangedListener<Boolean> listener);
|
||||
void unregisterThemeChangeListener(OnPreferenceValueChangedListener<String> listener);
|
||||
|
||||
@ClearMethod
|
||||
void clear();
|
||||
|
@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.utils.preferencestorage;
|
||||
package com.nextcloud.talk.utils.preferences.preferencestorage;
|
||||
|
||||
import android.content.Context;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.utils.preferencestorage;
|
||||
package com.nextcloud.talk.utils.preferences.preferencestorage;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
@ -120,12 +120,17 @@
|
||||
apc:mpc_title="@string/nc_settings_appearance"
|
||||
apc:mpc_title_color="@color/colorPrimary">
|
||||
|
||||
<com.yarolegovich.mp.MaterialSwitchPreference
|
||||
<com.yarolegovich.mp.MaterialChoicePreference
|
||||
android:id="@+id/settings_theme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
apc:mp_key="@string/nc_settings_theme_key"
|
||||
apc:mp_title="@string/nc_settings_theme_title" />
|
||||
apc:mp_title="@string/nc_settings_theme_title"
|
||||
apc:mp_default_value="@string/nc_default_theme"
|
||||
apc:mp_entry_values="@array/theme_entry_values"
|
||||
apc:mp_entry_descriptions="@array/theme_descriptions"
|
||||
apc:mp_show_value="onBottom"
|
||||
/>
|
||||
|
||||
</com.yarolegovich.mp.MaterialPreferenceCategory>
|
||||
|
||||
@ -184,7 +189,7 @@
|
||||
apc:mp_entry_values="@array/screen_lock_timeout_entry_values"
|
||||
apc:mp_entry_descriptions="@array/screen_lock_timeout_descriptions"
|
||||
apc:mp_key="@string/nc_settings_screen_lock_timeout_key"
|
||||
apc:mp_show_value="onRight"
|
||||
apc:mp_show_value="onBottom"
|
||||
apc:mp_title="@string/nc_settings_screen_lock_timeout_title" />
|
||||
|
||||
<com.yarolegovich.mp.MaterialSwitchPreference
|
||||
|
75
app/src/main/res/values-v28/arrays.xml
Normal file
75
app/src/main/res/values-v28/arrays.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<array name="proxy_type_descriptions">
|
||||
<item>@string/nc_no_proxy</item>
|
||||
<item>HTTP</item>
|
||||
<item>DIRECT</item>
|
||||
<item>SOCKS</item>
|
||||
</array>
|
||||
|
||||
<array name="message_notification_levels">
|
||||
<item>@string/nc_notify_me_never</item>
|
||||
<item>@string/nc_notify_me_mention</item>
|
||||
<item>@string/nc_notify_me_always</item>
|
||||
</array>
|
||||
|
||||
<array name="message_notification_levels_entry_values">
|
||||
<item>never</item>
|
||||
<item>mention</item>
|
||||
<item>always</item>
|
||||
</array>
|
||||
|
||||
<array name="screen_lock_timeout_descriptions">
|
||||
<item>@string/nc_screen_lock_timeout_30</item>
|
||||
<item>@string/nc_screen_lock_timeout_60</item>
|
||||
<item>@string/nc_screen_lock_timeout_300</item>
|
||||
<item>@string/nc_screen_lock_timeout_600</item>
|
||||
</array>
|
||||
|
||||
<array name="screen_lock_timeout_entry_values">
|
||||
<item>@string/nc_screen_lock_timeout_thirty</item>
|
||||
<item>@string/nc_screen_lock_timeout_sixty</item>
|
||||
<item>@string/nc_screen_lock_timeout_three_hundred</item>
|
||||
<item>@string/nc_screen_lock_timeout_six_hundred</item>
|
||||
</array>
|
||||
|
||||
<array name="screen_lock_timeout_entry_int_values">
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>300</item>
|
||||
<item>600</item>
|
||||
</array>
|
||||
|
||||
<array name="theme_descriptions">
|
||||
<item>@string/nc_settings_theme_follow_system</item>
|
||||
<item>@string/nc_settings_theme_light</item>
|
||||
<item>@string/nc_settings_theme_dark</item>
|
||||
</array>
|
||||
|
||||
<array name="theme_entry_values">
|
||||
<item>@string/nc_settings_theme_follow_system_key</item>
|
||||
<item>@string/nc_settings_theme_light_key</item>
|
||||
<item>night_yes</item>
|
||||
</array>
|
||||
|
||||
</resources>
|
24
app/src/main/res/values-v28/defaults.xml
Normal file
24
app/src/main/res/values-v28/defaults.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="nc_default_theme">@string/nc_settings_theme_follow_system_key</string>
|
||||
</resources>
|
@ -60,4 +60,16 @@
|
||||
<item>600</item>
|
||||
</array>
|
||||
|
||||
<array name="theme_descriptions">
|
||||
<item>@string/nc_settings_theme_battery_saver</item>
|
||||
<item>@string/nc_settings_theme_light</item>
|
||||
<item>@string/nc_settings_theme_dark</item>
|
||||
</array>
|
||||
|
||||
<array name="theme_entry_values">
|
||||
<item>@string/nc_settings_theme_battery_saver_key</item>
|
||||
<item>@string/nc_settings_theme_light_key</item>
|
||||
<item>night_yes</item>
|
||||
</array>
|
||||
|
||||
</resources>
|
||||
|
24
app/src/main/res/values/defaults.xml
Normal file
24
app/src/main/res/values/defaults.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="nc_default_theme">@string/nc_settings_theme_battery_saver_key</string>
|
||||
</resources>
|
@ -91,6 +91,11 @@
|
||||
<string name="nc_settings_appearance">Appearance</string>
|
||||
<string name="nc_settings_theme_title">Theme</string>
|
||||
<string name="nc_settings_theme_key">theme</string>
|
||||
<string name="nc_settings_theme_battery_saver_key" translatable="false">battery_saver</string>
|
||||
<string name="nc_settings_theme_follow_system_key" translatable="false">follow_system</string>
|
||||
<string name="nc_settings_theme_light_key" translatable="false">night_no</string>
|
||||
<string name="nc_settings_theme_follow_system">Use system default</string>
|
||||
<string name="nc_settings_theme_battery_saver">Set by Battery Saver</string>
|
||||
<string name="nc_settings_theme_light">Light</string>
|
||||
<string name="nc_settings_theme_dark">Dark</string>
|
||||
<string name="nc_settings_privacy">Privacy</string>
|
||||
|
Loading…
Reference in New Issue
Block a user