Add flavours

This commit is contained in:
Rahul Patel
2025-05-23 12:01:47 +05:30
parent 540e68f507
commit 6fa3be22dd
12 changed files with 425 additions and 223 deletions

View File

@@ -58,6 +58,8 @@ android {
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
buildConfigField("String", "EXODUS_API_KEY", "\"bbe6ebae4ad45a9cbacb17d69739799b8df2c7ae\"")
missingDimensionStrategy("device", "vanilla")
}
signingConfigs {
@@ -108,12 +110,26 @@ android {
}
}
flavorDimensions += "device"
productFlavors {
create("vanilla"){
dimension = "device"
}
create("huawei") {
dimension = "device"
versionNameSuffix = "-hw"
}
}
buildFeatures {
buildConfig = true
viewBinding = true
aidl = true
compose = true
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_21.toString()
}

View File

@@ -0,0 +1,83 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.onboarding
import androidx.fragment.app.Fragment
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.util.Preferences.PREFERENCE_DISPENSER_URLS
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FOR_YOU
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
import com.aurora.store.util.Preferences.PREFERENCE_SIMILAR
import com.aurora.store.util.Preferences.PREFERENCE_THEME_STYLE
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_CHECK_INTERVAL
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_EXTENDED
import com.aurora.store.util.Preferences.PREFERENCE_VENDING_VERSION
import com.aurora.store.util.save
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class OnboardingFragment : BaseFlavouredOnboardingFragment() {
override fun loadDefaultPreferences() {
/*Filters*/
save(PREFERENCE_FILTER_AURORA_ONLY, false)
save(PREFERENCE_FILTER_FDROID, true)
/*Network*/
save(PREFERENCE_DISPENSER_URLS, setOf())
save(PREFERENCE_VENDING_VERSION, 0)
/*Customization*/
save(PREFERENCE_THEME_STYLE, 0)
save(PREFERENCE_DEFAULT_SELECTED_TAB, 0)
save(PREFERENCE_FOR_YOU, true)
save(PREFERENCE_SIMILAR, true)
/*Installer*/
save(PREFERENCE_AUTO_DELETE, true)
save(PREFERENCE_INSTALLER_ID, 0)
/*Updates*/
save(PREFERENCE_UPDATES_EXTENDED, false)
save(PREFERENCE_UPDATES_CHECK_INTERVAL, 3)
}
override fun onboardingPages(): List<Fragment> {
return listOf(
WelcomeFragment(),
PermissionsFragment.newInstance()
)
}
override fun setupAutoUpdates() {
super.setupAutoUpdates()
// Remove super & implement variant logic here
}
override fun finishOnboarding() {
super.finishOnboarding()
// Remove super & implement variant logic here
}
}

View File

@@ -0,0 +1,69 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.splash
import android.accounts.AccountManager
import android.util.Log
import androidx.navigation.fragment.findNavController
import com.aurora.extensions.hide
import com.aurora.store.R
import com.aurora.store.data.model.AuthState
import com.aurora.store.util.CertUtil.GOOGLE_ACCOUNT_TYPE
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class SplashFragment : BaseFlavouredSplashFragment() {
private val TAG = SplashFragment::class.java.simpleName
override fun attachActions() {
binding.btnAnonymous.hide()
binding.btnGoogle.addOnClickListener {
if (viewModel.authState.value != AuthState.Fetching) {
binding.btnGoogle.updateProgress(true)
if (canLoginWithMicroG) {
Log.i(TAG, "Found supported microG, trying to request credentials")
val accountIntent = AccountManager.newChooseAccountIntent(
null,
null,
arrayOf(GOOGLE_ACCOUNT_TYPE),
null,
null,
null,
null
)
startForAccount.launch(accountIntent)
} else {
findNavController().navigate(R.id.googleFragment)
}
}
}
}
override fun resetActions() {
binding.btnAnonymous.hide()
binding.btnGoogle.apply {
updateProgress(false)
isEnabled = true
}
}
}

View File

