Bugfixes
This commit is contained in:
@ -29,6 +29,7 @@ import com.tommasoberlose.anotherwidget.ui.activities.SupportDevActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
import com.tommasoberlose.anotherwidget.utils.openURI
|
||||
import kotlinx.android.synthetic.main.fragment_advanced_settings.*
|
||||
import kotlinx.coroutines.delay
|
||||
@ -86,7 +87,7 @@ class AdvancedSettingsFragment : Fragment() {
|
||||
})
|
||||
|
||||
viewModel.showWallpaper.observe(viewLifecycleOwner, Observer {
|
||||
show_wallpaper_label.text = if (it && requireActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
show_wallpaper_label.text = if (it && activity?.checkGrantedPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == true) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
|
||||
})
|
||||
}
|
||||
|
||||
@ -136,15 +137,15 @@ class AdvancedSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
action_translate.setOnClickListener {
|
||||
requireActivity().openURI("https://github.com/tommasoberlose/another-widget/blob/master/app/src/main/res/values/strings.xml")
|
||||
activity?.openURI("https://github.com/tommasoberlose/another-widget/blob/master/app/src/main/res/values/strings.xml")
|
||||
}
|
||||
|
||||
action_website.setOnClickListener {
|
||||
requireActivity().openURI("http://tommasoberlose.com/")
|
||||
activity?.openURI("http://tommasoberlose.com/")
|
||||
}
|
||||
|
||||
action_feedback.setOnClickListener {
|
||||
requireActivity().openURI("https://github.com/tommasoberlose/another-widget/issues")
|
||||
activity?.openURI("https://github.com/tommasoberlose/another-widget/issues")
|
||||
}
|
||||
|
||||
action_help_dev.setOnClickListener {
|
||||
|
@ -208,7 +208,7 @@ class CalendarSettingsFragment : Fragment() {
|
||||
checkReadEventsPermission()
|
||||
}.show()
|
||||
} else {
|
||||
requireActivity().toast(getString(R.string.calendar_settings_list_error))
|
||||
activity?.toast(getString(R.string.calendar_settings_list_error))
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ class CalendarSettingsFragment : Fragment() {
|
||||
|
||||
dialog.addOnSelectItemListener { value ->
|
||||
if (value == "-") {
|
||||
startActivity(Intent(requireActivity(), CustomDateActivity::class.java))
|
||||
startActivity(Intent(requireContext(), CustomDateActivity::class.java))
|
||||
} else {
|
||||
Preferences.dateFormat = value
|
||||
}
|
||||
@ -311,7 +311,7 @@ class CalendarSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkReadEventsPermission(showEvents: Boolean = Preferences.showEvents) {
|
||||
if (requireActivity().checkGrantedPermission(Manifest.permission.READ_CALENDAR)) {
|
||||
if (activity?.checkGrantedPermission(Manifest.permission.READ_CALENDAR) == true) {
|
||||
show_events_label.text = if (showEvents) getString(R.string.show_events_visible) else getString(R.string.show_events_not_visible)
|
||||
read_calendar_permission_alert_icon.isVisible = false
|
||||
CalendarHelper.updateEventList(requireContext())
|
||||
@ -325,7 +325,7 @@ class CalendarSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun requirePermission() {
|
||||
Dexter.withContext(requireActivity())
|
||||
Dexter.withContext(requireContext())
|
||||
.withPermissions(
|
||||
Manifest.permission.READ_CALENDAR
|
||||
).withListener(object: MultiplePermissionsListener {
|
||||
|
@ -127,7 +127,7 @@ class ClockSettingsFragment : Fragment() {
|
||||
|
||||
action_clock_app.setOnClickListener {
|
||||
if (Preferences.showClock) {
|
||||
startActivityForResult(Intent(requireActivity(), ChooseApplicationActivity::class.java),
|
||||
startActivityForResult(Intent(requireContext(), ChooseApplicationActivity::class.java),
|
||||
RequestCode.CLOCK_APP_REQUEST_CODE.code
|
||||
)
|
||||
}
|
||||
|
@ -22,8 +22,10 @@ import com.tommasoberlose.anotherwidget.helpers.SettingsStringHelper
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_general_settings.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
class GeneralSettingsFragment : Fragment() {
|
||||
@ -33,6 +35,7 @@ class GeneralSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private lateinit var viewModel: MainViewModel
|
||||
private lateinit var colors: IntArray
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -59,6 +62,12 @@ class GeneralSettingsFragment : Fragment() {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
setupListener()
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val lazyColors = requireContext().resources.getIntArray(R.array.material_colors)
|
||||
withContext(Dispatchers.Main) {
|
||||
colors = lazyColors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +149,7 @@ class GeneralSettingsFragment : Fragment() {
|
||||
Color.parseColor(Preferences.textGlobalColor)
|
||||
}
|
||||
BottomSheetColorPicker(requireContext(),
|
||||
colors = requireActivity().resources.getIntArray(R.array.grey),
|
||||
colors = colors,
|
||||
header = getString(R.string.settings_font_color_title),
|
||||
selected = textColor,
|
||||
onColorSelected = { color: Int ->
|
||||
|
@ -132,7 +132,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkLocationPermission() {
|
||||
if (requireActivity().checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
if (activity?.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION) == true) {
|
||||
location_permission_alert_icon.isVisible = false
|
||||
WeatherReceiver.setUpdates(requireContext())
|
||||
} else if (Preferences.showWeather && Preferences.customLocationAdd == "") {
|
||||
@ -228,7 +228,7 @@ class WeatherSettingsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun requirePermission() {
|
||||
Dexter.withContext(requireActivity())
|
||||
Dexter.withContext(requireContext())
|
||||
.withPermissions(
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
).withListener(object: MultiplePermissionsListener {
|
||||
|
@ -49,13 +49,14 @@ class SupportDevViewModel : ViewModel() {
|
||||
fun handlePurchase(purchase: Purchase) {
|
||||
if (!purchase.isAcknowledged) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val token = purchase.purchaseToken
|
||||
val acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
|
||||
.setPurchaseToken(purchase.purchaseToken)
|
||||
.setPurchaseToken(token)
|
||||
billingClient.acknowledgePurchase(acknowledgePurchaseParams.build())
|
||||
|
||||
val consumeParams =
|
||||
ConsumeParams.newBuilder()
|
||||
.setPurchaseToken(purchase.purchaseToken)
|
||||
.setPurchaseToken(token)
|
||||
.build()
|
||||
billingClient.consumePurchase(consumeParams)
|
||||
}
|
||||
|
Reference in New Issue
Block a user