Skip to content

Commit

Permalink
update ringer mode warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton committed Sep 20, 2024
1 parent 2f9ced7 commit 18e9fd6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import de.felixnuesse.timedsilence.databinding.FragmentCheckupBinding
import de.felixnuesse.timedsilence.handler.PreferencesManager
import de.felixnuesse.timedsilence.model.contacts.Contact
import de.felixnuesse.timedsilence.model.contacts.ContactUtil
import de.felixnuesse.timedsilence.ui.ContactsListAdapter
Expand Down Expand Up @@ -196,6 +197,7 @@ class CheckupFragment : Fragment() {
adapter = viewAdapter
}

binding.checkupChangeRingerWarningContainer.visibility = if(PreferencesManager(requireContext()).changeRingerVolume()) View.VISIBLE else View.GONE
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,14 @@ class VolumeHandler(private var mContext: Context, private var mInstanceContext:
notifcationVolume
)

if(mPreferencesManager.changeRingerVolume()){
Log.d(TAG(), "VolumeHandler - $mInstanceContext: STREAM_RING: $ringerVolume")
Log.d(TAG(), "VolumeHandler - $mInstanceContext: Setting Ringer! This might be not what you want!")
setStreamToPercent(
manager,
AudioManager.STREAM_RING,
ringerVolume
)
}

// If we set the device to loud, this is exactly what we want.
Log.d(TAG(), "VolumeHandler - $mInstanceContext: STREAM_RING: $ringerVolume")
setStreamToPercent(
manager,
AudioManager.STREAM_RING,
ringerVolume
)

}

Expand Down
65 changes: 44 additions & 21 deletions app/src/main/res/layout/fragment_checkup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,51 @@
android:layout_height="match_parent"
tools:context=".fragments.CheckupFragment">

<TextView
android:id="@+id/label_checkup_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/fragment_title_checkup"
android:textStyle="bold"
android:layout_margin="@dimen/fragmentSideMargins"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp" />

<LinearLayout
android:id="@+id/checkupChangeRingerWarningContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_margin="@dimen/fragmentSideMargins"
app:layout_constraintTop_toBottomOf="@+id/label_checkup_fragment">

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_error"
app:tint="?colorError" />

<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/checkup_ringer_volume_warning"
android:textColor="?colorError" />
</LinearLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/CheckupPermissionCheckContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkupChangeRingerWarningContainer"
tools:visibility="visible">

<LinearLayout
Expand Down Expand Up @@ -46,36 +83,22 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/CheckupContentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkupChangeRingerWarningContainer"
tools:visibility="visible">

<TextView
android:id="@+id/label_checkup_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fragmentSideMargins"
android:layout_marginTop="12dp"
android:layout_marginEnd="@dimen/fragmentSideMargins"
android:gravity="center"
android:text="@string/fragment_title_checkup"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="@dimen/fragmentSideMargins"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label_checkup_fragment">
app:layout_constraintTop_toTopOf="parent">

<LinearLayout
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,5 @@
<string name="volume_selector_subtitle">Select how your phone should react</string>
<string name="calendar_selector_title">Calendars</string>
<string name="calendar_selector_subtitle">Select to wich calendar should apply</string>
<string name="checkup_ringer_volume_warning">You are changing the ringer volume. This is likely not what you want!</string>
</resources>

0 comments on commit 18e9fd6

Please sign in to comment.