mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Refactor: notification models (#4866)
* Refactor: move notification modesl to data.models.notification * Refactor: move notification models to notifications/models
This commit is contained in:
parent
8cdcd0f7c2
commit
6ad70932c5
14 changed files with 23 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ import androidx.fragment.app.FragmentTransaction;
|
|||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
import fr.free.nrw.commons.notification.Notification;
|
||||
import fr.free.nrw.commons.notification.models.Notification;
|
||||
import fr.free.nrw.commons.notification.NotificationController;
|
||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.notification
|
||||
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import fr.free.nrw.commons.upload.categories.BaseDelegateAdapter
|
||||
|
||||
internal class NotificatinAdapter(onNotificationClicked: (Notification) -> Unit) :
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import butterknife.ButterKnife;
|
|||
import com.google.android.material.snackbar.Snackbar;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.notification.models.Notification;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package fr.free.nrw.commons.notification
|
||||
|
||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import fr.free.nrw.commons.databinding.ItemNotificationBinding
|
||||
import org.wikipedia.util.StringUtil
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import fr.free.nrw.commons.notification.models.Notification;
|
||||
import org.wikipedia.csrf.CsrfTokenClient;
|
||||
import org.wikipedia.dataclient.Service;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import fr.free.nrw.commons.notification.models.Notification;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import fr.free.nrw.commons.notification.models.Notification;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.free.nrw.commons.notification
|
||||
package fr.free.nrw.commons.notification.models
|
||||
|
||||
import org.wikipedia.util.DateUtil
|
||||
|
||||
|
|
@ -6,18 +6,19 @@ import org.wikipedia.util.DateUtil
|
|||
* Created by root on 18.12.2017.
|
||||
*/
|
||||
data class Notification(var notificationType: NotificationType,
|
||||
var notificationText: String,
|
||||
var date: String,
|
||||
var link: String,
|
||||
var iconUrl: String,
|
||||
var notificationId: String) {
|
||||
var notificationText: String,
|
||||
var date: String,
|
||||
var link: String,
|
||||
var iconUrl: String,
|
||||
var notificationId: String) {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun from(wikiNotification: org.wikipedia.notifications.Notification): Notification {
|
||||
val contents = wikiNotification.contents
|
||||
val notificationLink = if (contents == null || contents.links == null || contents.links!!.primary == null) "" else contents.links!!.primary!!.url
|
||||
return Notification(NotificationType.UNKNOWN,
|
||||
return Notification(
|
||||
NotificationType.UNKNOWN,
|
||||
contents?.compactHeader ?: "",
|
||||
DateUtil.getMonthOnlyDateString(wikiNotification.timestamp),
|
||||
notificationLink,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
package fr.free.nrw.commons.notification.models;
|
||||
|
||||
public enum NotificationType {
|
||||
THANK_YOU_EDIT("thank-you-edit"),
|
||||
|
|
@ -17,9 +17,9 @@ import fr.free.nrw.commons.kvstore.JsonKvStore
|
|||
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||
import fr.free.nrw.commons.nearby.NearbyNotificationCardView
|
||||
import fr.free.nrw.commons.notification.Notification
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import fr.free.nrw.commons.notification.NotificationController
|
||||
import fr.free.nrw.commons.notification.NotificationType
|
||||
import fr.free.nrw.commons.notification.models.NotificationType
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import org.junit.Assert
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import fr.free.nrw.commons.R
|
|||
import fr.free.nrw.commons.ShadowActionBar
|
||||
import fr.free.nrw.commons.TestAppAdapter
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import fr.free.nrw.commons.notification.models.NotificationType
|
||||
import fr.free.nrw.commons.utils.NetworkUtils
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package fr.free.nrw.commons.notification
|
||||
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import android.app.NotificationManager
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.notification.models.Notification
|
||||
import fr.free.nrw.commons.notification.models.NotificationType
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue