Skip to content

Commit 857ab8d

Browse files
various ui tweaks
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 89e2d80 commit 857ab8d

12 files changed

Lines changed: 296 additions & 73 deletions

File tree

app/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,18 @@ android {
557557
}
558558
//noinspection GrDeprecatedAPIUsage
559559
buildToolsVersion = "34.0.0"
560+
kotlinOptions {
561+
jvmTarget = "17"
562+
}
560563
@Suppress("DEPRECATION") packagingOptions {
561564
jniLibs {
562565
useLegacyPackaging = true
563566
}
564567
}
568+
compileOptions {
569+
sourceCompatibility = JavaVersion.VERSION_17
570+
targetCompatibility = JavaVersion.VERSION_17
571+
}
565572
}
566573

567574
java {

app/src/main/AndroidManifest.xml

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
3-
<!--
4-
~ Copyright (c) 2023 to present Androidacy and contributors. Names, logos, icons, and the Androidacy name are all trademarks of Androidacy and may not be used without license. See LICENSE for more information.
5-
-->
6-
72
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
83
xmlns:tools="http://schemas.android.com/tools"
94
tools:ignore="QueryAllPackagesPermission"
@@ -15,16 +10,13 @@
1510
<intent>
1611
<action android:name="com.fox2code.mmm.utils.intent.action.OPEN_EXTERNAL" />
1712
</intent>
18-
</queries>
19-
<!-- Wifi is not the only way to get an internet connection -->
13+
</queries> <!-- Wifi is not the only way to get an internet connection -->
2014
<uses-feature
2115
android:name="android.hardware.wifi"
22-
android:required="false" />
23-
<!-- uses webview -->
16+
android:required="false" /> <!-- uses webview -->
2417
<uses-feature
2518
android:name="android.software.webview"
26-
android:required="true" />
27-
<!-- uses opengl 1.2 -->
19+
android:required="true" /> <!-- uses opengl 1.2 -->
2820
<uses-feature
2921
android:name="android.hardware.opengles.aep"
3022
android:required="false" />
@@ -51,28 +43,35 @@
5143
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
5244
<!-- wake lock -->
5345
<uses-permission android:name="android.permission.WAKE_LOCK" />
46+
<!-- request uninstall -->
47+
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
48+
<!-- wifi -->
49+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
5450

5551
<application
5652
android:name=".MainApplication"
5753
android:allowBackup="false"
58-
android:hardwareAccelerated="true"
54+
android:appCategory="productivity"
5955
android:dataExtractionRules="@xml/data_extraction_rules"
6056
android:enableOnBackInvokedCallback="true"
57+
android:forceDarkAllowed="false"
6158
android:fullBackupContent="@xml/full_backup_content"
59+
android:hardwareAccelerated="true"
6260
android:icon="@mipmap/ic_launcher"
6361
android:label="@string/app_name_v2"
62+
android:memtagMode="async"
6463
android:networkSecurityConfig="@xml/network_security_config"
6564
android:roundIcon="@mipmap/ic_launcher"
6665
android:supportsRtl="@bool/lang_support_rtl"
6766
android:testOnly="false"
68-
android:appCategory="productivity"
69-
android:memtagMode="async"
7067
android:theme="@style/Theme.MagiskModuleManager"
7168
android:usesCleartextTraffic="false"
72-
android:forceDarkAllowed="false"
7369
tools:ignore="ManifestResource"
7470
tools:replace="android:supportsRtl"
7571
tools:targetApi="tiramisu">
72+
<activity
73+
android:name=".ExpiredActivity"
74+
android:exported="false" />
7675
<activity
7776
android:name=".UpdateActivity"
7877
android:exported="false"
@@ -105,19 +104,18 @@
105104
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
106105
</intent-filter>
107106
</activity>
108-
109107
<activity
110108
android:name=".MainActivity"
111109
android:exported="true"
112110
android:label="@string/app_name_short_v2"
113111
android:launchMode="singleTask"
114-
android:theme="@style/Theme.MagiskModuleManager.NoActionBar" >
112+
android:theme="@style/Theme.MagiskModuleManager.NoActionBar">
115113
<intent-filter>
116114
<action android:name="android.intent.action.MAIN" />
115+
117116
<category android:name="android.intent.category.LAUNCHER" />
118117
</intent-filter>
119118
</activity>
120-
121119
<activity
122120
android:name=".installer.InstallerActivity"
123121
android:exported="false"
@@ -131,13 +129,11 @@
131129
<action android:name="${applicationId}.intent.action.INSTALL_MODULE_INTERNAL" />
132130
</intent-filter>
133131
-->
134-
</activity>
135-
136-
<!-- We can handle zip files -->
132+
</activity> <!-- We can handle zip files -->
137133
<activity
138134
android:name=".utils.ZipFileOpener"
139135
android:exported="true"
140-
android:theme="@style/Theme.MagiskModuleManager.NoActionBar" >
136+
android:theme="@style/Theme.MagiskModuleManager.NoActionBar">
141137
<intent-filter>
142138
<action android:name="android.intent.action.VIEW" />
143139

@@ -148,26 +144,23 @@
148144
<data android:scheme="content" />
149145
</intent-filter>
150146
</activity>
151-
152147
<activity
153148
android:name=".markdown.MarkdownActivity"
154149
android:exported="false"
155150
android:parentActivityName=".MainActivity"
156151
android:theme="@style/Theme.MagiskModuleManager.NoActionBar" />
157-
158152
<activity
159153
android:name=".androidacy.AndroidacyActivity"
160154
android:exported="false"
161155
android:parentActivityName=".MainActivity"
162-
android:theme="@style/Theme.MagiskModuleManager.NoActionBar" >
156+
android:theme="@style/Theme.MagiskModuleManager.NoActionBar">
163157

164158
<!--
165159
<intent-filter>
166160
<action android:name="${applicationId}.intent.action.OPEN_ANDROIDACY_INTERNAL" />
167161
</intent-filter>
168162
-->
169163
</activity>
170-
171164
<activity
172165
android:name="com.mikepenz.aboutlibraries.ui.LibsActivity"
173166
tools:node="remove" />
@@ -184,7 +177,6 @@
184177
android:name="androidx.work.WorkManagerInitializer"
185178
tools:node="remove" />
186179
</provider>
187-
188180
<provider
189181
android:name="androidx.core.content.FileProvider"
190182
android:authorities="${applicationId}.file-provider"
@@ -200,29 +192,25 @@
200192
android:value="false" />
201193
<meta-data
202194
android:name="io.sentry.dsn"
203-
android:value="https://e199c2a54a1f49b1b5beb3244f2c2358@sentry.androidacy.com/77" />
204-
<!-- enable view hierarchy for crashes -->
205-
<meta-data android:name="io.sentry.attach-view-hierarchy" android:value="true" />
206-
<!-- Sane value, but feel free to lower it -->
195+
android:value="https://e199c2a54a1f49b1b5beb3244f2c2358@sentry.androidacy.com/77" /> <!-- enable view hierarchy for crashes -->
196+
<meta-data
197+
android:name="io.sentry.attach-view-hierarchy"
198+
android:value="true" /> <!-- Sane value, but feel free to lower it -->
207199
<meta-data
208200
android:name="io.sentry.traces.sample-rate"
209-
android:value="0.2" />
210-
<!-- Doesn't actually monitor anything, just used to get the activities the user went through -->
201+
android:value="0.2" /> <!-- Doesn't actually monitor anything, just used to get the activities the user went through -->
211202
<meta-data
212203
android:name="io.sentry.traces.user-interaction.enable"
213-
android:value="true" />
214-
<!-- Just a screenshot of ONLY the current activity at the time of the crash -->
204+
android:value="true" /> <!-- Just a screenshot of ONLY the current activity at the time of the crash -->
215205
<meta-data
216206
android:name="io.sentry.attach-screenshot"
217-
android:value="true" />
218-
<!-- Just the current activity at the time of the crash -->
207+
android:value="true" /> <!-- Just the current activity at the time of the crash -->
219208
<meta-data
220209
android:name="io.sentry.attach-stacktrace"
221-
android:value="true" />
222-
<!-- Performance profiling -->
210+
android:value="true" /> <!-- Performance profiling -->
223211
<meta-data
224212
android:name="io.sentry.traces.profiling.sample-rate"
225213
android:value="0.2" />
226214
</application>
227215

228-
</manifest>
216+
</manifest>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fox2code.mmm
2+
3+
import android.annotation.SuppressLint
4+
import android.content.Intent
5+
import android.net.Uri
6+
import android.os.Bundle
7+
import com.fox2code.foxcompat.app.FoxActivity
8+
import com.google.android.material.button.MaterialButton
9+
10+
class ExpiredActivity : FoxActivity() {
11+
@SuppressLint("RestrictedApi")
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_expired)
15+
// download_button leads to the download page and uninstall_button leads to the uninstall dialog
16+
val downloadBtn = findViewById<MaterialButton>(R.id.download_button)
17+
val uninstallBtn = findViewById<MaterialButton>(R.id.uninstall_button)
18+
downloadBtn.setOnClickListener {
19+
// open https://www.androidacy.com/downloads/?view=FoxMMM
20+
startActivity(
21+
Intent(
22+
Intent.ACTION_VIEW,
23+
Uri.parse("https://www.androidacy.com/downloads/?view=FoxMMM")
24+
)
25+
)
26+
}
27+
uninstallBtn.setOnClickListener {
28+
// open system uninstall dialog
29+
val intent = Intent(Intent.ACTION_DELETE)
30+
// discover our package name
31+
intent.data = Uri.parse("package:$packageName")
32+
startActivity(intent)
33+
}
34+
}
35+
}

