mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-24 06:35:46 +00:00
Improve notification handling
This commit is contained in:
parent
75879bc8d6
commit
d1c28a8dff
10 changed files with 66 additions and 16 deletions
|
|
@ -147,7 +147,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 3020
|
||||
versionCode 3026
|
||||
versionName "3.3.1"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,28 @@
|
|||
android:text="http://habitica.wikia.com/"
|
||||
android:textSize="@dimen/card_medium_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/privacy_policy_button"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="35sp"
|
||||
style="@style/HabiticaButton.Gray"
|
||||
android:text="@string/privacy_policy"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="@dimen/card_medium_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/terms_button"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8sp"
|
||||
style="@style/HabiticaButton.Gray"
|
||||
android:text="@string/terms_of_service"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="@dimen/card_medium_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/googlePlayStoreButton"
|
||||
android:layout_width="250dp"
|
||||
|
|
@ -106,7 +128,7 @@
|
|||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="20sp"
|
||||
android:layout_marginTop="8sp"
|
||||
style="@style/HabiticaButton.Gray"
|
||||
android:text="@string/about_bugreport"
|
||||
android:textAllCaps="false"
|
||||
|
|
|
|||
|
|
@ -1177,4 +1177,6 @@
|
|||
<string name="empty_guilds_list">You aren\'t a member of any Guilds.</string>
|
||||
<string name="empty_discover_description">Head over to the Discover tab to find some to join!</string>
|
||||
<string name="all_tasks_completed">You completed all your tasks. Well done!</string>
|
||||
<string name="privacy_policy">Privacy Policy</string>
|
||||
<string name="terms_of_service">Terms of Service</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
|
|||
}
|
||||
.map { (res, user): Pair<TaskDirectionData, User> ->
|
||||
// save local task changes
|
||||
|
||||
analyticsManager.logEvent("task_scored", bundleOf(
|
||||
Pair("type", task.type),
|
||||
Pair("scored_up", up),
|
||||
|
|
|
|||
|
|
@ -70,9 +70,16 @@ class PushNotificationManager(var apiClient: ApiClient, private val sharedPrefer
|
|||
val notificationFactory = HabiticaLocalNotificationFactory()
|
||||
val notification = notificationFactory.build(remoteMessageIdentifier, context)
|
||||
if (userIsSubscribedToNotificationType(remoteMessageIdentifier) && notification != null) {
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = remoteMessageIdentifier ?: ""
|
||||
AmplitudeManager.sendEvent("receive notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
if (remoteMessage.data.containsKey("isPromo")) {
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = remoteMessageIdentifier ?: ""
|
||||
AmplitudeManager.sendEvent(
|
||||
"receive notification",
|
||||
AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR,
|
||||
AmplitudeManager.EVENT_HITTYPE_EVENT,
|
||||
additionalData
|
||||
)
|
||||
}
|
||||
notification.setExtras(remoteMessage.data)
|
||||
notification.notifyLocally(remoteMessage.data["title"], remoteMessage.data["body"], remoteMessage.data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,6 @@ class NotificationPublisher : BroadcastReceiver() {
|
|||
HabiticaBaseApplication.userComponent?.inject(this)
|
||||
}
|
||||
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = "daily_reminder"
|
||||
AmplitudeManager.sendEvent("receive notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
|
||||
var wasInactive = false
|
||||
//Show special notification if user hasn't logged in for a week
|
||||
if (sharedPreferences.getLong("lastAppLaunch", Date().time) < (Date().time - 604800000L)) {
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ class TaskReceiver : BroadcastReceiver() {
|
|||
return@Consumer
|
||||
}
|
||||
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = "task_reminder"
|
||||
AmplitudeManager.sendEvent("receive notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
|
||||
createNotification(context, it)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,9 +377,16 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
if ((intent.hasExtra("notificationIdentifier") || intent.hasExtra("openURL")) && lastNotificationOpen != intent.getLongExtra("notificationTimeStamp", 0)) {
|
||||
lastNotificationOpen = intent.getLongExtra("notificationTimeStamp", 0)
|
||||
val identifier = intent.getStringExtra("notificationIdentifier") ?: ""
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = identifier
|
||||
AmplitudeManager.sendEvent("open notification", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT, additionalData)
|
||||
if (intent.hasExtra("isPromo")) {
|
||||
val additionalData = HashMap<String, Any>()
|
||||
additionalData["identifier"] = identifier
|
||||
AmplitudeManager.sendEvent(
|
||||
"open notification",
|
||||
AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR,
|
||||
AmplitudeManager.EVENT_HITTYPE_EVENT,
|
||||
additionalData
|
||||
)
|
||||
}
|
||||
retrieveUser(true)
|
||||
NotificationOpenHandler.handleOpenedByNotification(identifier, intent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ class AboutFragment : BaseMainFragment<FragmentAboutBinding>() {
|
|||
component.inject(this)
|
||||
}
|
||||
|
||||
private val privacyPolicyLink = "https://habitica.com/static/privacy"
|
||||
private val termsLink = "https://habitica.com/static/terms"
|
||||
private val androidSourceCodeLink = "https://github.com/HabitRPG/habitrpg-android/"
|
||||
private val twitterLink = "https://twitter.com/habitica"
|
||||
|
||||
|
|
@ -107,6 +109,8 @@ class AboutFragment : BaseMainFragment<FragmentAboutBinding>() {
|
|||
binding?.updateAvailableWrapper?.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding?.privacyPolicyButton?.setOnClickListener { openBrowserLink(privacyPolicyLink) }
|
||||
binding?.termsButton?.setOnClickListener { openBrowserLink(termsLink) }
|
||||
binding?.sourceCodeLink?.setOnClickListener { openBrowserLink(androidSourceCodeLink) }
|
||||
binding?.twitter?.setOnClickListener { openBrowserLink(twitterLink) }
|
||||
binding?.sourceCodeButton?.setOnClickListener { openBrowserLink(androidSourceCodeLink) }
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ package com.habitrpg.android.habitica.ui.fragments.tasks
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.NO_POSITION
|
||||
|
|
@ -67,6 +70,8 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
lateinit var soundManager: SoundManager
|
||||
@Inject
|
||||
lateinit var configManager: AppConfigManager
|
||||
@Inject
|
||||
lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
internal var layoutManager: RecyclerView.LayoutManager? = null
|
||||
|
||||
|
|
@ -351,6 +356,16 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
private fun scoreTask(task: Task, direction: TaskDirection) {
|
||||
compositeSubscription.add(taskRepository.taskChecked(null, task, direction == TaskDirection.UP, false) { result ->
|
||||
handleTaskResult(result, task.value.toInt())
|
||||
if (!DateUtils.isToday(sharedPreferences.getLong("last_task_reporting", 0))) {
|
||||
AmplitudeManager.sendEvent(
|
||||
"task score",
|
||||
AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR,
|
||||
AmplitudeManager.EVENT_HITTYPE_EVENT
|
||||
)
|
||||
sharedPreferences.edit {
|
||||
putLong("last_task_reporting", Date().time)
|
||||
}
|
||||
}
|
||||
}.subscribeWithErrorHandler {})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue