Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0 #88

Merged
merged 104 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
e3f1bcb
Prepare for 3.0.0
qhy040404 Jun 22, 2022
4b5a17f
Reformat
qhy040404 Jun 22, 2022
efa0635
Add new themes
qhy040404 Jun 22, 2022
726d958
Modify color
qhy040404 Jun 22, 2022
5ff4b87
Convert to data class
qhy040404 Jun 22, 2022
d14fbcf
Convert Gson to Moshi
qhy040404 Jun 22, 2022
bcf88b0
Remove Gson
qhy040404 Jun 22, 2022
434ee63
Modify file structure
qhy040404 Jun 26, 2022
16c027b
Merge pull request #91 from qhy040404/master
qhy040404 Jun 30, 2022
749536e
Merge pull request #94 from qhy040404/master
qhy040404 Jul 2, 2022
b1a9a05
Merge pull request #97 from qhy040404/master
qhy040404 Jul 8, 2022
a1551af
Merge pull request #99 from qhy040404/master
qhy040404 Jul 13, 2022
a7ee2b8
Add foreground illustrator file
qhy040404 Jul 13, 2022
ed5d294
Modify foreground
qhy040404 Jul 13, 2022
e85055d
Prepare for new icon
qhy040404 Jul 13, 2022
60e81b3
Enable new icon
qhy040404 Jul 13, 2022
527c946
Reformat
qhy040404 Jul 13, 2022
21f7737
Merge pull request #101 from qhy040404/master
qhy040404 Jul 14, 2022
2e644e0
Disable Qodana in PR action
qhy040404 Jul 14, 2022
9d63bc0
Prepare for MD3 (Add switch)
qhy040404 Jul 14, 2022
6453b9c
Reformat implementations
qhy040404 Jul 15, 2022
a6b02f7
Add Material D3
qhy040404 Jul 15, 2022
62b2713
Remove `MD3 (Preview)` and `Theme` preferences
qhy040404 Jul 15, 2022
573cd7e
Using `MaterialAlertDialogBuilder` instead of `AlertDialog.Builder`
qhy040404 Jul 15, 2022
fbb2579
Remove remain md3 preferences
qhy040404 Jul 15, 2022
ba57de1
New `about` main coloe
qhy040404 Jul 15, 2022
f5cb674
New method to set `DayNight` and `DarkMode`
qhy040404 Jul 15, 2022
96e4e0b
Add `AboutAvtivityProxy`
qhy040404 Jul 15, 2022
8504803
Complete Coil
qhy040404 Jul 15, 2022
3557b76
Fix bug
qhy040404 Jul 15, 2022
52b42a2
Fix `AboutActivity` layout bug
qhy040404 Jul 15, 2022
3b83350
New method to getLayout
qhy040404 Jul 15, 2022
d6d89b3
Remove old UI
qhy040404 Jul 15, 2022
b1b6281
Misc
qhy040404 Jul 15, 2022
b88fc49
Modify shortcuts
qhy040404 Jul 15, 2022
0a64e3b
Add toolbar
qhy040404 Jul 15, 2022
31cce34
Add BaseFragment
qhy040404 Jul 15, 2022
b2d0f94
Convert `Activity` to `Fragment`
qhy040404 Jul 15, 2022
3d84aa4
Fix invalid session
qhy040404 Jul 15, 2022
8aa4067
Init new UI
qhy040404 Jul 15, 2022
c0f2e84
Fix session
qhy040404 Jul 15, 2022
abd5b5f
Add utils
qhy040404 Jul 15, 2022
51fc73a
Fix invisible part
qhy040404 Jul 15, 2022
e4ef6ef
Init utils
qhy040404 Jul 15, 2022
07a9c31
Cleanup AndroidManifest.xml
qhy040404 Jul 15, 2022
a3cc80d
Add new implementations
qhy040404 Jul 15, 2022
3b496fc
Add licenses
qhy040404 Jul 15, 2022
30e8c26
Modify UI
qhy040404 Jul 15, 2022
9ba046b
Misc
qhy040404 Jul 15, 2022
979c050
Enable minify
qhy040404 Jul 15, 2022
d8c5370
Disable minify for debug
qhy040404 Jul 15, 2022
7971b54
Add custom themes back
qhy040404 Jul 16, 2022
d8276dc
Misc
qhy040404 Jul 16, 2022
7317d0b
Add theme and md3 preference
qhy040404 Jul 16, 2022
52886ac
Bind Preference and code
qhy040404 Jul 16, 2022
74ca12f
Renew random data generator and apply custom theme
qhy040404 Jul 16, 2022
6763b1a
Fix no context bug
qhy040404 Jul 16, 2022
a54d19d
Modify strings
qhy040404 Jul 16, 2022
759dbcd
Fix language bug
qhy040404 Jul 16, 2022
735af35
Add Welcome dialog and fix shortcut bug
qhy040404 Jul 16, 2022
22366a3
Fix display bugs
qhy040404 Jul 16, 2022
1fda312
Add new const strings
qhy040404 Jul 16, 2022
1766db5
Add new methods to check basic information
qhy040404 Jul 16, 2022
9692489
Give up f**king minify
qhy040404 Jul 16, 2022
0c94a01
Fix view touch bug
qhy040404 Jul 16, 2022
11365ea
Fix preference bug
qhy040404 Jul 16, 2022
455b5c1
Fix icon
qhy040404 Jul 16, 2022
4df97bc
Fix `About` page display bug
qhy040404 Jul 16, 2022
848fc92
Fix `not attached to context`
qhy040404 Jul 16, 2022
571c77e
Add bottom navigation icons
qhy040404 Jul 16, 2022
6f72e7a
Make my IDE happy :joy:
qhy040404 Jul 16, 2022
bd1f77d
Rebuild new app icon
qhy040404 Jul 16, 2022
0d4fd54
Add tool icons (Close #57)
qhy040404 Jul 16, 2022
fb3ebd3
Rollback to targetApi 32 (Until newer AGP is released)
qhy040404 Jul 16, 2022
3890e25
Revert "Rollback to targetApi 32 (Until newer AGP is released)"
qhy040404 Jul 16, 2022
aa8a939
Clear warnings
qhy040404 Jul 16, 2022
d8bae31
New method to clear AppData
qhy040404 Jul 17, 2022
2f4c246
Add cache utils
qhy040404 Jul 17, 2022
917dc47
Add strings
qhy040404 Jul 17, 2022
7e01fbf
patch methods
qhy040404 Jul 17, 2022
9e337d2
Add icon
qhy040404 Jul 17, 2022
77bf964
Make my IDE happy :joy:
qhy040404 Jul 17, 2022
9277509
Add a RecycleView Model
qhy040404 Jul 18, 2022
721b9e7
Merge pull request #103 from qhy040404/master
qhy040404 Jul 19, 2022
75a6042
Merge pull request #104 from qhy040404/master
qhy040404 Jul 19, 2022
ab4b0cc
Merge pull request #105 from qhy040404/master
qhy040404 Jul 19, 2022
2a9d259
Check deprecation
qhy040404 Jul 19, 2022
142a745
Reformat file structure
qhy040404 Jul 19, 2022
212921d
Modify .gitignore
qhy040404 Jul 19, 2022
e8eed99
Remove resource sources
qhy040404 Jul 19, 2022
382b716
Make my IDE happy :joy:
qhy040404 Jul 19, 2022
2b64261
Make myself happy :stuck_out_tongue_winking_eye:
qhy040404 Jul 19, 2022
7b7444a
Add preference summary
qhy040404 Jul 19, 2022
ef84507
Reformat implementations
qhy040404 Jul 20, 2022
59cc485
Add a progressBar to RecycleView
qhy040404 Jul 20, 2022
55386f5
Add method to process HTTP 302
qhy040404 Jul 21, 2022
3abc92d
Add method to get 302 target
qhy040404 Jul 21, 2022
c5db268
Rename filename
qhy040404 Jul 21, 2022
859779d
Renew `About` icon
qhy040404 Jul 21, 2022
53ba913
Renew `About` theme
qhy040404 Jul 21, 2022
4439e1a
Add new theme
qhy040404 Jul 21, 2022
2f6e867
Add strings for new theme
qhy040404 Jul 21, 2022
934e827
Modify methods for new theme
qhy040404 Jul 21, 2022
fde7557
Close #106
qhy040404 Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:

jobs:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ app/debug/*
.project
.settings/org.eclipse.buildship.core.prefs
app/.settings/org.eclipse.buildship.core.prefs
.DS_Store
.DS_Store

resources/
42 changes: 29 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ plugins {
}

private static String baseVersionName() {
return "2.8.7"
return "3.0.0"
}

android {
compileSdk 33

defaultConfig {

applicationId "com.qhy040404.libraryonetap"
minSdk 29
targetSdk 33
Expand Down Expand Up @@ -43,21 +42,38 @@ android {
}
}

configurations.all {
exclude group: 'androidx.appcompat', module: 'appcompat'
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.appcompat:appcompat:1.6.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.google.code.gson:gson:2.9.0")
implementation("dev.rikka.rikkax.preference:simplemenu-preference:1.0.3")
implementation('com.tencent.bugly:crashreport:4.0.4')
implementation("com.drakeet.about:about:2.5.1")
implementation("com.drakeet.multitype:multitype:4.3.0")
implementation("io.coil-kt:coil:2.1.0")
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.drakeet.about:about:2.5.1'
implementation 'com.drakeet.multitype:multitype:4.3.0'
implementation 'com.github.zhaobozhen.libraries:utils:1.1.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.squareup.moshi:moshi-kotlin:1.13.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.tencent.bugly:crashreport:4.0.4'
implementation 'dev.rikka.rikkax.appcompat:appcompat:1.4.1'
implementation 'dev.rikka.rikkax.material:material:2.5.0'
implementation 'dev.rikka.rikkax.material:material-preference:2.0.0'
implementation 'dev.rikka.rikkax.preference:simplemenu-preference:1.0.3'
implementation 'dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.1'
implementation 'dev.rikka.rikkax.widget:borderview:1.1.0'
implementation 'io.coil-kt:coil:2.1.0'
implementation 'me.zhanghai.android.appiconloader:appiconloader:1.4.0'
}

import java.text.SimpleDateFormat
Expand Down
29 changes: 7 additions & 22 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
<application
android:name=".LibraryOneTapApp"
android:allowBackup="true"
android:icon="@mipmap/launcher_lol"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/launcher_lol"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Simple.NoActionBar"
android:theme="@style/AppTheme"
tools:targetApi="33">
<activity
android:name=".ui.tools.ToolsInitActivity"
android:name=".ui.about.AboutActivity"
android:exported="false"
android:label="@string/tools_title" />
<activity
android:name=".ui.AboutActivity"
android:exported="false"
android:label="@string/about_title" />
android:label="@string/about_title"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar.Library" />
<activity
android:name=".ui.secret.SecretActivity"
android:exported="false"
Expand All @@ -42,19 +39,7 @@
android:exported="false"
android:label="@string/bath_title" />
<activity
android:name=".ui.YanxiujianActivity"
android:exported="false"
android:label="@string/title_activity_yanxiujian" />
<activity
android:name=".ui.SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings" />
<activity
android:name=".ui.DetailActivity"
android:exported="false"
android:label="@string/library" />
<activity
android:name=".ui.MainActivity"
android:name=".ui.main.MainBottomActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/qhy040404/libraryonetap/LibraryOneTapApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ package com.qhy040404.libraryonetap

import android.app.Activity
import android.app.Application
import coil.Coil
import coil.ImageLoader
import com.absinthe.libraries.utils.utils.Utility
import com.google.android.material.color.DynamicColors
import com.qhy040404.libraryonetap.app.AppIconFetcherFactory
import com.qhy040404.libraryonetap.constant.Constants
import com.qhy040404.libraryonetap.constant.GlobalValues
import com.qhy040404.libraryonetap.utils.AppUtils
import com.tencent.bugly.crashreport.CrashReport
import rikka.material.app.DayNightDelegate
import rikka.material.app.LocaleDelegate
import java.util.*

class LibraryOneTapApp : Application() {
Expand All @@ -22,6 +31,21 @@ class LibraryOneTapApp : Application() {
strategy
)
app = this

LocaleDelegate.defaultLocale = AppUtils.locale
DayNightDelegate.setApplicationContext(this)
DayNightDelegate.setDefaultNightMode(AppUtils.getNightMode(GlobalValues.darkMode))
DynamicColors.applyToActivitiesIfAvailable(this)

Utility.init(this)

Coil.setImageLoader {
ImageLoader(this).newBuilder()
.components {
add(AppIconFetcherFactory(this@LibraryOneTapApp))
}
.build()
}
}

fun addActivity(activity: Activity) = activityList.add(activity)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.qhy040404.libraryonetap.app

import android.content.Context
import android.content.pm.PackageInfo
import android.graphics.drawable.BitmapDrawable
import coil.ImageLoader
import coil.decode.DataSource
import coil.fetch.DrawableResult
import coil.fetch.FetchResult
import coil.fetch.Fetcher
import coil.request.Options
import com.qhy040404.libraryonetap.utils.extensions.ViewExtensions.dp
import me.zhanghai.android.appiconloader.AppIconLoader

class AppIconFetcherFactory(private val ctx: Context) : Fetcher.Factory<PackageInfo> {
private val loader = AppIconLoader(40.dp, false, ctx)

override fun create(data: PackageInfo, options: Options, imageLoader: ImageLoader): Fetcher {
return AppIconFetcher(ctx, data, loader)
}

class AppIconFetcher(
private val context: Context,
private val info: PackageInfo,
private val loader: AppIconLoader,
) : Fetcher {
override suspend fun fetch(): FetchResult {
val icon = loader.loadIcon(info.applicationInfo)
return DrawableResult(BitmapDrawable(context.resources, icon), true, DataSource.DISK)
}
}
}
79 changes: 45 additions & 34 deletions app/src/main/java/com/qhy040404/libraryonetap/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
package com.qhy040404.libraryonetap.base

import android.content.res.Resources
import android.graphics.Color
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.viewbinding.ViewBinding
import com.qhy040404.libraryonetap.LibraryOneTapApp
import com.qhy040404.libraryonetap.R
import com.qhy040404.libraryonetap.constant.GlobalValues
import com.qhy040404.libraryonetap.utils.RandomDataUtils
import java.util.*
import com.qhy040404.libraryonetap.utils.AppUtils
import com.qhy040404.libraryonetap.utils.OsUtils
import com.qhy040404.libraryonetap.utils.extensions.CompatExtensions.inflateBinding
import rikka.material.app.MaterialActivity

@Suppress("DEPRECATION")
abstract class BaseActivity : AppCompatActivity() {
abstract class BaseActivity<VB : ViewBinding> : MaterialActivity() {

protected lateinit var binding: VB

override fun onCreate(savedInstanceState: Bundle?) {
val config = resources.configuration
val dm = resources.displayMetrics
var theme = GlobalValues.theme

when (GlobalValues.darkMode) {
"system" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
"on" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
"off" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
if (GlobalValues.theme == "random") {
theme = RandomDataUtils.randomTheme
if (!GlobalValues.md3) {
setTheme(AppUtils.getThemeID(GlobalValues.theme))
}
when (theme) {
"purple" -> setTheme(R.style.Theme_Purple)
"blue" -> setTheme(R.style.Theme_Blue)
"pink" -> setTheme(R.style.Theme_Pink)
"green" -> setTheme(R.style.Theme_Green)
"simple" -> setTheme(R.style.Theme_Simple)
}
config.setLocale(
when (GlobalValues.locale) {
"zh" -> Locale.SIMPLIFIED_CHINESE
"en" -> Locale.ENGLISH
else -> Locale.getDefault()
}
)
resources.updateConfiguration(config, dm)

super.onCreate(savedInstanceState)
LibraryOneTapApp.instance?.addActivity(this)

setContentView(getLayoutId())
if (!this::binding.isInitialized) {
binding = inflateBinding(layoutInflater)
}

setContentView(binding.root)

supportActionBar?.setDisplayHomeAsUpEnabled(true)
init()
}

override fun shouldApplyTranslucentSystemBars(): Boolean {
return true
}

override fun computeUserThemeKey(): String? {
return GlobalValues.darkMode + GlobalValues.theme + GlobalValues.md3
}

override fun onApplyTranslucentSystemBars() {
super.onApplyTranslucentSystemBars()
window.statusBarColor = Color.TRANSPARENT
window.decorView.post {
window.navigationBarColor = Color.TRANSPARENT
if (OsUtils.atLeastQ()) {
window.isNavigationBarContrastEnforced = false
}
}
}

override fun onApplyUserThemeResource(theme: Resources.Theme, isDecorView: Boolean) {
theme.applyStyle(R.style.ThemeOverlay, true)

if (!GlobalValues.md3) {
theme.applyStyle(AppUtils.getThemeID(GlobalValues.theme), true)
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
finish()
return super.onOptionsItemSelected(item)
}

protected abstract fun init()

protected abstract fun getLayoutId(): Int
}
38 changes: 38 additions & 0 deletions app/src/main/java/com/qhy040404/libraryonetap/base/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.qhy040404.libraryonetap.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.CallSuper
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.qhy040404.libraryonetap.utils.extensions.CompatExtensions.inflateBinding

abstract class BaseFragment<VB : ViewBinding> : Fragment() {
protected lateinit var binding: VB

private var parentActivityVisible = false
private var visible = false
private var localParentFragment: BaseFragment<VB>? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
init()
}

abstract fun init()

@CallSuper
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = inflateBinding(layoutInflater)
}

@CallSuper
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = binding.root
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ object Constants {

const val PREF_DARK = "dark"
const val PREF_THEME = "theme"
const val PREF_MD3 = "md3"
const val PREF_LOCALE = "locale"
const val PREF_RESET = "reset"

const val PREF_INIT = "initialized"

const val PREF_CACHE = "cache"
const val PREF_ABOUT = "about"

const val DEFAULT_DARK = "system"
const val DEFAULT_THEME = "simple"
const val DEFAULT_THEME = "blue"
const val DEFAULT_LOCALE = "system"

const val CONTENT_TYPE_SSO = "application/x-www-form-urlencoded; charset=utf-8"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.qhy040404.libraryonetap.constant

import android.content.pm.PackageManager
import com.google.gson.Gson
import com.qhy040404.libraryonetap.LibraryOneTapApp
import com.qhy040404.libraryonetap.utils.lazy.ResettableLazyUtils
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory

object GlobalManager {
val packageManager: PackageManager by lazy { LibraryOneTapApp.app.packageManager }
val lazyMgr = ResettableLazyUtils.resettableManager()
val gson: Gson by lazy { Gson() }
val moshi: Moshi = Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()
}
Loading