mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Notifications view header with title, badge with count + dismiss all button
This commit is contained in:
parent
4c2a48ae69
commit
60abfe12ac
6 changed files with 103 additions and 33 deletions
13
Habitica/res/drawable/badge_gray.xml
Normal file
13
Habitica/res/drawable/badge_gray.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners
|
||||
android:radius="12dip"/>
|
||||
<solid
|
||||
android:color="@color/gray_600" />
|
||||
<padding
|
||||
android:left="6dip"
|
||||
android:right="6dip"
|
||||
android:top="3dip"
|
||||
android:bottom="5dip" />
|
||||
</shape>
|
||||
|
|
@ -1,34 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.NotificationsActivity"
|
||||
android:orientation="vertical">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.activities.NotificationsActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layout_gravity="top|center" >
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_gravity="top|center"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/notifications_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -39,16 +40,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="?attr/actionBarSize">
|
||||
|
||||
<com.habitrpg.android.habitica.ui.views.PaddedLinearLayout
|
||||
android:id="@+id/notification_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:divider="?android:listDivider"
|
||||
android:showDividers="middle">
|
||||
</com.habitrpg.android.habitica.ui.views.PaddedLinearLayout>
|
||||
android:orientation="vertical"
|
||||
android:showDividers="middle"></com.habitrpg.android.habitica.ui.views.PaddedLinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/spacing_large">
|
||||
|
||||
<LinearLayout
|
||||
|
|
@ -27,10 +26,10 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="26dp">
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingTop="26dp"
|
||||
android:paddingRight="40dp">
|
||||
|
||||
<TextView
|
||||
style="@style/SectionTitle"
|
||||
|
|
@ -50,4 +49,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
50
Habitica/res/layout/notifications_header.xml
Normal file
50
Habitica/res/layout/notifications_header.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="14dp"
|
||||
android:paddingRight="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/spacing_medium">
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/title"
|
||||
style="@style/Body1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dip"
|
||||
android:background="@color/transparent"
|
||||
android:text="@string/notifications"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/gray_300"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notificationsTitleBadge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:background="@drawable/badge_gray"
|
||||
android:textColor="@color/gray_300"
|
||||
android:textSize="12sp"
|
||||
tools:text="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dismissAllButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
android:text="@string/dismiss_all"
|
||||
android:textColor="@color/brand_400" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -862,6 +862,7 @@
|
|||
<string name="preference_push_important_announcements">Important Announcements</string>
|
||||
<string name="no_notifications_title">You’re all caught up!</string>
|
||||
<string name="no_notifications_text">The notification fairies give you a raucous round of applause! Well done!</string>
|
||||
<string name="dismiss_all">Dismiss All</string>
|
||||
<string name="create">Create</string>
|
||||
<string name="only_leader_create_challenge">Only leader can create Challenges</string>
|
||||
<string name="create_party">Create Party</string>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.habitrpg.android.habitica.ui.activities
|
|||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
|
|
@ -66,11 +67,16 @@ class NotificationsActivity : BaseActivity(), androidx.swiperefreshlayout.widget
|
|||
|
||||
val inflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
|
||||
if (notifications.isEmpty()) {
|
||||
val item = inflater?.inflate(R.layout.no_notifications, notification_items, false)
|
||||
notification_items.addView(item)
|
||||
val no_notifications = inflater?.inflate(R.layout.no_notifications, notification_items, false)
|
||||
notification_items.addView(no_notifications)
|
||||
return
|
||||
}
|
||||
|
||||
val header = inflater?.inflate(R.layout.notifications_header, notification_items, false)
|
||||
val badge = header?.findViewById(R.id.notificationsTitleBadge) as? TextView
|
||||
badge?.setText(notifications.count().toString())
|
||||
notification_items.addView(header)
|
||||
|
||||
//TODO("not implemented")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue