From 63d442584c1bf0c8919793f1f20dae0cacde690d Mon Sep 17 00:00:00 2001 From: Andrew Gallasch Date: Thu, 13 Apr 2023 16:24:03 +0930 Subject: [PATCH 1/5] Fix empty message behind media message (#1150) --- .../conversation/v2/messages/VisibleMessageContentView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index 8c33e4473c..75a3c58752 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -10,10 +10,8 @@ import android.text.style.ForegroundColorSpan import android.text.style.URLSpan import android.text.util.Linkify import android.util.AttributeSet -import android.view.LayoutInflater import android.view.MotionEvent import android.view.View -import android.widget.LinearLayout import androidx.annotation.ColorInt import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout @@ -22,6 +20,7 @@ import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat import androidx.core.text.getSpans import androidx.core.text.toSpannable +import androidx.core.view.children import androidx.core.view.isVisible import network.loki.messenger.R import network.loki.messenger.databinding.ViewVisibleMessageContentBinding @@ -223,6 +222,7 @@ class VisibleMessageContentView : ConstraintLayout { } binding.bodyTextView.isVisible = message.body.isNotEmpty() && !hideBody + binding.contentParent.apply { isVisible = children.any { it.isVisible } } if (message.body.isNotEmpty() && !hideBody) { val color = getTextColor(context, message) From 7d33177e065099d1709045b97d820c624a92707b Mon Sep 17 00:00:00 2001 From: Andrew Gallasch Date: Wed, 26 Apr 2023 14:18:34 +0930 Subject: [PATCH 2/5] Fix status and nav bar colors (#1165) --- .../org/thoughtcrime/securesms/BaseActionBarActivity.java | 7 +++++++ app/src/main/res/values-v27/colors.xml | 5 +++++ app/src/main/res/values/colors.xml | 3 +++ app/src/main/res/values/themes.xml | 8 ++++---- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/values-v27/colors.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/BaseActionBarActivity.java b/app/src/main/java/org/thoughtcrime/securesms/BaseActionBarActivity.java index 7d82c760cc..51f66ec323 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/BaseActionBarActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/BaseActionBarActivity.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms; +import static android.os.Build.VERSION.SDK_INT; import static org.session.libsession.utilities.TextSecurePreferences.SELECTED_ACCENT_COLOR; import android.app.ActivityManager; @@ -18,6 +19,7 @@ import androidx.appcompat.app.AppCompatActivity; import org.session.libsession.utilities.TextSecurePreferences; import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper; import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper; +import org.thoughtcrime.securesms.conversation.v2.WindowUtil; import org.thoughtcrime.securesms.util.ActivityUtilitiesKt; import org.thoughtcrime.securesms.util.ThemeState; import org.thoughtcrime.securesms.util.UiModeUtilities; @@ -92,6 +94,11 @@ public abstract class BaseActionBarActivity extends AppCompatActivity { if (!currentThemeState.equals(ActivityUtilitiesKt.themeState(getPreferences()))) { recreate(); } + + // apply lightStatusBar manually as API 26 does not update properly via applyTheme + // https://issuetracker.google.com/issues/65883460?pli=1 + if (SDK_INT >= 26 && SDK_INT <= 27) WindowUtil.setLightStatusBarFromTheme(this); + if (SDK_INT == 27) WindowUtil.setLightNavigationBarFromTheme(this); } @Override diff --git a/app/src/main/res/values-v27/colors.xml b/app/src/main/res/values-v27/colors.xml new file mode 100644 index 0000000000..5c5e9494f1 --- /dev/null +++ b/app/src/main/res/values-v27/colors.xml @@ -0,0 +1,5 @@ + + + @color/classic_light_6 + @color/ocean_light_7 + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d3b9d9b255..196e587cdc 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -60,6 +60,9 @@ #40ffffff #aaffffff + @color/compose_view_background + @color/navigation_bar + @color/navigation_bar @color/gray65 #22000000 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 2874d42972..43d06ee7ad 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -326,7 +326,7 @@ ?android:textColorPrimary @color/gray27 ?colorPrimary - @color/compose_view_background + @color/navigation_bar @color/classic_dark_1 @style/Classic.Dark.BottomSheet ?android:textColorPrimary @@ -404,7 +404,7 @@ ?android:textColorPrimary @color/gray27 ?colorPrimary - ?colorPrimary + @color/classic_light_navigation_bar @color/classic_light_6 @color/classic_light_5 @color/classic_light_3 @@ -490,7 +490,7 @@ @color/ocean_dark_5 ?colorPrimary @color/default_background_start - @color/compose_view_background + @color/navigation_bar ?colorPrimary ?colorPrimaryDark @color/ocean_dark_3 @@ -570,7 +570,7 @@ @color/ocean_light_2 ?android:textColorPrimary @color/ocean_light_6 - @color/ocean_light_7 + @color/ocean_light_navigation_bar ?colorPrimary @color/default_background_start @color/ocean_light_7 From 716fc1f4fa840efee4e4dfb3c6596273c083aa62 Mon Sep 17 00:00:00 2001 From: Andrew Gallasch Date: Wed, 26 Apr 2023 14:24:54 +0930 Subject: [PATCH 3/5] Add SafeViewPager to fix touch exception in MediaPreviewActivity (#1166) --- .../securesms/components/SafeViewPager.kt | 30 +++++++++++++++++++ .../res/layout/media_preview_activity.xml | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/components/SafeViewPager.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/SafeViewPager.kt b/app/src/main/java/org/thoughtcrime/securesms/components/SafeViewPager.kt new file mode 100644 index 0000000000..6748478736 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/components/SafeViewPager.kt @@ -0,0 +1,30 @@ +package org.thoughtcrime.securesms.components + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import androidx.viewpager.widget.ViewPager + +/** + * An extension of ViewPager to swallow erroneous multi-touch exceptions. + * + * @see https://stackoverflow.com/questions/6919292/pointerindex-out-of-range-android-multitouch + */ +class SafeViewPager @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : ViewPager(context, attrs) { + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(event: MotionEvent?): Boolean = try { + super.onTouchEvent(event) + } catch (e: IllegalArgumentException) { + false + } + + override fun onInterceptTouchEvent(event: MotionEvent?): Boolean = try { + super.onInterceptTouchEvent(event) + } catch (e: IllegalArgumentException) { + false + } +} diff --git a/app/src/main/res/layout/media_preview_activity.xml b/app/src/main/res/layout/media_preview_activity.xml index 2f6aaff454..78327b6cc3 100644 --- a/app/src/main/res/layout/media_preview_activity.xml +++ b/app/src/main/res/layout/media_preview_activity.xml @@ -22,7 +22,7 @@ - Date: Wed, 26 Apr 2023 14:26:00 +0930 Subject: [PATCH 4/5] Remove unnecessary api version checks in WindowUtil (#1163) --- .../securesms/conversation/v2/WindowUtil.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/WindowUtil.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/WindowUtil.java index 4bff4e76aa..6083bb267c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/WindowUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/WindowUtil.java @@ -38,14 +38,10 @@ public final class WindowUtil { } public static void setNavigationBarColor(@NonNull Window window, @ColorInt int color) { - if (Build.VERSION.SDK_INT < 21) return; - window.setNavigationBarColor(color); } public static void setLightStatusBarFromTheme(@NonNull Activity activity) { - if (Build.VERSION.SDK_INT < 23) return; - final boolean isLightStatusBar = ThemeUtil.getThemedBoolean(activity, android.R.attr.windowLightStatusBar); if (isLightStatusBar) setLightStatusBar(activity.getWindow()); @@ -53,20 +49,14 @@ public final class WindowUtil { } public static void clearLightStatusBar(@NonNull Window window) { - if (Build.VERSION.SDK_INT < 23) return; - clearSystemUiFlags(window, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } public static void setLightStatusBar(@NonNull Window window) { - if (Build.VERSION.SDK_INT < 23) return; - setSystemUiFlags(window, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } public static void setStatusBarColor(@NonNull Window window, @ColorInt int color) { - if (Build.VERSION.SDK_INT < 21) return; - window.setStatusBarColor(color); } From ffef98ecc93780e367ebe08cb8a621e51cd86cf8 Mon Sep 17 00:00:00 2001 From: Andrew Gallasch Date: Wed, 26 Apr 2023 14:29:32 +0930 Subject: [PATCH 5/5] Fix LandingActivity textColor (#1159) --- app/src/main/res/values/styles.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 5f9ee03168..1cf88c0c06 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -228,11 +228,13 @@