diff --git a/README.md b/README.md index fd7930b..2f5d8e1 100644 --- a/README.md +++ b/README.md @@ -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. - `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. -- `QUERY_ALL_PACKAGES` - Used to ensure that the app properly detects all installed apps. +- `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. \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b310eee..3eacae3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index b832069..9fc815f 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -13,6 +13,7 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.os.UserHandle +import android.provider.AlarmClock import android.text.Editable import android.text.TextWatcher import android.view.GestureDetector @@ -302,6 +303,15 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh 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 onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt index faca0b2..945177d 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt @@ -98,6 +98,10 @@ class SharedPreferenceManager (context: Context) { return preferences.getString("tempUnits", "celsius") } + fun isClockGestureEnabled() : Boolean { + return preferences.getBoolean("clockClick", true) + } + // Gestures fun setGestures(direction: String, appName: String?) { val editor = preferences.edit() diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 2c3306e..f55ee26 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -153,6 +153,12 @@ android:layout_height="wrap_content" app:allowDividerAbove="false" app:title="Gestures"> +