implement the actual theme change
This commit is contained in:
parent
45527473e3
commit
c771904361
|
@ -47,7 +47,9 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/settings"/>
|
||||
android:allowTaskReparenting="true"
|
||||
android:label="@string/settings"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
|
||||
<receiver
|
||||
android:name=".MyWidgetProvider"
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Intent;
|
|||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
|
@ -21,7 +20,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
public class AboutActivity extends SimpleActivity {
|
||||
@BindView(R.id.about_copyright) TextView mCopyright;
|
||||
@BindView(R.id.about_email) TextView mEmailTV;
|
||||
@BindView(R.id.about_rate_us) View mRateUs;
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.os.Bundle;
|
|||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
|
@ -40,7 +39,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class DayActivity extends AppCompatActivity
|
||||
public class DayActivity extends SimpleActivity
|
||||
implements DBHelper.DBOperationsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener {
|
||||
@BindView(R.id.top_text) TextView mDateTV;
|
||||
@BindView(R.id.day_events) ListView mEventsList;
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.app.TimePickerDialog;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.AppCompatSpinner;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -34,7 +33,7 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnClick;
|
||||
import butterknife.OnItemSelected;
|
||||
|
||||
public class EventActivity extends AppCompatActivity implements DBHelper.DBOperationsListener {
|
||||
public class EventActivity extends SimpleActivity implements DBHelper.DBOperationsListener {
|
||||
@BindView(R.id.event_start_date) TextView mStartDate;
|
||||
@BindView(R.id.event_start_time) TextView mStartTime;
|
||||
@BindView(R.id.event_end_date) TextView mEndDate;
|
||||
|
|
|
@ -3,14 +3,13 @@ package com.simplemobiletools.calendar.activities;
|
|||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.simplemobiletools.calendar.R;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class LicenseActivity extends AppCompatActivity {
|
||||
public class LicenseActivity extends SimpleActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.PorterDuff;
|
|||
import android.os.Bundle;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -37,7 +36,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements Calendar {
|
||||
public class MainActivity extends SimpleActivity implements Calendar {
|
||||
@BindView(R.id.top_left_arrow) ImageView mLeftArrow;
|
||||
@BindView(R.id.top_right_arrow) ImageView mRightArrow;
|
||||
@BindView(R.id.top_text) TextView mMonthTV;
|
||||
|
@ -62,11 +61,12 @@ public class MainActivity extends AppCompatActivity implements Calendar {
|
|||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
final int baseColor = mConfig.getIsDarkTheme() ? Color.WHITE : Color.BLACK;
|
||||
mRes = getResources();
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
mTextColor = Utils.adjustAlpha(Color.BLACK, Constants.HIGH_ALPHA);
|
||||
mTextColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA);
|
||||
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA);
|
||||
mWeakTextColor = Utils.adjustAlpha(Color.BLACK, Constants.LOW_ALPHA);
|
||||
mWeakTextColor = Utils.adjustAlpha(baseColor, Constants.LOW_ALPHA);
|
||||
mWeakTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.LOW_ALPHA);
|
||||
mLeftArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||
mRightArrow.getDrawable().mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simplemobiletools.calendar.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
||||
import com.simplemobiletools.calendar.Config;
|
||||
|
@ -11,7 +11,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
public class SettingsActivity extends SimpleActivity {
|
||||
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
|
||||
|
||||
private static Config mConfig;
|
||||
|
@ -34,5 +34,10 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
public void handleDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
|
||||
mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked());
|
||||
restartActivity();
|
||||
}
|
||||
|
||||
private void restartActivity() {
|
||||
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.simplemobiletools.calendar.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.simplemobiletools.calendar.Config;
|
||||
import com.simplemobiletools.calendar.R;
|
||||
|
||||
public class SimpleActivity extends AppCompatActivity {
|
||||
protected Config mConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
mConfig = Config.newInstance(getApplicationContext());
|
||||
setTheme(mConfig.getIsDarkTheme() ? R.style.AppTheme_Dark : R.style.AppTheme);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,19 @@
|
|||
<item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dark" parent="Theme.AppCompat">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="buttonStyle">@style/MyButton</item>
|
||||
<item name="android:buttonStyle">@style/MyButton</item>
|
||||
<item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
|
||||
<item name="android:textSize">@dimen/normal_text_size</item>
|
||||
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
|
||||
<item name="spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
|
||||
<item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
|
||||
</style>
|
||||
|
||||
<style name="DayView">
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:textSize">@dimen/day_text_size</item>
|
||||
|
|
Loading…
Reference in New Issue