Add theme

This commit is contained in:
icewithcola 2024-06-02 00:42:29 +08:00
parent 96dd0869d4
commit b781948911
26 changed files with 486 additions and 39 deletions

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidTestResultsUserPreferences">
<option name="androidTestResultsTableState">
<map>
<entry key="231168827">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Resizable_Experimental_API_34" value="120" />
<entry key="Tests" value="360" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
<entry key="383667187">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Resizable_Experimental_API_34" value="120" />
<entry key="Tests" value="360" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
<entry key="1145031456">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Resizable_Experimental_API_34" value="120" />
<entry key="Tests" value="360" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
</map>
</option>
</component>
</project>

View file

@ -1,6 +1,7 @@
plugins { plugins {
alias(libs.plugins.androidApplication) alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid) alias(libs.plugins.jetbrainsKotlinAndroid)
} }
android { android {
@ -43,6 +44,9 @@ android {
androidResources { androidResources {
generateLocaleConfig = true generateLocaleConfig = true
} }
buildFeatures{
viewBinding = true
}
} }
dependencies { dependencies {
@ -68,6 +72,8 @@ dependencies {
implementation(libs.androidx.annotation) implementation(libs.androidx.annotation)
implementation(libs.androidx.lifecycle.livedata.ktx) implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx) implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.datastore.rxjava3)
implementation(libs.androidx.datastore.preferences)
testImplementation(libs.junit) testImplementation(libs.junit)

View file

@ -0,0 +1,31 @@
package uk.kagurach.android101
import org.junit.Assert
import org.junit.Test
import uk.kagurach.android101.helper.ColorHelper
import org.junit.runner.RunWith
class TestColorHelper {
val colorHelper = ColorHelper()
@Test
fun Test_toColorInt(){
Assert.assertEquals(0,colorHelper.toColorInt(0, 0, 0))
Assert.assertEquals(0xfffffe,colorHelper.toColorInt(255, 0xff, 254))
}
@Test(expected = Exception::class)
fun Test_error(){
val wtf1 = colorHelper.toColorInt(-1,256,1)
}
@Test
fun Test_toString(){
Assert.assertEquals("$000000",colorHelper.toString(0,"$"))
Assert.assertEquals("#ffffff",colorHelper.toString(0xffffff))
Assert.assertEquals("#ABCD12",colorHelper.toString(0xabcd12, upperCase = true))
}
}

View file

@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<application <application
@ -14,6 +13,9 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Android101"> android:theme="@style/Theme.Android101">
<activity
android:name=".SettingPage"
android:exported="false" />
<receiver <receiver
android:name=".misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver" android:name=".misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver"
@ -21,7 +23,7 @@
android:exported="true" android:exported="true"
android:permission="android.permission.VIBRATE"> android:permission="android.permission.VIBRATE">
<intent-filter> <intent-filter>
<action android:name="uk.kagurach.android101.vibrationBroadcastReceiver"/> <action android:name="uk.kagurach.android101.vibrationBroadcastReceiver" />
</intent-filter> </intent-filter>
</receiver> </receiver>

View file

@ -0,0 +1,14 @@
package uk.kagurach.android101
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.runBlocking
open class KaBaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val storage = SettingStorage(this)
this.setTheme(runBlocking { storage.getDefaultTheme() })
}
}

View file

@ -27,7 +27,7 @@ import java.util.Arrays;
import uk.kagurach.android101.helper.PageHelper; import uk.kagurach.android101.helper.PageHelper;
public class MainActivity extends AppCompatActivity { public class MainActivity extends KaBaseActivity {
PageHelper pageHelper; PageHelper pageHelper;
@Override @Override
@ -62,7 +62,7 @@ public class MainActivity extends AppCompatActivity {
101); 101);
} }
textViewAppendString(tv, "Check Finished"); textViewAppendString(tv, "Check Finished");
textViewAppendString(tv, "提示:常有惊喜"); textViewAppendString(tv, "提示:常有惊喜");
} }
textViewAppendString(tv, "*************************\nfinished"); textViewAppendString(tv, "*************************\nfinished");
@ -73,6 +73,9 @@ public class MainActivity extends AppCompatActivity {
button.setEnabled(true); button.setEnabled(true);
button.setOnClickListener(pageHelper.pageButtonHandler); button.setOnClickListener(pageHelper.pageButtonHandler);
button.setOnLongClickListener(new LongClickHandler(this)); button.setOnLongClickListener(new LongClickHandler(this));
Button SettingPageButton = findViewById(R.id.P1OpenAppSettingsLayout);
SettingPageButton.setOnClickListener(new SettingPageHandler());
} }
private void textViewAppendString(@NonNull TextView tv, String s) { private void textViewAppendString(@NonNull TextView tv, String s) {
@ -121,4 +124,15 @@ public class MainActivity extends AppCompatActivity {
return false; return false;
} }
} }
private final class SettingPageHandler implements View.OnClickListener {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),SettingPage.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
}
} }

