-
Notifications
You must be signed in to change notification settings - Fork 18
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
#16 Add dark mode #26
Conversation
@@ -40,6 +42,7 @@ public class AboutActivity extends AppCompatActivity { | |||
|
|||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setTheme(GetThemeRes(getApplicationContext())); |
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.
Afaik, we need to set the theme per activity
else | ||
setColor(context.getResources().getColor(R.color.button_empty_2)); | ||
|
||
setColor(GetColorRes(context, R.attr.buttonEmpty)); |
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 difference in colors are now handled by the ThemeResolver file
setContentView(R.layout.activity_settings); | ||
|
||
//setupActionBar(); | ||
|
||
overridePendingTransition(0, 0); | ||
} | ||
|
||
@Override | ||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { |
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.
This is to have an instant change in themes when selecting it in the menu
import org.secuso.privacyfriendly2048.R | ||
|
||
@StyleRes | ||
fun GetThemeRes(ctx: Context): Int { |
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.
This function returns the correct style depending on preferences/settings
} | ||
|
||
@ColorRes | ||
fun GetColorRes(ctx: Context, res: Int): Int { |
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.
This function returns the correct color depending on the color scheme chosen through preferences/settings
} | ||
|
||
@ColorInt | ||
fun GetColorInt(ctx: Context, res: Int): Int { |
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 setTextColor
requires an actual color instead of a reference like the GetColorRes
function. Somehow it works if I just cast the reference to an int
# Conflicts: # app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java
- Check preferences in `PF2048.kt` once instead of in every activity - Use AppCompatDelegate to set the theme
- Fix the warning/error `View class org.secuso.privacyfriendly2048.activities.Element is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).` by switching from the applicationContext to the activity
Thank you for the work you've put into this pull request. I wanted to look into it quite some time ago, but had other things to do and forgot about it. |
My pleasure! It should definitely be well tested. Let me know if you need/want me to do some testing |
privacy
This PR closes #16 by implementing theme switching functionality and a dark theme based on native Android dark mode colors. Images should still be updated to fit the dark background.
Let me know if I missed something and I'll sort it out. I'm not an Android developer, so I apologize for any silly mistakes.