Skip to content

Commit

Permalink
Merge pull request #31 from guyijie1211/theme
Browse files Browse the repository at this point in the history
0.2.8
  • Loading branch information
guyijie1211 authored Aug 25, 2022
2 parents f7062fd + aec8c53 commit efedcc9
Show file tree
Hide file tree
Showing 20 changed files with 260 additions and 133 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.setting.SettingActivity"
android:theme="@style/PreferenceScreen"
android:label="设置" />
<activity
android:name=".ui.login.LoginActivity"
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/sunnyweather/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MainActivity : AppCompatActivity(), AreaSingleFragment.FragmentListener {
private lateinit var mMenu: Menu
private var themeActived = R.style.SunnyWeather
private var autoDark = true
private var pureDark = false
private var mShortcutManager:ShortcutManager? = null
private var activityMain = this

Expand All @@ -62,6 +63,7 @@ class MainActivity : AppCompatActivity(), AreaSingleFragment.FragmentListener {
//颜色主题
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
autoDark = sharedPreferences.getBoolean("autoDark", true)
pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
themeActived = R.style.nightTheme
Expand All @@ -73,7 +75,11 @@ class MainActivity : AppCompatActivity(), AreaSingleFragment.FragmentListener {
} else {
themeActived = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(themeActived)
if (pureDark && themeActived == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
setTheme(themeActived)
}
setContentView(R.layout.activity_main)
drawer_dark_switch.isChecked = (themeActived == R.style.nightTheme)
BarUtils.addMarginTopEqualStatusBarHeight(drawer_nick)
Expand Down Expand Up @@ -171,7 +177,7 @@ class MainActivity : AppCompatActivity(), AreaSingleFragment.FragmentListener {
var sharedPref = getSharedPreferences("JustLive", Context.MODE_PRIVATE)
val ignoreVersion = sharedPref.getInt("ignoreVersion",0)
val versionNum = SunnyWeatherApplication.getVersionCode(SunnyWeatherApplication.context)
if (versionNum == updateInfo.versionNum || ignoreVersion == updateInfo.versionNum) {
if (versionNum >= updateInfo.versionNum || ignoreVersion == updateInfo.versionNum) {
if (isVersionCheck) {
Toast.makeText(SunnyWeatherApplication.context, "当前已是最新版本^_^", Toast.LENGTH_SHORT).show()
}
Expand Down Expand Up @@ -263,8 +269,9 @@ class MainActivity : AppCompatActivity(), AreaSingleFragment.FragmentListener {
super.onResume()
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val newTheme = sharedPreferences.getInt("theme", R.style.SunnyWeather)
val newPureDark = sharedPreferences.getBoolean("pureDark", false)
drawer_dark_switch.isChecked = (themeActived == R.style.nightTheme)
if (newTheme != themeActived){
if (newTheme != themeActived || newPureDark != pureDark){
recreate()
}
}
Expand Down
46 changes: 24 additions & 22 deletions app/src/main/java/com/sunnyweather/android/ui/about/AboutActvity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AboutActvity: AppCompatActivity(){
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
var themeActived: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
themeActived = R.style.nightTheme
Expand All @@ -33,19 +34,17 @@ class AboutActvity: AppCompatActivity(){
} else {
themeActived = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(themeActived)
setContentView(R.layout.activity_about)
BarUtils.transparentStatusBar(this)
BarUtils.addMarginTopEqualStatusBarHeight(about_container)
if (themeActived != R.style.nightTheme) {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, resources.getColor(R.color.colorPrimaryVariant))
if (pureDark && themeActived == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
BarUtils.setStatusBarLightMode(this, false)
BarUtils.setStatusBarColor(this, resources.getColor(R.color.colorPrimaryVariant_night))
setTheme(themeActived)
}
setContentView(R.layout.activity_about)
BarUtils.transparentStatusBar(this)
BarUtils.addMarginTopEqualStatusBarHeight(about_back)
BarUtils.setStatusBarLightMode(this, themeActived != R.style.nightTheme)

about_version.text = AppUtils.getAppVersionName()
about_version.text = "版本号:" + AppUtils.getAppVersionName()

about_pic.setImageDrawable(AppUtils.getAppIcon())

Expand All @@ -71,10 +70,6 @@ class AboutActvity: AppCompatActivity(){
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://qm.qq.com/cgi-bin/qm/qr?k=_2KootdkU0ikLiFhBCQMJKW7PjHzySZ8&authKey=2dGp04G04G/+a1KHiIjqjpg1Se+/TgpQ5yzpEbMkzP9Y6lkrFdReKdtBtg6xC+Cs&noverify=0"))
this.startActivity(intent)
}
about_telegram.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/+4r0VneskqvY1NWNl"))
this.startActivity(intent)
}
about_github.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/guyijie1211"))
this.startActivity(intent)
Expand All @@ -86,14 +81,21 @@ class AboutActvity: AppCompatActivity(){
about_back.setOnClickListener {
this.onBackPressed()
}
about_email.setOnClickListener {
val email = Intent(Intent.ACTION_SEND)
email.type = "text/plain"
email.putExtra(Intent.EXTRA_EMAIL, arrayOf("1056025931@qq.com"))
startActivity(Intent.createChooser(email, "选择邮件APP"))
about_bug.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.wolai.com/f/PjHjXcBVzyMs237mDLbrh"))
this.startActivity(intent)
}
about_new.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.wolai.com/f/eR8bqaBKPQeCDzyJWhBTNC"))
this.startActivity(intent)
}
about_progress.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.wolai.com/fpajKKnFwFiiai92UHd1Kk"))
this.startActivity(intent)
}
about_forum.setOnClickListener {
var intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.9rai.com"))
this.startActivity(intent)
}
// about_apple.setOnClickListener {
// ToastUtils.showShort("开发中")
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class OnLiveFragment(private val isLive: Boolean) : Fragment() {
refresh_home.finishLoadMoreWithNoMoreData()
return@setOnRefreshListener
}
viewModel.clearRoomList()
viewModel.getRoomsOn(SunnyWeatherApplication.userInfo?.uid)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class LiveRoomActivity : AppCompatActivity(), Utils.OnAppStatusChangedListener,
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
var theme: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
theme = R.style.nightTheme
Expand All @@ -117,7 +118,11 @@ class LiveRoomActivity : AppCompatActivity(), Utils.OnAppStatusChangedListener,
} else {
theme = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(theme)
if (pureDark && theme == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
setTheme(theme)
}
setContentView(R.layout.activity_liveroom)
val playBackGround = sharedPreferences.getBoolean("play_background", false)
val backTiny = sharedPreferences.getBoolean("tiny_when_back", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LoginActivity: AppCompatActivity() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
var theme: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
theme = R.style.nightTheme
Expand All @@ -46,7 +47,11 @@ class LoginActivity: AppCompatActivity() {
} else {
theme = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(theme)
if (pureDark && theme == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
setTheme(theme)
}
setContentView(R.layout.activity_login)
if (theme != R.style.nightTheme) {
BarUtils.setStatusBarLightMode(this, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RegisterActivity: AppCompatActivity() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
var theme: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
theme = R.style.nightTheme
Expand All @@ -41,7 +42,11 @@ class RegisterActivity: AppCompatActivity() {
} else {
theme = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(theme)
if (pureDark && theme == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
setTheme(theme)
}
setContentView(R.layout.activity_register)
if (theme != R.style.nightTheme) {
BarUtils.setStatusBarLightMode(this, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SearchActivity : AppCompatActivity(), View.OnClickListener {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
var themeActived: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
themeActived = R.style.nightTheme
Expand All @@ -60,7 +61,11 @@ class SearchActivity : AppCompatActivity(), View.OnClickListener {
} else {
themeActived = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
setTheme(themeActived)
if (pureDark && themeActived == R.style.nightTheme) {
setTheme(R.style.nightTheme_dark)
} else {
setTheme(themeActived)
}
setContentView(R.layout.activity_search)
BarUtils.transparentStatusBar(this)
if (themeActived != R.style.nightTheme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SettingActivity : AppCompatActivity() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
var theme: Int
val autoDark = sharedPreferences.getBoolean("autoDark", true)
val pureDark = sharedPreferences.getBoolean("pureDark", false)
if (autoDark) {
if(SunnyWeatherApplication.isNightMode(this)){
theme = R.style.nightTheme
Expand All @@ -28,11 +29,18 @@ class SettingActivity : AppCompatActivity() {
} else {
theme = sharedPreferences.getInt("theme", R.style.SunnyWeather)
}
theme = if (theme == R.style.SunnyWeather) {
R.style.PreferenceScreen
} else if (pureDark) {
R.style.PreferenceScreen_dark
} else {
R.style.PreferenceScreen_night
}
setTheme(theme)
setContentView(R.layout.activity_setting)
BarUtils.transparentStatusBar(this)
BarUtils.addMarginTopEqualStatusBarHeight(setting_toolbar)
if (theme != R.style.nightTheme) {
if (theme != R.style.PreferenceScreen_night) {
BarUtils.setStatusBarLightMode(this, true)
} else {
BarUtils.setStatusBarLightMode(this, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SettingFragment : PreferenceFragmentCompat() {
val versionPreferences = findPreference<Preference>("version")
val aboutPreferences = findPreference<Preference>("about_activity")
val donatePreferences = findPreference<Preference>("donate")
val pureDarkPreference: SwitchPreferenceCompat? = findPreference("pureDark")
signaturePreference?.isChecked =
sharedPreferences.getInt("theme", R.style.SunnyWeather) != R.style.SunnyWeather
signaturePreference?.setOnPreferenceChangeListener { _, newValue ->
Expand All @@ -52,6 +53,10 @@ class SettingFragment : PreferenceFragmentCompat() {
}
true
}
pureDarkPreference?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
true
}
autoDark?.setOnPreferenceChangeListener { _, newValue ->
if (newValue as Boolean) {
if(SunnyWeatherApplication.isNightMode(requireActivity())){
Expand Down Expand Up @@ -135,7 +140,7 @@ class SettingFragment : PreferenceFragmentCompat() {
var sharedPref = getSharedPreferences(requireContext(), "JustLive")
val ignoreVersion = sharedPref.getInt("ignoreVersion",0)
val versionNum = SunnyWeatherApplication.getVersionCode(SunnyWeatherApplication.context)
if (versionNum == updateInfo.versionNum) {
if (versionNum >= updateInfo.versionNum) {
Toast.makeText(SunnyWeatherApplication.context, "当前已是最新版本^_^", Toast.LENGTH_SHORT).show()
return@observe
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 并对部分api做了封装,方便使用
*/
public class YJControlWrapper extends ControlWrapper {
private Boolean isLandscape = false;
private Boolean isLandscape = ScreenUtils.isLandscape();

public YJControlWrapper(@NonNull MediaPlayerControl playerControl, @NonNull IVideoController controller) {
super(playerControl, controller);
Expand Down
Binary file added app/src/main/res/drawable-v24/logo_wolai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
android:tint="?attr/colorOnPrimary">
<path
android:fillColor="@android:color/white"
android:fillColor="?attr/colorOnPrimary"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>
Binary file added app/src/main/res/drawable/logo_forums.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit efedcc9

Please sign in to comment.