Added gesture to launch calendar by clicking date

This commit is contained in:
ottoptj 2024-08-30 22:24:56 +03:00
commit 3164694f42
3 changed files with 30 additions and 2 deletions

View file

@ -325,7 +325,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
true true
} }
binding.clockLayout.setOnClickListener {_ -> clock.setOnClickListener {_ ->
if (sharedPreferenceManager.isClockGestureEnabled()) { if (sharedPreferenceManager.isClockGestureEnabled()) {
val intent = Intent(AlarmClock.ACTION_SHOW_ALARMS) val intent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
if (intent.resolveActivity(packageManager) != null) { if (intent.resolveActivity(packageManager) != null) {
@ -334,7 +334,25 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
} }
} }
binding.clockLayout.setOnLongClickListener {_ -> dateText.setOnClickListener { _ ->
if (sharedPreferenceManager.isDateGestureEnabled()) {
startActivity(
Intent(
Intent.makeMainSelectorActivity(
Intent.ACTION_MAIN,
Intent.CATEGORY_APP_CALENDAR
)
)
)
}
}
clock.setOnLongClickListener {_ ->
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
true
}
dateText.setOnLongClickListener {_ ->
startActivity(Intent(this@MainActivity, SettingsActivity::class.java)) startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
true true
} }

View file

@ -131,6 +131,10 @@ class SharedPreferenceManager (private val context: Context) {
return preferences.getBoolean("clockClick", true) return preferences.getBoolean("clockClick", true)
} }
fun isDateGestureEnabled() : Boolean {
return preferences.getBoolean("dateClick", true)
}
// Gestures // Gestures
fun setGestures(direction: String, appName: String?) { fun setGestures(direction: String, appName: String?) {
val editor = preferences.edit() val editor = preferences.edit()

View file

@ -182,6 +182,12 @@
android:defaultValue="true" android:defaultValue="true"
android:title="Clicking Time Opens Clock" android:title="Clicking Time Opens Clock"
app:key="clockClick" /> app:key="clockClick" />
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:title="Clicking Date Opens Calendar"
app:key="dateClick" />
<SwitchPreference <SwitchPreference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"