mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Extend from AppCompatActivity instead of Activity
This commit is contained in:
parent
75f2201000
commit
8cc51c4dd9
6 changed files with 15 additions and 49 deletions
|
|
@ -1,37 +0,0 @@
|
|||
package fr.free.nrw.commons.theme;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
|
||||
public class BaseActivity extends Activity {
|
||||
boolean currentTheme;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true)) {
|
||||
currentTheme = true;
|
||||
setTheme(R.style.DarkAppTheme);
|
||||
}else {
|
||||
currentTheme = false;
|
||||
setTheme(R.style.LightAppTheme); // default
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
// Restart activity if theme is changed
|
||||
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",true);
|
||||
if(currentTheme!=newTheme){ // is activity theme changed
|
||||
Intent intent = getIntent();
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue