mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-31 02:44:57 +01:00
convert settings to kotlin
This commit is contained in:
parent
964c1ed7d1
commit
df0fcfcf4f
@ -1,63 +0,0 @@
|
||||
package com.simplemobiletools.calendar.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
||||
import com.simplemobiletools.calendar.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SettingsActivity extends SimpleActivity {
|
||||
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
|
||||
@BindView(R.id.settings_sunday_first) SwitchCompat mSundayFirstSwitch;
|
||||
@BindView(R.id.settings_week_numbers) SwitchCompat mWeekNumbersSwitch;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setupDarkTheme();
|
||||
setupSundayFirst();
|
||||
setupWeekNumbers();
|
||||
}
|
||||
|
||||
private void setupDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
|
||||
}
|
||||
|
||||
private void setupSundayFirst() {
|
||||
mSundayFirstSwitch.setChecked(mConfig.getIsSundayFirst());
|
||||
}
|
||||
|
||||
private void setupWeekNumbers() {
|
||||
mWeekNumbersSwitch.setChecked(mConfig.getDisplayWeekNumbers());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_dark_theme_holder)
|
||||
public void handleDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
|
||||
mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked());
|
||||
restartActivity();
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_sunday_first_holder)
|
||||
public void handleSundayFirst() {
|
||||
mSundayFirstSwitch.setChecked(!mSundayFirstSwitch.isChecked());
|
||||
mConfig.setIsSundayFirst(mSundayFirstSwitch.isChecked());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_week_numbers_holder)
|
||||
public void handleWeekNumbers() {
|
||||
mWeekNumbersSwitch.setChecked(!mWeekNumbersSwitch.isChecked());
|
||||
mConfig.setDisplayWeekNumbers(mWeekNumbersSwitch.isChecked());
|
||||
}
|
||||
|
||||
private void restartActivity() {
|
||||
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.simplemobiletools.calendar.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.TaskStackBuilder
|
||||
import com.simplemobiletools.calendar.R
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
setupDarkTheme()
|
||||
setupSundayFirst()
|
||||
setupWeekNumbers()
|
||||
}
|
||||
|
||||
private fun setupDarkTheme() {
|
||||
settings_dark_theme.isChecked = mConfig.isDarkTheme
|
||||
settings_dark_theme_holder.setOnClickListener {
|
||||
settings_dark_theme.toggle()
|
||||
mConfig.isDarkTheme = settings_dark_theme.isChecked
|
||||
restartActivity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSundayFirst() {
|
||||
settings_sunday_first.isChecked = mConfig.isSundayFirst
|
||||
settings_sunday_first_holder.setOnClickListener {
|
||||
settings_sunday_first.toggle()
|
||||
mConfig.isSundayFirst = settings_sunday_first.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupWeekNumbers() {
|
||||
settings_week_numbers!!.isChecked = mConfig.displayWeekNumbers
|
||||
settings_week_numbers_holder.setOnClickListener {
|
||||
settings_week_numbers.toggle()
|
||||
mConfig.displayWeekNumbers = settings_week_numbers.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun restartActivity() {
|
||||
TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user