Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.CheckResult
import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -214,6 +215,7 @@ open class Reviewer :
if (!ensureStoragePermissions()) {
return
}
enableEdgeToEdge()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed even in non-fullscreen mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShridharGoel, this is not a new change. Previously, android:fitsSystemWindows="true" was set in all modes directly in the XML files. I have now moved it to the activity using enableEdgeToEdge(), ensuring a single source of truth instead of declaring it separately in each XML file for this activity.

colorPalette = findViewById(R.id.whiteboard_editor)
answerTimer = AnswerTimer(findViewById(R.id.card_time))
textBarNew = findViewById(R.id.new_number)
Expand Down Expand Up @@ -343,9 +345,9 @@ open class Reviewer :

override fun getContentViewAttr(fullscreenMode: FullScreenMode): Int =
when (fullscreenMode) {
FullScreenMode.BUTTONS_ONLY -> R.layout.reviewer_fullscreen
FullScreenMode.BUTTONS_AND_MENU_WITH_STATUS_BAR -> R.layout.reviewer
FullScreenMode.BUTTONS_AND_MENU_ONLY -> R.layout.reviewer_fullscreen
FullScreenMode.FULLSCREEN_ALL_GONE -> R.layout.reviewer_fullscreen_noanswers
FullScreenMode.BUTTONS_AND_MENU -> R.layout.reviewer
}

public override fun fitsSystemWindows(): Boolean = !fullscreenMode.isFullScreenReview()
Expand Down Expand Up @@ -1419,14 +1421,14 @@ open class Reviewer :
val visible = flags and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION == 0
Timber.d("System UI visibility change. Visible: %b", visible)
if (visible) {
showViewWithAnimation(toolbar)
if (fullscreenMode == FullScreenMode.FULLSCREEN_ALL_GONE) {
showViewWithAnimation(toolbar)
showViewWithAnimation(topbar)
showViewWithAnimation(answerButtons)
}
} else {
hideViewWithAnimation(toolbar)
if (fullscreenMode == FullScreenMode.FULLSCREEN_ALL_GONE) {
hideViewWithAnimation(toolbar)
hideViewWithAnimation(topbar)
hideViewWithAnimation(answerButtons)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ import timber.log.Timber
enum class FullScreenMode(
private val prefValue: String,
) {
/** Display both navigation and buttons (default) */
BUTTONS_AND_MENU("0"),
/** Display both navigation and buttons with status bar (default) */
BUTTONS_AND_MENU_WITH_STATUS_BAR("0"),

/** Remove the menu bar, keeps answer button. */
BUTTONS_ONLY("1"),
/** Remove the status bar, keeps answer button and menu bar. */
BUTTONS_AND_MENU_ONLY("1"),

/** Remove both menu bar and buttons. Can only be set if gesture is on. */
/** Remove menu bar, buttons and status bar. Can only be set if gesture is on. */
FULLSCREEN_ALL_GONE("2"),
;

fun getPreferenceValue() = prefValue

fun isFullScreenReview() = this != BUTTONS_AND_MENU
fun isFullScreenReview() = this != BUTTONS_AND_MENU_WITH_STATUS_BAR

companion object {
const val PREF_KEY = "fullscreenMode"
val DEFAULT = BUTTONS_AND_MENU
val DEFAULT = BUTTONS_AND_MENU_WITH_STATUS_BAR

fun fromPreference(prefs: SharedPreferences): FullScreenMode {
val value = prefs.getString(PREF_KEY, DEFAULT.prefValue)
Expand All @@ -55,7 +55,7 @@ enum class FullScreenMode(
// clear fullscreen flag as we use a integer
val fullScreenModeKey = PREF_KEY
val old = preferences.getBoolean("fullscreenReview", false)
val newValue = if (old) BUTTONS_ONLY else BUTTONS_AND_MENU
val newValue = if (old) BUTTONS_AND_MENU_ONLY else BUTTONS_AND_MENU_WITH_STATUS_BAR
preferences.edit {
putString(fullScreenModeKey, newValue.getPreferenceValue())
remove("fullscreenReview")
Expand Down
3 changes: 1 addition & 2 deletions AnkiDroid/src/main/res/layout/reviewer_answer_buttons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
<FrameLayout
android:id="@+id/answer_options_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/ease_buttons"
Expand Down
20 changes: 9 additions & 11 deletions AnkiDroid/src/main/res/layout/reviewer_fullscreen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ xmlns:android="http://schemas.android.com/apk/res/android">
android:id="@+id/fullscreen_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/reviewer_topbar"
<include layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<include layout="@layout/reviewer_topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"/>
<include
layout="@layout/reviewer_mic_tool_bar"
android:layout_width="match_parent"
Expand All @@ -27,16 +31,10 @@ xmlns:android="http://schemas.android.com/apk/res/android">
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/bottom_area_layout"/>
<include layout="@layout/reviewer_answer_buttons"/>
</RelativeLayout>
<!-- Controls that are overlaid over the main content when the user interrupts immersive mode -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar"
<include layout="@layout/reviewer_answer_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"/>
</FrameLayout>
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<!-- Controls that are overlaid over the main content when the user interrupts immersive mode -->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<!-- AbstractFlashcardViewer pulls layout params from parent, casting it as RelativeLayout -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Main content that takes up the fullscreen -->
<include
layout="@layout/reviewer_mic_tool_bar"
Expand Down Expand Up @@ -36,7 +37,10 @@
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/bottom_area_layout"/>
<include layout="@layout/reviewer_answer_buttons"/>
<include layout="@layout/reviewer_answer_buttons"
tools:layout_width="match_parent"
tools:layout_height="wrap_content"
tools:layout_alignParentBottom="true"/>

</RelativeLayout>
</RelativeLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class ReviewerNoParamTest : RobolectricTest() {

private fun startReviewerFullScreen(): ReviewerExt {
val sharedPrefs = targetContext.sharedPrefs()
setPreference(sharedPrefs, FullScreenMode.BUTTONS_ONLY)
setPreference(sharedPrefs, FullScreenMode.BUTTONS_AND_MENU_ONLY)
return ReviewerTest.startReviewer(this, ReviewerExt::class.java)
}

Expand Down
Loading