display alarm label at the alarms list

This commit is contained in:
tibbi 2018-03-08 21:58:45 +01:00
parent 50a573cc33
commit a043529ddf
3 changed files with 30 additions and 8 deletions

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.clock.adapters
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.extensions.config
@ -12,9 +13,7 @@ import com.simplemobiletools.clock.interfaces.ToggleAlarmInterface
import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getSelectedDaysString
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.item_alarm.view.*
import java.util.*
@ -85,6 +84,10 @@ class AlarmsAdapter(activity: SimpleActivity, var alarms: ArrayList<Alarm>, val
alarm_days.text = activity.getSelectedDaysString(alarm.days)
alarm_days.setTextColor(textColor)
alarm_label.text = alarm.label
alarm_label.setTextColor(textColor)
alarm_label.beVisibleIf(alarm.label.isNotEmpty())
alarm_switch.isChecked = alarm.isEnabled
alarm_switch.setColors(textColor, adjustedPrimaryColor, backgroundColor)
alarm_switch.setOnClickListener {
@ -102,6 +105,9 @@ class AlarmsAdapter(activity: SimpleActivity, var alarms: ArrayList<Alarm>, val
alarm_switch.isChecked = false
}
}
val layoutParams = alarm_switch.layoutParams as RelativeLayout.LayoutParams
layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, if (alarm_label.isVisible()) alarm_label.id else alarm_days.id)
}
}
}

View File

@ -43,6 +43,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
}
edit_alarm_label_image.applyColorFilter(textColor)
edit_alarm_label.setText(alarm.label)
val dayLetters = activity.resources.getStringArray(R.array.week_day_letters).toList() as ArrayList<String>
if (activity.config.isSundayFirst) {

View File

@ -14,7 +14,9 @@
android:id="@+id/alarm_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_margin">
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/alarm_time"
@ -22,25 +24,38 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/alarm_text_size"
tools:text="07:00"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/alarm_days"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/alarm_time"
android:paddingBottom="@dimen/normal_margin"
android:layout_toLeftOf="@+id/alarm_switch"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="@dimen/tiny_margin"
android:textSize="@dimen/big_text_size"
tools:text="Mon, Tue, Wed, Thu, Fri"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/alarm_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/alarm_days"
android:layout_toLeftOf="@+id/alarm_switch"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="@dimen/tiny_margin"
android:textSize="@dimen/big_text_size"
tools:text="Good morning!"/>
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/alarm_switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@id/alarm_days"
android:layout_alignBottom="@id/alarm_label"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/alarm_time"
android:paddingLeft="@dimen/activity_margin"