Skip to content

Commit

Permalink
feat(new reviewer): hide answer buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO authored and mikehardy committed Jul 18, 2024
1 parent 712f9fa commit 4f47106
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.webkit.WebView
import android.widget.FrameLayout
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.StringRes
import androidx.appcompat.view.menu.MenuBuilder
Expand Down Expand Up @@ -165,6 +166,12 @@ class ReviewerFragment :
}

private fun setupAnswerButtons(view: View) {
val hideAnswerButtons = sharedPrefs().getBoolean(getString(R.string.hide_answer_buttons_key), false)
if (hideAnswerButtons) {
view.findViewById<FrameLayout>(R.id.buttons_area).isVisible = false
return
}

fun MaterialButton.setAnswerButtonNextTime(@StringRes title: Int, nextTime: String?) {
val titleString = context.getString(title)
text = ReviewerViewModel.buildAnswerButtonText(titleString, nextTime)
Expand Down
6 changes: 4 additions & 2 deletions AnkiDroid/src/main/res/layout/reviewer2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginBottom="4dp">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
Expand Down Expand Up @@ -69,6 +70,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="8dp"
android:layout_marginBottom="4dp"
app:layout_constraintTop_toBottomOf="@id/appbar"
app:layout_constraintBottom_toTopOf="@id/buttons_area"
style="@style/CardView.PreviewerStyle">
Expand All @@ -85,7 +87,7 @@
android:id="@+id/buttons_area"
android:layout_width="0dp"
android:layout_height="@dimen/touch_target"
android:layout_marginVertical="2dp"
android:layout_marginTop="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/webview_container"
app:layout_constraintStart_toStartOf="@id/webview_container"
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/10-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,5 @@ this formatter is used if the bind only applies to both the question and the ans
<string name="hide_system_bars_all_bars" comment="Setting option to hide all the system bars"
>All</string>
<string name="ignore_display_cutout" maxLength="41">Ignore display cutout</string>
<string name="hide_answer_buttons" maxLength="41">Hide answer buttons</string>
</resources>
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@
<!-- Reviewer options -->
<string name="hide_system_bars_key">hideSystemBars</string>
<string name="ignore_display_cutout_key">ignoreDisplayCutout</string>
<string name="hide_answer_buttons_key">hideAnswerButtons</string>
</resources>
6 changes: 6 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences_reviewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@
android:key="@string/ignore_display_cutout_key"
android:title="@string/ignore_display_cutout"
/>

<SwitchPreferenceCompat
android:defaultValue="false"
android:key="@string/hide_answer_buttons_key"
android:title="@string/hide_answer_buttons"
/>
</androidx.preference.PreferenceScreen>

0 comments on commit 4f47106

Please sign in to comment.