Clicking the time now opens the clock app. Can be disabled.

This commit is contained in:
ottoptj 2024-08-16 14:12:08 +03:00
commit 5f1c10eb54
5 changed files with 23 additions and 1 deletions

View file

@ -79,4 +79,5 @@ Enabling weather integration will send the coordinates that are set for the weat
- `EXPAND_STATUS_BAR` - Allows pulling down the status bar from the app. - `EXPAND_STATUS_BAR` - Allows pulling down the status bar from the app.
- `INTERNET` - Required for API calls to Open-Meteo. Only used if weather integration is enabled. - `INTERNET` - Required for API calls to Open-Meteo. Only used if weather integration is enabled.
- `ACCESS_COARSE_LOCATION` - Requested when enabling GPS location. Needs to be allowed to use GPS location. - `ACCESS_COARSE_LOCATION` - Requested when enabling GPS location. Needs to be allowed to use GPS location.
- `SET_ALARM` - Used for the clock opening gesture on clicking the time.
- `QUERY_ALL_PACKAGES` - Used to ensure that the app properly detects all installed apps. - `QUERY_ALL_PACKAGES` - Used to ensure that the app properly detects all installed apps.

View file

@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" /> tools:ignore="QueryAllPackagesPermission" />

View file

@ -13,6 +13,7 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.UserHandle import android.os.UserHandle
import android.provider.AlarmClock
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.GestureDetector import android.view.GestureDetector
@ -302,6 +303,15 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
true true
} }
binding.clockLayout.setOnClickListener {_ ->
if (sharedPreferenceManager.isClockGestureEnabled()) {
val intent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent)
}
}
}
// Return to home on back // Return to home on back
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {

View file

@ -98,6 +98,10 @@ class SharedPreferenceManager (context: Context) {
return preferences.getString("tempUnits", "celsius") return preferences.getString("tempUnits", "celsius")
} }
fun isClockGestureEnabled() : Boolean {
return preferences.getBoolean("clockClick", 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

@ -153,6 +153,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:allowDividerAbove="false" app:allowDividerAbove="false"
app:title="Gestures"> app:title="Gestures">
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:title="Clicking Time Opens Clock"
app:key="clockClick" />
<SwitchPreference <SwitchPreference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"