@@ -21,6 +21,7 @@ package com.aurora.extensions
import android.content.Context
import android.content.Intent
import android.net.UrlQuerySanitizer
import android.os.Bundle
inline fun <reified T : Context> Context.newIntent(): Intent =
@@ -40,3 +41,22 @@ inline fun <reified T : Context> Context.newIntent(flags: Int, extras: Bundle):
intent.putExtras(extras)
return intent
}
fun Intent.getPackageName(fallbackBundle: Bundle? = null): String? {
return when (action) {
Intent.ACTION_VIEW -> {
data?.getQueryParameter("id")
}
Intent.ACTION_SEND -> {
val clipData = getStringExtra(Intent.EXTRA_TEXT).orEmpty()
UrlQuerySanitizer(clipData).getValue("id")
}
Intent.ACTION_SHOW_APP_INFO -> {
extras?.getString(Intent.EXTRA_PACKAGE_NAME)
}
else -> {
extras?.getString("packageName") ?: fallbackBundle?.getString("packageName")
}
}
}

View File

@@ -24,6 +24,7 @@ import android.content.SharedPreferences
import androidx.core.content.edit
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.aurora.store.BuildConfig
object Preferences {
@@ -65,10 +66,17 @@ object Preferences {
private var prefs: SharedPreferences? = null
fun getPrefs(context: Context): SharedPreferences {
if (prefs == null) {
prefs = PreferenceManager.getDefaultSharedPreferences(context)
return when (BuildConfig.FLAVOR) {
"vanilla" -> {
prefs ?: PreferenceManager.getDefaultSharedPreferences(context).also { prefs = it }
}
else -> {
val prefName = "${context.packageName}_${BuildConfig.FLAVOR}_preferences"
prefs ?: context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.also { prefs = it }
}
}
return prefs!!
}
fun remove(context: Context, key: String) {

View File

@@ -42,7 +42,7 @@ abstract class BaseFragment<ViewBindingType : ViewBinding> : Fragment() {
lateinit var permissionProvider: PermissionProvider
private var _binding: ViewBindingType? = null
protected open var _binding: ViewBindingType? = null
protected val binding get() = _binding!!
override fun onCreate(savedInstanceState: Bundle?) {

View File

@@ -1,15 +0,0 @@
package com.aurora.store.view.ui.onboarding
import android.os.Bundle
import android.view.View
import com.aurora.store.databinding.FragmentAppLinksBinding
import com.aurora.store.view.ui.commons.BaseFragment
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class AppLinksFragment : BaseFragment<FragmentAppLinksBinding>() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

View File

@@ -1,26 +1,9 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.onboarding
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
@@ -29,59 +12,36 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
import com.aurora.Constants
import com.aurora.extensions.areNotificationsEnabled
import com.aurora.extensions.isIgnoringBatteryOptimizations
import com.aurora.store.R
import com.aurora.store.data.model.UpdateMode
import com.aurora.store.data.work.CacheWorker
import com.aurora.store.databinding.FragmentOnboardingBinding
import com.aurora.store.util.CertUtil
import com.aurora.store.util.PackageUtil
import com.aurora.store.util.Preferences
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.util.Preferences.PREFERENCE_DISPENSER_URLS
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FOR_YOU
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
import com.aurora.store.util.Preferences.PREFERENCE_INTRO
import com.aurora.store.util.Preferences.PREFERENCE_SIMILAR
import com.aurora.store.util.Preferences.PREFERENCE_THEME_STYLE
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_AUTO
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_CHECK_INTERVAL
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_EXTENDED
import com.aurora.store.util.Preferences.PREFERENCE_VENDING_VERSION
import com.aurora.store.util.save
import com.aurora.store.view.ui.commons.BaseFragment
import com.aurora.store.viewmodel.onboarding.OnboardingViewModel
import com.google.android.material.tabs.TabLayoutMediator
import com.jakewharton.processphoenix.ProcessPhoenix
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
abstract class BaseFlavouredOnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
private val viewModel: OnboardingViewModel by viewModels()
val viewModel: OnboardingViewModel by viewModels()
private var lastPosition = 0
var lastPosition = 0
internal class PagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
FragmentStateAdapter(fragmentManager, lifecycle) {
override fun createFragment(position: Int): Fragment {
when (position) {
0 -> return WelcomeFragment()
1 -> return PermissionsFragment.newInstance()
2 -> return AppLinksFragment()
}
return Fragment()
}
override fun getItemCount(): Int {
return 2
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentOnboardingBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -95,6 +55,7 @@ class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
}
val isDefaultPrefLoaded = Preferences.getBoolean(requireContext(), PREFERENCE_DEFAULT)
if (!isDefaultPrefLoaded) {
save(PREFERENCE_DEFAULT, true)
loadDefaultPreferences()
@@ -105,7 +66,11 @@ class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
// ViewPager2
binding.viewpager2.apply {
adapter = PagerAdapter(childFragmentManager, viewLifecycleOwner.lifecycle)
adapter = PagerAdapter(
childFragmentManager,
viewLifecycleOwner.lifecycle,
onboardingPages()
)
isUserInputEnabled = false
setCurrentItem(0, true)
registerOnPageChangeCallback(object : OnPageChangeCallback() {
@@ -149,7 +114,11 @@ class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
}
}
private fun finishOnboarding() {
abstract fun loadDefaultPreferences()
abstract fun onboardingPages(): List<Fragment>
open fun finishOnboarding() {
setupAutoUpdates()
CacheWorker.scheduleAutomatedCacheCleanup(requireContext())
Preferences.putBooleanNow(requireContext(), PREFERENCE_INTRO, true)
@@ -158,40 +127,29 @@ class OnboardingFragment : BaseFragment<FragmentOnboardingBinding>() {
ProcessPhoenix.triggerRebirth(context)
}
private fun loadDefaultPreferences() {
/*Filters*/
save(PREFERENCE_FILTER_AURORA_ONLY, false)
save(PREFERENCE_FILTER_FDROID, true)
/*Network*/
// TODO: Gather feedback and drop setting default dispenser for all builds
if (!CertUtil.isAppGalleryApp(requireContext(), requireContext().packageName)) {
save(PREFERENCE_DISPENSER_URLS, setOf(Constants.URL_DISPENSER))
}
save(PREFERENCE_VENDING_VERSION, 0)
/*Customization*/
save(PREFERENCE_THEME_STYLE, 0)
save(PREFERENCE_DEFAULT_SELECTED_TAB, 0)
save(PREFERENCE_FOR_YOU, true)
save(PREFERENCE_SIMILAR, false)
/*Installer*/
save(PREFERENCE_AUTO_DELETE, true)
save(PREFERENCE_INSTALLER_ID, 0)
/*Updates*/
save(PREFERENCE_UPDATES_EXTENDED, false)
save(PREFERENCE_UPDATES_CHECK_INTERVAL, 3)
}
private fun setupAutoUpdates() {
open fun setupAutoUpdates() {
val updateMode = when {
requireContext().isIgnoringBatteryOptimizations() -> UpdateMode.CHECK_AND_INSTALL
requireContext().areNotificationsEnabled() -> UpdateMode.CHECK_AND_NOTIFY
else -> UpdateMode.DISABLED
}
save(PREFERENCE_UPDATES_AUTO, updateMode.ordinal)
viewModel.updateHelper.scheduleAutomatedCheck()
}
internal class PagerAdapter(
fragmentManager: FragmentManager,
lifecycle: Lifecycle,
var items: List<Fragment>
) : FragmentStateAdapter(fragmentManager, lifecycle) {
override fun createFragment(position: Int): Fragment {
return items[position]
}
override fun getItemCount(): Int {
return items.size
}
}
}

View File

@@ -1,45 +1,25 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.splash
import android.accounts.Account
import android.accounts.AccountManager
import android.content.Intent
import android.net.UrlQuerySanitizer
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Base64
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.aurora.extensions.getPackageName
import com.aurora.extensions.hide
import com.aurora.extensions.isMAndAbove
import com.aurora.extensions.isNAndAbove
import com.aurora.extensions.navigate
import com.aurora.extensions.show
import com.aurora.gplayapi.helpers.AuthHelper
import com.aurora.store.R
import com.aurora.store.compose.navigation.Screen
@@ -56,22 +36,20 @@ import com.aurora.store.util.Preferences.PREFERENCE_INTRO
import com.aurora.store.util.Preferences.PREFERENCE_MICROG_AUTH
import com.aurora.store.view.ui.commons.BaseFragment
import com.aurora.store.viewmodel.auth.AuthViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
@AndroidEntryPoint
class SplashFragment : BaseFragment<FragmentSplashBinding>() {
abstract class BaseFlavouredSplashFragment : BaseFragment<FragmentSplashBinding>() {
private val TAG = SplashFragment::class.java.simpleName
private val viewModel: AuthViewModel by activityViewModels()
val viewModel: AuthViewModel by activityViewModels()
private val canLoginWithMicroG: Boolean
val canLoginWithMicroG: Boolean
get() = isMAndAbove && PackageUtil.hasSupportedMicroG(requireContext()) &&
Preferences.getBoolean(requireContext(), PREFERENCE_MICROG_AUTH, true)
private val startForAccount =
val startForAccount =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
val accountName = it.data?.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)
if (!accountName.isNullOrBlank()) {
@@ -81,6 +59,15 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentSplashBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -116,7 +103,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
attachActions()
// Show anonymous logins if we have dispenser URL
binding.btnAnonymous.isVisible = !viewModel.authProvider.dispenserURL.isNullOrBlank()
binding.btnAnonymous.isVisible = false
viewLifecycleOwner.lifecycleScope.launch {
viewModel.authState.collectLatest {
@@ -128,7 +115,8 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
}
AuthState.Valid -> {
val packageName = getPackageName(requireActivity().intent)
val packageName =
requireActivity().intent.getPackageName(requireArguments())
if (packageName.isNullOrBlank()) {
navigateToDefaultTab()
} else {
@@ -152,7 +140,8 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
}
AuthState.SignedIn -> {
val packageName = getPackageName(requireActivity().intent)
val packageName =
requireActivity().intent.getPackageName(requireArguments())
if (packageName.isNullOrBlank()) {
navigateToDefaultTab()
} else {
@@ -193,22 +182,12 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
}
private fun updateActionLayout(isVisible: Boolean) {
if (isVisible) {
binding.layoutAction.show()
binding.toolbar.visibility = View.VISIBLE
} else {
binding.layoutAction.hide()
binding.toolbar.visibility = View.GONE
}
binding.layoutAction.isVisible = isVisible
binding.toolbar.isVisible = isVisible
}
private fun attachActions() {
binding.btnAnonymous.addOnClickListener {
if (viewModel.authState.value != AuthState.Fetching) {
binding.btnAnonymous.updateProgress(true)
viewModel.buildAnonymousAuthData()
}
}
open fun attachActions() {
binding.btnAnonymous.hide()
binding.btnGoogle.addOnClickListener {
if (viewModel.authState.value != AuthState.Fetching) {
@@ -232,16 +211,11 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
}
}
private fun resetActions() {
open fun resetActions() {
binding.btnGoogle.apply {
updateProgress(false)
isEnabled = true
}
binding.btnAnonymous.apply {
updateProgress(false)
isEnabled = true
}
}
private fun navigateToDefaultTab() {
@@ -262,29 +236,6 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
findNavController().navigate(directions)
}
private fun getPackageName(intent: Intent): String? {
return when {
intent.action == Intent.ACTION_VIEW -> {
intent.data!!.getQueryParameter("id")
}
intent.action == Intent.ACTION_SEND -> {
val clipData = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
UrlQuerySanitizer(clipData).getValue("id")
}
isNAndAbove && intent.action == Intent.ACTION_SHOW_APP_INFO -> {
intent.extras?.getString(Intent.EXTRA_PACKAGE_NAME)
}
intent.extras != null -> {
intent.extras?.getString("packageName")
}
else -> requireArguments().getString("packageName")
}
}
private fun requestAuthTokenForGoogle(accountName: String, oldToken: String? = null) {
try {
if (oldToken != null) {

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".view.ui.onboarding.AppLinksFragment">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/appCompatTextView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:includeFontPadding="true"
android:paddingStart="@dimen/padding_normal"
android:paddingEnd="@dimen/padding_normal"
android:text="@string/app_links_title"
android:textAlignment="textStart"
android:textColor="?colorAccent"
android:textSize="42sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/appCompatTextView"
style="@style/AuroraTextStyle.Subtitle.Alt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/margin_small"
android:paddingStart="@dimen/padding_normal"
android:paddingEnd="@dimen/padding_normal"
android:text="@string/app_links_desc"
android:textAlignment="textStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appCompatTextView2" />
<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/epoxyRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:padding="@dimen/padding_medium"
tools:listitem="@layout/view_permission_switch" />
</LinearLayout>

View File

@@ -0,0 +1,84 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.onboarding
import androidx.fragment.app.Fragment
import com.aurora.Constants
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.util.Preferences.PREFERENCE_DISPENSER_URLS
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FOR_YOU
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
import com.aurora.store.util.Preferences.PREFERENCE_SIMILAR
import com.aurora.store.util.Preferences.PREFERENCE_THEME_STYLE
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_CHECK_INTERVAL
import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_EXTENDED
import com.aurora.store.util.Preferences.PREFERENCE_VENDING_VERSION
import com.aurora.store.util.save
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class OnboardingFragment : BaseFlavouredOnboardingFragment() {
override fun loadDefaultPreferences() {
/*Filters*/
save(PREFERENCE_FILTER_AURORA_ONLY, false)
save(PREFERENCE_FILTER_FDROID, true)
/*Network*/
save(PREFERENCE_DISPENSER_URLS, setOf(Constants.URL_DISPENSER))
save(PREFERENCE_VENDING_VERSION, 0)
/*Customization*/
save(PREFERENCE_THEME_STYLE, 0)
save(PREFERENCE_DEFAULT_SELECTED_TAB, 0)
save(PREFERENCE_FOR_YOU, true)
save(PREFERENCE_SIMILAR, false)
/*Installer*/
save(PREFERENCE_AUTO_DELETE, true)
save(PREFERENCE_INSTALLER_ID, 0)
/*Updates*/
save(PREFERENCE_UPDATES_EXTENDED, false)
save(PREFERENCE_UPDATES_CHECK_INTERVAL, 3)
}
override fun onboardingPages(): List<Fragment> {
return listOf(
WelcomeFragment(),
PermissionsFragment.newInstance()
)
}
override fun setupAutoUpdates() {
super.setupAutoUpdates()
// Remove super & implement variant logic here
}
override fun finishOnboarding() {
super.finishOnboarding()
// Remove super & implement variant logic here
}
}

View File

@@ -0,0 +1,75 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.ui.splash
import android.accounts.AccountManager
import android.util.Log
import androidx.navigation.fragment.findNavController
import com.aurora.store.R
import com.aurora.store.data.model.AuthState
import com.aurora.store.util.CertUtil.GOOGLE_ACCOUNT_TYPE
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class SplashFragment : BaseFlavouredSplashFragment() {
private val TAG = SplashFragment::class.java.simpleName
override fun attachActions() {
binding.btnAnonymous.addOnClickListener {
if (viewModel.authState.value != AuthState.Fetching) {
binding.btnAnonymous.updateProgress(true)
viewModel.buildAnonymousAuthData()
}
}
binding.btnGoogle.addOnClickListener {
if (viewModel.authState.value != AuthState.Fetching) {
binding.btnGoogle.updateProgress(true)
if (canLoginWithMicroG) {
Log.i(TAG, "Found supported microG, trying to request credentials")
val accountIntent = AccountManager.newChooseAccountIntent(
null,
null,
arrayOf(GOOGLE_ACCOUNT_TYPE),
null,
null,
null,
null
)
startForAccount.launch(accountIntent)
} else {
findNavController().navigate(R.id.googleFragment)
}
}
}
}
override fun resetActions() {
binding.btnGoogle.apply {
updateProgress(false)
isEnabled = true
}
binding.btnAnonymous.apply {
updateProgress(false)
isEnabled = true
}
}
}