diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt index 8878238..0b73d1e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt @@ -1,7 +1,6 @@ package cy.agorise.bitsybitshareswallet.fragments import android.content.Intent -import android.content.pm.PackageManager import android.graphics.drawable.Animatable import android.os.Bundle import android.util.Log @@ -22,7 +21,6 @@ import cy.agorise.bitsybitshareswallet.databinding.FragmentReceiveTransactionBin import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.Helper import cy.agorise.bitsybitshareswallet.utils.showKeyboard -import cy.agorise.bitsybitshareswallet.utils.toast import cy.agorise.bitsybitshareswallet.viewmodels.ReceiveTransactionViewModel import cy.agorise.graphenej.* import cy.agorise.graphenej.api.ConnectionStatusUpdate @@ -34,23 +32,10 @@ import java.text.DecimalFormat import java.text.DecimalFormatSymbols import java.util.* import java.util.concurrent.TimeUnit -import kotlin.collections.ArrayList import kotlin.math.min class ReceiveTransactionFragment : ConnectedFragment() { - companion object { - private const val TAG = "ReceiveTransactionFrag" - - private const val RESPONSE_LIST_ASSETS = 1 - private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100 - - /** Number of assets to request from the NetworkService to show as suggestions in the AutoCompleteTextView */ - private const val AUTO_SUGGEST_ASSET_LIMIT = 5 - - private const val OTHER_ASSET = "other_asset" - } - private val viewModel: ReceiveTransactionViewModel by viewModels() private var _binding: FragmentReceiveTransactionBinding? = null @@ -120,11 +105,11 @@ class ReceiveTransactionFragment : ConnectedFragment() { val userId = PreferenceManager.getDefaultSharedPreferences(context) .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") - viewModel.getUserAccount(userId!!).observe(viewLifecycleOwner, { user -> + viewModel.getUserAccount(userId!!).observe(viewLifecycleOwner) { user -> mUserAccount = UserAccount(user.id, user.name) - }) + } - viewModel.getAllNonZero().observe(viewLifecycleOwner, { assets -> + viewModel.getAllNonZero().observe(viewLifecycleOwner) { assets -> mAssets.clear() mAssets.addAll(assets) @@ -155,11 +140,11 @@ class ReceiveTransactionFragment : ConnectedFragment() { break } } - }) + } - viewModel.qrCodeBitmap.observe(viewLifecycleOwner, { bitmap -> + viewModel.qrCodeBitmap.observe(viewLifecycleOwner) { bitmap -> binding.ivQR.setImageBitmap(bitmap) - }) + } binding.spAsset.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onNothingSelected(parent: AdapterView<*>?) {} @@ -351,47 +336,12 @@ class ReceiveTransactionFragment : ConnectedFragment() { override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == R.id.menu_share) { - verifyStoragePermission() + shareQRScreenshot() return true } return super.onOptionsItemSelected(item) } - private fun verifyStoragePermission() { - if (ContextCompat.checkSelfPermission( - requireActivity(), - android.Manifest.permission.WRITE_EXTERNAL_STORAGE - ) - != PackageManager.PERMISSION_GRANTED - ) { - // Permission is not already granted - requestPermissions( - arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), - REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION - ) - } else { - // Permission is already granted - shareQRScreenshot() - } - } - - override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray - ) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults) - - if (requestCode == REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION) { - if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) { - shareQRScreenshot() - } else { - context?.toast(getString(R.string.msg__storage_permission_necessary_share)) - } - return - } - } - /** * This function takes a screenshot as a bitmap, saves it into a temporal cache image and then * sends an intent so the user can select the desired method to share the image. @@ -421,4 +371,15 @@ class ReceiveTransactionFragment : ConnectedFragment() { shareIntent.type = "*/*" startActivity(Intent.createChooser(shareIntent, getString(R.string.text__share_with))) } + + companion object { + private const val TAG = "ReceiveTransactionFrag" + + private const val RESPONSE_LIST_ASSETS = 1 + + /** Number of assets to request from the NetworkService to show as suggestions in the AutoCompleteTextView */ + private const val AUTO_SUGGEST_ASSET_LIMIT = 5 + + private const val OTHER_ASSET = "other_asset" + } } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt index 75fb185..f992f2a 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/CSVGenerationTask.kt @@ -32,8 +32,7 @@ class CSVGenerationTask(context: Context) : AsyncTask, Int, private fun createCSVDocument(transferDetails: List): String { return try { // Create and configure a new CSV file to save the transfers list - val externalStorageFolder = Environment.getExternalStorageDirectory().absolutePath + File.separator + - Constants.EXTERNAL_STORAGE_FOLDER + val externalStorageFolder = Environment.getExternalStorageDirectory().absolutePath + File.separator val fileName = mContext.get()?.resources?.let { "${it.getString(R.string.app_name)}-${it.getString(R.string.title_transactions)}"} + ".csv" val file = File(externalStorageFolder, fileName) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt index 0ad9922..b56aa92 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt @@ -48,9 +48,6 @@ object Constants { /** Coingecko's API URL */ const val COINGECKO_URL = "https://api.coingecko.com" - /** Key used to store and retrieve a cache of the coingecko supported currencies */ - const val KEY_COINGECKO_CURRENCIES_CACHE = "key_coingecko_currencies_cache" - /** The fee to send in every transfer (0.01%) */ const val FEE_PERCENTAGE = 0.0001 @@ -122,9 +119,6 @@ object Constants { /** Constant used to decide whether or not to update the tellers and merchants info from the webservice */ const val MERCHANTS_UPDATE_PERIOD = 1000L * 60 * 60 + 3 // 3 hours - /** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/ - const val EXTERNAL_STORAGE_FOLDER = "BiTSy" - /** Constant used to check if the current connected node is out of sync */ const val CHECK_NODE_OUT_OF_SYNC = 10 // 10 seconds diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 496a6c3..8dfe5c0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -125,7 +125,6 @@ BiTSy Rechnung von %1$s Aktie Teilen mit - Für die Freigabe von Bildern ist eine Speichererlaubnis erforderlich. Einstellungen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3a83673..8c1178d 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -124,7 +124,6 @@ Invoice BiTSy de %1$s Compartir Compartir con - El permiso de almacenamiento es necesario para compartir imágenes. Ajustes diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 88011ef..56bf69e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -125,7 +125,6 @@ Facture biTSy de %1$s Partager Partager avec - Une autorisation de stockage est nécessaire pour partager des images. Réglages diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 406aaca..23eac81 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -125,7 +125,6 @@ %1$s से बीटीएसआई चालान शेयर के साथ शेयर करें - छवियों को साझा करने के लिए भंडारण की अनुमति आवश्यक है। सेटिंग्स diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 88bd8f7..faaa736 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -125,7 +125,6 @@ %1$sからのBiTSy請求書 シェア と共有する - 画像を共有するには保存許可が必要です。 設定 diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 449942f..4a50ad2 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -125,7 +125,6 @@ %1$s ਦਾ ਬੀ.ਟੀ.ਸੀ ਚਲਾਨ ਸਾਂਝਾ ਕਰੋ ਨਾਲ ਸਾਂਝਾ ਕਰੋ - ਤਸਵੀਰਾਂ ਨੂੰ ਸਾਂਝਾ ਕਰਨ ਲਈ ਸਟੋਰੇਜ਼ ਦੀ ਆਗਿਆ ਜ਼ਰੂਰੀ ਹੈ. ਸੈਟਿੰਗਜ਼ diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 7117c8b..66171fe 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -125,7 +125,6 @@ Fatura BiTSy de %1$s Compartilhar Compartilhar com - É necessária permissão de armazenamento para compartilhar imagens. Definições diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 6d1c941..643c9b8 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -125,7 +125,6 @@ Счет BiTSy от %1$s Поделиться Поделиться с - Разрешение на хранение необходимо для обмена изображениями. настройки diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 45f3ec8..9f930ab 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -125,7 +125,6 @@ 来自%1$s的BiTSy发票 分享 与某人分享 - 共享图像需要存储权限。 设置 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4dba3c3..7e11008 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,7 +127,6 @@ BiTSy invoice from %1$s Share Share with - Storage permission is necessary to share images. Settings