Replace colors hard code with values-night.

This commit is contained in:
Sylvester Yao
2023-01-13 12:00:59 +08:00
parent db8942fe5a
commit 2990db305e
5 changed files with 16 additions and 52 deletions

View File

@@ -31,13 +31,15 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppThemeLight"
android:theme="@style/AppThemeDayNight"
android:usesCleartextTraffic="true"
tools:targetApi="m">
<activity
android:exported="true"
android:name=".ui.MainActivity"
android:launchMode="singleTask">
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/AppThemeDayNight.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View File

@@ -2,12 +2,10 @@ package com.v2ray.ang.ui
import android.content.Context
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.view.MenuItem
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import com.v2ray.ang.util.MyContextWrapper
import com.v2ray.ang.R
import com.v2ray.ang.util.Utils
abstract class BaseActivity : AppCompatActivity() {
@@ -19,27 +17,6 @@ abstract class BaseActivity : AppCompatActivity() {
else -> super.onOptionsItemSelected(item)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
checkDarkMode()
}
private fun checkDarkMode() {
if (Utils.getDarkModeStatus(this)) {
if (this.javaClass.simpleName == "MainActivity") {
setTheme(R.style.AppThemeDark_NoActionBar)
} else {
setTheme(R.style.AppThemeDark)
}
} else {
if (this.javaClass.simpleName == "MainActivity") {
setTheme(R.style.AppThemeLight_NoActionBar)
} else {
setTheme(R.style.AppThemeLight)
}
}
}
@RequiresApi(Build.VERSION_CODES.N)
override fun attachBaseContext(newBase: Context?) {
val context = newBase?.let {
@@ -47,7 +24,4 @@ abstract class BaseActivity : AppCompatActivity() {
}
super.attachBaseContext(context)
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorAccent">#12976F</color>
<color name="colorBg">#252525</color>
<color name="colorText">#CCCCCC</color>
</resources>

View File

@@ -15,10 +15,4 @@
<color name="colorAccent">#D81B60</color>
<color name="colorBg">#FFFFFF</color>
<color name="colorText">#000000</color>
<color name="colorPrimaryByDark">#2B2B2B</color>
<color name="colorPrimaryDarkByDark">#161616</color>
<color name="colorAccentByDark">#12976F</color>
<color name="colorBgByDark">#252525</color>
<color name="colorTextByDark">#CCCCCC</color>
</resources>

View File

@@ -1,5 +1,6 @@
<resources>
<style name="AppThemeLight" parent="Theme.AppCompat.DayNight.DarkActionBar">
<style name="AppThemeDayNight" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
@@ -7,20 +8,7 @@
<item name="colorMainText">@color/colorText</item>
</style>
<style name="AppThemeDark" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryByDark</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkByDark</item>
<item name="colorAccent">@color/colorAccentByDark</item>
<item name="colorMainBg">@color/colorBgByDark</item>
<item name="colorMainText">@color/colorTextByDark</item>
</style>
<style name="AppThemeLight_NoActionBar" parent="AppThemeLight">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppThemeDark_NoActionBar" parent="AppThemeDark">
<style name="AppThemeDayNight.NoActionBar" parent="AppThemeDayNight">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>