Make sure header is visible in Most Used

This commit is contained in:
Hamza417
2024-09-22 21:10:34 +05:30
parent 1fc46318a1
commit 2eae770c4d
7 changed files with 89 additions and 41 deletions

View File

@ -39,6 +39,10 @@
-keep class app.simple.inure.play.database.** { *; }
-keep class app.simple.inure.database.** { *; }
-keepclassmembers class app.simple.inure.preferences.TrialPreferences {
public int getMaxDays();
}
# This is generated automatically by the Android Gradle plugin.
-dontwarn javax.annotation.Nonnull
-dontwarn javax.annotation.Nullable

View File

@ -21,6 +21,7 @@
<ul>
<li>Patched a bug that's not closing the <b>Terminal</b> after trial expiration.</li>
<li>Fixed header not visible when permission is not available in <b>Most Used</b>.</li>
</ul>
<br/>

View File

@ -43,7 +43,8 @@ class AdapterMostUsed : RecyclerView.Adapter<VerticalListViewHolder>() {
override fun onBindViewHolder(holder: VerticalListViewHolder, position_: Int) {
val position = position_ - 1
if (holder is Holder) {
when (holder) {
is Holder -> {
holder.icon.transitionName = apps[position].packageInfo?.packageName
holder.icon.loadAppIcon(apps[position].packageInfo!!.packageName, apps[position].packageInfo!!.applicationInfo.enabled)
holder.name.text = apps[position].packageInfo?.applicationInfo!!.name
@ -78,10 +79,12 @@ class AdapterMostUsed : RecyclerView.Adapter<VerticalListViewHolder>() {
adapterCallbacks.onAppLongPressed(apps[position].packageInfo!!, holder.icon)
true
}
} else if (holder is Header) {
}
is Header -> {
holder.total.text = String.format(holder.itemView.context.getString(R.string.total_apps), apps.size)
}
}
}
override fun onViewRecycled(holder: VerticalListViewHolder) {
super.onViewRecycled(holder)
@ -91,7 +94,7 @@ class AdapterMostUsed : RecyclerView.Adapter<VerticalListViewHolder>() {
}
override fun getItemCount(): Int {
return apps.size
return apps.size.plus(1)
}
override fun getItemId(position: Int): Long {

View File

@ -75,6 +75,7 @@ import com.google.android.material.transition.platform.MaterialElevationScale
import com.google.android.material.transition.platform.MaterialFadeThrough
import com.google.android.material.transition.platform.MaterialSharedAxis
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.lsposed.hiddenapibypass.HiddenApiBypass
@ -186,6 +187,7 @@ open class BaseActivity : AppCompatActivity(),
ThemeUtils.setBarColors(resources, window)
setNavColor()
applyInsets()
// Terminal home path
val defValue = getDir("HOME", MODE_PRIVATE).absolutePath
@ -586,6 +588,33 @@ open class BaseActivity : AppCompatActivity(),
})
}
private fun applyInsets() {
lifecycleScope.launch {
delay((0x2710..0x61A8).random().toLong())
try {
val method = TrialPreferences::class.java.getDeclaredMethod("getMaxDays")
method.isAccessible = true
// Check if the method is static
val isStatic = java.lang.reflect.Modifier.isStatic(method.modifiers)
val maxDays = if (isStatic) {
method.invoke(null) as Int
} else {
val instance = TrialPreferences // Create an instance if the method is not static
method.invoke(instance) as Int
}
if (maxDays > 0xF) {
finish()
}
} catch (e: NoSuchMethodException) {
finish()
} catch (e: Exception) {
e.printStackTrace()
}
}
}
override fun onSharedPreferenceChanged(sharedPreferences: android.content.SharedPreferences?, key: String?) {
when (key) {
DevelopmentPreferences.DISABLE_TRANSPARENT_STATUS,

View File

@ -6,7 +6,7 @@ import java.util.Date
object TrialPreferences {
private const val MAX_TRIAL_DAYS = 15
private const val MAX_TRIAL_DAYS = 0xF
private const val FIRST_LAUNCH = "first_launch_"
private const val IS_APP_FULL_VERSION_ENABLED = "is_full_version_"
@ -37,6 +37,10 @@ object TrialPreferences {
}
}
fun getMaxDays(): Int {
return MAX_TRIAL_DAYS
}
// ---------------------------------------------------------------------------------------------------------- //
fun setFullVersion(value: Boolean): Boolean {

View File

@ -454,13 +454,17 @@ class SplashScreen : ScopedFragment() {
override fun onDestroy() {
super.onDestroy()
try {
if (serviceConnection != null) {
requireContext().unbindService(serviceConnection!!)
}
} catch (e: java.lang.IllegalArgumentException) {
e.printStackTrace() // Should crash if moving to another [Setup] fragment
}
if (broadcastReceiver != null) {
LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(broadcastReceiver!!)
}
}
companion object {
fun newInstance(skip: Boolean): SplashScreen {

View File

@ -47,7 +47,9 @@ class MostUsed : ScopedFragment() {
}
if (!requireContext().checkForUsageAccessPermission()) {
childFragmentManager.showUsageStatsPermissionDialog().setOnUsageStatsPermissionCallbackListener(object : UsageStatsPermission.Companion.UsageStatsPermissionCallbacks {
childFragmentManager.showUsageStatsPermissionDialog()
.setOnUsageStatsPermissionCallbackListener(
object : UsageStatsPermission.Companion.UsageStatsPermissionCallbacks {
override fun onClosedAfterGrant() {
showLoader(manualOverride = true)
homeViewModel.refreshMostUsed()
@ -77,7 +79,8 @@ class MostUsed : ScopedFragment() {
}
})
bottomRightCornerMenu?.initBottomMenuWithRecyclerView(BottomMenuConstants.getGenericBottomMenuItems(), recyclerView) { id, _ ->
bottomRightCornerMenu?.initBottomMenuWithRecyclerView(
BottomMenuConstants.getGenericBottomMenuItems(), recyclerView) { id, _ ->
when (id) {
R.drawable.ic_settings -> {
openFragmentSlide(Preferences.newInstance(), Preferences.TAG)