Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(new reviewer): box frame style #17746

Merged
merged 1 commit into from
Jan 7, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.shape.ShapeAppearanceModel
import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textview.MaterialTextView
import com.ichi2.anki.AbstractFlashcardViewer.Companion.RESULT_NO_MORE_CARDS
Expand Down Expand Up @@ -98,6 +99,7 @@ import com.ichi2.anki.utils.ext.menu
import com.ichi2.anki.utils.ext.removeSubMenu
import com.ichi2.anki.utils.ext.sharedPrefs
import com.ichi2.anki.utils.ext.window
import com.ichi2.anki.utils.setMargins
import com.ichi2.libanki.sched.Counts
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -140,6 +142,7 @@ class ReviewerFragment :
}

setupImmersiveMode(view)
setupFrame(view)
setupTypeAnswer(view)
setupAnswerButtons(view)
setupCounts(view)
Expand Down Expand Up @@ -461,6 +464,18 @@ class ReviewerFragment :
}
}

private fun setupFrame(view: View) {
val frameStyleKey = getString(R.string.reviewer_frame_style_key)
david-allison marked this conversation as resolved.
Show resolved Hide resolved
val boxValue = getString(R.string.reviewer_frame_style_box_value)
if (sharedPrefs().getString(frameStyleKey, null) == boxValue) {
view.findViewById<MaterialCardView>(R.id.webview_container).apply {
setMargins(0)
cardElevation = 0F
shapeAppearanceModel = ShapeAppearanceModel() // Remove corners
}
}
}

private val noteEditorLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.data?.getBooleanExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, false) == true ||
Expand Down
23 changes: 23 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/utils/Layout.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2025 Brayan Oliveira <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ichi2.anki.utils

import android.view.ViewGroup.MarginLayoutParams
import android.widget.FrameLayout

fun FrameLayout.setMargins(value: Int) {
(layoutParams as? MarginLayoutParams)?.setMargins(value, value, value, value)
}
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/res/layout/reviewer2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
tools:backgroundTint="@color/white"/>

</com.google.android.material.card.MaterialCardView>

Expand Down
7 changes: 6 additions & 1 deletion AnkiDroid/src/main/res/values/10-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<string name="keyboard">Keyboard</string>
<string name="bluetooth">Bluetooth</string>
<string name="answer_buttons" maxLength="41">Answer buttons</string>
<string name="card" maxLength="41">Card</string>
<string name="card" maxLength="41" comment="Generic term to refer to a card">Card</string>
<string name="note" maxLength="41">Note</string>
<string name="navigation" maxLength="41">Navigation</string>
<string name="media" maxLength="41">Media</string>
Expand Down Expand Up @@ -440,6 +440,11 @@ this formatter is used if the bind only applies to both the question and the ans
<string name="ignore_display_cutout" maxLength="41">Ignore display cutout</string>
<string name="hide_answer_buttons" maxLength="41">Hide answer buttons</string>
<string name="hide_hard_and_easy" maxLength="41">Hide ‘Hard’ and ‘Easy’ buttons</string>
<string name="reviewer_frame_style" maxLength="41">Frame style</string>
<string name="reviewer_frame_style_card" maxLength="41" comment="Style name of the 'Card' card frame of the Reviewer"
>Card</string>
<string name="reviewer_frame_style_box" maxLength="41" comment="Style name of the 'Box' card frame of the Reviewer"
>Box</string>

<!--Keyboard shortcuts dialog-->
<string name="open_settings" comment="Description of the shortcut that opens the app settings">Open settings</string>
Expand Down
14 changes: 14 additions & 0 deletions AnkiDroid/src/main/res/values/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@
<item>@string/hide_system_bars_all_value</item>
</string-array>

<string-array name="reviewer_frame_style_entries">
<item>@string/reviewer_frame_style_card</item>
<item>@string/reviewer_frame_style_box</item>
</string-array>

<string name="reviewer_frame_style_card_value">0</string>
<string name="reviewer_frame_style_box_value">1</string>

<string-array name="reviewer_frame_style_values">
<item>@string/reviewer_frame_style_card_value</item>
<item>@string/reviewer_frame_style_box_value</item>
</string-array>


<!-- Preferences headers summaries -->
<string-array name="general_summary_entries">
<item>@string/language</item>
Expand Down
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 @@ -204,5 +204,6 @@
<string name="hide_answer_buttons_key">hideAnswerButtons</string>
<string name="hide_hard_and_easy_key">hideHardAndEasy</string>
<string name="reviewer_menu_settings_key">reviewerMenuSettings</string>
<string name="reviewer_frame_style_key">reviewerFrameStyle</string>

</resources>
8 changes: 8 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences_reviewer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@
<Preference
android:title="Menu actions"
android:key="@string/reviewer_menu_settings_key" />

<ListPreference
android:defaultValue="@string/reviewer_frame_style_card_value"
android:entries="@array/reviewer_frame_style_entries"
android:entryValues="@array/reviewer_frame_style_values"
android:key="@string/reviewer_frame_style_key"
android:title="@string/reviewer_frame_style"
app:useSimpleSummaryProvider="true"/>
</androidx.preference.PreferenceScreen>
Loading