mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 11:48:35 +00:00
Fix theming issue in CameraContactSelectionFragment.
This commit is contained in:
parent
739e38a047
commit
e62e630987
@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.InviteActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
|
||||
@ -75,8 +76,8 @@ public class CameraContactSelectionFragment extends Fragment implements CameraCo
|
||||
|
||||
@Override
|
||||
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
int theme = TextSecurePreferences.getTheme(inflater.getContext()).equals("light") ? R.style.TextSecure_LightTheme
|
||||
: R.style.TextSecure_DarkTheme;
|
||||
int theme = DynamicTheme.isDarkTheme(inflater.getContext()) ? R.style.TextSecure_DarkTheme
|
||||
: R.style.TextSecure_LightTheme;
|
||||
return ThemeUtil.getThemedInflater(inflater.getContext(), inflater, theme)
|
||||
.inflate(R.layout.camera_contact_selection_fragment, container, false);
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
@ -35,15 +35,7 @@ public class DynamicTheme {
|
||||
}
|
||||
|
||||
private @StyleRes int getSelectedTheme(Activity activity) {
|
||||
String theme = TextSecurePreferences.getTheme(activity);
|
||||
|
||||
if (theme.equals(SYSTEM) && systemThemeAvailable()) {
|
||||
if (isSystemInDarkTheme(activity)) {
|
||||
return getDarkThemeStyle();
|
||||
} else {
|
||||
return getLightThemeStyle();
|
||||
}
|
||||
} else if (theme.equals(DARK)) {
|
||||
if (isDarkTheme(activity)) {
|
||||
return getDarkThemeStyle();
|
||||
} else {
|
||||
return getLightThemeStyle();
|
||||
@ -62,8 +54,21 @@ public class DynamicTheme {
|
||||
return Build.VERSION.SDK_INT >= 29;
|
||||
}
|
||||
|
||||
private static boolean isSystemInDarkTheme(@NonNull Activity activity) {
|
||||
return (activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
|
||||
/**
|
||||
* Takes the system theme into account.
|
||||
*/
|
||||
public static boolean isDarkTheme(@NonNull Context context) {
|
||||
String theme = TextSecurePreferences.getTheme(context);
|
||||
|
||||
if (theme.equals(SYSTEM) && systemThemeAvailable()) {
|
||||
return isSystemInDarkTheme(context);
|
||||
} else {
|
||||
return theme.equals(DARK);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSystemInDarkTheme(@NonNull Context context) {
|
||||
return (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
private static final class OverridePendingTransition {
|
||||
|
Loading…
x
Reference in New Issue
Block a user