Fix: Fixed the backup system.

This commit is contained in:
HeCodes2Much
2024-12-01 08:47:28 +00:00
parent 86540e55dd
commit 4832fecfbb
3 changed files with 5 additions and 15 deletions

View File

@@ -94,7 +94,7 @@ const val SMALLEST_WIDTH_600: Int = 600
fun Context.createIconWithResourceCompat( fun Context.createIconWithResourceCompat(
@DrawableRes vectorIconId: Int, @DrawableRes vectorIconId: Int,
@DrawableRes adaptiveIconForegroundId: Int, @DrawableRes adaptiveIconForegroundId: Int,
@DrawableRes adaptiveIconBackgroundId: Int @DrawableRes adaptiveIconBackgroundId: Int,
): IconCompat { ): IconCompat {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val adaptiveIconDrawable = AdaptiveIconDrawable( val adaptiveIconDrawable = AdaptiveIconDrawable(
@@ -116,7 +116,6 @@ fun Context.currentLanguage() = ConfigurationCompat.getLocales(resources.configu
fun Context.openBrowser(url: String, clearFromRecent: Boolean = true) { fun Context.openBrowser(url: String, clearFromRecent: Boolean = true) {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
browserIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
if (clearFromRecent) browserIntent.flags = if (clearFromRecent) browserIntent.flags =
browserIntent.flags or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS browserIntent.flags or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
startActivity(browserIntent) startActivity(browserIntent)
@@ -281,7 +280,6 @@ fun Context.launchCalendar() {
fun Context.openBatteryManager() { fun Context.openBatteryManager() {
try { try {
val intent = Intent(Intent.ACTION_POWER_USAGE_SUMMARY) val intent = Intent(Intent.ACTION_POWER_USAGE_SUMMARY)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
this.startActivity(intent) this.startActivity(intent)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
// Battery manager settings cannot be opened // Battery manager settings cannot be opened
@@ -312,7 +310,7 @@ fun Context.searchOnPlayStore(query: String? = null): Boolean {
fun Context.searchCustomSearchEngine( fun Context.searchCustomSearchEngine(
preferenceHelper: PreferenceHelper, preferenceHelper: PreferenceHelper,
searchQuery: String? = null searchQuery: String? = null,
): Boolean { ): Boolean {
val searchUrl = when (preferenceHelper.searchEngines) { val searchUrl = when (preferenceHelper.searchEngines) {
@@ -373,7 +371,7 @@ fun Context.hasInternetPermission(): Boolean {
fun Context.isPackageInstalled( fun Context.isPackageInstalled(
packageName: String, packageName: String,
userHandle: UserHandle = android.os.Process.myUserHandle() userHandle: UserHandle = android.os.Process.myUserHandle(),
): Boolean { ): Boolean {
val launcher = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps val launcher = getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
val activityInfo = launcher.getActivityList(packageName, userHandle) val activityInfo = launcher.getActivityList(packageName, userHandle)

View File

@@ -161,7 +161,6 @@ class AppHelper @Inject constructor() {
val intent = Intent() val intent = Intent()
intent.component = ComponentName(packageName, className) intent.component = ComponentName(packageName, className)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent) context.startActivity(intent)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
// Digital Wellbeing app is not installed or cannot be opened // Digital Wellbeing app is not installed or cannot be opened
@@ -264,21 +263,18 @@ class AppHelper @Inject constructor() {
Intent.EXTRA_TEXT, Intent.EXTRA_TEXT,
"$description https://f-droid.org/packages/${context.packageName}" "$description https://f-droid.org/packages/${context.packageName}"
) )
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(Intent.createChooser(shareIntent, "Share Application")) context.startActivity(Intent.createChooser(shareIntent, "Share Application"))
} }
fun helpFeedbackButton(context: Context) { fun helpFeedbackButton(context: Context) {
val uri = Uri.parse("https://github.com/DroidWorksStudio/EasyLauncher") val uri = Uri.parse("https://github.com/DroidWorksStudio/EasyLauncher")
val intent = Intent(Intent.ACTION_VIEW, uri) val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent) context.startActivity(intent)
} }
fun communitySupportButton(context: Context) { fun communitySupportButton(context: Context) {
val uri = Uri.parse("https://t.me/DroidWorksStudio/") val uri = Uri.parse("https://t.me/DroidWorksStudio/")
val intent = Intent(Intent.ACTION_VIEW, uri) val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent) context.startActivity(intent)
} }
@@ -286,7 +282,6 @@ class AppHelper @Inject constructor() {
val emailIntent = Intent(Intent.ACTION_SENDTO) val emailIntent = Intent(Intent.ACTION_SENDTO)
emailIntent.data = Uri.parse("mailto:droidworksstuido@063240.xyz") emailIntent.data = Uri.parse("mailto:droidworksstuido@063240.xyz")
emailIntent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name) emailIntent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name)
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(Intent.createChooser(emailIntent, "Choose Mail Application")) context.startActivity(Intent.createChooser(emailIntent, "Choose Mail Application"))
} }
@@ -300,7 +295,6 @@ class AppHelper @Inject constructor() {
type = "application/json" type = "application/json"
putExtra(Intent.EXTRA_TITLE, fileName) putExtra(Intent.EXTRA_TITLE, fileName)
} }
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity.startActivityForResult(intent, Constants.BACKUP_WRITE, null) activity.startActivityForResult(intent, Constants.BACKUP_WRITE, null)
} }
@@ -309,7 +303,6 @@ class AppHelper @Inject constructor() {
addCategory(Intent.CATEGORY_OPENABLE) addCategory(Intent.CATEGORY_OPENABLE)
type = "application/json" type = "application/json"
} }
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity.startActivityForResult(intent, Constants.BACKUP_READ, null) activity.startActivityForResult(intent, Constants.BACKUP_READ, null)
} }
@@ -370,7 +363,7 @@ class AppHelper @Inject constructor() {
fun fetchWeatherData( fun fetchWeatherData(
context: Context, context: Context,
latitude: Float, latitude: Float,
longitude: Float longitude: Float,
): WeatherResult { ): WeatherResult {
// Check if cached data is available and not expired // Check if cached data is available and not expired
val cachedWeatherData = context.getWeatherDataFromCache() val cachedWeatherData = context.getWeatherDataFromCache()

View File

@@ -11,8 +11,7 @@ object AppReloader {
val intent = packageManager.getLaunchIntentForPackage(context.packageName) val intent = packageManager.getLaunchIntentForPackage(context.packageName)
val componentName = intent?.component val componentName = intent?.component
val mainIntent = Intent.makeRestartActivityTask(componentName) val mainIntent = Intent.makeRestartActivityTask(componentName)
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) mainIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
// Delay the restart slightly to ensure all current activities are finished // Delay the restart slightly to ensure all current activities are finished
Handler(Looper.getMainLooper()).post { Handler(Looper.getMainLooper()).post {