Skip to content

Commit

Permalink
Merge pull request #15 from tianma8023/dev_1.4.0
Browse files Browse the repository at this point in the history
Merge dev_1.4.0 into dev branch
  • Loading branch information
tianma8023 authored Nov 2, 2021
2 parents 4ed8c94 + 639ac5b commit 16e2f92
Show file tree
Hide file tree
Showing 116 changed files with 3,088 additions and 2,829 deletions.
4 changes: 4 additions & 0 deletions LOG-CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 更新日志
- 21.11.02 1.4.0
1. 适配 MIUI 12.5 (21.10.13版本)
2. 修复: 天气显示问题
3. 修复: 始终显示状态栏时间问题
- 21.03.04 1.3.0
1. 适配 MIUI 12.5+
- 20.05.11 1.2.3
Expand Down
4 changes: 4 additions & 0 deletions LOG-EN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Update Logs
- 21.11.02 1.4.0
1. Adapt to MIUI 12.5 (21.10.13)
2. Fix: weather info showing issues.
3. Fix: always show status bar clock in status bar.
- 21.03.04 1.3.0
1. Adapt MIUI 12.5+
- 20.05.11 1.2.3
Expand Down
7 changes: 4 additions & 3 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# XMiTools
MIUI 10 / MIUI 11 / MIUI 12 系统界面模块
MIUI 10 / MIUI 11 / MIUI 12 / MIUI 12.5 系统界面模块

