mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 20:29:02 +00:00
Improve notification handling
This commit is contained in:
parent
a50b91713c
commit
baef77c7f9
11 changed files with 52 additions and 35 deletions
|
|
@ -16,7 +16,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
classpath('com.noveogroup.android:check:1.2.5') {
|
||||
exclude module: 'checkstyle'
|
||||
exclude module: 'pmd-java'
|
||||
|
|
@ -150,7 +150,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2644
|
||||
versionCode 2647
|
||||
versionName "3.1"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/transparent" />
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,23 @@
|
|||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layout_gravity="top|center" >
|
||||
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/snackbar_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="158dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:paddingBottom="68dp"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -70,10 +70,6 @@ class NotificationOpenHandler {
|
|||
MainNavigationController.navigate(R.id.prefsActivity)
|
||||
}
|
||||
|
||||
private fun displayWonChallengeNotificaiton(notification: Notification) {
|
||||
EventBus.getDefault().post(ShowWonChallengeDialog(notification.id, notification.data as? ChallengeWonData))
|
||||
}
|
||||
|
||||
private fun handleChatMessage(type: String?, groupID: String?) {
|
||||
when (type) {
|
||||
"party" -> MainNavigationController.navigate(R.id.partyFragment)
|
||||
|
|
|
|||
|
|
@ -73,27 +73,27 @@ class NotificationsManager (private val context: Context) {
|
|||
Notification.Type.ACHIEVEMENT_INVITED_FRIEND.type -> displayAchievementNotification(it)
|
||||
Notification.Type.WON_CHALLENGE.type -> displayWonChallengeNotificaiton(it)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_ALL_YOUR_BASE.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_BACK_TO_BASICS.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_JUST_ADD_WATER.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_LOST_MASTERCLASSER.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_MIND_OVER_MATTER.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_DUST_DEVIL.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_ARID_AUTHORITY.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_MONSTER_MAGUS.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_UNDEAD_UNDERTAKER.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_PRIMED_FOR_PAINTING.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_PEARLY_PRO.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_TICKLED_PINK.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_ROSY_OUTLOOK.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_BUG_BONANZA.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_BARE_NECESSITIES.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_FRESHWATER_FRIENDS.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_ALL_THAT_GLITTERS.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_BONE_COLLECTOR.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_SKELETON_CREW.type -> displayWonChallengeNotificaiton(it)
|
||||
Notification.Type.ACHIEVEMENT_ALL_YOUR_BASE.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_BACK_TO_BASICS.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_JUST_ADD_WATER.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_LOST_MASTERCLASSER.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_MIND_OVER_MATTER.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_DUST_DEVIL.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_ARID_AUTHORITY.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_MONSTER_MAGUS.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_UNDEAD_UNDERTAKER.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_PRIMED_FOR_PAINTING.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_PEARLY_PRO.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_TICKLED_PINK.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_ROSY_OUTLOOK.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_BUG_BONANZA.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_BARE_NECESSITIES.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_FRESHWATER_FRIENDS.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_ALL_THAT_GLITTERS.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_GOOD_AS_GOLD.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_BONE_COLLECTOR.type -> displayAchievementNotification(it)
|
||||
Notification.Type.ACHIEVEMENT_SKELETON_CREW.type -> displayAchievementNotification(it)
|
||||
|
||||
Notification.Type.ACHIEVEMENT_GENERIC.type -> displayAchievementNotification(it, notifications.find { notif ->
|
||||
notif.type == Notification.Type.ACHIEVEMENT_ONBOARDING_COMPLETE.type
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ abstract class HabiticaLocalNotification(protected var context: Context, protect
|
|||
protected open fun setNotificationActions(data: Map<String, String>) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.putExtra("notificationIdentifier", identifier)
|
||||
intent.putExtra("notificationTimeStamp", Date().time)
|
||||
configureMainIntent(intent)
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
var drawerToggle: ActionBarDrawerToggle? = null
|
||||
private var resumeFromActivity = false
|
||||
private var userQuestStatus = UserQuestStatus.NO_QUEST
|
||||
private var hasHandledNotificationOpen = false
|
||||
private var lastNotificationOpen: Int? = null
|
||||
|
||||
val userID: String
|
||||
get() = user?.id ?: ""
|
||||
|
|
@ -358,8 +358,8 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
putBoolean("preventDailyReminder", false)
|
||||
}
|
||||
|
||||
if (intent.hasExtra("notificationIdentifier") && !hasHandledNotificationOpen) {
|
||||
hasHandledNotificationOpen = true
|
||||
if (intent.hasExtra("notificationIdentifier") && lastNotificationOpen != intent.getIntExtra("notificationTimeStamp", 0)) {
|
||||
lastNotificationOpen = intent.getIntExtra("notificationTimeStamp", 0)
|
||||
val identifier = intent.getStringExtra("notificationIdentifier") ?: ""
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = identifier
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.PreferenceScreen
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.events.ShowSnackbarEvent
|
||||
import com.habitrpg.android.habitica.ui.fragments.preferences.*
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
|
||||
class PrefsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
||||
|
||||
|
|
@ -49,6 +52,11 @@ class PrefsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceStart
|
|||
return false
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun showSnackBarEvent(event: ShowSnackbarEvent) {
|
||||
HabiticaSnackbar.showSnackbar(findViewById(R.id.snackbar_container), event.leftImage, event.title, event.text, event.specialView, event.rightIcon, event.rightTextColor, event.rightText, event.type)
|
||||
}
|
||||
|
||||
private fun createNextPage(preferenceScreen: PreferenceScreen): PreferenceFragmentCompat? =
|
||||
when (preferenceScreen.key) {
|
||||
"profile" -> ProfilePreferencesFragment()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ class GuildsOverviewFragment : BaseMainFragment<FragmentGuildsOverviewBinding>()
|
|||
val uriUrl = "https://habitica.com/groups/myGuilds".toUri()
|
||||
val launchBrowser = Intent(Intent.ACTION_VIEW, uriUrl)
|
||||
val l = context.packageManager.queryIntentActivities(launchBrowser, PackageManager.MATCH_DEFAULT_ONLY)
|
||||
launchBrowser.setPackage(l[0].activityInfo.processName)
|
||||
val notHabitica = l.first { !it.activityInfo.processName.contains("habitica") }
|
||||
launchBrowser.setPackage(notHabitica.activityInfo.processName)
|
||||
startActivity(launchBrowser)
|
||||
}
|
||||
dialog.addCloseButton()
|
||||
|
|
|
|||
|
|
@ -182,7 +182,8 @@ class ChallengeDetailFragment: BaseMainFragment<FragmentChallengeDetailBinding>(
|
|||
val uriUrl = "https://habitica.com/challenges/${challengeID}".toUri()
|
||||
val launchBrowser = Intent(Intent.ACTION_VIEW, uriUrl)
|
||||
val l = context.packageManager.queryIntentActivities(launchBrowser, PackageManager.MATCH_DEFAULT_ONLY)
|
||||
launchBrowser.setPackage(l[0].activityInfo.processName)
|
||||
val notHabitica = l.first { !it.activityInfo.processName.contains("habitica") }
|
||||
launchBrowser.setPackage(notHabitica.activityInfo.processName)
|
||||
startActivity(launchBrowser)
|
||||
}
|
||||
dialog.addCloseButton()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ buildscript {
|
|||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
classpath 'com.google.gms:google-services:4.3.4'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
|
||||
|
|
|
|||
Loading…
Reference in a new issue