From d26c4587f28c6f7954709a9f61ce6566356e3672 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 30 Dec 2018 16:55:06 +0800 Subject: [PATCH] Reduce log levels --- mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt | 6 +++--- .../mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt | 9 ++++++--- .../java/be/mygod/vpnhotspot/manage/TetherManager.kt | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt b/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt index 2eb8ec89..834e230b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/MainActivity.kt @@ -9,6 +9,7 @@ import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity import androidx.browser.customtabs.CustomTabsIntent import androidx.core.content.ContextCompat +import androidx.core.os.bundleOf import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.lifecycle.Observer @@ -24,7 +25,6 @@ import be.mygod.vpnhotspot.widget.SmartSnackbar import com.google.android.material.bottomnavigation.BottomNavigationMenuView import com.google.android.material.bottomnavigation.BottomNavigationView import q.rorbin.badgeview.QBadgeView -import timber.log.Timber class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener { private lateinit var binding: ActivityMainBinding @@ -38,10 +38,10 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS fun launchUrl(url: Uri) = if (packageManager.hasSystemFeature("android.hardware.faketouch")) try { customTabsIntent.launchUrl(this, url) } catch (e: ActivityNotFoundException) { - Timber.w(e) + DebugHelper.logEvent("launch_url", bundleOf(Pair("message", e.message))) SmartSnackbar.make(url.toString()).show() } catch (e: SecurityException) { - Timber.w(e) + DebugHelper.logEvent("launch_url", bundleOf(Pair("message", e.message))) SmartSnackbar.make(url.toString()).show() } else SmartSnackbar.make(url.toString()).show() diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt index eb81cfbd..831448bf 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt @@ -18,14 +18,16 @@ import android.text.style.TypefaceSpan import android.view.View import android.widget.Toast import androidx.core.content.getSystemService +import androidx.core.os.bundleOf import androidx.recyclerview.widget.RecyclerView +import be.mygod.vpnhotspot.DebugHelper import be.mygod.vpnhotspot.LocalOnlyHotspotService import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding import be.mygod.vpnhotspot.net.TetherType import be.mygod.vpnhotspot.util.ServiceForegroundConnector import be.mygod.vpnhotspot.util.formatAddresses -import timber.log.Timber +import be.mygod.vpnhotspot.widget.SmartSnackbar import java.net.NetworkInterface @TargetApi(26) @@ -57,11 +59,12 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager() Settings.Secure.getInt(context.contentResolver, Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF } else context.getSystemService()?.isLocationEnabled != true) { - Toast.makeText(context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show() try { context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) + Toast.makeText(context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show() } catch (e: ActivityNotFoundException) { - Timber.w(e) + DebugHelper.logEvent("location_settings", bundleOf(Pair("message", e.message))) + SmartSnackbar.make(R.string.tethering_temp_hotspot_location).show() } return } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt index ac449c61..c0ee1594 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt @@ -8,12 +8,14 @@ import android.view.View import android.widget.Toast import androidx.annotation.RequiresApi import androidx.core.net.toUri +import androidx.core.os.bundleOf import androidx.core.view.updatePaddingRelative import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.OnLifecycleEvent import androidx.recyclerview.widget.RecyclerView import be.mygod.vpnhotspot.App.Companion.app +import be.mygod.vpnhotspot.DebugHelper import be.mygod.vpnhotspot.MainActivity import be.mygod.vpnhotspot.R import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding @@ -49,7 +51,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), "package:${mainActivity.packageName}".toUri())) return } catch (e: ActivityNotFoundException) { - Timber.w(e) + DebugHelper.logEvent("manage_write_settings", bundleOf(Pair("message", e.message))) } val started = manager.isStarted try {