app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,28 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
135135
}
136136
}.start()
137137
val ts = Timestamp(System.currentTimeMillis() - 30L * 24 * 60 * 60 * 1000)
138-
// check if this build has expired
139138
val buildTime = Timestamp(BuildConfig.BUILD_TIME)
140-
// if the build time is more than 30 days ago, throw an exception
141139
if (BuildConfig.DEBUG) {
142-
check(ts.time < buildTime.time) { getString(R.string.build_expired) }
140+
if (ts.time > buildTime.time) {
141+
val pm = packageManager
142+
val intent = Intent(this, ExpiredActivity::class.java)
143+
@Suppress("DEPRECATION") val resolveInfo = pm.queryIntentActivities(intent, 0)
144+
if (resolveInfo.size > 0) {
145+
startActivity(intent)
146+
finish()
147+
return
148+
} else {
149+
throw IllegalAccessError("This build has expired")
150+
}
151+
}
143152
} else {
144-
// non-debug builds expire after 1 year but only show a toast
145153
val ts2 = Timestamp(System.currentTimeMillis() - 365L * 24 * 60 * 60 * 1000)
146154
if (ts2.time > buildTime.time) {
147155
Toast.makeText(this, R.string.build_expired, Toast.LENGTH_LONG).show()
148156
}
149157
}
150158
setContentView(R.layout.activity_main)
151-
this.setTitle(R.string.app_name)
159+
this.setTitle(R.string.app_name_v2)
152160
// set window flags to ignore status bar
153161
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
154162
// ignore status bar space
@@ -342,6 +350,14 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
342350
}
343351
true
344352
}
353+
// parse intent. if action is SHOW_ONLINE, show online modules
354+
val action = intent.action
355+
if (action == "android.intent.action.SHOW_ONLINE") {
356+
// select online modules
357+
bottomNavigationView.selectedItemId = R.id.online_menu_item
358+
} else {
359+
bottomNavigationView.selectedItemId = R.id.installed_menu_item
360+
}
345361
// update the padding of blur_frame to match the new bottom nav height
346362
val blurFrame = findViewById<View>(R.id.blur_frame)
347363
blurFrame.post {

app/src/main/kotlin/com/fox2code/mmm/SetupActivity.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.apache.commons.io.FileUtils
3939
import timber.log.Timber
4040
import java.io.File
4141
import java.io.IOException
42+
import java.sql.Timestamp
4243
import java.util.Objects
4344

4445
class SetupActivity : FoxActivity(), LanguageActivity {
@@ -62,6 +63,27 @@ class SetupActivity : FoxActivity(), LanguageActivity {
6263
}
6364
val binding = ActivitySetupBinding.inflate(layoutInflater)
6465
setContentView(binding.root)
66+
val ts = Timestamp(System.currentTimeMillis() - 30L * 24 * 60 * 60 * 1000)
67+
val buildTime = Timestamp(BuildConfig.BUILD_TIME)
68+
if (BuildConfig.DEBUG) {
69+
if (ts.time > buildTime.time) {
70+
val pm = packageManager
71+
val intent = Intent(this, ExpiredActivity::class.java)
72+
@Suppress("DEPRECATION") val resolveInfo = pm.queryIntentActivities(intent, 0)
73+
if (resolveInfo.size > 0) {
74+
startActivity(intent)
75+
finish()
76+
return
77+
} else {
78+
throw IllegalAccessError("This build has expired")
79+
}
80+
}
81+
} else {
82+
val ts2 = Timestamp(System.currentTimeMillis() - 365L * 24 * 60 * 60 * 1000)
83+
if (ts2.time > buildTime.time) {
84+
Toast.makeText(this, R.string.build_expired, Toast.LENGTH_LONG).show()
85+
}
86+
}
6587
val view: View = binding.root
6688
(Objects.requireNonNull<Any>(view.findViewById(R.id.setup_background_update_check)) as MaterialSwitch).isChecked =
6789
BuildConfig.ENABLE_AUTO_UPDATER

app/src/main/kotlin/com/fox2code/mmm/UpdateActivity.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.view.View
1212
import android.webkit.CookieManager
1313
import android.webkit.WebSettings
1414
import android.webkit.WebView
15+
import android.widget.Toast
1516
import androidx.core.content.FileProvider
1617
import androidx.webkit.WebSettingsCompat
1718
import androidx.webkit.WebViewFeature
@@ -28,6 +29,7 @@ import timber.log.Timber
2829
import java.io.File
2930
import java.io.FileOutputStream
3031
import java.io.IOException
32+
import java.sql.Timestamp
3133
import java.util.Objects
3234

3335
class UpdateActivity : FoxActivity() {
@@ -38,6 +40,27 @@ class UpdateActivity : FoxActivity() {
3840
override fun onCreate(savedInstanceState: Bundle?) {
3941
super.onCreate(savedInstanceState)
4042
setContentView(R.layout.activity_update)
43+
val ts = Timestamp(System.currentTimeMillis() - 30L * 24 * 60 * 60 * 1000)
44+
val buildTime = Timestamp(BuildConfig.BUILD_TIME)
45+
if (BuildConfig.DEBUG) {
46+
if (ts.time > buildTime.time) {
47+
val pm = packageManager
48+
val intent = Intent(this, ExpiredActivity::class.java)
49+
@Suppress("DEPRECATION") val resolveInfo = pm.queryIntentActivities(intent, 0)
50+
if (resolveInfo.size > 0) {
51+
startActivity(intent)
52+
finish()
53+
return
54+
} else {
55+
throw IllegalAccessError("This build has expired")
56+
}
57+
}
58+
} else {
59+
val ts2 = Timestamp(System.currentTimeMillis() - 365L * 24 * 60 * 60 * 1000)
60+
if (ts2.time > buildTime.time) {
61+
Toast.makeText(this, R.string.build_expired, Toast.LENGTH_LONG).show()
62+
}
63+
}
4164
chgWv = findViewById(R.id.changelog_webview)
4265
if (MainApplication.isMatomoAllowed()) {
4366
TrackHelper.track().screen(this).with(MainApplication.INSTANCE!!.tracker)

0 commit comments

Comments
 (0)