ktlint: Reformat all views

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2026-01-01 12:11:01 +08:00
parent 5452385c6d
commit 0e3f8ae150
39 changed files with 252 additions and 251 deletions

View File

@@ -79,4 +79,4 @@ class ActionHeaderLayout : RelativeLayout {
binding.imgAction.visibility = View.VISIBLE
binding.imgAction.setOnClickListener(onclickListener)
}
}
}

View File

@@ -64,11 +64,11 @@ class StateButton : RelativeLayout {
}
fun updateProgress(isVisible: Boolean) {
if (isVisible)
if (isVisible) {
binding.progress.visibility = View.VISIBLE
else
} else {
binding.progress.visibility = View.INVISIBLE
}
}
fun addOnClickListener(onClickListener: OnClickListener) {

View File

@@ -42,11 +42,9 @@ class AuroraListPreference : ListPreference {
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
override fun getPersistedString(defaultReturnValue: String?): String {
return getPersistedInt(defaultReturnValue?.toInt() ?: -1).toString()
}
override fun getPersistedString(defaultReturnValue: String?): String =
getPersistedInt(defaultReturnValue?.toInt() ?: -1).toString()
override fun persistString(value: String?): Boolean {
return if (value != null) persistInt(Integer.valueOf(value)) else false
}
override fun persistString(value: String?): Boolean =
if (value != null) persistInt(Integer.valueOf(value)) else false
}

View File

@@ -6,7 +6,6 @@ import android.view.WindowManager
import androidx.preference.EditTextPreferenceDialogFragmentCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class M3EditTextPreference : EditTextPreferenceDialogFragmentCompat() {
companion object {
@@ -40,7 +39,6 @@ class M3EditTextPreference : EditTextPreferenceDialogFragmentCompat() {
return builder.create()
}
override fun onResume() {
super.onResume()
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

View File

@@ -54,16 +54,20 @@ abstract class EndlessRecyclerOnScrollListener : RecyclerView.OnScrollListener {
private fun findFirstVisibleItemPosition(recyclerView: RecyclerView): Int {
val child = findOneVisibleChild(0, layoutManager.childCount, true, false)
return if (child == null) RecyclerView.NO_POSITION else recyclerView.getChildAdapterPosition(
child
)
return if (child == null) {
RecyclerView.NO_POSITION
} else {
recyclerView.getChildAdapterPosition(child)
}
}
private fun findLastVisibleItemPosition(recyclerView: RecyclerView): Int {
val child = findOneVisibleChild(recyclerView.childCount - 1, -1, false, true)
return if (child == null) RecyclerView.NO_POSITION else recyclerView.getChildAdapterPosition(
child
)
return if (child == null) {
RecyclerView.NO_POSITION
} else {
recyclerView.getChildAdapterPosition(child)
}
}
private fun findOneVisibleChild(
@@ -72,12 +76,15 @@ abstract class EndlessRecyclerOnScrollListener : RecyclerView.OnScrollListener {
completelyVisible: Boolean,
acceptPartiallyVisible: Boolean
): View? {
if (layoutManager.canScrollVertically() != isOrientationHelperVertical || orientationHelper == null) {
if (layoutManager.canScrollVertically() != isOrientationHelperVertical ||
orientationHelper == null
) {
isOrientationHelperVertical = layoutManager.canScrollVertically()
orientationHelper = if (isOrientationHelperVertical)
orientationHelper = if (isOrientationHelperVertical) {
OrientationHelper.createVerticalHelper(layoutManager)
else
} else {
OrientationHelper.createHorizontalHelper(layoutManager)
}
}
val mOrientationHelper = this.orientationHelper ?: return null
@@ -118,12 +125,9 @@ abstract class EndlessRecyclerOnScrollListener : RecyclerView.OnScrollListener {
?: throw RuntimeException("A LayoutManager is required")
}
if (visibleThreshold == RecyclerView.NO_POSITION) {
visibleThreshold =
findLastVisibleItemPosition(recyclerView) - findFirstVisibleItemPosition(
recyclerView
)
visibleThreshold = findLastVisibleItemPosition(recyclerView) -
findFirstVisibleItemPosition(recyclerView)
}
visibleItemCount = recyclerView.childCount
@@ -137,7 +141,9 @@ abstract class EndlessRecyclerOnScrollListener : RecyclerView.OnScrollListener {
}
}
if (!isLoading && totalItemCount - visibleItemCount <= firstVisibleItem + visibleThreshold) {
if (!isLoading &&
totalItemCount - visibleItemCount <= firstVisibleItem + visibleThreshold
) {
currentPage++
onLoadMore(currentPage)
isLoading = true
@@ -164,4 +170,4 @@ abstract class EndlessRecyclerOnScrollListener : RecyclerView.OnScrollListener {
}
abstract fun onLoadMore(currentPage: Int)
}
}

View File

@@ -24,6 +24,6 @@ import com.aurora.gplayapi.data.models.StreamCluster
class CategoryCarouselController(callbacks: Callbacks) : GenericCarouselController(callbacks) {
override fun applyFilter(streamBundle: StreamCluster): Boolean {
return streamBundle.clusterAppList.isNotEmpty() //Filter empty clusters
return streamBundle.clusterAppList.isNotEmpty() // Filter empty clusters
}
}
}

View File

@@ -41,9 +41,9 @@ open class GenericCarouselController(private val callbacks: Callbacks) :
}
open fun applyFilter(streamBundle: StreamCluster): Boolean {
return streamBundle.clusterTitle.isNotBlank() //Filter noisy cluster
&& streamBundle.clusterAppList.isNotEmpty() //Filter empty clusters
&& streamBundle.clusterAppList.count() > 1 //Filter clusters with single apps (mostly promotions)
return streamBundle.clusterTitle.isNotBlank() && // Filter noisy cluster
streamBundle.clusterAppList.isNotEmpty() && // Filter empty clusters
streamBundle.clusterAppList.count() > 1 // Filter clusters with single apps (promotions)
}
override fun buildModels(streamBundle: StreamBundle?) {
@@ -79,7 +79,6 @@ open class GenericCarouselController(private val callbacks: Callbacks) :
)
}
}
} else {
streamBundle
.streamClusters
@@ -88,13 +87,13 @@ open class GenericCarouselController(private val callbacks: Callbacks) :
.forEach { streamCluster ->
add(CarouselModelGroup(streamCluster, callbacks))
}
}
if (streamBundle.hasNext())
if (streamBundle.hasNext()) {
add(
CarouselShimmerGroup()
.id("progress")
)
}
}
}
}

