Refactor: notification models (#4866)

* Refactor: move notification modesl to data.models.notification

* Refactor: move notification models to notifications/models
This commit is contained in:
Benard Mathu 2022-04-28 18:23:44 +03:00 committed by GitHub
parent 8cdcd0f7c2
commit 6ad70932c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 23 additions and 11 deletions

View file

@ -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;

View file

@ -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) :

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import androidx.annotation.Nullable;
import fr.free.nrw.commons.notification.models.Notification;
import java.util.List;
/**

View file

@ -1,4 +1,4 @@
package fr.free.nrw.commons.notification
package fr.free.nrw.commons.notification.models
import org.wikipedia.util.DateUtil
@ -17,7 +17,8 @@ data class Notification(var notificationType: NotificationType,
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,

View file

@ -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"),

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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