Skip to content

Commit

Permalink
Merge pull request #149 from ergoplatform/release/2.0.x
Browse files Browse the repository at this point in the history
2.0.2217
  • Loading branch information
MrStahlfelge authored Sep 6, 2022
2 parents e071ec6 + 59e84a4 commit 44684b6
Show file tree
Hide file tree
Showing 89 changed files with 2,130 additions and 424 deletions.
9 changes: 8 additions & 1 deletion PRIVACYPOLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ The terms used in this Privacy Policy have the same meanings as in our Terms and

#### Information Collection and Use

There is no data collected. We don't track you. We don't profile you.
There is no data collected by us. We don't track you. We don't profile you.

If you enable dApp plugins within the app, third-party providers will get the following information to improve your experience:

* A random, anonymous universal ID to help the services store preferences for you. The ID is different for each third-party provider.
* Your application language, platform and version as well as your device form factor.

Please note that third-party providers might store and collect the information you give on the dApp plugin pages. Please contact the app provider for further questions.

#### Log Data

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Official Ergo Wallet App ([official announcement](https://ergoplatform.org/en/blog/2021-07-29-ergo-for-android-released/))

<a href="https://play.google.com/store/apps/details?id=org.ergoplatform.android"><img alt="Get it on Google Play" src="https://user-images.githubusercontent.com/11427267/75923897-483f3b00-5e66-11ea-8ec7-e86887afea51.png"></a>
<a href="https://testflight.apple.com/join/MRyG2qfm"><img alt="Download App Store" src="https://user-images.githubusercontent.com/11427267/75923896-47a6a480-5e66-11ea-87c1-3ec73ebcf7a5.png"></a>
<a href="https://apps.apple.com/app/terminus-wallet-ergo/id1643137927"><img alt="Download App Store" src="https://user-images.githubusercontent.com/11427267/75923896-47a6a480-5e66-11ea-87c1-3ec73ebcf7a5.png"></a>

Features:
* generating wallets, restoring wallets in a way compatible to Yoroi and Ergo node
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "org.ergoplatform.android"
minSdkVersion 24
targetSdkVersion 31
versionCode 2215
versionName "2.0.2215"
versionCode 2217
versionName "2.0.2217"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
4 changes: 0 additions & 4 deletions android/src/main/java/org/ergoplatform/android/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.appcompat.app.AppCompatDelegate
import org.ergoplatform.WalletStateSyncManager
import org.ergoplatform.appkit.NetworkType
import org.ergoplatform.isErgoMainNet
import org.ergoplatform.mosaik.MosaikLogger
import org.ergoplatform.utils.LogUtils

class App : Application() {
Expand All @@ -26,8 +25,5 @@ class App : Application() {

LogUtils.stackTraceLogger = { lastStackTrace = it }
LogUtils.logDebug = BuildConfig.DEBUG
MosaikLogger.logger = { severity, msg, throwable ->
LogUtils.logDebug("Mosaik", "$severity: $msg", throwable)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class MainActivity : AppCompatActivity() {
if (savedInstanceState == null) {
handleIntent(navController)
}

setMosaikButtonVisibility(navView)
}

fun setMosaikButtonVisibility(navView: BottomNavigationView = findViewById(R.id.nav_view)) {
navView.menu.findItem(R.id.navigation_mosaik).isVisible = Preferences(this).mosaikEnabled
}

fun scanQrCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.fragment.findNavController
import kotlinx.coroutines.launch
import org.ergoplatform.android.AppDatabase
import org.ergoplatform.android.Preferences
import org.ergoplatform.android.databinding.FragmentAppOverviewBinding
import org.ergoplatform.android.databinding.FragmentAppOverviewItemBinding
import org.ergoplatform.android.persistence.AndroidCacheFiles
Expand Down Expand Up @@ -66,6 +67,19 @@ class AppOverviewFragment : Fragment() {
}
}
}

setTermsAndOverviewVisibility()

binding.buttonAccept.setOnClickListener {
Preferences(requireContext()).mosaikEnabled = true
setTermsAndOverviewVisibility()
}
}

private fun setTermsAndOverviewVisibility() {
val enabled = Preferences(requireContext()).mosaikEnabled
binding.mosaikAppOverview.visibility = if (enabled) View.VISIBLE else View.GONE
binding.mosaikAcceptTerms.visibility = if (enabled) View.GONE else View.VISIBLE
}

private fun refreshSuggestions(suggestions: List<MosaikAppSuggestion>) {
Expand All @@ -83,8 +97,6 @@ class AppOverviewFragment : Fragment() {
}

private fun refreshFavorites(favorites: List<MosaikAppEntry>) {
if (favorites.isNotEmpty())
binding.descEmpty.visibility = View.GONE
binding.descFavoritesEmpty.visibility =
if (favorites.isEmpty()) View.VISIBLE else View.GONE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.google.zxing.integration.android.IntentIntegrator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.ergoplatform.ApiServiceManager
import org.ergoplatform.android.AppDatabase
import org.ergoplatform.android.Preferences
import org.ergoplatform.android.R
Expand All @@ -31,6 +32,7 @@ import org.ergoplatform.android.wallet.ChooseWalletListBottomSheetDialog
import org.ergoplatform.android.wallet.WalletChooserCallback
import org.ergoplatform.android.wallet.addresses.AddressChooserCallback
import org.ergoplatform.android.wallet.addresses.ChooseAddressListDialogFragment
import org.ergoplatform.compose.tokens.getAppMosaikTokenLabelBuilder
import org.ergoplatform.mosaik.MosaikComposeConfig
import org.ergoplatform.mosaik.MosaikViewTree
import org.ergoplatform.mosaik.model.MosaikContext
Expand Down Expand Up @@ -188,7 +190,8 @@ class MosaikFragment : Fragment(), WalletChooserCallback, AddressChooserCallback
}
qrCodeSize = 250.dp
val qrSizePx = (250 * dpToPx).toInt()
convertQrCodeContentToImageBitmap = { convertQrCodeToBitmap(it, qrSizePx, qrSizePx)?.asImageBitmap() }
convertQrCodeContentToImageBitmap =
{ convertQrCodeToBitmap(it, qrSizePx, qrSizePx)?.asImageBitmap() }
preselectEditableInputs = false

DropDownMenu = { expanded,
Expand All @@ -206,6 +209,12 @@ class MosaikFragment : Fragment(), WalletChooserCallback, AddressChooserCallback
DropDownItem = { onClick, content ->
DropdownMenuItem(onClick = onClick, content = content)
}

TokenLabel = getAppMosaikTokenLabelBuilder(
tokenDb = { AppDatabase.getInstance(requireContext()).tokenDbProvider },
apiService = { ApiServiceManager.getOrInit(Preferences(requireContext())) },
stringResolver = { AndroidStringProvider(requireContext()) }
)
}
binding.composeView.setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
binding.composeView.setContent {
Expand Down Expand Up @@ -297,6 +306,8 @@ class MosaikFragment : Fragment(), WalletChooserCallback, AddressChooserCallback
override fun onDestroyView() {
super.onDestroyView()
_binding = null
// TokenLabel references this fragment (requireContext Call), so we set it as a DisposableEffect that is cleaned up
MosaikComposeConfig.TokenLabel = { properties, modifier, content -> }
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.stringResource
import androidx.core.widget.NestedScrollView
import androidx.navigation.navGraphViewModels
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.ergoplatform.android.Preferences
import org.ergoplatform.android.R
Expand All @@ -27,12 +29,15 @@ import org.ergoplatform.mosaik.model.ui.text.LabelStyle
*/
class ConnectionSettingsDialogFragment : BottomSheetDialogFragment() {

private val viewModel: SettingsViewModel by navGraphViewModels(R.id.navigation_settings)

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {

return ComposeView(requireContext()).apply {
val context = requireContext()
val nestedScroll = NestedScrollView(context)
nestedScroll.addView(ComposeView(context).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
AppComposeTheme {
Expand All @@ -45,13 +50,19 @@ class ConnectionSettingsDialogFragment : BottomSheetDialogFragment() {
)

ConnectionSettingsLayout(
preferences = Preferences(requireContext()),
stringProvider = AndroidStringProvider(requireContext()),
viewModel.uiLogic,
onStartNodeDetection = {
viewModel.startNodeDetection(Preferences(context))
},
preferences = Preferences(context),
stringProvider = AndroidStringProvider(context),
onDismissRequest = { dismiss() }
)
}
}
}
}
})

return nestedScroll
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.navGraphViewModels
import org.ergoplatform.android.*
import org.ergoplatform.android.databinding.FragmentSettingsBinding
import org.ergoplatform.android.ui.AndroidStringProvider
import org.ergoplatform.android.ui.enableLinks
import org.ergoplatform.android.ui.navigateSafe
import org.ergoplatform.android.ui.showDialogWithCopyOption
import org.ergoplatform.uilogic.settings.SettingsUiLogic

class SettingsFragment : Fragment() {

Expand All @@ -24,7 +24,7 @@ class SettingsFragment : Fragment() {
// This property is only valid between onCreateView and onDestroyView.
private val binding get() = _binding!!

private val uiLogic = SettingsUiLogic()
private val viewModel: SettingsViewModel by navGraphViewModels(R.id.navigation_settings)

@SuppressLint("SetTextI18n")
override fun onCreateView(
Expand Down Expand Up @@ -78,14 +78,6 @@ class SettingsFragment : Fragment() {
preferences.downloadNftContent = !preferences.downloadNftContent
setButtonDownloadContentText()
}

setButtonMosaikEnabledText()
binding.buttonMosaikEnabled.setOnClickListener {
val preferences = Preferences(requireContext())
preferences.mosaikEnabled = !preferences.mosaikEnabled
setButtonMosaikEnabledText()
(requireActivity() as? MainActivity)?.setMosaikButtonVisibility()
}
}

private fun setButtonDownloadContentText() {
Expand All @@ -95,13 +87,6 @@ class SettingsFragment : Fragment() {
)
}

private fun setButtonMosaikEnabledText() {
binding.buttonMosaikEnabled.setText(
if (Preferences(requireContext()).mosaikEnabled) R.string.button_mosaik_enabled
else R.string.button_mosaik_disabled
)
}

private fun changeDayNightMode(mode: Int) {
Preferences(requireContext()).dayNightMode = mode
setDayNightModeButtonColor(mode)
Expand Down Expand Up @@ -129,7 +114,7 @@ class SettingsFragment : Fragment() {
}

fun showDisplayCurrency() {
binding.displayCurrency.text = uiLogic.getFiatCurrencyButtonText(
binding.displayCurrency.text = viewModel.uiLogic.getFiatCurrencyButtonText(
Preferences(requireContext()), AndroidStringProvider(requireContext())
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.ergoplatform.android.settings

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.ergoplatform.persistance.PreferencesProvider
import org.ergoplatform.uilogic.settings.SettingsUiLogic

class SettingsViewModel : ViewModel() {
val uiLogic = SettingsUiLogic()

fun startNodeDetection(prefs: PreferencesProvider) {
viewModelScope.launch(Dispatchers.IO) { uiLogic.checkAvailableNodes(prefs) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.ergoplatform.android.databinding.FragmentErgoPaySigningBinding
import org.ergoplatform.android.ui.AndroidStringProvider
import org.ergoplatform.android.ui.getSeverityDrawableResId
import org.ergoplatform.android.ui.navigateSafe
import org.ergoplatform.android.ui.openStorePage
import org.ergoplatform.android.wallet.ChooseWalletListBottomSheetDialog
import org.ergoplatform.android.wallet.WalletChooserCallback
import org.ergoplatform.persistance.WalletConfig
Expand Down Expand Up @@ -118,6 +119,9 @@ class ErgoPaySigningFragment : SubmitTransactionFragment(), WalletChooserCallbac
binding.buttonChooseAddress.setOnClickListener {
showAddressOrWalletChooser()
}
binding.buttonRate.setOnClickListener {
openStorePage(requireContext())
}

if (args.closeApp) {
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
Expand Down Expand Up @@ -210,6 +214,9 @@ class ErgoPaySigningFragment : SubmitTransactionFragment(), WalletChooserCallbac
(uiLogic.getDoneSeverity() == MessageSeverity.ERROR && uiLogic.canReloadFromDapp())
binding.buttonDismiss.visibility = if (!shouldReload) View.VISIBLE else View.GONE
binding.buttonRetry.visibility = if (shouldReload) View.VISIBLE else View.GONE
val showRatingPrompt = uiLogic.showRatingPrompt()
binding.buttonRate.visibility = if (showRatingPrompt) View.VISIBLE else View.GONE
binding.tvRate.visibility = if (showRatingPrompt) View.VISIBLE else View.GONE

viewModel.uiLogic.txId?.let {
parentFragmentManager.setFragmentResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class SendFundsFragment : SubmitTransactionFragment() {
findNavController().navigate(R.id.navigation_wallet)
}
}
binding.buttonRate.setOnClickListener {
openStorePage(requireContext())
}

binding.buttonSend.setOnClickListener {
startPayment()
Expand Down
16 changes: 16 additions & 0 deletions android/src/main/java/org/ergoplatform/android/ui/ComposeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.ergoplatform.android.R
import org.ergoplatform.compose.ComposePlatformUtils
import org.ergoplatform.compose.settings.defaultPadding
import org.ergoplatform.mosaik.MosaikStyleConfig
import org.ergoplatform.mosaik.labelStyle
Expand All @@ -21,6 +23,7 @@ import org.ergoplatform.mosaik.model.ui.text.LabelStyle
@Composable
fun AppComposeTheme(content: @Composable () -> Unit) {
prepareMosaikConfig()
initComposePlatformUtils()

MaterialTheme(
colors = MaterialTheme.colors.copy(
Expand Down Expand Up @@ -62,4 +65,17 @@ private fun prepareMosaikConfig() {
buttonShapeRadius = 16.dp
buttonPadding = PaddingValues(defaultPadding, 10.dp)
}
}

private fun initComposePlatformUtils() {
ComposePlatformUtils.getDrawablePainter = {
painterResource(
when (it) {
ComposePlatformUtils.Drawable.Octagon -> R.drawable.ic_octagon_48
ComposePlatformUtils.Drawable.NftImage -> R.drawable.ic_photo_camera_24
ComposePlatformUtils.Drawable.NftAudio -> R.drawable.ic_music_note_24
ComposePlatformUtils.Drawable.NftVideo -> R.drawable.ic_videocam_24
}
)
}
}
7 changes: 7 additions & 0 deletions android/src/main/java/org/ergoplatform/android/ui/UiUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ fun openUrlWithBrowser(context: Context, url: String): Boolean {
}
}

fun openStorePage(context: Context) {
openUrlWithBrowser(
context,
"http://play.google.com/store/apps/details?id=org.ergoplatform.android"
)
}

/**
* Copies address to system clipboard and shows a Snackbar on given view
*/
Expand Down
Loading

0 comments on commit 44684b6

Please sign in to comment.