replace the Manage event types FAB with a menu button

This commit is contained in:
tibbi 2017-04-02 12:37:20 +02:00
parent 85c870dbc1
commit d5a4a02726
3 changed files with 30 additions and 27 deletions

View File

@ -1,6 +1,8 @@
package com.simplemobiletools.calendar.activities
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.adapters.EventTypeAdapter
import com.simplemobiletools.calendar.dialogs.NewEventTypeDialog
@ -19,11 +21,7 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteItemsListener {
setContentView(R.layout.activity_manage_event_types)
getEventTypes()
manage_event_types_fab.setOnClickListener {
showEventTypeDialog()
}
updateTextColors(manage_event_types_coordinator)
updateTextColors(manage_event_types_list)
}
private fun showEventTypeDialog(eventType: EventType? = null) {
@ -42,6 +40,19 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteItemsListener {
}
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_event_types, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.add_event_type -> showEventTypeDialog()
else -> return super.onOptionsItemSelected(item)
}
return true
}
override fun deleteItems(ids: ArrayList<Int>) {
if (ids.contains(DBHelper.REGULAR_EVENT_TYPE_ID)) {
toast(R.string.cannot_delete_default_type)

View File

@ -1,26 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/manage_event_types_coordinator"
android:id="@+id/manage_event_types_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/manage_event_types_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
<com.simplemobiletools.commons.views.MyFloatingActionButton
android:id="@+id/manage_event_types_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/activity_margin"
android:src="@drawable/ic_plus"
app:backgroundTint="@color/color_primary"
app:rippleColor="@color/pressed_item_foreground"/>
</android.support.design.widget.CoordinatorLayout>
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/add_event_type"
android:icon="@drawable/ic_plus"
android:title="@string/add_new_type"
app:showAsAction="ifRoom"/>
</menu>