mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Move theme checkbox to settings activity
This commit is contained in:
parent
c7909b4f66
commit
7e256175dc
23 changed files with 118 additions and 121 deletions
|
|
@ -0,0 +1,39 @@
|
|||
package fr.free.nrw.commons.theme;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
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",false)) {
|
||||
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
|
||||
Log.d("deneme","onResume Base");
|
||||
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false);
|
||||
if(currentTheme!=newTheme){ //is activity theme changed
|
||||
Intent intent = getIntent();
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package fr.free.nrw.commons.theme;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
|
||||
public class BaseAppCompatActivity extends AppCompatActivity {
|
||||
boolean currentTheme;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false)) {
|
||||
currentTheme = true;g
|
||||
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
|
||||
Log.d("deneme","onResume Base");
|
||||
boolean newTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme",false);
|
||||
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