-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tianma8023/dev_1.4.0
Merge dev_1.4.0 into dev branch
- Loading branch information
Showing
116 changed files
with
3,088 additions
and
2,829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
app/src/main/java/com/tianma/tweaks/miui/app/base/BaseActivity.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/tianma/tweaks/miui/app/base/BaseActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
app/src/main/java/com/tianma/tweaks/miui/app/base/BasePreferenceFragment.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/tianma/tweaks/miui/app/base/BasePreferenceFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/tianma/tweaks/miui/app/fragment/BaseSettingsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.