View file

@ -21,10 +21,11 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import uk.kagurach.android101.helper.ColorHelper;
import uk.kagurach.android101.helper.PageHelper; import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.helper.ToastHelper; import uk.kagurach.android101.helper.ToastHelper;
public class MainActivity2 extends AppCompatActivity { public class MainActivity2 extends KaBaseActivity {
PageHelper pageHelper; PageHelper pageHelper;
@ -159,9 +160,8 @@ public class MainActivity2 extends AppCompatActivity {
private void updateCurrentSettingShower(){ private void updateCurrentSettingShower(){
TextView tv = findViewById(R.id.P2SettingResult); TextView tv = findViewById(R.id.P2SettingResult);
String sb = "Color = #" + String sb = "Color = " +
String.format("%6s",Integer.toString(_text_color&0xffffff, 16)) new ColorHelper().toString(_text_color,"#",false) +
.replace(" ","0") +
"; TextSize = " + "; TextSize = " +
_text_size + _text_size +
"." + "." +

View file

@ -16,7 +16,7 @@ import androidx.core.view.WindowInsetsCompat;
import uk.kagurach.android101.helper.PageHelper; import uk.kagurach.android101.helper.PageHelper;
public class Page3 extends AppCompatActivity { public class Page3 extends KaBaseActivity {
PageHelper pageHelper; PageHelper pageHelper;

View file

@ -22,7 +22,7 @@ import androidx.core.view.WindowInsetsCompat;
import uk.kagurach.android101.helper.PageHelper; import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver; import uk.kagurach.android101.misc.vibrationBroadcastReceiver.vibrationBroadcastReceiver;
public class Page4 extends AppCompatActivity { public class Page4 extends KaBaseActivity {
PageHelper pageHelper; PageHelper pageHelper;
ActivityResultLauncher<Intent> mLauncher; ActivityResultLauncher<Intent> mLauncher;

View file

@ -25,7 +25,7 @@ import uk.kagurach.android101.helper.PageHelper;
import uk.kagurach.android101.helper.ToastHelper; import uk.kagurach.android101.helper.ToastHelper;
import uk.kagurach.android101.helper.AutoCompleHelper.AnimalTypeAutoCompleteHelper; import uk.kagurach.android101.helper.AutoCompleHelper.AnimalTypeAutoCompleteHelper;
public class Page5 extends AppCompatActivity { public class Page5 extends KaBaseActivity {
AnimalTypeAutoCompleteHelper completeHelper = null; AnimalTypeAutoCompleteHelper completeHelper = null;
final AnimalDatabaseHelper dbHelper = new AnimalDatabaseHelper(this); final AnimalDatabaseHelper dbHelper = new AnimalDatabaseHelper(this);

View file

@ -0,0 +1,88 @@
package uk.kagurach.android101
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageButton
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
import uk.kagurach.android101.databinding.ActivitySettingPageBinding
import uk.kagurach.android101.helper.ColorHelper
val Context.datastore by preferencesDataStore(name = "settings")
val DefaultColor = intPreferencesKey("default_color")
class SettingPage : KaBaseActivity() {
lateinit var binding: ActivitySettingPageBinding
lateinit var settingStorage: SettingStorage
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setting_page)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
binding = ActivitySettingPageBinding.inflate(layoutInflater)
setContentView(binding.root)
settingStorage = SettingStorage(this)
binding.ThemeRed.setOnClickListener(SetColorHandler())
binding.ThemeBlue.setOnClickListener(SetColorHandler())
binding.ThemeCyan.setOnClickListener(SetColorHandler())
binding.ThemePink.setOnClickListener(SetColorHandler())
binding.ThemeGreen.setOnClickListener(SetColorHandler())
binding.SettingPageSubmit.setOnClickListener(FinishButtonHandler())
}
inner class SetColorHandler: View.OnClickListener {
override fun onClick(v: View?) {
if (v == null){
return
}
val colorTheme = when(v.id){
R.id.ThemeBlue -> R.style.Theme_Blue
R.id.ThemeGreen -> R.style.Theme_Green
R.id.ThemeRed -> R.style.Theme_Red
R.id.ThemeCyan -> R.style.Theme_Cyan
R.id.ThemePink -> R.style.Theme_Pink
else -> {throw RuntimeException("Impossible branch met!")}
}
runBlocking {
settingStorage.setDefaultTheme(colorTheme)
}
val intent = Intent(v.context,this@SettingPage::class.java)
startActivity(intent)
finish()
}
}
inner class FinishButtonHandler: View.OnClickListener{
override fun onClick(v: View?) {
val intent = Intent(v!!.context,MainActivity::class.java)
startActivity(intent)
finish()
}
}
}

View file

@ -0,0 +1,28 @@
package uk.kagurach.android101
import android.content.Context
import androidx.datastore.preferences.core.edit
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
class SettingStorage(val context: Context) {
suspend fun getDefaultTheme(): Int {
return getDefaultColorFlow.first()
}
suspend fun setDefaultTheme(newValue: Int) {
context.datastore.edit {
preferences ->
preferences[DefaultColor] = newValue
}
}
private val getDefaultColorFlow: Flow<Int> =
context.datastore.data
.map {
preferences ->
preferences[DefaultColor] ?: R.id.ThemeBlue
}
}

View file

@ -0,0 +1,23 @@
package uk.kagurach.android101.helper
import android.graphics.Color
import androidx.compose.ui.util.fastJoinToString
class ColorHelper {
fun toColorInt(r: Int, g: Int, b: Int): Int {
if (r !in 0..255 || g !in 0..255 || b !in 0..255) {
throw Exception("RGB not in range")
}
return Color.rgb(r, g, b).and(0xffffff) // Preserve only low 48 bit
}
@OptIn(ExperimentalStdlibApi::class)
fun toString(colorInt: Int, start: String = "#", upperCase: Boolean = false): String {
val colorInt = colorInt.and(0xffffff) // Keep only low six digit
val colorString = colorInt.toHexString(
if (upperCase) { HexFormat.UpperCase }
else{ HexFormat.Default }
).drop(2)
return "$start$colorString"
}
}

View file

@ -9,15 +9,15 @@ fun Kaculate(src: String, ctx: Context): String {
return src return src
} }
val OpList = charArrayOf('+', '-', 'x', '/', '^') val opList = charArrayOf('+', '-', 'x', '/', '^')
var numStack = floatArrayOf() var numStack = floatArrayOf()
var opStack = charArrayOf() var opStack = charArrayOf()
var _curnum = "" var _curnum = ""
// Fix for expression starts with operator // Fix for expression starts with operator
val src = if (src[0] in OpList){ val src = if (src[0] in opList){
"0" + src "0$src"
}else{ }else{
src src
} }
@ -25,7 +25,7 @@ fun Kaculate(src: String, ctx: Context): String {
for (i in src.indices) { for (i in src.indices) {
if (src[i] in '0'..'9' || src[i] == '.') { if (src[i] in '0'..'9' || src[i] == '.') {
_curnum += src[i] _curnum += src[i]
} else if (src[i] in OpList) { } else if (src[i] in opList) {
try { try {
numStack += _curnum.toFloat() numStack += _curnum.toFloat()
_curnum = "" _curnum = ""

View file

@ -4,25 +4,51 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity"
tools:viewBindingIgnore="true">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
>
<TextView <ScrollView
android:id="@+id/tv_hello"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="620dp" android:layout_height="wrap_content"
android:text="@string/hello_world" android:minHeight="500dp"
android:textSize="15sp" >
android:visibility="visible" /> <TextView
android:id="@+id/tv_hello"
android:layout_width="match_parent"
android:layout_height="620dp"
android:text="@string/hello_world"
android:textSize="15sp"
android:visibility="visible" />
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<Button
android:id="@+id/P1OpenAppSettingsLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/settings"
/>
</LinearLayout>
<Button <Button
android:id="@+id/Page1NextPage" android:id="@+id/Page1NextPage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginVertical="10dp"
android:layout_marginHorizontal="15dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/next_page" android:text="@string/next_page"
android:enabled="false" android:enabled="false"

View file

@ -6,7 +6,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize"
tools:context=".MainActivity2"> tools:context=".MainActivity2"
tools:viewBindingIgnore="true"
>
<LinearLayout <LinearLayout

View file

@ -4,7 +4,8 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".Page3"> tools:context=".Page3"
tools:viewBindingIgnore="true">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -4,7 +4,8 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".Page4"> tools:context=".Page4"
tools:viewBindingIgnore="true">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -4,7 +4,8 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".Page5"> tools:context=".Page5"
tools:viewBindingIgnore="true">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingPage"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings"
android:textSize="45sp"
android:fontFamily="serif-monospace"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginVertical="15dp"
android:layout_marginHorizontal="20sp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/set_default_theme"
android:textSize="30sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<ImageButton
android:id="@+id/ThemeBlue"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginVertical="15dp"
android:layout_marginStart="15dp"
android:background="#039BE5"
android:contentDescription="@string/add" />
<ImageButton
android:id="@+id/ThemeGreen"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginVertical="15dp"
android:layout_marginStart="30dp"
android:background="#43A047"
android:contentDescription="@string/add" />
<ImageButton
android:id="@+id/ThemeRed"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginVertical="15dp"
android:layout_marginStart="30dp"
android:background="#E53935"
android:contentDescription="@string/add" />
<ImageButton
android:id="@+id/ThemeCyan"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginVertical="15dp"
android:layout_marginStart="30dp"
android:background="#00ACC1"
android:contentDescription="@string/add" />
<ImageButton
android:id="@+id/ThemePink"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginVertical="15dp"
android:layout_marginStart="30dp"
android:background="#FF80AB"
android:contentDescription="@string/add" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/SettingPageSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/finish"
android:textSize="35sp"
android:textAllCaps="false"
android:layout_marginBottom="20dp"
android:layout_marginHorizontal="55sp"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -2,13 +2,10 @@
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.Android101" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <style name="Theme.Android101" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item> <item name="colorPrimary">@color/tfb</item>
<item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorPrimaryVariant">@color/tfp </item>
<item name="colorOnPrimary">@color/black</item> <item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. --> <!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item> <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->

View file

@ -44,4 +44,5 @@
<string name="set_per_unit_font_size">设置每个单位的字体大小</string> <string name="set_per_unit_font_size">设置每个单位的字体大小</string>
<string name="font_size">字体\n大小</string> <string name="font_size">字体\n大小</string>
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string> <string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
<string name="set_default_theme">设置默认主题</string>
</resources> </resources>

View file

@ -1,10 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>

View file

@ -44,4 +44,5 @@
<string name="set_per_unit_font_size">Set per unit font size</string> <string name="set_per_unit_font_size">Set per unit font size</string>
<string name="font_size">Font\nSize</string> <string name="font_size">Font\nSize</string>
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string> <string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
<string name="set_default_theme">Set Default Theme</string>
</resources> </resources>

View file

@ -6,8 +6,8 @@
<item name="colorPrimaryVariant">#D500F9</item> <item name="colorPrimaryVariant">#D500F9</item>
<item name="colorOnPrimary">@color/white</item> <item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item> <item name="colorSecondary">@color/black</item>
<item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorSecondaryVariant">@color/black</item>
<item name="colorOnSecondary">@color/black</item> <item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. --> <!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item> <item name="android:statusBarColor">#0D47A1</item>
@ -16,5 +16,65 @@
<style name="Theme.TODOList" parent="android:Theme.Material.Light.NoActionBar" /> <style name="Theme.TODOList" parent="android:Theme.Material.Light.NoActionBar" />
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Base.Theme.TODOList" parent="Theme.Material3.DayNight.NoActionBar"/> <style name="Base.Theme.TODOList" parent="Theme.Material3.DayNight.NoActionBar"/>
<style name="Theme.Blue" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#039BE5</item>
<item name="colorSecondary">#1976D2</item>
<item name="colorSecondaryVariant">#81D4FA</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item>
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Green" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#43A047</item>
<item name="colorSecondary">#388E3C</item>
<item name="colorSecondaryVariant">#A5D6A7</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item>
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Red" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#E53935</item>
<item name="colorPrimaryVariant">#D500F9</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/black</item>
<item name="colorSecondaryVariant">@color/black</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item>
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Cyan" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#00ACC1</item>
<item name="colorPrimaryVariant">#D500F9</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/black</item>
<item name="colorSecondaryVariant">@color/black</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item>
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Pink" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#FF80AB</item>
<item name="colorPrimaryVariant">#D500F9</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/black</item>
<item name="colorSecondaryVariant">@color/black</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">#0D47A1</item>
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
</resources> </resources>

View file

@ -1,5 +1,6 @@
[versions] [versions]
agp = "8.4.1" agp = "8.4.1"
datastorePreferences = "1.1.1"
kotlin = "1.9.0" kotlin = "1.9.0"
coreKtx = "1.13.1" coreKtx = "1.13.1"
junit = "4.13.2" junit = "4.13.2"
@ -19,9 +20,11 @@ navigationUiKtx = "2.7.7"
annotation = "1.8.0" annotation = "1.8.0"
lifecycleLivedataKtx = "2.8.1" lifecycleLivedataKtx = "2.8.1"
lifecycleViewmodelKtx = "2.8.1" lifecycleViewmodelKtx = "2.8.1"
datastoreRxjava3 = "1.1.1"
[libraries] [libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
junit = { group = "junit", name = "junit", version.ref = "junit" } junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
@ -46,6 +49,7 @@ androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" } androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" }
androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" } androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
androidx-datastore-rxjava3 = { group = "androidx.datastore", name = "datastore-rxjava3", version.ref = "datastoreRxjava3" }
[plugins] [plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" } androidApplication = { id = "com.android.application", version.ref = "agp" }