-
-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android] Implement Light, Dark, and System modes on android(Auto) #8309
base: master
Are you sure you want to change the base?
Conversation
Really good changes 🙂 |
Thanks! |
I prefer 4 options
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It would be better to merge this PR first, and implement "Follow the sun" behavior separately, if needed.
android:windowSoftInputMode="stateVisible"/> | ||
<activity | ||
android:name="app.organicmaps.widget.placepage.PlaceDescriptionActivity" | ||
android:configChanges="uiMode" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to automatically add it to any activity without explicitly specifying everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XML attributes are only inherited by activities that actualy inherit (in java) other activities. So we were able to reduce the number of 'android:configChanges="uiMode"' by adding the BaseMwmFragmentActivity to the manifest and giving it that attribute.
However, any activity that specifies its configChanges, has to have "uiMode" set explicitly
@@ -103,6 +105,11 @@ protected void onDestroy() | |||
mPermissionRequest = null; | |||
} | |||
|
|||
@Override | |||
public void onConfigurationChanged(@NonNull Configuration newConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void onConfigurationChanged(@NonNull Configuration newConfig) { | |
public void onConfigurationChanged(@NonNull Configuration newConfig) | |
{ |
@@ -128,6 +130,12 @@ public void onPostResume() | |||
} | |||
} | |||
|
|||
@Override | |||
public void onConfigurationChanged(@NonNull Configuration newConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void onConfigurationChanged(@NonNull Configuration newConfig) { | |
public void onConfigurationChanged(@NonNull Configuration newConfig) | |
{ |
if (themeMode.equals(followSystemTheme)) { | ||
return ThemeMode.FOLLOW_SYSTEM; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One-liners don't need braces.
if (themeMode.equals(followSystemTheme)) { | |
return ThemeMode.FOLLOW_SYSTEM; | |
} | |
if (themeMode.equals(followSystemTheme)) | |
return ThemeMode.FOLLOW_SYSTEM; |
mAutoThemeChecker.run(); | ||
return; | ||
} | ||
System.out.println("theme:" + theme); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to add a formatter. A lot of time and effort is spent on these nit comments.
@Framework.MapStyle | ||
int oldStyle = Framework.nativeGetMapStyle(); | ||
|
||
private int getStyle(@NonNull String theme) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private int getStyle(@NonNull String theme) { | |
private int getStyle(@NonNull String theme) | |
{ |
else | ||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); | ||
|
||
if (ThemeUtils.isNightTheme(mContext, theme)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ThemeUtils.isNightTheme(mContext, theme)) { | |
if (ThemeUtils.isNightTheme(mContext, theme)) | |
{ |
else | ||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); | ||
|
||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
} | |
else | |
{ |
@@ -45,6 +47,25 @@ public static int getResource(@NonNull Context context, @AttrRes int style, @Att | |||
return VALUE_BUFFER.resourceId; | |||
} | |||
|
|||
public static String getAndroidTheme(@NonNull Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix braces in other places.
@@ -97,39 +97,39 @@ | |||
android:summary="@string/enable_show_on_lock_screen_description" | |||
android:defaultValue="true" | |||
android:order="17"/> | |||
<ListPreference | |||
android:key="@string/pref_map_style" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indentation?
closes organicmaps#749 Changed from the existing night modes (on, off, auto), to "appearence" modes: - Light; - Dark; - System; System mode follows whatever mode the user's device is in. This implementation works for both normal android and AndroidAuto. Main changes: - added necessary strings to XML files; - changed the position and option names of the "map style preferences"; - implemented system mode, and some helper methods on ThemeSwitcher.java and ThemeUtils.java; - added uiMode changes detection to all activities; - removed "auto" mode implementation; Signed-off-by: Sebastiao Sousa <[email protected]> Co-authored-by: Francisco Nael Salgado <[email protected]>
Added system, light, and dark to strings.txt. Modified pref_map_style_title from Night Mode to Appearance Signed-off-by: Sebastiao Sousa <[email protected]> Co-authored-by: Francisco Nael Salgado <[email protected]>
Sorry for the formatting mistakes! |
Signed-off-by: Sebastião Andrade e Sousa <[email protected]> Co-authored-by: Francisco Nael Salgado <[email protected]>
eu = Argi | ||
fa = نور | ||
fi = Vaalea | ||
fr = Claire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fr = Claire | |
fr = Clair |
Hi, thanks for contributing. This PR is my backlog and I will try to review and test it quickly. Please be patient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Pixel 6 - Android 14
How system value works on device using Android 8 or Android 5 (In this version native settings to update theme device doesn't exist) ?
Change Android theme settings is not seen by the app when users is in OSM profile fragment and about fragment
Are these fragments recolored when they are closed/opened again? |
To refresh theme, that's require switch to another screen on app. |
I will look into it! |
closes #749
Changed from the existing night modes (on, off, auto), to "appearence" modes:
- Light;
- Dark;
- System;
System mode follows whatever mode the user's device is in. This implementation works for both normal android and AndroidAuto.
Main changes:
- added necessary strings to XML files;
- changed the position and option names of the "map style preferences";
- implemented system mode, and some helper methods on ThemeSwitcher.java and ThemeUtils.java;
- added uiMode changes detection to all activities;
- removed "auto" mode implementation;
Co-authored-by: Francisco Nael Salgado [email protected]