Fix date / time view actions

Close #69
This commit is contained in:
Finn M Glas 2020-10-12 20:49:44 +02:00
parent ff77c93b3f
commit 92c20c62d4
No known key found for this signature in database
GPG key ID: 902A30146014DFBF
2 changed files with 16 additions and 11 deletions

View file

@ -7,7 +7,6 @@ import android.os.AsyncTask
import android.os.Bundle
import android.provider.MediaStore
import android.view.*
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GestureDetectorCompat
import com.finnmglas.launcher.tutorial.TutorialActivity
@ -119,12 +118,12 @@ class HomeActivity: UIObject, AppCompatActivity(),
clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) {
this@HomeActivity.runOnUiThread {
val t = timeFormat.format(Date())
if (home_time_view.text != t)
home_time_view.text = t
if (home_lower_view.text != t)
home_lower_view.text = t
val d = dateFormat.format(Date())
if (home_date_view.text != d)
home_date_view.text = d
if (home_upper_view.text != d)
home_upper_view.text = d
}
}
}
@ -260,12 +259,18 @@ class HomeActivity: UIObject, AppCompatActivity(),
launch("launcher:settings", this, R.anim.bottom_up)
}
home_date_view.setOnClickListener() {
launch(calendarApp, this)
home_upper_view.setOnClickListener() {
when (launcherPreferences.getInt(PREF_DATE_FORMAT, 0)) {
0 -> launch(calendarApp, this)
else -> launch(clockApp,this)
}
}
home_time_view.setOnClickListener() {
launch(clockApp,this)
home_lower_view.setOnClickListener() {
when (launcherPreferences.getInt(PREF_DATE_FORMAT, 0)) {
0 -> launch(clockApp, this)
else -> launch(calendarApp,this)
}
}
}

View file

@ -21,7 +21,7 @@
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/home_date_view"
android:id="@+id/home_upper_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
@ -33,7 +33,7 @@
app:layout_constraintVertical_bias="0.45" />
<TextView
android:id="@+id/home_time_view"
android:id="@+id/home_lower_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"