From 663d264bf18d4af84553d969fd85e782d94faa41 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 7 Sep 2020 13:41:12 -0300 Subject: [wallet] add logcat viewer to dev settings --- build.gradle | 2 +- taler-kotlin-android/build.gradle | 7 +++++++ .../src/main/java/net/taler/common/AndroidUtils.kt | 10 ++++++++++ .../main/java/net/taler/wallet/settings/SettingsFragment.kt | 9 +++++++++ wallet/src/main/res/drawable/ic_bug_report.xml | 10 ++++++++++ wallet/src/main/res/values/strings.xml | 2 ++ wallet/src/main/res/xml/settings_main.xml | 8 ++++++++ 7 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 wallet/src/main/res/drawable/ic_bug_report.xml diff --git a/build.gradle b/build.gradle index 61fff53..8973530 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext.kotlin_version = '1.4.0' ext.ktor_version = "1.4.0" ext.nav_version = "2.3.0" - ext.material_version = "1.2.0" + ext.material_version = "1.2.1" ext.lifecycle_version = "2.2.0" ext.constraintlayout_version = "2.0.1" // check https://android-rebuilds.beuc.net/ for availability of free build tools diff --git a/taler-kotlin-android/build.gradle b/taler-kotlin-android/build.gradle index e57d365..872b1cd 100644 --- a/taler-kotlin-android/build.gradle +++ b/taler-kotlin-android/build.gradle @@ -69,6 +69,13 @@ dependencies { // QR codes implementation 'com.google.zxing:core:3.4.0' // needs minSdkVersion 24+ + // Logcat viewer + implementation('com.github.pedrovgs:lynx:1.1.0') { + exclude group: 'com.android.support' + exclude group: 'com.squareup' + } + implementation 'com.github.pedrovgs:renderers:4.0.0' + // JSON parsing and serialization api "org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC" diff --git a/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt b/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt index ceb5ead..72740df 100644 --- a/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt +++ b/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt @@ -43,6 +43,9 @@ import androidx.core.content.ContextCompat.getSystemService import androidx.fragment.app.Fragment import androidx.navigation.NavDirections import androidx.navigation.fragment.findNavController +import com.github.pedrovgs.lynx.LynxActivity +import com.github.pedrovgs.lynx.LynxConfig +import com.github.pedrovgs.lynx.model.TraceLevel import net.taler.lib.common.Version fun View.fadeIn(endAction: () -> Unit = {}) { @@ -90,6 +93,13 @@ fun Context.isOnline(): Boolean { } } +fun Context.showLogViewer() { + val lynxActivityIntent = LynxActivity.getIntent(this, LynxConfig().apply { + maxNumberOfTracesToShow = 1500 // higher numbers seem to break share functionality + }) + startActivity(lynxActivityIntent) +} + fun Intent.isSafe(context: Context): Boolean { return context.packageManager.queryIntentActivities(this, MATCH_DEFAULT_ONLY).isNotEmpty() } diff --git a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt index 63492f4..b321061 100644 --- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt @@ -25,6 +25,7 @@ import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreferenceCompat import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_SHORT import com.google.android.material.snackbar.Snackbar +import net.taler.common.showLogViewer import net.taler.common.toRelativeTime import net.taler.wallet.BuildConfig.FLAVOR import net.taler.wallet.BuildConfig.VERSION_CODE @@ -42,6 +43,7 @@ class SettingsFragment : PreferenceFragmentCompat() { private lateinit var prefBackup: Preference private lateinit var prefDevMode: SwitchPreferenceCompat private lateinit var prefWithdrawTest: Preference + private lateinit var prefLogcat: Preference private lateinit var prefVersionApp: Preference private lateinit var prefVersionCore: Preference private lateinit var prefVersionExchange: Preference @@ -51,6 +53,7 @@ class SettingsFragment : PreferenceFragmentCompat() { listOf( prefBackup, prefWithdrawTest, + prefLogcat, prefVersionApp, prefVersionCore, prefVersionExchange, @@ -64,6 +67,7 @@ class SettingsFragment : PreferenceFragmentCompat() { prefBackup = findPreference("pref_backup")!! prefDevMode = findPreference("pref_dev_mode")!! prefWithdrawTest = findPreference("pref_testkudos")!! + prefLogcat = findPreference("pref_logcat")!! prefVersionApp = findPreference("pref_version_app")!! prefVersionCore = findPreference("pref_version_core")!! prefVersionExchange = findPreference("pref_version_protocol_exchange")!! @@ -103,6 +107,11 @@ class SettingsFragment : PreferenceFragmentCompat() { true } + prefLogcat.setOnPreferenceClickListener { + requireContext().showLogViewer() + true + } + prefReset.setOnPreferenceClickListener { showResetDialog() true diff --git a/wallet/src/main/res/drawable/ic_bug_report.xml b/wallet/src/main/res/drawable/ic_bug_report.xml new file mode 100644 index 0000000..233af37 --- /dev/null +++ b/wallet/src/main/res/drawable/ic_bug_report.xml @@ -0,0 +1,10 @@ + + + diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml index d49f5f7..b419766 100644 --- a/wallet/src/main/res/values/strings.xml +++ b/wallet/src/main/res/values/strings.xml @@ -158,6 +158,8 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card Shows more information intended for debugging Withdraw TESTKUDOS Get money for testing + Debug log + View/send internal log App Version Wallet Core Version Supported Exchange Versions diff --git a/wallet/src/main/res/xml/settings_main.xml b/wallet/src/main/res/xml/settings_main.xml index 4c2f149..a713838 100644 --- a/wallet/src/main/res/xml/settings_main.xml +++ b/wallet/src/main/res/xml/settings_main.xml @@ -46,6 +46,14 @@ app:title="@string/settings_withdraw_testkudos" tools:isPreferenceVisible="true" /> + +