This commit is contained in:
Lachie Major 2024-10-18 20:19:10 +11:00
commit 8b631e468f
11 changed files with 38 additions and 13 deletions

View file

@ -13,7 +13,9 @@
android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Permission needed up to Android 5.1, see https://github.com/commons-app/apps-android-commons/pull/5863 -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"
android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

View file

@ -19,6 +19,7 @@ import fr.free.nrw.commons.databinding.ActivityNotificationBinding;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException;
import fr.free.nrw.commons.notification.models.Notification;
import fr.free.nrw.commons.notification.models.NotificationType;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.NetworkUtils;
import fr.free.nrw.commons.utils.ViewUtil;
@ -148,7 +149,11 @@ public class NotificationActivity extends BaseActivity {
}
adapter = new NotificatinAdapter(item -> {
Timber.d("Notification clicked %s", item.getLink());
if (item.getNotificationType() == NotificationType.EMAIL){
ViewUtil.showLongSnackbar(binding.container,getString(R.string.check_your_email_inbox));
} else {
handleUrl(item.getLink());
}
removeNotification(item);
return Unit.INSTANCE;
});

View file

@ -51,13 +51,23 @@ class NotificationClient
}
}
private fun WikimediaNotification.toCommonsNotification() =
Notification(
notificationType = NotificationType.UNKNOWN,
notificationText = contents?.compactHeader ?: "",
private fun WikimediaNotification.toCommonsNotification() :
Notification {
val notificationText = contents?.compactHeader ?: ""
val notificationType =
if (notificationText.contains("Sent you an email", ignoreCase = true)) {
NotificationType.EMAIL
} else {
NotificationType.UNKNOWN
}
return Notification(
notificationType = notificationType,
notificationText = notificationText,
date = DateUtil.getMonthOnlyDateString(timestamp),
link = contents?.links?.primary?.url ?: "",
iconUrl = "",
notificationId = id().toString(),
)
}
}

View file

@ -4,6 +4,7 @@ public enum NotificationType {
THANK_YOU_EDIT("thank-you-edit"),
EDIT_USER_TALK("edit-user-talk"),
MENTION("mention"),
EMAIL("email"),
WELCOME("welcome"),
UNKNOWN("unknown");
private String type;

View file

@ -679,6 +679,7 @@
<string name="error_sending_thanks">作者への感謝の送信エラー。</string>
<string name="invalid_login_message">ログインが期限切れになりました。もう一度ログインしてください。</string>
<string name="no_application_available_to_open_gpx_files">GPXファイルを開くことができるアプリケーションがありません</string>
<string name="check_your_email_inbox">メールをご確認ください</string>
<plurals name="custom_picker_images_selected_title_appendix">
<item quantity="other">%d件の画像が選択されました</item>
</plurals>

View file

@ -149,8 +149,8 @@
<string name="media_detail_coordinates_empty">ਕੋਈ ਉਪਲਬਧ ਨਹੀਂ</string>
<string name="_2fa_code">2FA ਕੋਡ</string>
<string name="logout_verification">ਕੀ ਤੁਸੀਂ ਸੱਚੀਂ ਬੰਦ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹੋ?</string>
<string name="welcome_image_welcome_wikipedia">ਵਿਕੀਪੀਡੀਆ \'ਤੇ ਸੁਆਗਤ</string>
<string name="welcome_image_welcome_copyright">ਕਾਪੀਰਾਈਟ ਸੁਆਗਤ</string>
<string name="welcome_image_welcome_wikipedia">ਵਿਕੀਪੀਡੀਆ \'ਤੇ ਜੀ ਆਇਆਂ ਨੂੰ</string>
<string name="welcome_image_welcome_copyright">ਜੀ ਆਇਆਂ ਨੂੰ ਕਾਪੀਰਾਈਟ</string>
<string name="cancel">ਰੱਦ ਕਰੋ</string>
<string name="navigation_drawer_open">ਖੋਲ੍ਹੋ</string>
<string name="navigation_drawer_close">ਬੰਦ ਕਰੋ</string>
@ -179,6 +179,7 @@
<string name="menu_search_button">ਲੱਭੋ</string>
<string name="title_activity_search">ਲੱਭੋ</string>
<string name="search_recent_header">ਹਾਲੀਆ ਖੋਜਾਂ:</string>
<string name="provider_searches">ਹਾਲ ਦੀਆਂ ਪੁੱਛਗਿੱਛ ਖੋਜਾਂ</string>
<string name="provider_recent_languages">ਹਾਲ ਹੀ ਵਿੱਚ ਬੋਲੀਆਂ ਬਾਰੇ ਪੁੱਛਗਿੱਛ</string>
<string name="search_tab_title_categories">ਸ਼੍ਰੇਣੀਆਂ</string>
<string name="explore_tab_title_map">ਨਕਸ਼ਾ</string>

View file

@ -111,4 +111,5 @@
<string name="detail_description_empty">没有说明</string>
<string name="detail_license_empty">未知授权协议</string>
<string name="menu_refresh">刷新</string>
<string name="check_your_email_inbox">请查看你的电子邮箱</string>
</resources>

View file

@ -215,4 +215,5 @@
<string name="description_info">請盡可能描述媒體內容:拍攝於何處?是顯示什麼事物?有什麼脈絡?請描述對象或人物。透露出一些較不易猜測的訊息,例如是風景的話,可以是一天裡的時間。如果媒體顯示出了一些不尋常的事物,請說明不尋常原因。</string>
<string name="learn_how_to_write_a_useful_description">學習如何編寫有用的描述</string>
<string name="learn_how_to_write_a_useful_caption">學習如何編寫有用的標題</string>
<string name="check_your_email_inbox">請查看你的電子郵件信箱</string>
</resources>

View file

@ -805,4 +805,5 @@
<string name="pending">待處理</string>
<string name="failed">失敗</string>
<string name="could_not_load_place_data">無法載入地點資料</string>
<string name="check_your_email_inbox">請查看你的電子郵件信箱</string>
</resources>

View file

@ -834,4 +834,5 @@
<string name="pending">待处理</string>
<string name="failed">失败</string>
<string name="could_not_load_place_data">无法加载地点数据</string>
<string name="check_your_email_inbox">请查看你的电子邮箱</string>
</resources>

View file

@ -504,6 +504,7 @@ Upload your first media by tapping on the add button.</string>
<string name="no_notification">You have no unread notifications</string>
<string name="no_read_notification">You have no read notifications</string>
<string name="share_logs_using">Share logs using</string>
<string name="check_your_email_inbox">Check your email inbox</string>
<string name="menu_option_read">View read</string>
<string name="menu_option_unread">View unread</string>