[English README](/README-EN.md)
# 效果截图
Expand All @@ -12,8 +12,8 @@ MIUI 10 / MIUI 11 / MIUI 12 系统界面模块
- [Xposed仓库](https://repo.xposed.info/module/com.tianma.tweaks.miui)

# 注意
- 仅适用于MIUI 10,其他版本的 MIUI 系统以及非 MIUI 系统,请慎用。
- 支持 Xposed,EdXposed 和 太极阳。
- 仅适用于MIUI,其他版本的系统,请慎用。
- 支持 Xposed,EdXposed,LSPosed 和 太极阳。

# 功能
- 状态栏
Expand All @@ -31,6 +31,7 @@ MIUI 10 / MIUI 11 / MIUI 12 系统界面模块
- 锁屏界面
1. 水平时钟显示秒数
2. 垂直时钟显示秒数
- 等等...

# 感谢
- [custoMIUIzer](https://code.highspec.ru/Mikanoshi/CustoMIUIzer/)
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# XMiTools
An xposed module for MIUI 10 / MIUI 11 / MIUI 12 SystemUI.
An xposed module for MIUI 10 / MIUI 11 / MIUI 12 / MIUI 12.5 SystemUI.

[中文说明](/README-CN.md)
# Screenshots
Expand All @@ -12,8 +12,8 @@ You can download in the following sites:
- [Xposed Repository](https://repo.xposed.info/module/com.tianma.tweaks.miui)

# Attention
- Only compatible for MIUI 10. Other ROM may not suitable.
- Support Xposed, EdXposed and TaiChi.
- Only compatible for MIUI. Other ROM may not suitable.
- Support Xposed, EdXposed, LSPosed and TaiChi.

# Features
- Status Bar
Expand All @@ -31,6 +31,7 @@ You can download in the following sites:
- Lock Screen
1. Show seconds in horizontal clock
2. Show seconds in vertical clock
- And so on...


# Credits
Expand Down
9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def static releaseTime() {
}

ext {
VERSION_CODE = 16
VERSION_NAME = "1.3.0"
VERSION_CODE = 17
VERSION_NAME = "1.4.0"
}

android {
Expand Down Expand Up @@ -56,6 +56,8 @@ android {
println "using keystore"
signingConfig signingConfigs.release
}

debuggable false
}

release {
Expand All @@ -78,6 +80,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package="com.tianma.tweaks.miui">

<application
android:name=".app.App"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -24,6 +25,7 @@

<activity
android:name=".app.MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:screenOrientation="unspecified">
<intent-filter>
Expand All @@ -35,6 +37,7 @@

<activity-alias
android:name=".app.MainActivityAlias"
android:exported="true"
android:targetActivity=".app.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/tianma/tweaks/miui/app/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.tianma.tweaks.miui.app

import android.app.Application

/**
* desc: Application instance
* date: 2021/10/7
*/
class App : Application() {

companion object {
lateinit var appContext: Application
private set
}

override fun onCreate() {
super.onCreate()

appContext = this
}

}
7 changes: 4 additions & 3 deletions app/src/main/java/com/tianma/tweaks/miui/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import android.view.MenuItem
import com.afollestad.materialdialogs.MaterialDialog
import com.tianma.tweaks.miui.R
import com.tianma.tweaks.miui.app.base.BaseActivity
import com.tianma.tweaks.miui.app.base.BasePreferenceFragment
import com.tianma.tweaks.miui.app.fragment.*
import com.tianma.tweaks.miui.utils.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.toolbar.*
import kotlin.math.max

/**
* HomeActivity
*/
class MainActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -30,7 +31,7 @@ class MainActivity : BaseActivity() {
}

private fun initFragments() {
val fragments = mutableListOf<BasePreferenceFragment>().apply {
val fragments = mutableListOf<BaseSettingsFragment>().apply {
add(GeneralSettingsFragment(getString(R.string.pref_general_title)))
add(StatusBarSettingsFragment(getString(R.string.pref_status_bar_title)))
add(DropDownStatusBarSettingsFragment(getString(R.string.pref_dropdown_status_bar_title)))
Expand Down

This file was deleted.

27 changes: 27 additions & 0 deletions app/src/main/java/com/tianma/tweaks/miui/app/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.tianma.tweaks.miui.app.base

import android.content.Context
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import com.tianma.tweaks.miui.utils.ContextUtils

abstract class BaseActivity : AppCompatActivity() {

override fun attachBaseContext(newBase: Context?) {
val context = if (newBase != null) {
ContextUtils.getProtectedContextIfNecessary(newBase)
} else {
newBase
}
super.attachBaseContext(context)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val itemId = item.itemId
if (itemId == android.R.id.home) {
onBackPressed()
return true
}
return super.onOptionsItemSelected(item)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.tianma.tweaks.miui.app.base

import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
import com.tianma.tweaks.miui.cons.AppConst

abstract class BasePreferenceFragment : PreferenceFragmentCompat() {

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
val pm = preferenceManager
pm.sharedPreferencesName = AppConst.XMI_TOOLS_PREFS_NAME
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.tianma.tweaks.miui.app.fragment

import com.tianma.tweaks.miui.app.base.BasePreferenceFragment
import com.tianma.tweaks.miui.cons.AppConst
import com.tianma.tweaks.miui.utils.ContextUtils
import com.tianma.tweaks.miui.utils.StorageUtils

/**
* Base Fragment for settings.
*/
abstract class BaseSettingsFragment @JvmOverloads constructor(val title: CharSequence? = "") :
BasePreferenceFragment() {

override fun onPause() {
super.onPause()
setPreferenceWorldWritable()
}

private fun setPreferenceWorldWritable() {
val activity = activity ?: return
val context = ContextUtils.getProtectedContextIfNecessary(activity.applicationContext)

val prefsFile = StorageUtils.getSharedPreferencesFile(context, AppConst.XMI_TOOLS_PREFS_NAME)
StorageUtils.setFileWorldWritable(prefsFile, 2)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import android.text.InputType
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import com.tianma.tweaks.miui.R
import com.tianma.tweaks.miui.app.base.BasePreferenceFragment
import com.tianma.tweaks.miui.cons.PrefConst

/**
* dSettings fragment for System DropDown StatusBar
*/
class DropDownStatusBarSettingsFragment(title: CharSequence? = ""): BasePreferenceFragment(title), Preference.OnPreferenceChangeListener {
class DropDownStatusBarSettingsFragment(title: CharSequence? = ""): BaseSettingsFragment(title), Preference.OnPreferenceChangeListener {

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package com.tianma.tweaks.miui.app.fragment

import android.annotation.SuppressLint
import android.app.Activity
import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import androidx.preference.Preference
import com.tianma.tweaks.miui.BuildConfig
import com.tianma.tweaks.miui.R
import com.tianma.tweaks.miui.app.base.BasePreferenceFragment
import com.tianma.tweaks.miui.cons.AppConst
import com.tianma.tweaks.miui.cons.PrefConst
import com.tianma.tweaks.miui.utils.ContextUtils
import com.tianma.tweaks.miui.utils.PackageUtils
import com.tianma.tweaks.miui.utils.StorageUtils
import com.tianma.tweaks.miui.utils.Utils

class GeneralSettingsFragment(title: CharSequence? = "") : BasePreferenceFragment(title), Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
class GeneralSettingsFragment(title: CharSequence? = "") : BaseSettingsFragment(title), Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {

private lateinit var mActivity: Activity

Expand All @@ -38,11 +32,6 @@ class GeneralSettingsFragment(title: CharSequence? = "") : BasePreferenceFragmen
mActivity = requireActivity()
}

override fun onPause() {
super.onPause()
setPreferenceWorldWritable()
}

override fun onResume() {
super.onResume()

Expand Down Expand Up @@ -86,23 +75,6 @@ class GeneralSettingsFragment(title: CharSequence? = "") : BasePreferenceFragmen
}
}

@SuppressLint("SetWorldReadable", "SetWorldWritable")
private fun setPreferenceWorldWritable() {
val context: Context = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// API >= 24 (Android 7.0+)
// dataDir: /data/user_de/0/<package_name>/
// spDir: /data/user_de/0/<package_name>/shared_prefs/
// spFile: /data/user_de/0/<package_name>/shared_prefs/<preferences_name>.xml
ContextUtils.getProtectedContext(mActivity.applicationContext)
} else {
// API < 24, there is no data encrypt.
// dataDir: /data/data/<package_name>/
mActivity.applicationContext
}
val prefsFile = StorageUtils.getSharedPreferencesFile(context, AppConst.X_MIUI_CLOCK_PREFS_NAME)
StorageUtils.setFileWorldWritable(prefsFile, 2)
}

private fun showVersionInfo() {
findPreference<Preference>(PrefConst.APP_VERSION)?.summary = BuildConfig.VERSION_NAME
}
Expand Down
Loading

0 comments on commit 16e2f92

Please sign in to comment.