diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/components/FixedFocusScrollView.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/components/FixedFocusScrollView.kt index b5f88ab..09539d4 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/components/FixedFocusScrollView.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/components/FixedFocusScrollView.kt @@ -6,13 +6,14 @@ import android.util.AttributeSet import android.util.Log import android.view.View import android.widget.ScrollView +import androidx.core.widget.NestedScrollView class FixedFocusScrollView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = 0 -) : ScrollView(context, attrs, defStyle) { +) : NestedScrollView(context, attrs, defStyle) { var isScrollable = true diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/components/GlanceSettingsDialog.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/components/GlanceSettingsDialog.kt index 8ed3a9d..842c80f 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/components/GlanceSettingsDialog.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/components/GlanceSettingsDialog.kt @@ -7,7 +7,6 @@ import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.os.Build -import android.os.Bundle import android.util.Log import android.view.View import androidx.core.app.NotificationManagerCompat @@ -29,10 +28,9 @@ import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper import com.tommasoberlose.anotherwidget.receivers.ActivityDetectionReceiver import com.tommasoberlose.anotherwidget.ui.activities.MusicPlayersFilterActivity import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission -import kotlinx.android.synthetic.main.fragment_glance_settings.* import kotlinx.android.synthetic.main.glance_provider_settings_layout.view.* -class GlanceSettingsDialog(val context: Activity, val provider: Constants.GlanceProviderId, val statusCallback: (() -> Unit)?) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) { +class GlanceSettingsDialog(val context: Activity, val provider: Constants.GlanceProviderId, private val statusCallback: (() -> Unit)?) : BottomSheetDialog(context, R.style.BottomSheetDialogTheme) { override fun show() { val view = View.inflate(context, R.layout.glance_provider_settings_layout, null) @@ -44,6 +42,8 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> context.getString(R.string.settings_low_battery_level_title) Constants.GlanceProviderId.CUSTOM_INFO -> context.getString(R.string.settings_custom_notes_title) Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> context.getString(R.string.settings_daily_steps_title) + Constants.GlanceProviderId.NOTIFICATIONS -> context.getString(R.string.settings_show_notifications_title) + Constants.GlanceProviderId.GREETINGS -> context.getString(R.string.settings_show_greetings_title) } /* SUBTITLE*/ @@ -53,14 +53,16 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> context.getString(R.string.settings_low_battery_level_subtitle) Constants.GlanceProviderId.CUSTOM_INFO -> "" Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> context.getString(R.string.settings_daily_steps_subtitle) + Constants.GlanceProviderId.NOTIFICATIONS -> context.getString(R.string.settings_show_notifications_subtitle) + Constants.GlanceProviderId.GREETINGS -> context.getString(R.string.settings_show_greetings_subtitle) } /* SONG */ view.action_filter_music_players.isVisible = provider == Constants.GlanceProviderId.PLAYING_SONG - view.action_filter_music_players.setOnClickListener { - context.startActivity(Intent(context, MusicPlayersFilterActivity::class.java)) - } if (provider == Constants.GlanceProviderId.PLAYING_SONG) { + view.action_filter_music_players.setOnClickListener { + context.startActivity(Intent(context, MusicPlayersFilterActivity::class.java)) + } checkNotificationPermission(view) } @@ -68,27 +70,35 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance view.alarm_set_by_container.isVisible = provider == Constants.GlanceProviderId.NEXT_CLOCK_ALARM if (provider == Constants.GlanceProviderId.NEXT_CLOCK_ALARM) { view.header.text = context.getString(R.string.information_header) - } - if (provider == Constants.GlanceProviderId.NEXT_CLOCK_ALARM) { view.warning_container.isVisible = false checkNextAlarm(view) } /* GOOGLE STEPS */ + view.action_toggle_google_fit.isVisible = provider == Constants.GlanceProviderId.GOOGLE_FIT_STEPS if (provider == Constants.GlanceProviderId.GOOGLE_FIT_STEPS) { checkFitnessPermission(view) } /* BATTERY INFO */ - view.header.isVisible = provider != Constants.GlanceProviderId.BATTERY_LEVEL_LOW if (provider == Constants.GlanceProviderId.BATTERY_LEVEL_LOW) { view.warning_container.isVisible = false + view.header.isVisible = false view.divider.isVisible = false } - /* CUSTOM NOTES */ - view.subtitle.isVisible = provider != Constants.GlanceProviderId.CUSTOM_INFO - view.provider_switch.isVisible = provider != Constants.GlanceProviderId.CUSTOM_INFO + /* NOTIFICATIONS */ + view.action_filter_notifications_app.isVisible = provider == Constants.GlanceProviderId.NOTIFICATIONS + if (provider == Constants.GlanceProviderId.NOTIFICATIONS) { + checkLastNotificationsPermission(view) + } + + /* GREETINGS */ + if (provider == Constants.GlanceProviderId.GREETINGS) { + view.warning_container.isVisible = false + view.header.isVisible = false + view.divider.isVisible = false + } /* TOGGLE */ view.provider_switch.isChecked = when (provider) { @@ -97,6 +107,8 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> Preferences.showBatteryCharging Constants.GlanceProviderId.CUSTOM_INFO -> true Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> Preferences.showDailySteps + Constants.GlanceProviderId.NOTIFICATIONS -> Preferences.showNotifications + Constants.GlanceProviderId.GREETINGS -> Preferences.showGreetings } view.provider_switch.setOnCheckedChangeListener { _, isChecked -> @@ -112,6 +124,13 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> { Preferences.showBatteryCharging = isChecked } + Constants.GlanceProviderId.NOTIFICATIONS -> { + Preferences.showNotifications = isChecked + checkLastNotificationsPermission(view) + } + Constants.GlanceProviderId.GREETINGS -> { + Preferences.showGreetings = isChecked + } Constants.GlanceProviderId.GOOGLE_FIT_STEPS -> { if (isChecked) { val account: GoogleSignInAccount? = GoogleSignIn.getLastSignedInAccount(context) @@ -161,6 +180,7 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance } private fun checkNotificationPermission(view: View) { + Log.d("ciao", NotificationManagerCompat.getEnabledListenerPackages(context).toString()) when { NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.packageName) -> { view.warning_container.isVisible = false @@ -172,7 +192,25 @@ class GlanceSettingsDialog(val context: Activity, val provider: Constants.Glance view.warning_container.setOnClickListener { context.startActivity(Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")) } - Log.d("ciao", "ok: ${view.warning_container.isVisible}") + } + else -> { + view.warning_container.isVisible = false + } + } + statusCallback?.invoke() + } + + private fun checkLastNotificationsPermission(view: View) { + when { + NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.packageName) -> { + view.warning_container.isVisible = false + } + Preferences.showNotifications -> { + view.warning_container.isVisible = true + view.warning_title.text = context.getString(R.string.settings_request_last_notification_access) + view.warning_container.setOnClickListener { + context.startActivity(Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")) + } } else -> { view.warning_container.isVisible = false diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt index 49c1f91..57727c4 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt @@ -12,4 +12,5 @@ object Actions { const val ACTION_GO_TO_NEXT_EVENT = "com.tommasoberlose.anotherwidget.action.GO_TO_NEXT_EVENT" const val ACTION_GO_TO_PREVIOUS_EVENT = "com.tommasoberlose.anotherwidget.action.GO_TO_PREVIOUS_EVENT" const val ACTION_REPORT_CRASH = "com.tommasoberlose.anotherwidget.action.REPORT_CRASH" + const val ACTION_CLEAR_NOTIFICATION = "com.tommasoberlose.anotherwidget.action.CLEAR_NOTIFICATION" } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Constants.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Constants.kt index 9aff1ec..12e5f04 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Constants.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Constants.kt @@ -30,7 +30,9 @@ object Constants { NEXT_CLOCK_ALARM("NEXT_CLOCK_ALARM"), BATTERY_LEVEL_LOW("BATTERY_LEVEL_LOW"), CUSTOM_INFO("CUSTOM_INFO"), - GOOGLE_FIT_STEPS("GOOGLE_FIT_STEPS"); + GOOGLE_FIT_STEPS("GOOGLE_FIT_STEPS"), + NOTIFICATIONS("NOTIFICATIONS"), + GREETINGS("GREETINGS"); companion object { private val map = GlanceProviderId.values().associateBy(GlanceProviderId::id) diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt index 0de6864..b4c72b1 100755 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Preferences.kt @@ -123,8 +123,14 @@ object Preferences : KotprefModel() { var isCharging by booleanPref(default = false) var googleFitSteps by longPref(default = -1) var showDailySteps by booleanPref(default = false) + var showGreetings by booleanPref(default = false) var showNotifications by booleanPref(default = false) + var lastNotificationId by intPref(default = -1) + var lastNotificationTitle by stringPref(default = "") + var lastNotificationIcon by intPref(default = 0) + var lastNotificationPackage by stringPref(default = "") + var showMusic by booleanPref(default = false) var mediaInfoFormat by stringPref(default = "") var mediaPlayerTitle by stringPref(default = "") diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ActiveNotificationsHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ActiveNotificationsHelper.kt index 4a9da77..f07a049 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ActiveNotificationsHelper.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/ActiveNotificationsHelper.kt @@ -1,19 +1,28 @@ package com.tommasoberlose.anotherwidget.helpers +import android.app.Notification import android.app.NotificationManager import android.content.Context import android.service.notification.StatusBarNotification import android.util.Log +import com.chibatching.kotpref.Kotpref +import com.chibatching.kotpref.blockingBulk import com.google.gson.Gson +import com.tommasoberlose.anotherwidget.global.Preferences +import java.lang.Exception object ActiveNotificationsHelper { - fun getLastNotification(context: Context): StatusBarNotification? { - with(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager) { - activeNotifications.forEach { - Log.d("ciao", Gson().toJson(it).toString()) - } + fun showLastNotification(): Boolean { + return Preferences.lastNotificationId != -1 && Preferences.lastNotificationIcon != 0 && Preferences.lastNotificationPackage.isNotBlank() && Preferences.lastNotificationTitle.isNotBlank() + } - return activeNotifications.lastOrNull() + fun clearLastNotification(context: Context) { + Kotpref.init(context) + Preferences.blockingBulk { + remove(Preferences::lastNotificationId) + remove(Preferences::lastNotificationTitle) + remove(Preferences::lastNotificationPackage) + remove(Preferences::lastNotificationIcon) } } } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/GlanceProviderHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/GlanceProviderHelper.kt index a9f8436..ee55308 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/GlanceProviderHelper.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/GlanceProviderHelper.kt @@ -1,7 +1,6 @@ package com.tommasoberlose.anotherwidget.helpers import android.content.Context -import android.util.Log import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.db.EventRepository import com.tommasoberlose.anotherwidget.global.Constants @@ -71,6 +70,18 @@ object GlanceProviderHelper { R.drawable.round_directions_walk ) } + Constants.GlanceProviderId.NOTIFICATIONS -> { + GlanceProvider(providerId.id, + context.getString(R.string.settings_show_notifications_title), + R.drawable.round_notifications + ) + } + Constants.GlanceProviderId.GREETINGS -> { + GlanceProvider(providerId.id, + context.getString(R.string.settings_show_greetings_title), + R.drawable.round_history_edu + ) + } } } @@ -84,12 +95,12 @@ object GlanceProviderHelper { val showGlance = Preferences.showGlance && (eventRepository.getEventsCount() == 0 || !Preferences.showEvents) && ( + (Preferences.showNotifications && ActiveNotificationsHelper.showLastNotification()) || (Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") || (MediaPlayerHelper.isSomeonePlaying(context)) || (Preferences.showBatteryCharging && Preferences.isCharging || Preferences.isBatteryLevelLow) || (Preferences.customNotes.isNotEmpty()) || - (Preferences.showDailySteps && Preferences.googleFitSteps > 0) || - (Preferences.showNotifications && ActiveNotificationsHelper.getLastNotification(context) != null) + (Preferences.showDailySteps && Preferences.googleFitSteps > 0) ) eventRepository.close() return showGlance diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt index 8615f85..4bb7752 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt @@ -222,4 +222,16 @@ object IntentHelper { Intent() } } + + fun getNotificationIntent(context: Context): Intent { + val pm: PackageManager = context.packageManager + return try { + pm.getLaunchIntentForPackage(Preferences.lastNotificationPackage)!!.apply { + addCategory(Intent.CATEGORY_LAUNCHER) + } + } catch (e: Exception) { + context.toast(context.getString(R.string.error_opening_app)) + Intent() + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt index e77a428..57227aa 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/NotificationListener.kt @@ -1,19 +1,18 @@ package com.tommasoberlose.anotherwidget.receivers -import android.app.Notification -import android.media.MediaMetadata -import android.media.session.MediaController +import android.app.* +import android.content.Context +import android.content.Intent import android.media.session.MediaSession -import android.media.session.PlaybackState +import android.os.Build import android.service.notification.NotificationListenerService import android.service.notification.StatusBarNotification -import android.util.Log -import com.chibatching.kotpref.bulk -import com.google.gson.Gson +import com.tommasoberlose.anotherwidget.global.Actions import com.tommasoberlose.anotherwidget.global.Preferences +import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper -import com.tommasoberlose.anotherwidget.helpers.WidgetHelper import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget +import java.util.* class NotificationListener : NotificationListenerService() { @@ -27,19 +26,58 @@ class NotificationListener : NotificationListenerService() { sbn?.notification?.extras?.let { bundle -> bundle.getParcelable(Notification.EXTRA_MEDIA_SESSION)?.let { MediaPlayerHelper.updatePlayingMediaInfo(this) + } ?: run { + val isGroupHeader = sbn.notification.flags and Notification.FLAG_GROUP_SUMMARY != 0 + val isOngoing = sbn.notification.flags and Notification.FLAG_ONGOING_EVENT != 0 + + if (bundle.containsKey(Notification.EXTRA_TITLE) && !isGroupHeader && !isOngoing) { + Preferences.lastNotificationId = sbn.id + Preferences.lastNotificationTitle = bundle.getString(Notification.EXTRA_TITLE) ?: "" + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + Preferences.lastNotificationIcon = sbn.notification.smallIcon.resId + Preferences.lastNotificationPackage = sbn.notification.smallIcon.resPackage + } else { + Preferences.lastNotificationIcon = sbn.notification.icon + Preferences.lastNotificationPackage = sbn.packageName + } + MainWidget.updateWidget(this) + setTimeout(this) + } } } - Log.d("ciao", Gson().toJson(sbn?.notification?.smallIcon)) - Log.d("ciao", Gson().toJson(sbn?.notification?.contentIntent)) - Log.d("ciao", Gson().toJson(sbn?.notification)) - MainWidget.updateWidget(this) super.onNotificationPosted(sbn) } override fun onNotificationRemoved(sbn: StatusBarNotification?) { MediaPlayerHelper.updatePlayingMediaInfo(this) + + sbn?.let { + if (sbn.id == Preferences.lastNotificationId && sbn.packageName == Preferences.lastNotificationPackage) { + ActiveNotificationsHelper.clearLastNotification(this) + } + } + MainWidget.updateWidget(this) super.onNotificationRemoved(sbn) } + + private fun setTimeout(context: Context) { + with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) { + val intent = Intent(context, UpdatesReceiver::class.java).apply { + action = Actions.ACTION_CLEAR_NOTIFICATION + } + cancel(PendingIntent.getBroadcast(context, 28943, intent, 0)) + setExact( + AlarmManager.RTC, + Calendar.getInstance().timeInMillis + 30 * 1000, + PendingIntent.getBroadcast( + context, + 5, + intent, + 0 + ) + ) + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt index c930d86..f7159ee 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt @@ -12,8 +12,10 @@ import com.tommasoberlose.anotherwidget.db.EventRepository import com.tommasoberlose.anotherwidget.global.Actions import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.global.Preferences +import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper import com.tommasoberlose.anotherwidget.helpers.BatteryHelper import com.tommasoberlose.anotherwidget.helpers.CalendarHelper +import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper import com.tommasoberlose.anotherwidget.models.Event import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget import org.joda.time.Period @@ -32,16 +34,24 @@ class UpdatesReceiver : BroadcastReceiver() { Intent.ACTION_DATE_CHANGED, Actions.ACTION_CALENDAR_UPDATE -> { CalendarHelper.updateEventList(context) + ActiveNotificationsHelper.clearLastNotification(context) + MediaPlayerHelper.updatePlayingMediaInfo(context) } "com.sec.android.widgetapp.APPWIDGET_RESIZE", AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED, + Actions.ACTION_ALARM_UPDATE, Actions.ACTION_TIME_UPDATE -> { MainWidget.updateWidget(context) if (intent.hasExtra(EVENT_ID)) { setUpdates(context, intent.getLongExtra(EVENT_ID, -1)) } } + + Actions.ACTION_CLEAR_NOTIFICATION -> { + ActiveNotificationsHelper.clearLastNotification(context) + MainWidget.updateWidget(context) + } } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/GlanceTabFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/GlanceTabFragment.kt index 669c662..5a1673e 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/GlanceTabFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/GlanceTabFragment.kt @@ -7,19 +7,16 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.content.pm.PackageManager -import android.net.Uri +import android.graphics.Canvas import android.os.Build import android.os.Bundle -import android.provider.Settings -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat -import androidx.core.view.isVisible +import androidx.core.view.ViewCompat import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.lifecycle.Observer @@ -30,15 +27,11 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.gms.auth.api.signin.GoogleSignIn import com.google.android.gms.auth.api.signin.GoogleSignInAccount -import com.google.android.gms.auth.api.signin.GoogleSignInOptions import com.google.android.gms.common.api.ApiException -import com.karumi.dexter.Dexter -import com.karumi.dexter.MultiplePermissionsReport -import com.karumi.dexter.PermissionToken -import com.karumi.dexter.listener.PermissionRequest -import com.karumi.dexter.listener.multi.MultiplePermissionsListener +import com.google.android.material.card.MaterialCardView import com.tommasoberlose.anotherwidget.R -import com.tommasoberlose.anotherwidget.components.* +import com.tommasoberlose.anotherwidget.components.CustomNotesDialog +import com.tommasoberlose.anotherwidget.components.GlanceSettingsDialog import com.tommasoberlose.anotherwidget.databinding.FragmentGlanceSettingsBinding import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.global.Preferences @@ -49,14 +42,10 @@ import com.tommasoberlose.anotherwidget.models.GlanceProvider import com.tommasoberlose.anotherwidget.receivers.ActivityDetectionReceiver import com.tommasoberlose.anotherwidget.receivers.ActivityDetectionReceiver.Companion.FITNESS_OPTIONS import com.tommasoberlose.anotherwidget.ui.activities.MainActivity -import com.tommasoberlose.anotherwidget.ui.activities.MusicPlayersFilterActivity import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission -import com.tommasoberlose.anotherwidget.utils.checkIfFitInstalled -import com.tommasoberlose.anotherwidget.utils.toast -import kotlinx.android.synthetic.main.fragment_calendar_settings.* +import com.tommasoberlose.anotherwidget.utils.convertDpToPixel import kotlinx.android.synthetic.main.fragment_glance_settings.* -import kotlinx.android.synthetic.main.fragment_glance_settings.scrollView import kotlinx.coroutines.delay import kotlinx.coroutines.launch import net.idik.lib.slimadapter.SlimAdapter @@ -79,11 +68,14 @@ class GlanceTabFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { viewModel = ViewModelProvider(activity as MainActivity).get(MainViewModel::class.java) - val binding = DataBindingUtil.inflate(inflater, R.layout.fragment_glance_settings, container, false) + val binding = DataBindingUtil.inflate(inflater, + R.layout.fragment_glance_settings, + container, + false) subscribeUi(binding, viewModel) @@ -97,8 +89,6 @@ class GlanceTabFragment : Fragment() { super.onActivityCreated(savedInstanceState) // List - adapter = SlimAdapter.create() - providers_list.setHasFixedSize(true) val mLayoutManager = LinearLayoutManager(context) providers_list.layoutManager = mLayoutManager @@ -130,45 +120,106 @@ class GlanceTabFragment : Fragment() { when (provider) { Constants.GlanceProviderId.PLAYING_SONG -> { when { - NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName) -> { + NotificationManagerCompat.getEnabledListenerPackages(requireContext()) + .contains( + requireContext().packageName) -> { MediaPlayerHelper.updatePlayingMediaInfo(requireContext()) - injector.invisible(R.id.error_icon) - injector.text(R.id.label, if (Preferences.showMusic) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) + injector.text(R.id.label, + if (Preferences.showMusic) getString(R.string.settings_visible) else getString( + R.string.settings_not_visible)) } Preferences.showMusic -> { - injector.visible(R.id.error_icon) + injector.visibility(R.id.error_icon, View.VISIBLE) + injector.visibility(R.id.info_icon, View.GONE) injector.text(R.id.label, getString(R.string.settings_not_visible)) } else -> { - injector.invisible(R.id.error_icon) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) injector.text(R.id.label, getString(R.string.settings_not_visible)) } } } Constants.GlanceProviderId.NEXT_CLOCK_ALARM -> { - injector.text(R.id.label, if (Preferences.showNextAlarm && !AlarmHelper.isAlarmProbablyWrong(requireContext())) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)) - injector.visibility(R.id.error_icon, if (Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong(requireContext())) View.VISIBLE else View.GONE) + injector.text(R.id.label, + if (Preferences.showNextAlarm && !AlarmHelper.isAlarmProbablyWrong( + requireContext()) + ) getString(R.string.settings_visible) else getString( + R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, + if (Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong( + requireContext()) + ) View.VISIBLE else View.GONE) + injector.visibility(R.id.info_icon, + if (!(Preferences.showNextAlarm && AlarmHelper.isAlarmProbablyWrong( + requireContext())) + ) View.VISIBLE else View.GONE) } Constants.GlanceProviderId.BATTERY_LEVEL_LOW -> { - injector.text(R.id.label, if (Preferences.showBatteryCharging) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)) - injector.invisible(R.id.error_icon) + injector.text(R.id.label, + if (Preferences.showBatteryCharging) getString(R.string.settings_visible) else getString( + R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) + } + Constants.GlanceProviderId.NOTIFICATIONS -> { + when { + NotificationManagerCompat.getEnabledListenerPackages(requireContext()) + .contains( + requireContext().packageName) -> { + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) + injector.text(R.id.label, + if (Preferences.showNotifications) getString( + R.string.settings_visible) else getString(R.string.settings_not_visible)) + } + Preferences.showNotifications -> { + injector.visibility(R.id.error_icon, View.VISIBLE) + injector.visibility(R.id.info_icon, View.GONE) + injector.text(R.id.label, getString(R.string.settings_not_visible)) + } + else -> { + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) + injector.text(R.id.label, getString(R.string.settings_not_visible)) + } + } + } + Constants.GlanceProviderId.GREETINGS -> { + injector.text(R.id.label, + if (Preferences.showGreetings) getString(R.string.settings_visible) else getString( + R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) } Constants.GlanceProviderId.CUSTOM_INFO -> { - injector.text(R.id.label, if (Preferences.customNotes != "") getString(R.string.settings_visible) else getString(R.string.settings_not_visible)) - injector.invisible(R.id.error_icon) + injector.text(R.id.label, + if (Preferences.customNotes != "") getString(R.string.settings_visible) else getString( + R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, View.GONE) + 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) { - injector.text(R.id.label, if (Preferences.showDailySteps) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)) - injector.invisible(R.id.error_icon) + if (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( + R.string.settings_not_visible)) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) } else if (Preferences.showDailySteps) { ActivityDetectionReceiver.unregisterFence(requireContext()) - injector.visible(R.id.error_icon) + injector.visibility(R.id.error_icon, View.VISIBLE) + injector.visibility(R.id.info_icon, View.GONE) injector.text(R.id.label, getString(R.string.settings_not_visible)) } else { ActivityDetectionReceiver.unregisterFence(requireContext()) injector.text(R.id.label, getString(R.string.settings_not_visible)) - injector.invisible(R.id.error_icon) + injector.visibility(R.id.error_icon, View.GONE) + injector.visibility(R.id.info_icon, View.VISIBLE) } } } @@ -180,28 +231,66 @@ class GlanceTabFragment : Fragment() { ItemTouchHelper.UP or ItemTouchHelper.DOWN, 0 ) { + + val list = GlanceProviderHelper.getGlanceProviders(requireContext()) + override fun onMove( recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder + viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder, ): Boolean { val fromPos = viewHolder.adapterPosition val toPos = target.adapterPosition // move item in `fromPos` to `toPos` in adapter. adapter.notifyItemMoved(fromPos, toPos) - val list = GlanceProviderHelper.getGlanceProviders(requireContext()) Collections.swap(list, fromPos, toPos) - GlanceProviderHelper.saveGlanceProviderOrder(list) return true } - override fun getSwipeThreshold(viewHolder: RecyclerView.ViewHolder): Float { - return 1f + override fun isItemViewSwipeEnabled(): Boolean { + return false + } + + override fun clearView( + recyclerView: RecyclerView, + viewHolder: RecyclerView.ViewHolder + ) { + super.clearView(recyclerView, viewHolder) + GlanceProviderHelper.saveGlanceProviderOrder(list) + } + + override fun onChildDraw( + c: Canvas, + recyclerView: RecyclerView, + viewHolder: RecyclerView.ViewHolder, + dX: Float, + dY: Float, + actionState: Int, + isCurrentlyActive: Boolean, + ) { + val view = viewHolder.itemView as MaterialCardView + if (isCurrentlyActive) { + ViewCompat.setElevation(view, 2f.convertDpToPixel(requireContext())) + view.setCardBackgroundColor(ContextCompat.getColor(requireContext(), + R.color.colorPrimary)) + } else { + ViewCompat.setElevation(view, 0f) + view.setCardBackgroundColor(ContextCompat.getColor(requireContext(), + R.color.colorPrimaryDark)) + } + + super.onChildDraw(c, + recyclerView, + viewHolder, + dX, + dY, + actionState, + isCurrentlyActive) } override fun onSwiped( viewHolder: RecyclerView.ViewHolder, - direction: Int + direction: Int, ) { // remove from adapter } @@ -219,14 +308,16 @@ class GlanceTabFragment : Fragment() { private fun subscribeUi( binding: FragmentGlanceSettingsBinding, - viewModel: MainViewModel + viewModel: MainViewModel, ) { binding.isGlanceVisible = Preferences.showGlance viewModel.showGlance.observe(viewLifecycleOwner, Observer { maintainScrollPosition { binding.isGlanceVisible = it - show_glance_label.text = if (it) getString(R.string.description_show_glance_visible) else getString(R.string.description_show_glance_not_visible) + show_glance_label.text = + if (it) getString(R.string.description_show_glance_visible) else getString( + R.string.description_show_glance_not_visible) } }) } @@ -243,13 +334,14 @@ class GlanceTabFragment : Fragment() { private val nextAlarmChangeBroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { - adapter.notifyItemChanged(1) + adapter.notifyItemRangeChanged(0, adapter.data.size) } } override fun onStart() { super.onStart() - activity?.registerReceiver(nextAlarmChangeBroadcastReceiver, IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) + activity?.registerReceiver(nextAlarmChangeBroadcastReceiver, + IntentFilter(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) if (dialog != null) { dialog?.show() } @@ -263,12 +355,12 @@ class GlanceTabFragment : Fragment() { override fun onActivityResult( requestCode: Int, resultCode: Int, - data: Intent? + data: Intent?, ) { when (requestCode) { 1 -> { if (resultCode == Activity.RESULT_OK) { - adapter.notifyItemChanged(2) + adapter.notifyItemRangeChanged(0, adapter.data.size) if (dialog != null) { dialog?.show() } @@ -279,9 +371,10 @@ class GlanceTabFragment : Fragment() { } } } - 2-> { + 2 -> { try { - val account: GoogleSignInAccount? = GoogleSignIn.getSignedInAccountFromIntent(data).getResult(ApiException::class.java) + val account: GoogleSignInAccount? = GoogleSignIn.getSignedInAccountFromIntent( + data).getResult(ApiException::class.java) if (!GoogleSignIn.hasPermissions(account, FITNESS_OPTIONS)) { GoogleSignIn.requestPermissions( requireActivity(), @@ -289,7 +382,7 @@ class GlanceTabFragment : Fragment() { account, FITNESS_OPTIONS) } else { - adapter.notifyItemChanged(2) + adapter.notifyItemRangeChanged(0, adapter.data.size) if (dialog != null) { dialog?.show() } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt index 53e98b7..1e81b23 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/MainFragment.kt @@ -35,6 +35,7 @@ import com.tommasoberlose.anotherwidget.helpers.ColorHelper 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 import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel @@ -363,7 +364,8 @@ class MainFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList tabs?.getTabAt(4)?.orCreateBadge?.apply { backgroundColor = ContextCompat.getColor(requireContext(), R.color.errorColorText) badgeGravity = BadgeDrawable.TOP_END - }?.isVisible = Preferences.showMusic && !NotificationManagerCompat.getEnabledListenerPackages(requireContext()).contains(requireContext().packageName) + }?.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))) } override fun onResume() { diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt index 53ab98b..2e01549 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/fragments/SettingsFragment.kt @@ -26,6 +26,7 @@ import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.components.BottomSheetMenu import com.tommasoberlose.anotherwidget.databinding.FragmentSettingsBinding import com.tommasoberlose.anotherwidget.global.Preferences +import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper import com.tommasoberlose.anotherwidget.ui.activities.MainActivity import com.tommasoberlose.anotherwidget.ui.activities.SupportDevActivity import com.tommasoberlose.anotherwidget.ui.viewmodels.MainViewModel @@ -131,9 +132,6 @@ class SettingsFragment : Fragment() { Preferences.showPreview = isChecked } - action_show_wallpaper.setOnClickListener { - } - action_show_wallpaper.setOnClickListener { show_wallpaper_toggle.isChecked = !show_wallpaper_toggle.isChecked } @@ -198,6 +196,7 @@ class SettingsFragment : Fragment() { } CalendarHelper.updateEventList(requireContext()) MediaPlayerHelper.updatePlayingMediaInfo(requireContext()) + ActiveNotificationsHelper.clearLastNotification(requireContext()) } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt index 96b7dd5..ab9101d 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/ui/widgets/MainWidget.kt @@ -7,23 +7,21 @@ import android.appwidget.AppWidgetProvider import android.content.ComponentName import android.content.Context import android.content.Intent +import android.content.IntentSender import android.content.res.Resources import android.graphics.Color import android.graphics.Typeface import android.os.Bundle -import android.os.Handler -import android.os.HandlerThread -import android.os.Looper import android.text.format.DateUtils import android.util.Log import android.util.TypedValue import android.view.View -import android.view.ViewGroup -import android.widget.* +import android.widget.ImageView +import android.widget.RemoteViews +import android.widget.TextView import androidx.core.content.ContextCompat -import androidx.core.provider.FontRequest -import androidx.core.provider.FontsContractCompat import androidx.core.view.isVisible +import com.google.gson.Gson import com.tommasoberlose.anotherwidget.R import com.tommasoberlose.anotherwidget.db.EventRepository import com.tommasoberlose.anotherwidget.global.Actions @@ -32,9 +30,10 @@ import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.helpers.* import com.tommasoberlose.anotherwidget.helpers.ColorHelper.toIntValue import com.tommasoberlose.anotherwidget.receivers.* -import com.tommasoberlose.anotherwidget.utils.* +import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission +import com.tommasoberlose.anotherwidget.utils.isDarkTheme +import com.tommasoberlose.anotherwidget.utils.toPixel import kotlinx.android.synthetic.main.the_widget.view.* -import java.lang.Exception import java.text.DateFormat import java.util.* import java.util.concurrent.TimeUnit @@ -348,6 +347,26 @@ class MainWidget : AppWidgetProvider() { break@loop } } + Constants.GlanceProviderId.NOTIFICATIONS -> { + if (Preferences.showNotifications && ActiveNotificationsHelper.showLastNotification()) { + try { + val remotePackageContext = context.createPackageContext(Preferences.lastNotificationPackage, 0) + val icon = ContextCompat.getDrawable(remotePackageContext, Preferences.lastNotificationIcon) + val notificationIntent = PendingIntent.getActivity( + context, + widgetID, + IntentHelper.getNotificationIntent(context), + PendingIntent.FLAG_UPDATE_CURRENT + ) + views.setOnClickPendingIntent( + R.id.second_row_rect, + notificationIntent + ) + showSomething = true + break@loop + } catch (ex: Exception) {} + } + } } } @@ -695,6 +714,19 @@ class MainWidget : AppWidgetProvider() { break@loop } } + Constants.GlanceProviderId.NOTIFICATIONS -> { + if (Preferences.showNotifications && ActiveNotificationsHelper.showLastNotification()) { + try { + val remotePackageContext = context.createPackageContext(Preferences.lastNotificationPackage, 0) + val icon = ContextCompat.getDrawable(remotePackageContext, Preferences.lastNotificationIcon) + v.second_row_icon.isVisible = true + v.second_row_icon.setImageDrawable(icon) + v.next_event_date.text = Preferences.lastNotificationTitle + showSomething = true + break@loop + } catch (ex: Exception) {} + } + } } } diff --git a/app/src/main/res/drawable-hdpi/round_history_edu.png b/app/src/main/res/drawable-hdpi/round_history_edu.png new file mode 100644 index 0000000..42c946b Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_history_edu.png differ diff --git a/app/src/main/res/drawable-hdpi/round_history_edu_black_18.png b/app/src/main/res/drawable-hdpi/round_history_edu_black_18.png new file mode 100644 index 0000000..475e52c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_history_edu_black_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_history_edu_black_24.png b/app/src/main/res/drawable-hdpi/round_history_edu_black_24.png new file mode 100644 index 0000000..eacbbaf Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_history_edu_black_24.png differ diff --git a/app/src/main/res/drawable-hdpi/round_history_edu_black_36.png b/app/src/main/res/drawable-hdpi/round_history_edu_black_36.png new file mode 100644 index 0000000..de439eb Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_history_edu_black_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_notifications.png b/app/src/main/res/drawable-hdpi/round_notifications.png new file mode 100644 index 0000000..b42b127 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_notifications.png differ diff --git a/app/src/main/res/drawable-hdpi/round_notifications_white_18.png b/app/src/main/res/drawable-hdpi/round_notifications_white_18.png new file mode 100644 index 0000000..88df81c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_notifications_white_18.png differ diff --git a/app/src/main/res/drawable-hdpi/round_notifications_white_36.png b/app/src/main/res/drawable-hdpi/round_notifications_white_36.png new file mode 100644 index 0000000..57b6433 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_notifications_white_36.png differ diff --git a/app/src/main/res/drawable-hdpi/round_notifications_white_48.png b/app/src/main/res/drawable-hdpi/round_notifications_white_48.png new file mode 100644 index 0000000..45058bb Binary files /dev/null and b/app/src/main/res/drawable-hdpi/round_notifications_white_48.png differ diff --git a/app/src/main/res/drawable-mdpi/round_history_edu.png b/app/src/main/res/drawable-mdpi/round_history_edu.png new file mode 100644 index 0000000..02219f7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_history_edu.png differ diff --git a/app/src/main/res/drawable-mdpi/round_history_edu_black_18.png b/app/src/main/res/drawable-mdpi/round_history_edu_black_18.png new file mode 100644 index 0000000..8e14917 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_history_edu_black_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_history_edu_black_24.png b/app/src/main/res/drawable-mdpi/round_history_edu_black_24.png new file mode 100644 index 0000000..2bd2c8e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_history_edu_black_24.png differ diff --git a/app/src/main/res/drawable-mdpi/round_history_edu_black_36.png b/app/src/main/res/drawable-mdpi/round_history_edu_black_36.png new file mode 100644 index 0000000..eacbbaf Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_history_edu_black_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_notifications.png b/app/src/main/res/drawable-mdpi/round_notifications.png new file mode 100644 index 0000000..da136cf Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_notifications.png differ diff --git a/app/src/main/res/drawable-mdpi/round_notifications_white_18.png b/app/src/main/res/drawable-mdpi/round_notifications_white_18.png new file mode 100644 index 0000000..48beb73 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_notifications_white_18.png differ diff --git a/app/src/main/res/drawable-mdpi/round_notifications_white_36.png b/app/src/main/res/drawable-mdpi/round_notifications_white_36.png new file mode 100644 index 0000000..b42b127 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_notifications_white_36.png differ diff --git a/app/src/main/res/drawable-mdpi/round_notifications_white_48.png b/app/src/main/res/drawable-mdpi/round_notifications_white_48.png new file mode 100644 index 0000000..b81cf5c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/round_notifications_white_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_history_edu.png b/app/src/main/res/drawable-xhdpi/round_history_edu.png new file mode 100644 index 0000000..84e48a0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_history_edu.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_history_edu_black_18.png b/app/src/main/res/drawable-xhdpi/round_history_edu_black_18.png new file mode 100644 index 0000000..eacbbaf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_history_edu_black_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_history_edu_black_24.png b/app/src/main/res/drawable-xhdpi/round_history_edu_black_24.png new file mode 100644 index 0000000..02219f7 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_history_edu_black_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_history_edu_black_36.png b/app/src/main/res/drawable-xhdpi/round_history_edu_black_36.png new file mode 100644 index 0000000..42c946b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_history_edu_black_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_notifications.png b/app/src/main/res/drawable-xhdpi/round_notifications.png new file mode 100644 index 0000000..b81cf5c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_notifications.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_notifications_white_18.png b/app/src/main/res/drawable-xhdpi/round_notifications_white_18.png new file mode 100644 index 0000000..b42b127 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_notifications_white_18.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_notifications_white_36.png b/app/src/main/res/drawable-xhdpi/round_notifications_white_36.png new file mode 100644 index 0000000..45058bb Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_notifications_white_36.png differ diff --git a/app/src/main/res/drawable-xhdpi/round_notifications_white_48.png b/app/src/main/res/drawable-xhdpi/round_notifications_white_48.png new file mode 100644 index 0000000..bdea9e2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/round_notifications_white_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_history_edu.png b/app/src/main/res/drawable-xxhdpi/round_history_edu.png new file mode 100644 index 0000000..c428693 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_history_edu.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_history_edu_black_18.png b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_18.png new file mode 100644 index 0000000..de439eb Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_history_edu_black_24.png b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_24.png new file mode 100644 index 0000000..42c946b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_history_edu_black_36.png b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_36.png new file mode 100644 index 0000000..dd5ba18 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_history_edu_black_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_notifications.png b/app/src/main/res/drawable-xxhdpi/round_notifications.png new file mode 100644 index 0000000..45058bb Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_notifications.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_notifications_white_18.png b/app/src/main/res/drawable-xxhdpi/round_notifications_white_18.png new file mode 100644 index 0000000..57b6433 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_notifications_white_18.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_notifications_white_36.png b/app/src/main/res/drawable-xxhdpi/round_notifications_white_36.png new file mode 100644 index 0000000..6511a5f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_notifications_white_36.png differ diff --git a/app/src/main/res/drawable-xxhdpi/round_notifications_white_48.png b/app/src/main/res/drawable-xxhdpi/round_notifications_white_48.png new file mode 100644 index 0000000..e3ec74f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/round_notifications_white_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_history_edu.png b/app/src/main/res/drawable-xxxhdpi/round_history_edu.png new file mode 100644 index 0000000..cd172f6 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_history_edu.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_18.png b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_18.png new file mode 100644 index 0000000..42c946b Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_24.png b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_24.png new file mode 100644 index 0000000..84e48a0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_24.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_36.png b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_36.png new file mode 100644 index 0000000..c428693 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_history_edu_black_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_notifications.png b/app/src/main/res/drawable-xxxhdpi/round_notifications.png new file mode 100644 index 0000000..bdea9e2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_notifications.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_notifications_white_18.png b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_18.png new file mode 100644 index 0000000..45058bb Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_18.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_notifications_white_36.png b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_36.png new file mode 100644 index 0000000..e3ec74f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_36.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/round_notifications_white_48.png b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_48.png new file mode 100644 index 0000000..4fdeb57 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/round_notifications_white_48.png differ diff --git a/app/src/main/res/drawable/round_history_edu_24.xml b/app/src/main/res/drawable/round_history_edu_24.xml new file mode 100644 index 0000000..9645ac6 --- /dev/null +++ b/app/src/main/res/drawable/round_history_edu_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/round_notifications_24.xml b/app/src/main/res/drawable/round_notifications_24.xml new file mode 100644 index 0000000..1ccc080 --- /dev/null +++ b/app/src/main/res/drawable/round_notifications_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_glance_settings.xml b/app/src/main/res/layout/fragment_glance_settings.xml index 987e8f3..784944e 100644 --- a/app/src/main/res/layout/fragment_glance_settings.xml +++ b/app/src/main/res/layout/fragment_glance_settings.xml @@ -96,7 +96,8 @@ android:textAppearance="@style/AnotherWidget.Settings.Header"/> + app:cardCornerRadius="8dp"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/glance_provider_settings_layout.xml b/app/src/main/res/layout/glance_provider_settings_layout.xml index f3445fb..895c8bd 100644 --- a/app/src/main/res/layout/glance_provider_settings_layout.xml +++ b/app/src/main/res/layout/glance_provider_settings_layout.xml @@ -173,6 +173,72 @@ style="@style/AnotherWidget.Settings.Subtitle"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 3ad6bbe..181eff5 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -127,7 +127,7 @@ Der kan gå op til 10 minutter inden din API nøgle er aktiveret. Vejret vil blive opdateret så snart det er tilgængeligt. Ikonpakke Ikonpakke %d - Vi indsamler placeringsdata for at opdatere vejrinformationer, selv når app'en er lukket eller ikke er i brug.\nVi bruger ikke disse data på andre måder. + Vi indsamler placeringsdata for at opdatere vejrinformationer, selv når app\'en er lukket eller ikke er i brug.\nVi bruger ikke disse data på andre måder. Vejrudbyder Open Weather Map @@ -188,7 +188,6 @@ Vis næste alarm - Den næste alarm lader til at være forkert.\nDen er indstillet af %s. Overblik Aktuel sang Vi har brug for tilladelse til aflæsning af notifikationer, for at vise den aktuelle sang. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index f74b707..82d47da 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -179,6 +179,7 @@ Glance Canzone in riproduzione È necessario l\'accesso alle notifiche per controllare la canzone in riproduzione. + È necessario l\'accesso alle notifiche per mostrare le ultime che ti sono arrivate. Sono necessari i permessi per accedere ai passi di oggi su Google Fit. Mostra At a Glance Informazioni visibili diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 84ed6d0..38b7a9a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -191,6 +191,7 @@ Glance Current playing song We need the notification access permission to check the current playing song. + We need the notification access permission to check your last notifications. We need a few permissions to get your daily steps from Google Fit. Show at a glance info Service enabled @@ -215,6 +216,10 @@ Alarm set by %s The next alarm clock seems to be wrong. The next alarm clock seems to be correct. + Last notifications + Take a quick view of the last notifications showed up on your device. + Greetings + View some cool phrase when you don\'t expect it. Share