Skip to content

Commit

Permalink
refactor: migrate to non-transitive R classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennoard committed Jul 16, 2024
1 parent 6afae38 commit 0e19ca7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/src/main/kotlin/com/androidvip/sysctlgui/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import com.androidvip.sysctlgui.receivers.TaskerReceiver
import com.google.android.material.color.ColorRoles
import com.google.android.material.color.MaterialColors
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.InputStream
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

fun View.goAway() { this.visibility = View.GONE }
fun View.hide() { this.visibility = View.INVISIBLE }
fun View.show() { this.visibility = View.VISIBLE }

fun View.getColorRoles(@AttrRes colorAttrRes: Int = R.attr.colorPrimary): ColorRoles {
fun View.getColorRoles(@AttrRes colorAttrRes: Int = androidx.appcompat.R.attr.colorPrimary): ColorRoles {
val color = MaterialColors.getColor(this, colorAttrRes)
return MaterialColors.getColorRoles(context, color)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.androidvip.sysctlgui.ui.base
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import com.androidvip.sysctlgui.R
import com.androidvip.sysctlgui.design.DesignStyles
import com.androidvip.sysctlgui.domain.repository.AppPrefs
import org.koin.android.ext.android.inject

Expand All @@ -19,7 +19,7 @@ abstract class BaseAppCompatActivity : AppCompatActivity() {
WindowCompat.setDecorFitsSystemWindows(window, false)

if (prefs.forceDark) {
setTheme(R.style.AppTheme_ForceDark)
setTheme(DesignStyles.AppTheme_ForceDark)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
Expand All @@ -38,6 +38,8 @@ import androidx.navigation.fragment.findNavController
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.androidvip.sysctlgui.R
import com.androidvip.sysctlgui.data.models.KernelParam
import com.androidvip.sysctlgui.design.DesignIds
import com.androidvip.sysctlgui.design.DesignLayouts
import com.androidvip.sysctlgui.getColorRoles
import com.androidvip.sysctlgui.goAway
import com.androidvip.sysctlgui.show
Expand Down Expand Up @@ -185,14 +187,14 @@ class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListen

val dialog = Dialog(requireContext()).apply {
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.dialog_web)
setContentView(DesignLayouts.dialog_web)
setCancelable(true)
}

val progressBar: ProgressBar = dialog.findViewById(R.id.webDialogProgress)
val swipeLayout: SwipeRefreshLayout = dialog.findViewById(R.id.webDialogSwipeLayout)
val progressBar: ProgressBar = dialog.findViewById(DesignIds.webDialogProgress)
val swipeLayout: SwipeRefreshLayout = dialog.findViewById(DesignIds.webDialogSwipeLayout)

val webView = dialog.findViewById<WebView>(R.id.webDialogWebView).apply {
val webView = dialog.findViewById<WebView>(DesignIds.webDialogWebView).apply {
val colorRoles = getColorRoles()
settings.apply {
javaScriptEnabled = true
Expand Down Expand Up @@ -264,7 +266,10 @@ class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListen
paramFile = File(param.path)
)
if (index < params.lastIndex) {
Divider(color = MaterialTheme.colorScheme.outlineVariant, thickness = 1.dp)
HorizontalDivider(
thickness = 1.dp,
color = MaterialTheme.colorScheme.outlineVariant
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.androidvip.sysctlgui.design

typealias DesignIds = com.androidvip.sysctlgui.design.R.id
typealias DesignLayouts = com.androidvip.sysctlgui.design.R.layout
typealias DesignStyles = com.androidvip.sysctlgui.design.R.style
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ kotlin.code.style=official

# Configuration cache
org.gradle.configuration-cache=true
android.nonTransitiveRClass=false
android.nonTransitiveRClass=true
android.nonFinalResIds=false

0 comments on commit 0e19ca7

Please sign in to comment.