Skip to content

Commit

Permalink
fix rboard on P & Q
Browse files Browse the repository at this point in the history
  • Loading branch information
AkosPaha01 committed Jul 18, 2021
1 parent 00950fe commit c2df8b9
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .idea/render.experimental.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package de.dertyp7214.rboardthememanager.screens

import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import androidx.recyclerview.widget.LinearLayoutManager
import de.Maxr1998.modernpreferences.PreferencesAdapter
import de.dertyp7214.rboardthememanager.databinding.ActivityPreferencesBinding
Expand All @@ -14,10 +17,13 @@ class PreferencesActivity : AppCompatActivity() {

private lateinit var binding: ActivityPreferencesBinding

@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPreferencesBinding.inflate(layoutInflater)
window.setDecorFitsSystemWindows(false)
window.run{
WindowCompat.setDecorFitsSystemWindows(this, false)
}
setContentView(binding.root)

val preferences = Preferences(this, intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.ViewTreeObserver
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.preference.PreferenceManager
Expand Down Expand Up @@ -44,6 +46,7 @@ class SplashScreen : AppCompatActivity() {
return checkedForUpdate || !rootAccess
}

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash_screen)
Expand Down Expand Up @@ -190,6 +193,7 @@ class SplashScreen : AppCompatActivity() {
}
}

@RequiresApi(Build.VERSION_CODES.O)
private fun createNotificationChannels() {
val namePush = getString(R.string.channel_name)
val channelIdPush = getString(R.string.default_notification_channel_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class Flags(val context: Context) {
}
}
}
),
EMPTY1(
"empty1",
-1,
-1,
-1,
"",
TYPE.GROUP
);

@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.dertyp7214.rboardthememanager.utils
import android.app.Activity
import android.content.Intent
import android.os.Build
import androidx.annotation.RequiresApi
import de.Maxr1998.modernpreferences.PreferenceScreen
import de.Maxr1998.modernpreferences.helpers.categoryHeader
import de.Maxr1998.modernpreferences.helpers.pref
Expand All @@ -13,6 +14,7 @@ import de.dertyp7214.rboardthememanager.R

class Preferences(private val activity: Activity, private val intent: Intent) {
val preferences: PreferenceScreen
@RequiresApi(Build.VERSION_CODES.R)
get() {
return when (intent.getStringExtra("type")) {
"info" -> getInfoPreferences()
Expand All @@ -38,6 +40,7 @@ class Preferences(private val activity: Activity, private val intent: Intent) {
private fun getFlagsPreferences() = screen(activity, Flags(activity)::preferences)
private fun getAllFlagsPreferences() = screen(activity, Flags(activity)::allFlagsPreferences)

@RequiresApi(Build.VERSION_CODES.R)
private fun getInfoPreferences(): PreferenceScreen {
val usingModule = MagiskUtils.getModules().any { it.id == Config.MODULE_ID }
return screen(activity) {
Expand Down Expand Up @@ -66,7 +69,7 @@ class Preferences(private val activity: Activity, private val intent: Intent) {
}
pref("android_version") {
titleRes = R.string.android_version
summary = Build.VERSION.RELEASE_OR_CODENAME
summary = Build.VERSION.RELEASE
iconRes = R.drawable.ic_android
}
if (MagiskUtils.isMagiskInstalled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package de.dertyp7214.rboardthememanager.utils

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import com.downloader.Error
import com.downloader.OnDownloadListener
Expand All @@ -12,6 +14,7 @@ import de.dertyp7214.rboardthememanager.BuildConfig
import java.io.File
import kotlin.math.roundToLong


class UpdateHelper(
private val url: String,
private val context: Context,
Expand Down Expand Up @@ -59,15 +62,22 @@ class UpdateHelper(
finishListener("$path/update.apk", System.currentTimeMillis() - startTime)
val toInstall: File = File(path, "$path/update.apk")
val intent: Intent
val apkUri = FileProvider.getUriForFile(
context,
BuildConfig.APPLICATION_ID + ".fileprovider",
toInstall
)
intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.data = apkUri
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
val apkUri = FileProvider.getUriForFile(
context,
BuildConfig.APPLICATION_ID + ".fileprovider",
toInstall
)
intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.data = apkUri
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
} else {
val apkUri: Uri = Uri.fromFile(toInstall)
intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
}

override fun onError(error: Error?) {
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
<item name="android:statusBarColor">@color/foreground</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:navigationBarColor">@color/foreground</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="Theme.RboardThemeManagerV3.InstallPack" parent="Theme.RboardThemeManagerV3">
<item name="android:statusBarColor">@color/foreground</item>
<item name="android:navigationBarColor">@color/foreground</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="Theme.RboardThemeManagerV3.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">@color/foreground</item>
<item name="colorPrimaryVariant">@color/foreground</item>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@

<style name="Theme.RboardThemeManagerV3.Main" parent="Theme.RboardThemeManagerV3">
<item name="android:navigationBarColor">@color/foreground</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="Theme.RboardThemeManagerV3.Info" parent="Theme.RboardThemeManagerV3">
<item name="android:statusBarColor">@color/foreground</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:navigationBarColor">@color/foreground</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="Theme.RboardThemeManagerV3.InstallPack" parent="Theme.RboardThemeManagerV3">
<item name="android:statusBarColor">@color/foreground</item>
<item name="android:navigationBarColor">@color/foreground</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>

<style name="Theme.RboardThemeManagerV3.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">@color/foreground</item>
<item name="colorPrimaryVariant">@color/foreground</item>
Expand Down

0 comments on commit c2df8b9

Please sign in to comment.