Skip to content

Commit

Permalink
Add module and RRO to default tags, v4.1.1 release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
cliuff committed Sep 22, 2023
1 parent 74f2fcc commit 8d50cf7
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.database.getStringOrNull
import androidx.fragment.app.Fragment
import androidx.sqlite.db.SupportSQLiteQueryBuilder
import com.absinthe.rulesbundle.LCRules
import com.madness.collision.chief.chiefContext
import com.madness.collision.misc.MiscApp
import com.madness.collision.unit.Bridge
import com.madness.collision.unit.Unit
Expand All @@ -40,6 +41,7 @@ import com.madness.collision.unit.api_viewing.database.AppRoom
import com.madness.collision.unit.api_viewing.tag.app.AppTagInfo
import com.madness.collision.unit.api_viewing.util.ApkRetriever
import com.madness.collision.unit.api_viewing.util.PrefUtil
import com.madness.collision.util.P
import com.madness.collision.util.Page
import kotlin.reflect.KClass
import com.madness.collision.R as MainR
Expand Down Expand Up @@ -98,26 +100,20 @@ object MyBridge: Bridge() {
AppTagInfo.ID_TECH_FLUTTER,
AppTagInfo.ID_TECH_REACT_NATIVE,
AppTagInfo.ID_TECH_XAMARIN,
AppTagInfo.ID_APP_SYSTEM_MODULE,
AppTagInfo.ID_TYPE_OVERLAY,
)
prefSettings.edit {
putStringSet(PrefUtil.AV_TAGS, tagSettings)
}
}

