diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e262e90882..253bdaea82 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -87,6 +87,10 @@ android:label="@string/title_activity_nearby" android:parentActivityName=".contributions.ContributionsActivity" /> + + create(List notifications) { + RendererBuilder builder = new RendererBuilder() + .bind(Notification.class, new NotificationRenderer(listener)); + ListAdapteeCollection collection = new ListAdapteeCollection<>( + notifications != null ? notifications : Collections.emptyList()); + return new RVRendererAdapter<>(builder, collection); + } +} diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationController.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationController.java new file mode 100644 index 0000000000..84f5c15d8e --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationController.java @@ -0,0 +1,23 @@ +package fr.free.nrw.commons.notification; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by root on 19.12.2017. + */ + +public class NotificationController { + + public static List loadNotifications() { + List notifications = new ArrayList<>(); + notifications.add(new Notification(Notification.NotificationType.message, "notification 1")); + notifications.add(new Notification(Notification.NotificationType.edit, "notification 2")); + notifications.add(new Notification(Notification.NotificationType.mention, "notification 3")); + notifications.add(new Notification(Notification.NotificationType.message, "notification 4")); + notifications.add(new Notification(Notification.NotificationType.edit, "notification 5")); + notifications.add(new Notification(Notification.NotificationType.mention, "notification 6")); + notifications.add(new Notification(Notification.NotificationType.message, "notification 7")); + return notifications; + } +} diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java new file mode 100644 index 0000000000..36272d4a2e --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java @@ -0,0 +1,70 @@ +package fr.free.nrw.commons.notification; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.pedrogomez.renderers.Renderer; + +import butterknife.BindView; +import butterknife.ButterKnife; +import fr.free.nrw.commons.R; + +/** + * Created by root on 19.12.2017. + */ + +public class NotificationRenderer extends Renderer { + @BindView(R.id.title) TextView title; + @BindView(R.id.description) TextView description; + @BindView(R.id.time) TextView time; + @BindView(R.id.icon) ImageView icon; + private NotificationClicked listener; + + + NotificationRenderer(NotificationClicked listener) { + this.listener = listener; + } + + @Override + protected void setUpView(View view) { } + + @Override + protected void hookListeners(View rootView) { + rootView.setOnClickListener(v -> listener.notificationClicked(getContent())); + } + + @Override + protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) { + View inflatedView = layoutInflater.inflate(R.layout.item_notification, viewGroup, false); + ButterKnife.bind(this, inflatedView); + return inflatedView; + } + + @Override + public void render() { + Notification notification = getContent(); + title.setText(notification.notificationText); + time.setText("3d"); + description.setText("Example notification description"); + switch (notification.notificationType) { + case edit: + icon.setImageResource(R.drawable.ic_edit_black_24dp); + break; + case message: + icon.setImageResource(R.drawable.ic_message_black_24dp); + break; + case mention: + icon.setImageResource(R.drawable.ic_chat_bubble_black_24px); + break; + default: + icon.setImageResource(R.drawable.round_icon_unknown); + } + } + + public interface NotificationClicked{ + void notificationClicked(Notification notification); + } +} diff --git a/app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java b/app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java index 60ea325e40..4e7cf767f2 100644 --- a/app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java @@ -27,6 +27,7 @@ import fr.free.nrw.commons.auth.LoginActivity; import fr.free.nrw.commons.contributions.ContributionsActivity; import fr.free.nrw.commons.nearby.NearbyActivity; +import fr.free.nrw.commons.notification.NotificationActivity; import fr.free.nrw.commons.settings.SettingsActivity; import timber.log.Timber; @@ -143,6 +144,10 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) { .setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel()) .show(); return true; + case R.id.action_notifications: + drawerLayout.closeDrawer(navigationView); + startActivityWithFlags(this, NotificationActivity.class, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + return true; default: Timber.e("Unknown option [%s] selected from the navigation menu", itemId); return false; diff --git a/app/src/main/res/drawable/ic_chat_bubble_black_24px.xml b/app/src/main/res/drawable/ic_chat_bubble_black_24px.xml new file mode 100644 index 0000000000..8d40c6d63a --- /dev/null +++ b/app/src/main/res/drawable/ic_chat_bubble_black_24px.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_edit_black_24dp.xml b/app/src/main/res/drawable/ic_edit_black_24dp.xml new file mode 100644 index 0000000000..2ab2fb7533 --- /dev/null +++ b/app/src/main/res/drawable/ic_edit_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_message_black_24dp.xml b/app/src/main/res/drawable/ic_message_black_24dp.xml new file mode 100644 index 0000000000..d2876bfad9 --- /dev/null +++ b/app/src/main/res/drawable/ic_message_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000000..7009a6763c --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_notification.xml b/app/src/main/res/layout/activity_notification.xml new file mode 100644 index 0000000000..b2eb38475d --- /dev/null +++ b/app/src/main/res/layout/activity_notification.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_notification.xml b/app/src/main/res/layout/item_notification.xml new file mode 100644 index 0000000000..d8f4dd8d49 --- /dev/null +++ b/app/src/main/res/layout/item_notification.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/drawer.xml b/app/src/main/res/menu/drawer.xml index f0a0a5e29f..83c1bf0ade 100644 --- a/app/src/main/res/menu/drawer.xml +++ b/app/src/main/res/menu/drawer.xml @@ -35,4 +35,9 @@ android:icon="@drawable/ic_exit_to_app_black_24dp" android:title="@string/navigation_item_logout"/> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2e38b9211..5cd10090b4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -194,6 +194,7 @@ Feedback Logout Tutorial + Notifications Nearby places cannot be displayed without location permissions no description found Commons file page