diff options
author | Torsten Grote <t@grobox.de> | 2020-09-07 13:41:12 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-09-07 13:41:12 -0300 |
commit | 663d264bf18d4af84553d969fd85e782d94faa41 (patch) | |
tree | c3e427b7863d0e68b619603cf732bbf3ad09a89b | |
parent | d78c2003df1db7af448de1c91449201020109190 (diff) | |
download | taler-android-663d264bf18d4af84553d969fd85e782d94faa41.tar.gz taler-android-663d264bf18d4af84553d969fd85e782d94faa41.tar.bz2 taler-android-663d264bf18d4af84553d969fd85e782d94faa41.zip |
[wallet] add logcat viewer to dev settings
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | taler-kotlin-android/build.gradle | 7 | ||||
-rw-r--r-- | taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt | 10 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt | 9 | ||||
-rw-r--r-- | wallet/src/main/res/drawable/ic_bug_report.xml | 10 | ||||
-rw-r--r-- | wallet/src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | wallet/src/main/res/xml/settings_main.xml | 8 |
7 files changed, 47 insertions, 1 deletions
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 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:tint="?attr/colorControlNormal" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z" /> +</vector> 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 <string name="settings_dev_mode_summary">Shows more information intended for debugging</string> <string name="settings_withdraw_testkudos">Withdraw TESTKUDOS</string> <string name="settings_withdraw_testkudos_summary">Get money for testing</string> + <string name="settings_logcat">Debug log</string> + <string name="settings_logcat_summary">View/send internal log</string> <string name="settings_version_app">App Version</string> <string name="settings_version_core">Wallet Core Version</string> <string name="settings_version_protocol_exchange">Supported Exchange Versions</string> 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 @@ -47,6 +47,14 @@ tools:isPreferenceVisible="true" /> <Preference + app:icon="@drawable/ic_bug_report" + app:isPreferenceVisible="false" + app:key="pref_logcat" + app:summary="@string/settings_logcat_summary" + app:title="@string/settings_logcat" + tools:isPreferenceVisible="true" /> + + <Preference app:icon="@drawable/ic_account_balance_wallet" app:isPreferenceVisible="false" app:key="pref_version_app" |