Skip to content

Commit

Permalink
Add new styles for setting (#1204)
Browse files Browse the repository at this point in the history
Signed-off-by: singleNeuron <Cryolitia@gmail.com>
  • Loading branch information
Cryolitia authored Dec 26, 2021
1 parent 58f9a4e commit 413f072
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import me.ketal.data.ConfigData
import me.singleneuron.qn_kernel.ui.activity.Material3Activity
import me.singleneuron.qn_kernel.ui.activity.MaterialActivity
import me.singleneuron.qn_kernel.ui.activity.NewSettingsActivity
import me.singleneuron.qn_kernel.ui.activity.SettingActivity
import nil.nadph.qnotified.R
Expand All @@ -51,7 +53,7 @@ object ActivityRouter : UiChangeableItemFactory<String>() {
override var onClickListener: (Activity) -> Boolean = {
MaterialAlertDialogBuilder(it, R.style.MaterialDialog)
.setTitle("选择设置界面样式")
.setItems(arrayOf("QQ主题", "关怀模式")) { _: DialogInterface, i: Int ->
.setItems(arrayOf("QQ主题", "关怀模式", "Android Classic", "Material You")) { _: DialogInterface, i: Int ->
when (i) {
0 -> {
value.value = "QQ主题"
Expand All @@ -61,6 +63,14 @@ object ActivityRouter : UiChangeableItemFactory<String>() {
value.value = "关怀模式"
it.startActivity(Intent(it, SettingActivity::class.java))
}
2 -> {
value.value = "Android Classic"
it.startActivity(Intent(it, MaterialActivity::class.java))
}
3 -> {
value.value = "Material You"
it.startActivity(Intent(it, Material3Activity::class.java))
}
}
}
.create()
Expand All @@ -72,6 +82,8 @@ object ActivityRouter : UiChangeableItemFactory<String>() {
return when (value.value) {
"QQ主题" -> NewSettingsActivity::class.java
"关怀模式" -> SettingActivity::class.java
"Android Classic" -> MaterialActivity::class.java
"Material You" -> Material3Activity::class.java
else -> NewSettingsActivity::class.java
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* QNotified - An Xposed module for QQ/TIM
* Copyright (C) 2019-2021 dmca@ioctl.cc
* https://github.com/ferredoxin/QNotified
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version and our eula as published
* by ferredoxin.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* and eula along with this software. If not, see
* <https://www.gnu.org/licenses/>
* <https://github.com/ferredoxin/QNotified/blob/master/LICENSE.md>.
*/

package me.singleneuron.qn_kernel.ui.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceFragmentCompat
import me.singleneuron.qn_kernel.tlb.UiTable
import nil.nadph.qnotified.ui.ResUtils
import nil.nadph.qnotified.util.Utils
import org.ferredoxin.ferredoxinui.common.activity.MaterialSettingActivity
import org.ferredoxin.ferredoxinui.common.base.TitleAble
import org.ferredoxin.ferredoxinui.common.fragment.MaterialSettingFragment

class Material3Activity<T> : MaterialSettingActivity<T>() where T : PreferenceFragmentCompat, T : TitleAble {

override val fragment: T = MaterialSettingFragment().setUiScreen(UiTable.second) as T
override val theme: MaterialTheme = MaterialTheme.You

private val mLoader by lazy { this::class.java.classLoader }

override fun getClassLoader() = mLoader!!

override fun onCreate(savedInstanceState: Bundle?) {
runCatching {
AppCompatDelegate.setDefaultNightMode(
if (ResUtils.isInNightMode()) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO)
}.onFailure {
Utils.log(it)
}
super.onCreate(savedInstanceState)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* QNotified - An Xposed module for QQ/TIM
* Copyright (C) 2019-2021 dmca@ioctl.cc
* https://github.com/ferredoxin/QNotified
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version and our eula as published
* by ferredoxin.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* and eula along with this software. If not, see
* <https://www.gnu.org/licenses/>
* <https://github.com/ferredoxin/QNotified/blob/master/LICENSE.md>.
*/

package me.singleneuron.qn_kernel.ui.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceFragmentCompat
import me.singleneuron.qn_kernel.tlb.UiTable
import nil.nadph.qnotified.ui.ResUtils
import nil.nadph.qnotified.util.Utils
import org.ferredoxin.ferredoxinui.common.activity.MaterialSettingActivity
import org.ferredoxin.ferredoxinui.common.base.TitleAble
import org.ferredoxin.ferredoxinui.common.fragment.MaterialSettingFragment

class MaterialActivity<T> : MaterialSettingActivity<T>() where T : PreferenceFragmentCompat, T : TitleAble {

override val fragment: T = MaterialSettingFragment().setUiScreen(UiTable.second) as T
override val theme: MaterialTheme = MaterialTheme.Classic

private val mLoader by lazy { this::class.java.classLoader }

override fun getClassLoader() = mLoader!!

override fun onCreate(savedInstanceState: Bundle?) {
runCatching {
AppCompatDelegate.setDefaultNightMode(
if (ResUtils.isInNightMode()) AppCompatDelegate.MODE_NIGHT_YES else AppCompatDelegate.MODE_NIGHT_NO)
}.onFailure {
Utils.log(it)
}
super.onCreate(savedInstanceState)
}

}

0 comments on commit 413f072

Please # to comment.