@Suppress("unused")
fun updateTagSettings(prefSettings: SharedPreferences) {
val tags = prefSettings.getStringSet(PrefUtil.AV_TAGS, null)?.let { HashSet(it) } ?: return
mapOf(
"avTagsValNlArm" to listOf(AppTagInfo.ID_PKG_ARM32, AppTagInfo.ID_PKG_ARM64),
"avTagsValNlX86" to listOf(AppTagInfo.ID_PKG_X86, AppTagInfo.ID_PKG_X64)
).forEach { (oldID, newIds) ->
if (tags.contains(oldID).not()) return@forEach // continue
tags.addAll(newIds)
tags.remove(oldID)
}
prefSettings.edit {
putStringSet(PrefUtil.AV_TAGS, tags)
}
fun addModOverlayTags() {
val prefSettings = chiefContext.getSharedPreferences(P.PREF_SETTINGS, Context.MODE_PRIVATE)
val tags = prefSettings.getStringSet(PrefUtil.AV_TAGS, null)?.toHashSet() ?: return
tags.addAll(listOf(AppTagInfo.ID_APP_SYSTEM_MODULE, AppTagInfo.ID_TYPE_OVERLAY))
prefSettings.edit { putStringSet(PrefUtil.AV_TAGS, tags) }
}

@Suppress("unused")
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ android {
applicationId = "com.madness.collision"
minSdk = 23
targetSdk = 34
versionCode = 23081415
versionName = "4.1.0"
versionCode = 23092018
versionName = "4.1.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testApplicationId = "${applicationId}.test"
renderscriptSupportModeEnabled = true
Expand Down
67 changes: 3 additions & 64 deletions app/src/main/kotlin/com/madness/collision/misc/MiscMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@ package com.madness.collision.misc

import android.content.Context
import android.content.SharedPreferences
import android.content.pm.ShortcutManager
import android.os.Environment
import androidx.core.content.edit
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.madness.collision.BuildConfig
import com.madness.collision.instant.Instant
import com.madness.collision.settings.LanguageMan
import com.madness.collision.unit.Unit
import com.madness.collision.unit.api_viewing.AccessAV
import com.madness.collision.util.*
import com.madness.collision.util.config.LocaleUtils
import com.madness.collision.util.os.OsUtils
import java.io.File
import java.io.IOException
import java.lang.Exception
import kotlin.random.Random

internal object MiscMain {
Expand Down Expand Up @@ -67,65 +62,6 @@ internal object MiscMain {
}
// below: app in update process to the newest
// below: apply actions
if (verOri in 0 until 20032901) {
// remove old format frequency data
val pref = context.getSharedPreferences(P.PREF_SETTINGS, Context.MODE_PRIVATE)
pref.edit { remove(P.UNIT_FREQUENCIES) }
// init pinned units
initPinnedUnits(prefSettings)
// init tags
AccessAV.initTagSettings(context, prefSettings)
}
if (verOri in 0 until 20042923) {
// delete legacy location pics in cache
val valCachePubExterior = F.createPath(F.cachePublicPath(context), Environment.DIRECTORY_PICTURES, "Exterior")
arrayOf(
F.createPath(valCachePubExterior, "back.webp"),
F.createPath(valCachePubExterior, "backDark.webp"),
F.createPath(valCachePubExterior, "twBack.webp"),
F.createPath(valCachePubExterior, "twBackDark.webp"),
).forEach {
val oriFile = File(it)
if (oriFile.exists().not()) return@forEach // continue
try { oriFile.delete() } catch (e: IOException) { e.printStackTrace() }
}
}
if ((verOri in 0 until 20092514) && X.aboveOn(X.N_MR1)) {
val sm = context.getSystemService(ShortcutManager::class.java)
if (sm != null) Instant(context, sm).refreshDynamicShortcuts(P.SC_ID_AUDIO_TIMER)
}
if (verOri in 0 until 21010113) {
deleteDirs(F.valCachePubAvSeal(context))
}
if (verOri in 0 until 21081315) {
// remove preference of Cool App unit
prefSettings.edit {
remove("toolsAppPackageName")
}
// remove unit config of removed units
listOf("cool_app", "no_media", "we_chat_evo", "qq_contacts").forEach {
Unit.unpinUnit(context, it, prefSettings)
Unit.enableUnit(context, it, prefSettings)
Unit.removeFrequency(context, it, prefSettings)
}
// clear qq contacts data
if (OsUtils.satisfy(OsUtils.N_MR1)) {
context.getSystemService(ShortcutManager::class.java)?.let { sm ->
val instant = Instant(context, sm)
val dataDir = F.createPath(F.cachePublicPath(context),
Environment.DIRECTORY_PICTURES, "qqInstantManager")
instant.dynamicShortcuts.filter {
it.id.startsWith("qq")
}.map { it.id }.let {
instant.removeDynamicShortcuts(*it.toTypedArray())
}
X.deleteFolder(File(dataDir))
}
}
}
if (verOri in 0 until 21090720) {
AccessAV.updateTagSettings(context)
}
if (verOri in 0 until 22041320) {
// remove unit config of school timetable
"school_timetable".let {
Expand Down Expand Up @@ -167,6 +103,9 @@ internal object MiscMain {
val keys = listOf("icsInstructor", "googleCalendarDefault", "iCalendarAppMode", "icsFilePath")
prefSettings.edit { keys.forEach { remove(it) } }
}
listOf(SelfUpdater23()).forEach { updater ->
if (verOri in 0..<updater.maxVerCode) updater.apply(verOri)
}
}

private fun initPinnedUnits(pref: SharedPreferences) {
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/kotlin/com/madness/collision/misc/SelfUpdater23.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2023 Clifford Liu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.madness.collision.misc

import com.madness.collision.unit.api_viewing.AccessAV

class SelfUpdater23 {
val maxVerCode = 23092018
fun apply(oldVerCode: Int) {
// check illegal version code
if (oldVerCode < 0) return
// use ifs instead of when to implement fallthrough
if (oldVerCode < 23092018) {
AccessAV.addModOverlayTags()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ object AccessAV: UnitAccess(Unit.UNIT_NAME_API_VIEWING) {
getMethod("initTagSettings", SharedPreferences::class).invoke(prefSettings)
}

fun updateTagSettings(
context: Context,
prefSettings: SharedPreferences = context.getSharedPreferences(P.PREF_SETTINGS, Context.MODE_PRIVATE)
) {
getMethod("updateTagSettings", SharedPreferences::class).invoke(prefSettings)
fun addModOverlayTags() {
invokeWithoutArg("addModOverlayTags")
}

fun resolveUri(context: Context, uri: Uri): Any? {
Expand Down
17 changes: 17 additions & 0 deletions release notes/04.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@


- **4.1.1** 23092018
<en-US>
- App API: redirect to Xiaomi and Huawei app stores
- App API: fix setting changes not automatically reflected
- Themed Wallpaper: fix wallpaper previews not automatically updated
- Themed Wallpaper: fix missing dynamic wallpaper permission on MIUI
- Fix rectangle icons for splash screen and app list on MIUI/HarmonyOS
</en-US>
<zh-CN>
- 应用API:支持跳转小米和华为应用商店
- 应用API:修复设置更改后界面未自动更新
- 主题壁纸:修复壁纸更换后预览未自动更新
- 主题壁纸:修复部分MIUI版本上未请求动态壁纸权限
- 修复MIUI和HarmonyOS上开屏页面和应用列表的矩形图标
</zh-CN>


- **4.1.0** 23081415
<en-US>
- App API details page: conveniently switch between apps
Expand Down

0 comments on commit 8d50cf7

Please sign in to comment.