mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[UI/Counter] Add Bell Sync option in counter activity.
This commit is contained in:
parent
f6a8e9d2fa
commit
6ece6ca52a
@ -6,11 +6,16 @@ package pl.szczodrzynski.edziennik.ui.modules.home
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
|
||||
import com.mikepenz.iconics.utils.colorInt
|
||||
import com.mikepenz.iconics.utils.sizeDp
|
||||
import kotlinx.coroutines.*
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
import pl.szczodrzynski.edziennik.data.db.full.LessonFull
|
||||
import pl.szczodrzynski.edziennik.databinding.ActivityCounterBinding
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.bell.BellSyncTimeChooseDialog
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
@ -32,7 +37,7 @@ class CounterActivity : AppCompatActivity(), CoroutineScope {
|
||||
private val syncedNow: Time
|
||||
get() = Time.fromMillis(Time.getNow().inMillis - bellSyncDiffMillis)
|
||||
|
||||
private val countInSeconts: Boolean
|
||||
private val countInSeconds: Boolean
|
||||
get() = app.config.timetable.countInSeconds
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -54,6 +59,13 @@ class CounterActivity : AppCompatActivity(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
b.bellSync.setImageDrawable(IconicsDrawable(this@CounterActivity, SzkolnyFont.Icon.szf_alarm_bell_outline)
|
||||
.colorInt(0xff404040.toInt())
|
||||
.sizeDp(36))
|
||||
b.bellSync.onClick {
|
||||
BellSyncTimeChooseDialog(activity = this@CounterActivity)
|
||||
}
|
||||
|
||||
app.config.timetable.bellSyncDiff?.let {
|
||||
bellSyncDiffMillis = (it.hour * 60 * 60 * 1000 + it.minute * 60 * 1000 + it.second * 1000).toLong()
|
||||
bellSyncDiffMillis *= app.config.timetable.bellSyncMultiplier.toLong()
|
||||
@ -85,13 +97,13 @@ class CounterActivity : AppCompatActivity(), CoroutineScope {
|
||||
b.lessonName.text = actual.displaySubjectName
|
||||
|
||||
val left = actual.displayEndTime!! - now
|
||||
b.timeLeft.text = timeLeft(left.toInt(), "\n", countInSeconts)
|
||||
b.timeLeft.text = timeLeft(left.toInt(), "\n", countInSeconds)
|
||||
}
|
||||
next != null -> {
|
||||
b.lessonName.text = next.displaySubjectName
|
||||
|
||||
val till = next.displayStartTime!! - now
|
||||
b.timeLeft.text = timeTill(till.toInt(), "\n", countInSeconts)
|
||||
b.timeLeft.text = timeTill(till.toInt(), "\n", countInSeconds)
|
||||
}
|
||||
else -> {
|
||||
b.lessonName.text = app.getString(R.string.lessons_finished)
|
||||
|
@ -8,6 +8,30 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/counter_activity_sync"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#ff606060" />
|
||||
<ImageView
|
||||
android:id="@+id/bellSync"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="10dp"
|
||||
tools:tint="#ff404040"
|
||||
tools:src="@sample/settings" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lessonName"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -1157,4 +1157,5 @@
|
||||
<string name="event_manual_share">Udostępniam wydarzenie...</string>
|
||||
<string name="event_manual_unshare_remove">Usuwam udostępnione wydarzenie...</string>
|
||||
<string name="event_manual_remove">Usuwam wydarzenie...</string>
|
||||
<string name="counter_activity_sync">Synchronizuj</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user