Fix #282, bug fixes
This commit is contained in:
parent
57eecd630d
commit
81578f5f4a
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
package com.tommasoberlose.anotherwidget.components
|
||||
|
||||
import android.view.View
|
||||
|
||||
class OnSingleClickListener : View.OnClickListener {
|
||||
|
||||
private val onClickListener: View.OnClickListener
|
||||
|
||||
constructor(listener: View.OnClickListener) {
|
||||
onClickListener = listener
|
||||
}
|
||||
|
||||
constructor(listener: (View) -> Unit) {
|
||||
onClickListener = View.OnClickListener { listener.invoke(it) }
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val currentTimeMillis = System.currentTimeMillis()
|
||||
|
||||
if (currentTimeMillis >= previousClickTimeMillis + DELAY_MILLIS) {
|
||||
previousClickTimeMillis = currentTimeMillis
|
||||
onClickListener.onClick(v)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DELAY_MILLIS = 200L
|
||||
private var previousClickTimeMillis = 0L
|
||||
}
|
||||
|
||||
}
|
@ -94,7 +94,7 @@ class MainFragment : Fragment() {
|
||||
navHost?.navController?.addOnDestinationChangedListener { controller, destination, _ ->
|
||||
val show = destination.id != R.id.tabSelectorFragment
|
||||
binding.actionBack.animate().alpha(if (show) 1f else 0f).setDuration(200).translationX((if (show) 0f else 4f).convertDpToPixel(requireContext())).start()
|
||||
binding.actionBack.setOnClickListener {
|
||||
binding.actionBack.setOnSingleClickListener {
|
||||
controller.navigateUp()
|
||||
}
|
||||
binding.actionBack.isClickable = show
|
||||
@ -105,7 +105,7 @@ class MainFragment : Fragment() {
|
||||
binding.fragmentTitle.text = if (show) destination.label.toString() else getString(R.string.app_name)
|
||||
}
|
||||
|
||||
binding.actionSettings.setOnClickListener {
|
||||
binding.actionSettings.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_appMainFragment_to_appSettingsFragment,)
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import com.tommasoberlose.anotherwidget.ui.activities.settings.SupportDevActivit
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.openURI
|
||||
import com.tommasoberlose.anotherwidget.utils.setOnSingleClickListener
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@ -76,7 +77,7 @@ class SettingsFragment : Fragment() {
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
binding.actionBack.setOnClickListener {
|
||||
binding.actionBack.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).popBackStack()
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class GesturesFragment : Fragment() {
|
||||
maintainScrollPosition {
|
||||
binding.calendarAppLabel.text = when {
|
||||
it == IntentHelper.DO_NOTHING_OPTION -> getString(R.string.gestures_do_nothing)
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> "None, the widget will be refreshed"
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> getString(R.string.gestures_refresh_widget)
|
||||
it != IntentHelper.DEFAULT_OPTION -> it
|
||||
else -> {
|
||||
if (IntentHelper.getCalendarIntent(requireContext()).isDefaultSet(requireContext())) {
|
||||
@ -125,7 +125,7 @@ class GesturesFragment : Fragment() {
|
||||
maintainScrollPosition {
|
||||
binding.clockAppLabel.text = when {
|
||||
it == IntentHelper.DO_NOTHING_OPTION -> getString(R.string.gestures_do_nothing)
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> "None, the widget will be refreshed"
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> getString(R.string.gestures_refresh_widget)
|
||||
it != IntentHelper.DEFAULT_OPTION -> it
|
||||
else -> {
|
||||
if (IntentHelper.getClockIntent(requireContext()).isDefaultSet(requireContext())) {
|
||||
@ -144,7 +144,7 @@ class GesturesFragment : Fragment() {
|
||||
maintainScrollPosition {
|
||||
binding.weatherAppLabel.text = when {
|
||||
it == IntentHelper.DO_NOTHING_OPTION -> getString(R.string.gestures_do_nothing)
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> "None, the widget will be refreshed"
|
||||
it == IntentHelper.REFRESH_WIDGET_OPTION -> getString(R.string.gestures_refresh_widget)
|
||||
it != IntentHelper.DEFAULT_OPTION -> it
|
||||
else -> getString(R.string.default_weather_app)
|
||||
}
|
||||
|
@ -106,15 +106,15 @@ class PreferencesFragment : Fragment() {
|
||||
|
||||
private fun setupListener() {
|
||||
|
||||
binding.actionTypography.setOnClickListener {
|
||||
binding.actionTypography.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_typographyTabFragment)
|
||||
}
|
||||
|
||||
binding.actionGeneralSettings.setOnClickListener {
|
||||
binding.actionGeneralSettings.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_generalTabFragment)
|
||||
}
|
||||
|
||||
binding.actionShowEvents.setOnClickListener {
|
||||
binding.actionShowEvents.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_calendarTabFragment)
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ class PreferencesFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
binding.actionShowWeather.setOnClickListener {
|
||||
binding.actionShowWeather.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_weatherTabFragment)
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ class PreferencesFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
binding.actionShowClock.setOnClickListener {
|
||||
binding.actionShowClock.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_clockTabFragment)
|
||||
}
|
||||
|
||||
@ -147,11 +147,11 @@ class PreferencesFragment : Fragment() {
|
||||
Preferences.showClock = enabled
|
||||
}
|
||||
|
||||
binding.actionShowGlance.setOnClickListener {
|
||||
binding.actionShowGlance.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_glanceTabFragment)
|
||||
}
|
||||
|
||||
binding.actionTabDefaultApp.setOnClickListener {
|
||||
binding.actionTabDefaultApp.setOnSingleClickListener {
|
||||
Navigation.findNavController(it).navigate(R.id.action_tabSelectorFragment_to_gesturesFragment)
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||
import androidx.core.animation.addListener
|
||||
import androidx.core.view.isVisible
|
||||
import com.tommasoberlose.anotherwidget.R
|
||||
import com.tommasoberlose.anotherwidget.components.OnSingleClickListener
|
||||
import java.util.*
|
||||
|
||||
|
||||
@ -253,4 +254,12 @@ fun Locale.isMetric(): Boolean {
|
||||
"US", "LR", "MM", "GB" -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
fun View.setOnSingleClickListener(l: View.OnClickListener) {
|
||||
setOnClickListener(OnSingleClickListener(l))
|
||||
}
|
||||
|
||||
fun View.setOnSingleClickListener(l: (View) -> Unit) {
|
||||
setOnClickListener(OnSingleClickListener(l))
|
||||
}
|
@ -358,4 +358,5 @@
|
||||
<string name="layout_settings_subtitle">Widget spacing and tweaks</string>
|
||||
<string name="smart_content_header">Smart content</string>
|
||||
<string name="spacing_settings_header">Spacing</string>
|
||||
<string name="gestures_refresh_widget">None, the widget will be refreshed</string>
|
||||
</resources>
|
||||
|
@ -10,7 +10,7 @@ buildscript {
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.google.gms:google-services:4.3.4'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user