mirror of https://github.com/Corewala/Buran
Removed code block toggle
This commit is contained in:
parent
227d745f5c
commit
2024f88bb2
|
@ -274,12 +274,6 @@ class GemActivity : AppCompatActivity() {
|
|||
else -> hideClientCertShield()
|
||||
}
|
||||
|
||||
val hideCodeBlocks = prefs.getBoolean(
|
||||
"collapse_code_blocks",
|
||||
false
|
||||
)
|
||||
adapter.hideCodeBlocks(hideCodeBlocks)
|
||||
|
||||
val showInlineIcons = prefs.getBoolean(
|
||||
"show_inline_icons",
|
||||
true
|
||||
|
|
|
@ -10,7 +10,6 @@ abstract class AbstractGemtextAdapter(
|
|||
): RecyclerView.Adapter<GmiViewHolder>() {
|
||||
|
||||
var showInlineIcons: Boolean = false
|
||||
var hideCodeBlocks: Boolean = false
|
||||
var showLinkButtons: Boolean = false
|
||||
var showInlineImages: Boolean = false
|
||||
|
||||
|
@ -18,7 +17,6 @@ abstract class AbstractGemtextAdapter(
|
|||
abstract fun loadImage(position: Int, cacheUri: Uri)
|
||||
abstract fun inlineIcons(visible: Boolean)
|
||||
abstract fun inlineImages(visible: Boolean)
|
||||
abstract fun hideCodeBlocks(hideCodeBlocks: Boolean)
|
||||
abstract fun linkButtons(visible: Boolean)
|
||||
|
||||
abstract fun inferTitle(): String?
|
||||
|
|
|
@ -95,27 +95,6 @@ class GemtextAdapter(
|
|||
}else{
|
||||
holder.itemView.gemtext_text_monospace_textview.text = line.substring(3)
|
||||
}
|
||||
|
||||
if(hideCodeBlocks){
|
||||
holder.itemView.show_code_block.setText(R.string.show_code)//reset for recycling
|
||||
altText?.let{
|
||||
holder.itemView.show_code_block.append(": $altText")
|
||||
}
|
||||
holder.itemView.show_code_block.visible(true)
|
||||
holder.itemView.show_code_block.paint.isUnderlineText = true
|
||||
holder.itemView.show_code_block.setOnClickListener {
|
||||
setupCodeBlockToggle(holder, altText)
|
||||
}
|
||||
holder.itemView.gemtext_text_monospace_textview.visible(false)
|
||||
|
||||
when {
|
||||
showInlineIcons -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.vector_code, 0)
|
||||
else -> holder.itemView.show_code_block.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0)
|
||||
}
|
||||
}else{
|
||||
holder.itemView.show_code_block.visible(false)
|
||||
holder.itemView.gemtext_text_monospace_textview.visible(true)
|
||||
}
|
||||
}
|
||||
is GmiViewHolder.Quote -> holder.itemView.gemtext_text_monospace_textview.text = line.substring(1).trim()
|
||||
is GmiViewHolder.H1 -> {
|
||||
|
@ -280,26 +259,6 @@ class GemtextAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupCodeBlockToggle(holder: GmiViewHolder.Code, altText: String?) {
|
||||
//val adapterPosition = holder.adapterPosition
|
||||
when {
|
||||
holder.itemView.gemtext_text_monospace_textview.isVisible -> {
|
||||
holder.itemView.show_code_block.setText(R.string.show_code)
|
||||
holder.itemView.gemtext_text_monospace_textview.visible(false)
|
||||
altText?.let{
|
||||
holder.itemView.show_code_block.append(": $altText")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
holder.itemView.show_code_block.setText(R.string.hide_code)
|
||||
holder.itemView.gemtext_text_monospace_textview.visible(true)
|
||||
altText?.let{
|
||||
holder.itemView.show_code_block.append(": $altText")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLink(line: String): String{
|
||||
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
|
||||
return linkParts[0]
|
||||
|
@ -337,9 +296,4 @@ class GemtextAdapter(
|
|||
this.showInlineImages = visible
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun hideCodeBlocks(hideCodeBlocks: Boolean) {
|
||||
this.hideCodeBlocks = hideCodeBlocks
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
|
@ -179,18 +179,6 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
|||
accessibilityCategory.title = getString(R.string.accessibility)
|
||||
screen.addPreference(accessibilityCategory)
|
||||
|
||||
//Accessibility - code blocks
|
||||
val aboutCodeBlocksPref = Preference(context)
|
||||
aboutCodeBlocksPref.summary = getString(R.string.collapse_code_blocks_about)
|
||||
aboutCodeBlocksPref.isPersistent = false
|
||||
aboutCodeBlocksPref.isSelectable = false
|
||||
accessibilityCategory.addPreference(aboutCodeBlocksPref)
|
||||
|
||||
val collapseCodeBlocksPreference = SwitchPreferenceCompat(context)
|
||||
collapseCodeBlocksPreference.key = "collapse_code_blocks"
|
||||
collapseCodeBlocksPreference.title = getString(R.string.collapse_code_blocks)
|
||||
accessibilityCategory.addPreference(collapseCodeBlocksPreference)
|
||||
|
||||
//Accessibility - inline icons
|
||||
val showInlineIconsPreference = SwitchPreferenceCompat(context)
|
||||
showInlineIconsPreference.setDefaultValue(true)
|
||||
|
|
|
@ -9,27 +9,12 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:textSize="@dimen/default_text_size"
|
||||
android:textColor="@color/stroke"
|
||||
android:id="@+id/show_code_block"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:focusable="true" android:clickable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin_small"
|
||||
android:layout_marginBottom="@dimen/default_margin_small"
|
||||
android:text="@string/show_code"
|
||||
android:drawablePadding="4.0dip"
|
||||
/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:background="@drawable/block_background"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/def_quarter"
|
||||
android:layout_marginBottom="@dimen/def_quarter"
|
||||
android:layout_below="@id/show_code_block">
|
||||
android:layout_marginBottom="@dimen/def_quarter">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:scrollbarStyle="insideOverlay"
|
||||
|
|
|
@ -73,10 +73,6 @@
|
|||
<string name="import_bookmarks">Importer des marque-pages</string>
|
||||
<string name="export_bookmarks">Exporter des marque-pages</string>
|
||||
<string name="accessibility">Accessibilité</string>
|
||||
<string name="collapse_code_blocks">Cacher les rectangles pleins</string>
|
||||
<string name="show_code">Montrer le code</string>
|
||||
<string name="hide_code">Cacher le code</string>
|
||||
<string name="collapse_code_blocks_about">Les capsules Gemini utilisent malheureusement souvent des en-têtes en ascii-art rendus avec des rectangles pleins à largeur fixe. Quand les rectangles pleins sont cachés, ils nécessitent un clic pour être affichés, ce qui améliore l\'ergonomie en cas d\'utilisation d\'un lecteur d\'écran.</string>
|
||||
<string name="prefs_override_page_background">Utiliser une couleur d\'arrière-plan personnalisée</string>
|
||||
<string name="prefs_override_page_background_dialog_title">Couleur d\'arrière-plan</string>
|
||||
<string name="prefs_override_page_background_title">Couleur d\'arrière-plan</string>
|
||||
|
|
|
@ -73,10 +73,6 @@
|
|||
<string name="import_bookmarks">Import bookmarks</string>
|
||||
<string name="export_bookmarks">Export bookmarks</string>
|
||||
<string name="accessibility">Accessibility</string>
|
||||
<string name="collapse_code_blocks">Hide code blocks</string>
|
||||
<string name="show_code">Show code</string>
|
||||
<string name="hide_code">Hide code</string>
|
||||
<string name="collapse_code_blocks_about">Gemini capsules unfortunately often use ascii-art headers rendered in monospaced code blocks. When code blocks are hidden they require a tap to expand which improves usability when using a screen reader.</string>
|
||||
<string name="prefs_override_page_background">Use custom page background colour</string>
|
||||
<string name="prefs_override_page_background_dialog_title">Page Background Colour</string>
|
||||
<string name="prefs_override_page_background_title">Page Background Colour</string>
|
||||
|
|
Loading…
Reference in New Issue