add event type dialog

This commit is contained in:
tibbi 2017-02-11 12:55:31 +01:00
parent f16cfc63ca
commit ff2d587050
3 changed files with 82 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.activities
import android.os.Bundle
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.EventTypeDialog
import com.simplemobiletools.calendar.helpers.DBHelper
import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.activity_manage_event_types.*
@ -16,9 +17,15 @@ class ManageEventTypesActivity : SimpleActivity() {
}
manage_event_types_fab.setOnClickListener {
showEventTypeDialog()
}
updateTextColors(manage_event_types_coordinator)
}
private fun showEventTypeDialog() {
EventTypeDialog(this) {
}
}
}

View File

@ -0,0 +1,31 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.WindowManager
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.commons.extensions.setBackgroundWithStroke
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_event_type.view.*
class EventTypeDialog(val activity: Activity, val callback: () -> Unit) : AlertDialog.Builder(activity) {
init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_event_type, null).apply {
type_color.setBackgroundWithStroke(activity.config.primaryColor, activity.config.backgroundColor)
}
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.add_new_type)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
})
}
}
}

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_type_dialog_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/type_title_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"/>
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/type_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginStart="@dimen/small_margin"
android:maxLength="50"
android:singleLine="true"
android:textCursorDrawable="@null"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/type_color_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/color"/>
<ImageView
android:id="@+id/type_color"
android:layout_width="@dimen/color_sample_size"
android:layout_height="@dimen/color_sample_size"
android:layout_marginLeft="@dimen/medium_margin"
android:layout_marginStart="@dimen/medium_margin"
android:layout_marginTop="@dimen/medium_margin"/>
</LinearLayout>