-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from st235/feature/notifications
Feature/notifications
- Loading branch information
Showing
32 changed files
with
882 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/src/main/java/github/com/st235/expandablebottombar/screens/NotificationBadgeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package github.com.st235.expandablebottombar.screens | ||
|
||
import android.graphics.Color | ||
import android.os.Bundle | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.view.ViewAnimationUtils | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.graphics.ColorUtils | ||
import github.com.st235.expandablebottombar.R | ||
import github.com.st235.lib_expandablebottombar.ExpandableBottomBar | ||
import github.com.st235.lib_expandablebottombar.ExpandableBottomBarNotification | ||
import kotlinx.android.synthetic.main.activity_xml_declared.* | ||
|
||
class NotificationBadgeActivity : AppCompatActivity() { | ||
|
||
private lateinit var bottomBar: ExpandableBottomBar | ||
|
||
private val notificationsLookup = mutableMapOf<Int, ExpandableBottomBarNotification>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_notification_badge) | ||
setSupportActionBar(toolbar) | ||
|
||
val color: View = findViewById(R.id.color) | ||
bottomBar = findViewById(R.id.expandable_bottom_bar) | ||
|
||
color.setBackgroundColor(ColorUtils.setAlphaComponent(Color.GRAY, 60)) | ||
|
||
bottomBar.onItemSelectedListener = { v, i -> | ||
val anim = ViewAnimationUtils.createCircularReveal(color, | ||
bottomBar.x.toInt() + v.x.toInt() + v.width / 2, | ||
bottomBar.y.toInt() + v.y.toInt() + v.height / 2, 0F, | ||
findViewById<View>(android.R.id.content).height.toFloat()) | ||
color.setBackgroundColor(ColorUtils.setAlphaComponent(i.activeColor, 60)) | ||
anim.duration = 420 | ||
anim.start() | ||
} | ||
|
||
bottomBar.onItemReselectedListener = { v, i -> | ||
if (!notificationsLookup.containsKey(i.itemId)) { | ||
notificationsLookup[i.itemId] = bottomBar.getNotificationFor(i.itemId) | ||
} | ||
val notification = notificationsLookup.getValue(i.itemId) | ||
|
||
if (v.tag == null) { | ||
notification.show() | ||
v.tag = 0 | ||
} else { | ||
val counter = (v.tag as Int) + 1 | ||
notification.show(counter.toString()) | ||
v.tag = counter | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | ||
menuInflater.inflate(R.menu.toolbar_menu, menu) | ||
return true | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
when (item.itemId) { | ||
R.id.clear -> { | ||
for (notification in notificationsLookup.values) { | ||
notification.clear() | ||
} | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
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" | ||
android:fitsSystemWindows="true" | ||
tools:context=".screens.ProgrammaticallyCreatedDemoActivity"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="0dp" | ||
android:layout_height="?attr/actionBarSize" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" /> | ||
|
||
<View | ||
android:id="@+id/color" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<github.com.st235.lib_expandablebottombar.ExpandableBottomBar | ||
android:id="@+id/expandable_bottom_bar" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
app:exb_items="@menu/notification_badge_menu" | ||
app:exb_itemInactiveColor="#CCCCCC" | ||
app:exb_notificationBadgeBackgroundColor="#757575" | ||
app:exb_notificationBadgeTextColor="#FFFFFF" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:id="@+id/home" | ||
android:title="@string/text" | ||
android:icon="@drawable/ic_home" | ||
app:exb_color="#FF8888" | ||
app:exb_badgeColor="#FF5555" | ||
app:exb_badgeTextColor="#FFFFFF" /> | ||
|
||
<item | ||
android:id="@+id/settings" | ||
android:title="@string/text4" | ||
android:icon="@drawable/ic_settings" | ||
app:exb_color="@color/colorSettings" /> | ||
|
||
<item | ||
android:id="@+id/bookmarks" | ||
android:title="@string/text3" | ||
android:icon="@drawable/ic_bookmarks" | ||
app:exb_color="#fa2" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:id="@+id/clear" | ||
android:title="@string/action_clear" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.