View File

@@ -28,9 +28,8 @@ import com.airbnb.epoxy.ModelView
@ModelView(saveViewState = true, autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
class CarouselHorizontal(context: Context?) : Carousel(context) {
override fun createLayoutManager(): LayoutManager {
return LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
}
override fun createLayoutManager(): LayoutManager =
LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
override fun getSnapHelperFactory(): Nothing? = null
}
}

View File

@@ -34,7 +34,8 @@ class CarouselModelGroup(
callbacks: GenericCarouselController.Callbacks
) :
EpoxyModelGroup(
R.layout.model_carousel_group, buildModels(
R.layout.model_carousel_group,
buildModels(
streamCluster,
callbacks
)

View File

@@ -28,7 +28,8 @@ import java.util.UUID
class CarouselShimmerGroup :
EpoxyModelGroup(
R.layout.model_carousel_group, buildModels()
R.layout.model_carousel_group,
buildModels()
) {
companion object {
private fun buildModels(): List<EpoxyModel<*>> {
@@ -50,7 +51,7 @@ class CarouselShimmerGroup :
models.add(
CarouselHorizontalModel_()
.id("cluster_${idPrefix}")
.id("cluster_$idPrefix")
.models(clusterViewModels)
)
return models

View File

@@ -29,4 +29,4 @@ class AppProgressView @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : BaseView<ViewAppProgressBinding>(context, attrs, defStyleAttr)
) : BaseView<ViewAppProgressBinding>(context, attrs, defStyleAttr)

View File

@@ -38,8 +38,8 @@ abstract class BaseView<ViewBindingType : ViewBinding> : RelativeLayout {
@Suppress("UNCHECKED_CAST")
private fun inflateViewBinding(inflater: LayoutInflater): ViewBindingType {
val type =
(javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0] as Class<ViewBindingType>
val type = (javaClass.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<ViewBindingType>
val method = type.getMethod(
"inflate",
LayoutInflater::class.java,
@@ -48,4 +48,4 @@ abstract class BaseView<ViewBindingType : ViewBinding> : RelativeLayout {
)
return method.invoke(null, inflater, this, false) as ViewBindingType
}
}
}

View File

@@ -45,8 +45,9 @@ class HeaderView @JvmOverloads constructor(
@JvmOverloads
@ModelProp
fun browseUrl(browseUrl: String? = String()) {
if (browseUrl.isNullOrEmpty())
if (browseUrl.isNullOrEmpty()) {
binding.imgAction.visibility = INVISIBLE
}
}
@CallbackProp

View File

@@ -27,7 +27,6 @@ import com.airbnb.epoxy.ModelView
import com.airbnb.epoxy.OnViewRecycled
import com.aurora.store.databinding.ViewHeaderUpdateBinding
@ModelView(
autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT,
baseModelClass = BaseModel::class

View File

@@ -60,17 +60,20 @@ class AppListView @JvmOverloads constructor(
extras.add(if (app.size > 0) CommonUtil.addSiPrefix(app.size) else app.downloadString)
extras.add("${app.labeledRating}")
extras.add(
if (app.isFree)
if (app.isFree) {
ContextCompat.getString(context, R.string.details_free)
else
} else {
ContextCompat.getString(context, R.string.details_paid)
}
)
if (app.containsAds)
if (app.containsAds) {
extras.add(ContextCompat.getString(context, R.string.details_contains_ads))
}
if (app.dependencies.dependentPackages.isNotEmpty())
if (app.dependencies.dependentPackages.isNotEmpty()) {
extras.add(ContextCompat.getString(context, R.string.details_gsf_dependent))
}
binding.txtLine3.text = extras.joinToString(separator = "")
}

View File

@@ -76,14 +76,15 @@ class AppUpdateView @JvmOverloads constructor(
binding.txtLine2.text = developerName
binding.txtLine3.text = ("${CommonUtil.addSiPrefix(size)}$updatedOn")
binding.txtLine4.text = ("$versionName (${versionCode})")
binding.txtChangelog.text = if (changelog.isNotEmpty())
binding.txtLine4.text = ("$versionName ($versionCode)")
binding.txtChangelog.text = if (changelog.isNotEmpty()) {
HtmlCompat.fromHtml(
changelog,
HtmlCompat.FROM_HTML_OPTION_USE_CSS_COLORS
)
else
} else {
context.getString(R.string.details_changelog_unavailable)
}
binding.headerIndicator.setOnClickListener {
if (binding.cardChangelog.isVisible) {
@@ -162,11 +163,13 @@ class AppUpdateView @JvmOverloads constructor(
val isDownloadVisible = binding.progressDownload.isShown
// Avoids flickering when the download is in progress
if (isDownloadVisible && scaleFactor != 1f)
if (isDownloadVisible && scaleFactor != 1f) {
return
}
if (!isDownloadVisible && scaleFactor == 1f)
if (!isDownloadVisible && scaleFactor == 1f) {
return
}
if (scaleFactor == 1f) {
binding.progressDownload.invisible()
@@ -190,10 +193,11 @@ class AppUpdateView @JvmOverloads constructor(
iconDrawable?.let {
binding.imgIcon.load(it) {
transformations(
if (scaleFactor == 1f)
if (scaleFactor == 1f) {
cornersTransformation
else
} else {
CircleCropTransformation()
}
)
}
}

View File

@@ -53,10 +53,11 @@ class AppView @JvmOverloads constructor(
transformations(RoundedCornersTransformation(32F))
}
if (app.size > 0)
if (app.size > 0) {
binding.txtSize.text = CommonUtil.addSiPrefix(app.size)
else
} else {
binding.txtSize.text = app.downloadString
}
}
@CallbackProp

View File

@@ -96,7 +96,7 @@ class AppsContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
)
binding.pager.isUserInputEnabled =
false //Disable viewpager scroll to avoid scroll conflicts
false // Disable viewpager scroll to avoid scroll conflicts
val tabTitles: MutableList<String> = mutableListOf<String>().apply {
if (isForYouEnabled) {
@@ -141,12 +141,8 @@ class AppsContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
add(CategoryFragment.newInstance(0))
}
override fun createFragment(position: Int): Fragment {
return tabFragments[position]
}
override fun createFragment(position: Int): Fragment = tabFragments[position]
override fun getItemCount(): Int {
return tabFragments.size
}
override fun getItemCount(): Int = tabFragments.size
}
}

View File

@@ -42,8 +42,8 @@ abstract class BaseFragment<ViewBindingType : ViewBinding> : Fragment() {
lateinit var permissionProvider: PermissionProvider
protected open var _binding: ViewBindingType? = null
protected val binding get() = _binding!!
protected open var viewBindingType: ViewBindingType? = null
protected val binding get() = viewBindingType!!
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -52,18 +52,19 @@ abstract class BaseFragment<ViewBindingType : ViewBinding> : Fragment() {
@Suppress("UNCHECKED_CAST")
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val type =
(javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0] as Class<ViewBindingType>
val type = (javaClass.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<ViewBindingType>
val method = type.getMethod(
"inflate",
LayoutInflater::class.java,
ViewGroup::class.java,
Boolean::class.java
)
_binding = method.invoke(null, inflater, container, false) as ViewBindingType
viewBindingType = method.invoke(null, inflater, container, false) as ViewBindingType
return binding.root
}
@@ -75,7 +76,7 @@ abstract class BaseFragment<ViewBindingType : ViewBinding> : Fragment() {
override fun onDestroyView() {
cleanupRecyclerViews(findAllRecyclerViews(requireView()))
_binding = null
viewBindingType = null
super.onDestroyView()
}

View File

@@ -37,7 +37,8 @@ import com.aurora.store.viewmodel.subcategory.CategoryStreamViewModel
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class CategoryBrowseFragment : BaseFragment<FragmentGenericWithToolbarBinding>(),
class CategoryBrowseFragment :
BaseFragment<FragmentGenericWithToolbarBinding>(),
GenericCarouselController.Callbacks {
private val args: CategoryBrowseFragmentArgs by navArgs()
private val viewModel: CategoryStreamViewModel by activityViewModels()
@@ -95,6 +96,5 @@ class CategoryBrowseFragment : BaseFragment<FragmentGenericWithToolbarBinding>()
}
override fun onAppLongClick(app: App) {
}
}

View File

@@ -39,11 +39,9 @@ class CategoryFragment : BaseFragment<FragmentGenericRecyclerBinding>() {
companion object {
@JvmStatic
fun newInstance(pageType: Int): CategoryFragment {
return CategoryFragment().apply {
arguments = Bundle().apply {
putInt(Constants.PAGE_TYPE, pageType)
}
fun newInstance(pageType: Int): CategoryFragment = CategoryFragment().apply {
arguments = Bundle().apply {
putInt(Constants.PAGE_TYPE, pageType)
}
}
}

View File

@@ -63,8 +63,9 @@ class ExpandedStreamBrowseFragment : BaseFragment<FragmentGenericWithToolbarBind
}
private fun updateTitle(streamCluster: StreamCluster) {
if (streamCluster.clusterTitle.isNotEmpty())
if (streamCluster.clusterTitle.isNotEmpty()) {
binding.toolbar.title = streamCluster.clusterTitle
}
}
private fun attachRecycler() {

View File

@@ -38,7 +38,8 @@ import com.aurora.store.viewmodel.homestream.StreamViewModel
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class ForYouFragment : BaseFragment<FragmentForYouBinding>(),
class ForYouFragment :
BaseFragment<FragmentForYouBinding>(),
GenericCarouselController.Callbacks {
private val viewModel: StreamViewModel by activityViewModels()
@@ -47,11 +48,9 @@ class ForYouFragment : BaseFragment<FragmentForYouBinding>(),
companion object {
@JvmStatic
fun newInstance(pageType: Int): ForYouFragment {
return ForYouFragment().apply {
arguments = Bundle().apply {
putInt(Constants.PAGE_TYPE, pageType)
}
fun newInstance(pageType: Int): ForYouFragment = ForYouFragment().apply {
arguments = Bundle().apply {
putInt(Constants.PAGE_TYPE, pageType)
}
}
}
@@ -110,6 +109,5 @@ class ForYouFragment : BaseFragment<FragmentForYouBinding>(),
}
override fun onAppLongClick(app: App) {
}
}

View File

@@ -9,17 +9,16 @@ import com.jakewharton.processphoenix.ProcessPhoenix
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class ForceRestartDialog: DialogFragment() {
class ForceRestartDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return MaterialAlertDialogBuilder(requireContext())
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.force_restart_title)
.setMessage(R.string.force_restart_summary)
.setPositiveButton(getString(R.string.action_restart)) { _, _ ->
ProcessPhoenix.triggerRebirth(requireContext())
}
.create()
}
override fun onResume() {
super.onResume()

View File

@@ -80,7 +80,7 @@ class MoreDialogFragment : DialogFragment() {
private abstract class Option(
@StringRes open val title: Int,
@DrawableRes open val icon: Int,
@DrawableRes open val icon: Int
)
private data class ViewOption(
@@ -95,76 +95,59 @@ class MoreDialogFragment : DialogFragment() {
val screen: Screen
) : Option(title, icon)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return MaterialAlertDialogBuilder(requireContext())
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
MaterialAlertDialogBuilder(requireContext())
.setView(customDialogView(requireContext()))
.create()
}
private fun customDialogView(context: Context): ComposeView {
return ComposeView(context).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
AuroraTheme {
primaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorSurface))
onPrimaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorOnSurface))
secondaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorSecondaryContainer))
onSecondaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorOnSecondaryContainer))
private fun customDialogView(context: Context): ComposeView = ComposeView(context).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
AuroraTheme {
primaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorSurface))
onPrimaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorOnSurface))
secondaryColor =
Color(requireContext().getStyledAttributeColor(MR.colorSecondaryContainer))
onSecondaryColor =
Color(
requireContext().getStyledAttributeColor(MR.colorOnSecondaryContainer)
)
Column(
modifier = Modifier
.fillMaxWidth()
.background(color = primaryColor)
.verticalScroll(rememberScrollState())
.padding(10.dp),
verticalArrangement = Arrangement.spacedBy(
4.dp,
Alignment.CenterVertically
)
) {
AppBar(onBackgroundColor = onPrimaryColor)
AccountHeader(
backgroundColor = secondaryColor,
onBackgroundColor = onSecondaryColor
)
Column(
modifier = Modifier
.fillMaxWidth()
.background(color = primaryColor)
.verticalScroll(rememberScrollState())
.padding(10.dp),
verticalArrangement = Arrangement.spacedBy(
4.dp,
Alignment.CenterVertically
)
.clip(
RoundedCornerShape(
topStart = 2.dp,
topEnd = 2.dp,
bottomStart = 25.dp,
bottomEnd = 25.dp
)
)
.background(color = secondaryColor)
) {
AppBar(onBackgroundColor = onPrimaryColor)
AccountHeader(
backgroundColor = secondaryColor,
onBackgroundColor = onSecondaryColor
)
Column(
modifier = Modifier
.clip(
RoundedCornerShape(
topStart = 2.dp,
topEnd = 2.dp,
bottomStart = 25.dp,
bottomEnd = 25.dp
)
)
.background(color = secondaryColor)
) {
getOptions().fastForEach { option ->
OptionItem(
option = option,
tintColor = onPrimaryColor,
textColor = onSecondaryColor,
onClick = {
when (option) {
is ViewOption -> {
findNavController().navigate(option.destinationID)
}
is ComposeOption -> context.navigate(option.screen)
}
}
)
}
}
getExtraOptions().fastForEach { option ->
getOptions().fastForEach { option ->
OptionItem(
option = option,
tintColor = onPrimaryColor,
textColor = onPrimaryColor,
textColor = onSecondaryColor,
onClick = {
when (option) {
is ViewOption -> {
@@ -176,8 +159,24 @@ class MoreDialogFragment : DialogFragment() {
}
)
}
Footer(onPrimaryColor)
}
getExtraOptions().fastForEach { option ->
OptionItem(
option = option,
tintColor = onPrimaryColor,
textColor = onPrimaryColor,
onClick = {
when (option) {
is ViewOption -> {
findNavController().navigate(option.destinationID)
}
is ComposeOption -> context.navigate(option.screen)
}
}
)
}
Footer(onPrimaryColor)
}
}
}
@@ -322,7 +321,11 @@ class MoreDialogFragment : DialogFragment() {
shape = RoundedCornerShape(12.dp),
border = BorderStroke(
1.dp,
Color(requireContext().getStyledAttributeColor(androidx.appcompat.R.attr.colorControlHighlight))
Color(
requireContext().getStyledAttributeColor(
androidx.appcompat.R.attr.colorControlHighlight
)
)
),
modifier = Modifier.fillMaxWidth()
) {
@@ -331,7 +334,7 @@ class MoreDialogFragment : DialogFragment() {
color = onBackgroundColor,
fontWeight = FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
overflow = TextOverflow.Ellipsis
)
}
}
@@ -372,9 +375,7 @@ class MoreDialogFragment : DialogFragment() {
}
@Composable
fun ThreeStateIconButton(
tint: Color = Color.White
) {
fun ThreeStateIconButton(tint: Color = Color.White) {
var currentState by remember {
mutableStateOf(
Preferences.getInteger(
@@ -418,46 +419,42 @@ class MoreDialogFragment : DialogFragment() {
enum class State(val value: Int) {
Auto(0),
Light(1),
Dark(2),
Dark(2)
}
private fun getOptions(): List<Option> {
return listOf(
ComposeOption(
title = R.string.title_apps_games,
icon = R.drawable.ic_apps,
screen = Screen.Installed
),
ComposeOption(
title = R.string.title_blacklist_manager,
icon = R.drawable.ic_blacklist,
screen = Screen.Blacklist
),
ComposeOption(
title = R.string.title_favourites_manager,
icon = R.drawable.ic_favorite_unchecked,
screen = Screen.Favourite
),
ComposeOption(
title = R.string.title_spoof_manager,
icon = R.drawable.ic_spoof,
screen = Screen.Spoof
)
private fun getOptions(): List<Option> = listOf(
ComposeOption(
title = R.string.title_apps_games,
icon = R.drawable.ic_apps,
screen = Screen.Installed
),
ComposeOption(
title = R.string.title_blacklist_manager,
icon = R.drawable.ic_blacklist,
screen = Screen.Blacklist
),
ComposeOption(
title = R.string.title_favourites_manager,
icon = R.drawable.ic_favorite_unchecked,
screen = Screen.Favourite
),
ComposeOption(
title = R.string.title_spoof_manager,
icon = R.drawable.ic_spoof,
screen = Screen.Spoof
)
}
)
private fun getExtraOptions(): List<Option> {
return listOf(
ViewOption(
title = R.string.title_settings,
icon = R.drawable.ic_menu_settings,
destinationID = R.id.settingsFragment
),
ComposeOption(
title = R.string.title_about,
icon = R.drawable.ic_menu_about,
screen = Screen.About
)
private fun getExtraOptions(): List<Option> = listOf(
ViewOption(
title = R.string.title_settings,
icon = R.drawable.ic_menu_settings,
destinationID = R.id.settingsFragment
),
ComposeOption(
title = R.string.title_about,
icon = R.drawable.ic_menu_about,
screen = Screen.About
)
}
)
}

View File

@@ -35,13 +35,12 @@ import dagger.hilt.android.AndroidEntryPoint
class TopChartContainerFragment : BaseFragment<FragmentTopChartBinding>() {
companion object {
@JvmStatic
fun newInstance(chartType: Int): TopChartContainerFragment {
return TopChartContainerFragment().apply {
fun newInstance(chartType: Int): TopChartContainerFragment =
TopChartContainerFragment().apply {
arguments = Bundle().apply {
putInt(Constants.TOP_CHART_TYPE, chartType)
}
}
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -96,12 +95,8 @@ class TopChartContainerFragment : BaseFragment<FragmentTopChartBinding>() {
TopChartFragment.newInstance(chartType, 3)
)
override fun createFragment(position: Int): Fragment {
return tabFragments[position]
}
override fun createFragment(position: Int): Fragment = tabFragments[position]
override fun getItemCount(): Int {
return tabFragments.size
}
override fun getItemCount(): Int = tabFragments.size
}
}

View File

@@ -46,14 +46,13 @@ class TopChartFragment : BaseFragment<FragmentTopContainerBinding>() {
companion object {
@JvmStatic
fun newInstance(chartType: Int, chartCategory: Int): TopChartFragment {
return TopChartFragment().apply {
fun newInstance(chartType: Int, chartCategory: Int): TopChartFragment =
TopChartFragment().apply {
arguments = Bundle().apply {
putInt(Constants.TOP_CHART_TYPE, chartType)
putInt(Constants.TOP_CHART_CATEGORY, chartCategory)
}
}
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

View File

@@ -37,7 +37,8 @@ import com.aurora.store.viewmodel.details.DevProfileViewModel
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class DevProfileFragment : BaseFragment<FragmentDevProfileBinding>(),
class DevProfileFragment :
BaseFragment<FragmentDevProfileBinding>(),
GenericCarouselController.Callbacks {
private val args: DevProfileFragmentArgs by navArgs()
@@ -46,10 +47,14 @@ class DevProfileFragment : BaseFragment<FragmentDevProfileBinding>(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Toolbar
binding.toolbar.apply {
title = if (args.title.isNullOrBlank()) getString(R.string.details_dev_profile) else args.title
title =
if (args.title.isNullOrBlank()) {
getString(R.string.details_dev_profile)
} else {
args.title
}
setNavigationOnClickListener { findNavController().navigateUp() }
}
@@ -61,15 +66,12 @@ class DevProfileFragment : BaseFragment<FragmentDevProfileBinding>(),
}
is ViewState.Loading -> {
}
is ViewState.Error -> {
}
is ViewState.Status -> {
}
is ViewState.Success<*> -> {
@@ -101,6 +103,5 @@ class DevProfileFragment : BaseFragment<FragmentDevProfileBinding>(),
}
override fun onAppLongClick(app: App) {
}
}

View File

@@ -140,12 +140,8 @@ class GamesContainerFragment : BaseFragment<FragmentAppsGamesBinding>() {
add(CategoryFragment.newInstance(1))
}
override fun createFragment(position: Int): Fragment {
return tabFragments[position]
}
override fun createFragment(position: Int): Fragment = tabFragments[position]
override fun getItemCount(): Int {
return tabFragments.size
}
override fun getItemCount(): Int = tabFragments.size
}
}

View File

@@ -28,6 +28,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() {
M3EditTextPreference.PREFERENCE_DIALOG_FRAGMENT_TAG
)
}
is ListPreference -> {
val dialogFragment = M3ListPreference.newInstance(preference.getKey())
dialogFragment.setTargetFragment(this, 0)
@@ -36,6 +37,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() {
M3ListPreference.PREFERENCE_DIALOG_FRAGMENT_TAG
)
}
else -> super.onDisplayPreferenceDialog(preference)
}
}

View File

@@ -42,9 +42,11 @@ class UIPreference : BasePreferenceFragment() {
if (isTAndAbove) {
summary = Locale.getDefault().displayName
setOnPreferenceClickListener {
startActivity(Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
data = ("package:" + requireContext().packageName).toUri()
})
startActivity(
Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
data = ("package:" + requireContext().packageName).toUri()
}
)
true
}
} else {

View File

@@ -23,7 +23,7 @@ import com.google.android.material.textfield.TextInputLayout
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class ProxyURLDialog: DialogFragment() {
class ProxyURLDialog : DialogFragment() {
private val viewModel: ProxyURLViewModel by viewModels()
@@ -40,7 +40,7 @@ class ProxyURLDialog: DialogFragment() {
.setView(view)
.setPositiveButton(getString(R.string.set), null)
.setNeutralButton(getString(R.string.disable), null)
.setNegativeButton(getString(android.R.string.cancel)) { _, _ -> dialog?.dismiss()}
.setNegativeButton(getString(android.R.string.cancel)) { _, _ -> dialog?.dismiss() }
.create()
alertDialog.setOnShowListener {

View File

@@ -54,7 +54,10 @@ class UpdatesPreference : BasePreferenceFragment() {
val updatesEnabled = Preferences.getInteger(requireContext(), PREFERENCE_UPDATES_AUTO) != 0
findPreference<ListPreference>(PREFERENCE_UPDATES_AUTO)?.setOnPreferenceChangeListener { _, newValue ->
findPreference<ListPreference>(PREFERENCE_UPDATES_AUTO)?.setOnPreferenceChangeListener {
_,
newValue
->
when (UpdateMode.entries[newValue.toString().toInt()]) {
UpdateMode.DISABLED -> {
handleAutoUpdateDependentPrefs(false)

View File

@@ -31,7 +31,7 @@ class UpdatesRestrictionsDialog : DialogFragment() {
.setTitle(R.string.pref_updates_restrictions_title)
.setMessage(R.string.pref_updates_restrictions_desc)
.setView(view)
.setPositiveButton(getString(android.R.string.ok)) { _, _ -> dialog?.dismiss()}
.setPositiveButton(getString(android.R.string.ok)) { _, _ -> dialog?.dismiss() }
.create()
}

View File

@@ -65,16 +65,17 @@ class AppMenuSheet : BaseDialogSheet<SheetAppMenuBinding>() {
val isBlacklisted: Boolean = viewModel.blacklistProvider.isBlacklisted(args.app.packageName)
with(binding.navigationView) {
//Switch strings for Add/Remove Blacklist
// Switch strings for Add/Remove Blacklist
val blackListMenu: MenuItem = menu.findItem(R.id.action_blacklist)
blackListMenu.setTitle(
if (isBlacklisted)
if (isBlacklisted) {
R.string.action_whitelist
else
} else {
R.string.action_blacklist_add
}
)
//Show/Hide actions based on installed status
// Show/Hide actions based on installed status
val installed = PackageUtil.isInstalled(requireContext(), args.app.packageName)
menu.findItem(R.id.action_uninstall).isVisible = installed
menu.findItem(R.id.action_local).isVisible = installed
@@ -82,7 +83,6 @@ class AppMenuSheet : BaseDialogSheet<SheetAppMenuBinding>() {
setNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.action_blacklist -> {
if (isBlacklisted) {
viewModel.blacklistProvider.whitelist(args.app.packageName)
requireContext().toast(R.string.toast_apk_whitelisted)

View File

@@ -47,8 +47,8 @@ abstract class BaseDialogSheet<ViewBindingType : ViewBinding> : BottomSheetDialo
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val type =
(javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0] as Class<ViewBindingType>
val type = (javaClass.genericSuperclass as ParameterizedType)
.actualTypeArguments[0] as Class<ViewBindingType>
val method = type.getMethod(
"inflate",

View File

@@ -38,10 +38,7 @@ class NetworkDialogSheet : BaseDialogSheet<SheetNetworkBinding>() {
const val TAG = "NetworkDialogSheet"
@JvmStatic
fun newInstance(): NetworkDialogSheet {
return NetworkDialogSheet().apply {
}
fun newInstance(): NetworkDialogSheet = NetworkDialogSheet().apply {
}
}

View File

@@ -44,7 +44,7 @@ abstract class BaseFlavouredSplashFragment : BaseFragment<FragmentSplashBinding>
val canLoginWithMicroG: Boolean
get() = PackageUtil.hasSupportedMicroGVariant(requireContext()) &&
Preferences.getBoolean(requireContext(), PREFERENCE_MICROG_AUTH, true)
Preferences.getBoolean(requireContext(), PREFERENCE_MICROG_AUTH, true)
val startForAccount =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
@@ -61,7 +61,7 @@ abstract class BaseFlavouredSplashFragment : BaseFragment<FragmentSplashBinding>
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentSplashBinding.inflate(inflater, container, false)
viewBindingType = FragmentSplashBinding.inflate(inflater, container, false)
return binding.root
}
@@ -180,7 +180,9 @@ abstract class BaseFlavouredSplashFragment : BaseFragment<FragmentSplashBinding>
}
1 -> SplashFragmentDirections.actionSplashFragmentToGamesContainerFragment()
2 -> SplashFragmentDirections.actionSplashFragmentToUpdatesFragment()
else -> SplashFragmentDirections.actionSplashFragmentToNavigationApps()
}
requireActivity().viewModelStore.clear() // Clear ViewModelStore to avoid bugs with logout

View File

@@ -89,12 +89,15 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
viewModel.updates
.combine(viewModel.downloadsList) { uList, dList ->
uList?.associateWith { a ->
dList.find { it.packageName == a.packageName && it.versionCode == a.versionCode }
dList.find {
it.packageName == a.packageName && it.versionCode == a.versionCode
}
}
}.collectLatest { map ->
updateController(map)
viewModel.updateAllEnqueued =
map?.values?.all { it?.isRunning == true } ?: false
viewModel.updateAllEnqueued = map?.values?.all {
it?.isRunning == true
} ?: false
}
}
@@ -143,10 +146,11 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
.id("header_all")
.title(
"${appList.size} " +
if (appList.size == 1)
getString(R.string.update_available)
else
getString(R.string.updates_available)
if (appList.size == 1) {
getString(R.string.update_available)
} else {
getString(R.string.updates_available)
}
)
.action(
if (viewModel.updateAllEnqueued) {