From 73fdde7e8a4af9e98797b5310dbec0ac0a305a4b Mon Sep 17 00:00:00 2001 From: Wrichik Basu <56736644+WrichikBasu@users.noreply.github.com> Date: Thu, 1 Apr 2021 20:59:58 +0530 Subject: [PATCH] Fixed #45 --- .../shakealarmclock/Activity_Settings.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/in/basulabs/shakealarmclock/Activity_Settings.java b/app/src/main/java/in/basulabs/shakealarmclock/Activity_Settings.java index b368123..1c98ae7 100644 --- a/app/src/main/java/in/basulabs/shakealarmclock/Activity_Settings.java +++ b/app/src/main/java/in/basulabs/shakealarmclock/Activity_Settings.java @@ -116,7 +116,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { R.array.shakeAndPowerOptions, android.R.layout.simple_spinner_item); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); shakeOpSpinner.setAdapter(arrayAdapter); - shakeOpSpinner.setSelection(sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_SHAKE_OPERATION,ConstantsAndStatics.SNOOZE)); + shakeOpSpinner.setSelection(sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_SHAKE_OPERATION, + ConstantsAndStatics.SNOOZE)); shakeOpSpinner.setOnItemSelectedListener(this); ///////////////////////////////////////////////////////// @@ -308,6 +309,8 @@ public void afterTextChanged(Editable editable) { } + //----------------------------------------------------------------------------------------------------- + @Override protected void onResume() { super.onResume(); @@ -316,6 +319,8 @@ protected void onResume() { } } + //----------------------------------------------------------------------------------------------------- + @Override protected void onPause() { super.onPause(); @@ -342,8 +347,12 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { * @return {@code true} if the file exists, otherwise {@code false}. */ private boolean doesFileExist(Uri uri) { - try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) { - return cursor != null; + try { + try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) { + return cursor != null; + } + } catch (java.lang.SecurityException exception) { + return false; } } @@ -420,7 +429,7 @@ private void setDefaultTone(Uri uri) { //----------------------------------------------------------------------------------------------------- /** - * Sets the volume in the {@link #volumeImageView} as per the progress in the volume seekbar. + * Sets the image in the {@link #volumeImageView} as per the progress in the volume seekbar. * * @param volume The current volume (or progress in volume SeekBar. */ @@ -434,6 +443,12 @@ private void setVolumeImageView(int volume) { //---------------------------------------------------------------------------------------------------- + /** + * Change the image in {@link #shakeImageView}. + * + * @param state The state of the shake ExpandableLayout. Either {@link ExpandableLayout.State#EXPANDED} or {@link + * ExpandableLayout.State#COLLAPSED}. + */ private void setShakeImageView(int state) { if (state == ExpandableLayout.State.EXPANDED) { shakeImageView.setImageResource(R.drawable.ic_collapse); @@ -444,6 +459,12 @@ private void setShakeImageView(int state) { //---------------------------------------------------------------------------------------------------- + /** + * Change the image in {@link #snoozeImageView}. + * + * @param state The state of the snooze ExpandableLayout. Either {@link ExpandableLayout.State#EXPANDED} or {@link + * ExpandableLayout.State#COLLAPSED}. + */ private void setSnoozeImageView(int state) { if (state == ExpandableLayout.State.EXPANDED) { snoozeImageView.setImageResource(R.drawable.ic_collapse);