diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-08 19:30:21 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-08 19:30:21 +0100 |
commit | ae09585ce2ebc97cad21df69b90753f7236990b6 (patch) | |
tree | fb0eb35d64b78de3b7f4240aaa434e3eaea759df /src | |
parent | e96467e5ad9e001086be19cb6521c0f59ab8fd64 (diff) |
add preferece to use unicolored background
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 13 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/SettingsActivity.java | 3 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/XmppActivity.java | 4 | ||||
-rw-r--r-- | src/main/res/layout/fragment_conversation.xml | 1 | ||||
-rw-r--r-- | src/main/res/values/defaults.xml | 1 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/main/res/xml/preferences.xml | 5 |
7 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 5a6f542f3..ef09a6a41 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -58,6 +58,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.view.menu.MenuBuilder; import androidx.appcompat.view.menu.MenuPopupHelper; import androidx.appcompat.widget.PopupMenu; +import androidx.core.content.ContextCompat; import androidx.core.view.inputmethod.InputConnectionCompat; import androidx.core.view.inputmethod.InputContentInfoCompat; import androidx.databinding.DataBindingUtil; @@ -111,6 +112,7 @@ import de.pixart.messenger.ui.util.ScrollState; import de.pixart.messenger.ui.util.SendButtonAction; import de.pixart.messenger.ui.util.SendButtonTool; import de.pixart.messenger.ui.util.ShareUtil; +import de.pixart.messenger.ui.util.StyledAttributes; import de.pixart.messenger.ui.util.ViewUtil; import de.pixart.messenger.ui.widget.EditMessage; import de.pixart.messenger.utils.Compatibility; @@ -1672,6 +1674,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } + private void updateChatBG() { + if (activity.unicoloredBG()) { + binding.conversationsFragment.setBackgroundResource(0); + binding.conversationsFragment.setBackgroundColor(StyledAttributes.getColor(activity, R.attr.color_background_tertiary)); + } else { + binding.conversationsFragment.setBackgroundColor(0); + binding.conversationsFragment.setBackground(ContextCompat.getDrawable(activity, R.drawable.chatbg)); + } + } + public void startDownloadable(Message message) { if (!hasPermissions(REQUEST_START_DOWNLOAD, Manifest.permission.WRITE_EXTERNAL_STORAGE) && !hasPermissions(REQUEST_START_DOWNLOAD, Manifest.permission.READ_EXTERNAL_STORAGE)) { this.mPendingDownloadableMessage = message; @@ -2563,6 +2575,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return; } } + updateChatBG(); this.refresh(true); } diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 68e0c9809..a85d4ddb2 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -76,6 +76,7 @@ public class SettingsActivity extends XmppActivity implements public static final String USE_INVIDIOUS = "use_invidious"; public static final String ALLOW_MESSAGE_CORRECTION = "allow_message_correction"; public static final String ENABLE_OTR_ENCRYPTION = "enable_otr_encryption"; + public static final String USE_UNICOLORED_CHATBG = "unicolored_chatbg"; public static final int REQUEST_CREATE_BACKUP = 0xbf8701; Preference multiAccountPreference; @@ -512,6 +513,8 @@ public class SettingsActivity extends XmppActivity implements xmppConnectionService.expireOldMessages(true); } else if (name.equals(THEME) || name.equals(THEME_COLOR)) { updateTheme(); + } else if (name.equals(USE_UNICOLORED_CHATBG)) { + xmppConnectionService.updateConversationUi(); } } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 9d6fd1bf6..f2a3f5c76 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -434,6 +434,10 @@ public abstract class XmppActivity extends ActionBarActivity { return getStringPreference("theme_color", R.string.theme_color); } + public boolean unicoloredBG() { + return getBooleanPreference("unicolored_chatbg", R.bool.use_unicolored_chatbg); + } + public void setBubbleColor(final View v, final int backgroundColor, final int borderColor) { GradientDrawable shape = (GradientDrawable) v.getBackground(); shape.setColor(backgroundColor); diff --git a/src/main/res/layout/fragment_conversation.xml b/src/main/res/layout/fragment_conversation.xml index 768c38647..d7f177514 100644 --- a/src/main/res/layout/fragment_conversation.xml +++ b/src/main/res/layout/fragment_conversation.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <RelativeLayout xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/conversations_fragment" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/chatbg" diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 2ccb19a1f..ecfd9b224 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -71,6 +71,7 @@ <string name="theme_color">blue</string> <string name="default_font_size">small</string> <string name="default_channel_discovery">JABBER_NETWORK</string> + <bool name="use_unicolored_chatbg">false</bool> <string-array name="domains"> <item>pix-art.de</item> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 3d9e642e0..95075eb63 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -996,4 +996,6 @@ <string name="account_status_regis_invalid_token">Invalid registration token</string> <string name="magic_create_text_fixed">You have been invited to %1$s. A username has already been picked for you. We will guide you through the process of creating an account.\nYou will be able to communicate with users of other providers by giving them your full XMPP address.</string> <string name="your_server_invitation">Your server invitation</string> + <string name="pref_use_unicolored_chatbg_summary">Use unicolored background in chats.</string> + <string name="pref_use_unicolored_chatbg">Use unicolored background</string> </resources> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index f6f018cd2..a17ef3ae2 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -36,6 +36,11 @@ android:summary="@string/pref_font_size_summary" android:title="@string/pref_font_size" /> <CheckBoxPreference + android:defaultValue="@bool/use_unicolored_chatbg" + android:key="unicolored_chatbg" + android:summary="@string/pref_use_unicolored_chatbg_summary" + android:title="@string/pref_use_unicolored_chatbg" /> + <CheckBoxPreference android:defaultValue="@bool/send_button_status" android:key="send_button_status" android:summary="@string/pref_use_send_button_to_indicate_status_summary" |