Update the glance section

This commit is contained in:
Tommaso Berlose
2020-10-14 01:41:43 +02:00
parent c5eb5358aa
commit c5fefb0e06
51 changed files with 186 additions and 88 deletions

View File

@ -202,8 +202,9 @@ class GlanceTabFragment : Fragment() {
injector.visibility(R.id.info_icon, View.VISIBLE)
}
Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || activity?.checkGrantedPermission(
Manifest.permission.ACTIVITY_RECOGNITION) == true
val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(context)
if (GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || activity?.checkGrantedPermission(
Manifest.permission.ACTIVITY_RECOGNITION) == true)
) {
injector.text(R.id.label,
if (Preferences.showDailySteps) getString(R.string.settings_visible) else getString(
@ -361,14 +362,12 @@ class GlanceTabFragment : Fragment() {
1 -> {
if (resultCode == Activity.RESULT_OK) {
adapter.notifyItemRangeChanged(0, adapter.data.size)
if (dialog != null) {
dialog?.show()
}
} else {
Preferences.showDailySteps = false
if (dialog != null) {
dialog?.show()
}
}
if (dialog != null) {
dialog?.show()
}
}
2 -> {
@ -383,16 +382,14 @@ class GlanceTabFragment : Fragment() {
FITNESS_OPTIONS)
} else {
adapter.notifyItemRangeChanged(0, adapter.data.size)
if (dialog != null) {
dialog?.show()
}
}
} catch (e: ApiException) {
e.printStackTrace()
Preferences.showDailySteps = false
if (dialog != null) {
dialog?.show()
}
}
if (dialog != null) {
dialog?.show()
}
}
}
@ -410,5 +407,8 @@ class GlanceTabFragment : Fragment() {
override fun onResume() {
super.onResume()
adapter.notifyItemRangeChanged(0, adapter.data.size)
if (dialog != null) {
dialog?.show()
}
}
}

View File

@ -30,11 +30,8 @@ import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.components.MaterialBottomSheetDialog
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.helpers.BitmapHelper
import com.tommasoberlose.anotherwidget.helpers.ColorHelper
import com.tommasoberlose.anotherwidget.helpers.*
import com.tommasoberlose.anotherwidget.helpers.ColorHelper.isColorDark
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
import com.tommasoberlose.anotherwidget.helpers.WidgetHelper
import com.tommasoberlose.anotherwidget.receivers.ActivityDetectionReceiver
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
import com.tommasoberlose.anotherwidget.ui.adapters.ViewPagerAdapter
@ -360,12 +357,13 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList
false
}
// Music error indicator
// Glance error indicator
tabs?.getTabAt(4)?.orCreateBadge?.apply {
backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText)
badgeGravity = BadgeDrawable.TOP_END
}?.isVisible = ((Preferences.showMusic || Preferences.showNotifications) && !NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName)) ||
(Preferences.showDailySteps && !(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission(Manifest.permission.ACTIVITY_RECOGNITION)))
(Preferences.showDailySteps && !(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || requireActivity().checkGrantedPermission(Manifest.permission.ACTIVITY_RECOGNITION))) ||
(AlarmHelper.isAlarmProbablyWrong(requireContext()))
}
override fun onResume() {