Commit 8c7b68eb authored by michael lundquist's avatar michael lundquist

Dynamic theme changing is mostly done, but it doesn't work. I'm going to...

Dynamic theme changing is mostly done, but it doesn't work. I'm going to checkout master to debug the issue.
parent fc69eed7
Pipeline #3029 passed with stages
in 3 minutes and 16 seconds
package srct.whatsopen.views.activities;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import srct.whatsopen.R;
public abstract class BaseThemeActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle bundle) {
setTheme(R.style.darkTheme);
protected void onCreate(Bundle bundle) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean dark = prefs.getBoolean("dark_theme", false);
// look at the udacity course. In this section you might want to reload,
// but this would mean every activity would have to set the right theme
if(dark){
//setTheme(R.style.darkTheme);
Log.e("Mike's log", "BaseThemeActivity: dark");
}else{
//setTheme(R.style.AppTheme);
Log.e("Mike's log", "BaseThemeActivity: light");
}
super.onCreate(bundle);
}
}
......@@ -42,7 +42,7 @@ import srct.whatsopen.presenters.FacilityPresenter;
import srct.whatsopen.views.fragments.NotificationDialogFragment;
public class DetailActivity extends AppCompatActivity implements FacilityView,
public class DetailActivity extends BaseThemeActivity implements FacilityView,
NotificationDialogFragment.NotificationDialogListener {
@BindView(R.id.open_status)
......
......@@ -27,7 +27,7 @@ import srct.whatsopen.views.adapters.FacilityListAdapter;
import srct.whatsopen.views.adapters.FacilityListFragmentPagerAdapter;
import srct.whatsopen.views.fragments.FacilityListFragment;
public class MainActivity extends AppCompatActivity implements MainView {
public class MainActivity extends BaseThemeActivity implements MainView {
@BindView(R.id.progress_bar)
ProgressBar mProgressBar;
......
......@@ -16,7 +16,7 @@ import srct.whatsopen.MyApplication;
import srct.whatsopen.R;
import srct.whatsopen.views.fragments.SettingsFragment;
public class SettingsActivity extends AppCompatActivity {
public class SettingsActivity extends BaseThemeActivity {
private SharedPreferences mSharedPreferences;
......@@ -75,17 +75,7 @@ public class SettingsActivity extends AppCompatActivity {
MyApplication.setRotation(SettingsActivity.this);
}else if (key.equals("dark_theme")){
boolean dark = prefs.getBoolean("dark_theme", false);
// look at the udacity course. In this section you might want to reload,
// but this would mean every activity would have to set the right theme
/*
if(dark){
setTheme(R.style.darkTheme);
}else{
setTheme(R.style.AppTheme);
}
*/
String darkText = dark?"dark":"light";//TODO: remove this after you set the theme
Log.e("Mike's log", "onSharedPreferenceChanged: " + darkText);
finish();
......
......@@ -18,7 +18,7 @@
android:entryValues="@array/entryvalues_list_view_default_tab_preference" />
<SwitchPreference
android:defaultValue="true"
android:defaultValue="false"
android:key="dark_theme"
android:title="@string/title_dark_theme"
android:entries="@array/entries_list_view_default_tab_preference"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment