Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1a91a2a authored by Hasib Prince's avatar Hasib Prince
Browse files

resolved conflict: merged main -> 6010-truncated_string_settings

parents f73eadbc 4cc5616a
Loading
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -468,7 +468,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        appSize: MaterialTextView
    ) {
        installButton.apply {
            text = getString(R.string.retry)
            enableInstallButton(R.string.retry)
            setOnClickListener {
                applicationIcon?.let {
                    mainActivityViewModel.getApplication(fusedApp, it)
@@ -504,7 +504,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        downloadPB: RelativeLayout,
        appSize: MaterialTextView
    ) {
        installButton.isEnabled = false
        installButton.disableInstallButton(R.string.installing)
        downloadPB.visibility = View.GONE
        appSize.visibility = View.VISIBLE
    }
@@ -516,6 +516,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        appSize: MaterialTextView
    ) {
        installButton.apply {
            enableInstallButton(R.string.cancel)
            text = getString(R.string.cancel)
            setOnClickListener {
                mainActivityViewModel.cancelDownload(fusedApp)
@@ -539,6 +540,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        downloadPB.visibility = View.GONE
        appSize.visibility = View.VISIBLE
        installButton.apply {
            enableInstallButton(R.string.cancel)
            text = getString(R.string.cancel)
            setOnClickListener {
                mainActivityViewModel.cancelDownload(fusedApp)
@@ -553,6 +555,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        appSize: MaterialTextView
    ) {
        installButton.apply {
            enableInstallButton(R.string.install)
            text = when {
                mainActivityViewModel.checkUnsupportedApplication(fusedApp) ->
                    getString(R.string.not_available)
@@ -565,6 +568,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                }
                applicationIcon?.let {
                    if (fusedApp.isFree) {
                        disableInstallButton(R.string.cancel)
                        installApplication(fusedApp, it)
                    } else {
                        if (!mainActivityViewModel.shouldShowPaidAppsSnackBar(fusedApp)) {
@@ -590,6 +594,24 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        appSize.visibility = View.VISIBLE
    }

    private fun MaterialButton.disableInstallButton(buttonStringID: Int) {
        isEnabled = false
        text = context.getString(buttonStringID)
        strokeColor = ContextCompat.getColorStateList(context, R.color.light_grey)
        setTextColor(context.getColor(R.color.light_grey))
        backgroundTintList =
            ContextCompat.getColorStateList(context, android.R.color.transparent)
    }

    private fun MaterialButton.enableInstallButton(buttonStringID: Int) {
        isEnabled = true
        text = context.getString(buttonStringID)
        strokeColor = ContextCompat.getColorStateList(context, R.color.colorAccent)
        setTextColor(context.getColor(R.color.colorAccent))
        backgroundTintList =
            ContextCompat.getColorStateList(context, android.R.color.transparent)
    }

    private fun installApplication(
        fusedApp: FusedApp,
        it: ImageView
@@ -616,6 +638,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        appSize: MaterialTextView
    ) {
        installButton.apply {
            enableInstallButton(R.string.not_available)
            text = if (mainActivityViewModel.checkUnsupportedApplication(fusedApp))
                getString(R.string.not_available)
            else getString(R.string.update)
@@ -645,8 +668,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
        downloadPB.visibility = View.GONE
        appSize.visibility = View.VISIBLE
        installButton.apply {
            isEnabled = true
            text = getString(R.string.open)
            enableInstallButton(R.string.open)
            setTextColor(Color.WHITE)
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package foundation.e.apps.applicationlist.model
package foundation.e.apps.applicationlist

import androidx.recyclerview.widget.DiffUtil
import foundation.e.apps.api.fused.data.FusedApp
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import foundation.e.apps.api.ResultSupreme
import foundation.e.apps.api.fused.FusedAPIInterface
import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.application.subFrags.ApplicationDialogFragment
import foundation.e.apps.applicationlist.model.ApplicationListRVAdapter
import foundation.e.apps.databinding.FragmentApplicationListBinding
import foundation.e.apps.manager.download.data.DownloadProgress
import foundation.e.apps.manager.pkg.PkgManagerModule
+32 −55
Original line number Diff line number Diff line
/*
 * Apps  Quickly and easily install Android apps onto your device!
 * Copyright (C) 2021  E FOUNDATION
 *  Copyright (C) 2022  ECORP
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
@@ -16,9 +15,8 @@
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.applicationlist.model
package foundation.e.apps.applicationlist

import android.graphics.Color
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@@ -45,11 +43,12 @@ import foundation.e.apps.R
import foundation.e.apps.api.cleanapk.CleanAPKInterface
import foundation.e.apps.api.fused.FusedAPIInterface
import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.applicationlist.ApplicationListFragmentDirections
import foundation.e.apps.databinding.ApplicationListItemBinding
import foundation.e.apps.manager.pkg.InstallerService
import foundation.e.apps.search.SearchFragmentDirections
import foundation.e.apps.updates.UpdatesFragmentDirections
import foundation.e.apps.utils.disableInstallButton
import foundation.e.apps.utils.enableInstallButton
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.User
@@ -244,19 +243,19 @@ class ApplicationListRVAdapter(
        showMore.visibility = View.INVISIBLE
        when (searchApp.status) {
            Status.INSTALLED -> {
                handleInstalled(view, searchApp)
                handleInstalled(searchApp)
            }
            Status.UPDATABLE -> {
                handleUpdatable(view, searchApp)
                handleUpdatable(searchApp)
            }
            Status.UNAVAILABLE -> {
                handleUnavailable(view, searchApp, holder)
                handleUnavailable(searchApp, holder)
            }
            Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> {
                handleDownloading(view, searchApp)
                handleDownloading(searchApp)
            }
            Status.INSTALLING, Status.UNINSTALLING -> {
                handleInstalling(view, holder)
                handleInstalling()
            }
            Status.BLOCKED -> {
                handleBlocked(view)
@@ -293,10 +292,8 @@ class ApplicationListRVAdapter(
        searchApp: FusedApp
    ) {
        installButton.apply {
            isEnabled = !faultyAppResult.first
            if (faultyAppResult.first) disableInstallButton() else enableInstallButton()
            text = getInstallationIssueText(faultyAppResult, view)
            strokeColor = getStrokeColor(isEnabled, view)
            setButtonTextColor(isEnabled)
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, android.R.color.transparent)
            setOnClickListener {
@@ -401,29 +398,20 @@ class ApplicationListRVAdapter(
        appPrivacyScore.visibility = View.VISIBLE
    }

    private fun ApplicationListItemBinding.handleInstalling(view: View, holder: ViewHolder) {
    private fun ApplicationListItemBinding.handleInstalling() {
        installButton.apply {
            isEnabled = false
            text = context.getString(R.string.installing)
            setTextColor(context.getColor(R.color.light_grey))
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, android.R.color.transparent)
            strokeColor = ContextCompat.getColorStateList(view.context, R.color.light_grey)
            disableInstallButton()
            text = context.getText(R.string.installing)
        }
        progressBarInstall.visibility = View.GONE
    }

    private fun ApplicationListItemBinding.handleDownloading(
        view: View,
        searchApp: FusedApp,
    ) {
        installButton.apply {
            isEnabled = true
            enableInstallButton()
            text = context.getString(R.string.cancel)
            setTextColor(context.getColor(R.color.colorAccent))
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, android.R.color.transparent)
            strokeColor = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                cancelDownload(searchApp)
            }
@@ -433,21 +421,18 @@ class ApplicationListRVAdapter(
    }

    private fun ApplicationListItemBinding.handleUnavailable(
        view: View,
        searchApp: FusedApp,
        holder: ViewHolder,
    ) {
        installButton.apply {
            updateUIByPaymentType(searchApp, this, this@handleUnavailable, holder)
            setTextColor(context.getColor(R.color.colorAccent))
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, android.R.color.transparent)
            strokeColor = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (mainActivityViewModel.checkUnsupportedApplication(searchApp, context)) {
                    return@setOnClickListener
                }
                if (searchApp.isFree || searchApp.isPurchased) {
                    disableInstallButton()
                    text = context.getText(R.string.cancel)
                    installApplication(searchApp, appIcon)
                } else {
                    paidAppHandler?.invoke(searchApp)
@@ -464,17 +449,17 @@ class ApplicationListRVAdapter(
    ) {
        when {
            mainActivityViewModel.checkUnsupportedApplication(searchApp) -> {
                materialButton.isEnabled = true
                materialButton.enableInstallButton()
                materialButton.text = materialButton.context.getString(R.string.not_available)
                applicationListItemBinding.progressBarInstall.visibility = View.GONE
            }
            searchApp.isFree -> {
                materialButton.isEnabled = true
                materialButton.enableInstallButton()
                materialButton.text = materialButton.context.getString(R.string.install)
                applicationListItemBinding.progressBarInstall.visibility = View.GONE
            }
            else -> {
                materialButton.isEnabled = false
                materialButton.disableInstallButton()
                materialButton.text = ""
                applicationListItemBinding.progressBarInstall.visibility = View.VISIBLE
                holder.isPurchasedLiveData = appInfoFetchViewModel.isAppPurchased(searchApp)
@@ -482,7 +467,7 @@ class ApplicationListRVAdapter(
                    return
                }
                holder.isPurchasedLiveData.observe(lifecycleOwner!!) {
                    materialButton.isEnabled = true
                    materialButton.enableInstallButton()
                    applicationListItemBinding.progressBarInstall.visibility = View.GONE
                    materialButton.text =
                        if (it) materialButton.context.getString(R.string.install) else searchApp.price
@@ -492,17 +477,13 @@ class ApplicationListRVAdapter(
    }

    private fun ApplicationListItemBinding.handleUpdatable(
        view: View,
        searchApp: FusedApp
    ) {
        installButton.apply {
            isEnabled = true
            enableInstallButton(Status.UPDATABLE)
            text = if (mainActivityViewModel.checkUnsupportedApplication(searchApp))
                context.getString(R.string.not_available)
            else context.getString(R.string.update)
            setTextColor(Color.WHITE)
            backgroundTintList = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            strokeColor = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (mainActivityViewModel.checkUnsupportedApplication(searchApp, context)) {
                    return@setOnClickListener
@@ -514,15 +495,11 @@ class ApplicationListRVAdapter(
    }

    private fun ApplicationListItemBinding.handleInstalled(
        view: View,
        searchApp: FusedApp,
    ) {
        installButton.apply {
            isEnabled = true
            enableInstallButton(Status.INSTALLED)
            text = context.getString(R.string.open)
            setTextColor(Color.WHITE)
            backgroundTintList = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            strokeColor = ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (searchApp.is_pwa) {
                    mainActivityViewModel.launchPwa(searchApp)
+17 −42
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

package foundation.e.apps.home.model

import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -41,6 +40,8 @@ import foundation.e.apps.api.fused.FusedAPIInterface
import foundation.e.apps.api.fused.data.FusedApp
import foundation.e.apps.databinding.HomeChildListItemBinding
import foundation.e.apps.home.HomeFragmentDirections
import foundation.e.apps.utils.disableInstallButton
import foundation.e.apps.utils.enableInstallButton
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
import foundation.e.apps.utils.enums.User
@@ -108,13 +109,13 @@ class HomeChildRVAdapter(
                    handleUpdatable(view, homeApp)
                }
                Status.UNAVAILABLE -> {
                    handleUnavailable(homeApp, holder, view)
                    handleUnavailable(homeApp, holder)
                }
                Status.QUEUED, Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED -> {
                    handleQueued(view, homeApp)
                }
                Status.INSTALLING, Status.UNINSTALLING -> {
                    handleInstalling(view)
                    handleInstalling()
                }
                Status.BLOCKED -> {
                    handleBlocked(view)
@@ -131,14 +132,8 @@ class HomeChildRVAdapter(
        homeApp: FusedApp
    ) {
        installButton.apply {
            enableInstallButton()
            text = view.context.getString(R.string.retry)
            setTextColor(context.getColor(R.color.colorAccent))
            backgroundTintList = ContextCompat.getColorStateList(
                view.context,
                android.R.color.transparent
            )
            strokeColor =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                installApplication(homeApp, appIcon)
            }
@@ -147,6 +142,7 @@ class HomeChildRVAdapter(
    }

    private fun HomeChildListItemBinding.handleBlocked(view: View) {
        installButton.enableInstallButton()
        installButton.setOnClickListener {
            val errorMsg = when (mainActivityViewModel.getUser()) {
                User.ANONYMOUS,
@@ -160,17 +156,10 @@ class HomeChildRVAdapter(
        progressBarInstall.visibility = View.GONE
    }

    private fun HomeChildListItemBinding.handleInstalling(view: View) {
    private fun HomeChildListItemBinding.handleInstalling() {
        installButton.apply {
            isEnabled = false
            setTextColor(context.getColor(R.color.light_grey))
            disableInstallButton()
            text = context.getString(R.string.installing)
            backgroundTintList = ContextCompat.getColorStateList(
                view.context,
                android.R.color.transparent
            )
            strokeColor =
                ContextCompat.getColorStateList(view.context, R.color.light_grey)
        }
        progressBarInstall.visibility = View.GONE
    }
@@ -180,6 +169,7 @@ class HomeChildRVAdapter(
        homeApp: FusedApp
    ) {
        installButton.apply {
            enableInstallButton()
            text = context.getString(R.string.cancel)
            setTextColor(context.getColor(R.color.colorAccent))
            backgroundTintList = ContextCompat.getColorStateList(
@@ -199,22 +189,16 @@ class HomeChildRVAdapter(
    private fun HomeChildListItemBinding.handleUnavailable(
        homeApp: FusedApp,
        holder: ViewHolder,
        view: View
    ) {
        installButton.apply {
            updateUIByPaymentType(homeApp, this, holder.binding)
            setTextColor(context.getColor(R.color.colorAccent))
            backgroundTintList = ContextCompat.getColorStateList(
                view.context,
                android.R.color.transparent
            )
            strokeColor =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (mainActivityViewModel.checkUnsupportedApplication(homeApp, context)) {
                    return@setOnClickListener
                }
                if (homeApp.isFree) {
                    disableInstallButton()
                    text = context.getString(R.string.cancel)
                    installApplication(homeApp, appIcon)
                } else {
                    paidAppHandler?.invoke(homeApp)
@@ -228,14 +212,10 @@ class HomeChildRVAdapter(
        homeApp: FusedApp
    ) {
        installButton.apply {
            enableInstallButton(Status.UPDATABLE)
            text = if (mainActivityViewModel.checkUnsupportedApplication(homeApp))
                context.getString(R.string.not_available)
            else context.getString(R.string.update)
            setTextColor(Color.WHITE)
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            strokeColor =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (mainActivityViewModel.checkUnsupportedApplication(homeApp, context)) {
                    return@setOnClickListener
@@ -251,13 +231,8 @@ class HomeChildRVAdapter(
        homeApp: FusedApp
    ) {
        installButton.apply {
            isEnabled = true
            enableInstallButton(Status.INSTALLED)
            text = context.getString(R.string.open)
            setTextColor(Color.WHITE)
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            strokeColor =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (homeApp.is_pwa) {
                    mainActivityViewModel.launchPwa(homeApp)
@@ -276,22 +251,22 @@ class HomeChildRVAdapter(
    ) {
        when {
            mainActivityViewModel.checkUnsupportedApplication(homeApp) -> {
                materialButton.isEnabled = true
                materialButton.enableInstallButton()
                materialButton.text = materialButton.context.getString(R.string.not_available)
            }
            homeApp.isFree -> {
                materialButton.isEnabled = true
                materialButton.enableInstallButton()
                materialButton.text = materialButton.context.getString(R.string.install)
                homeChildListItemBinding.progressBarInstall.visibility = View.GONE
            }
            else -> {
                materialButton.isEnabled = false
                materialButton.disableInstallButton()
                materialButton.text = ""
                homeChildListItemBinding.progressBarInstall.visibility = View.VISIBLE
                lifecycleOwner?.let {
                    appInfoFetchViewModel.isAppPurchased(homeApp).observe(it) {
                        materialButton.isEnabled = true
                        homeChildListItemBinding.progressBarInstall.visibility = View.GONE
                        materialButton.enableInstallButton()
                        materialButton.text =
                            if (it) materialButton.context.getString(R.string.install) else homeApp.price
                    }
Loading