Skip to content

Commit

Permalink
Disable headings button from the wikitext keyboard overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey committed Nov 6, 2023
1 parent 2b01ea5 commit 9392739
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
15 changes: 10 additions & 5 deletions app/src/main/java/org/wikipedia/edit/WikiTextKeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import android.view.LayoutInflater
import android.view.inputmethod.InputConnection
import android.widget.EditText
import android.widget.FrameLayout
import androidx.core.content.withStyledAttributes
import androidx.core.view.isVisible
import org.wikipedia.R
import org.wikipedia.databinding.ViewWikitextKeyboardBinding
import org.wikipedia.page.PageTitle
import org.wikipedia.util.StringUtil

class WikiTextKeyboardView : FrameLayout {
class WikiTextKeyboardView constructor(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
interface Callback {
fun onPreviewLink(title: String)
fun onRequestInsertMedia()
Expand All @@ -30,11 +32,14 @@ class WikiTextKeyboardView : FrameLayout {
get() { return binding.wikitextButtonUserMention.isVisible }
set(value) { binding.wikitextButtonUserMention.isVisible = value }

constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)

init {
attrs?.let {
context.withStyledAttributes(it, R.styleable.WikitextKeyboardView) {
val headingsEnable = getBoolean(R.styleable.WikitextKeyboardView_headingsEnable, true)
binding.wikitextButtonHeading.isVisible = headingsEnable
}
}

binding.wikitextButtonUndo.visibility = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) VISIBLE else GONE
binding.wikitextButtonRedo.visibility = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) VISIBLE else GONE
binding.wikitextButtonTextFormat.setExpandable(true)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_add_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/paper_color"
android:elevation="12dp"/>
android:elevation="12dp"
app:headingsEnable="false"/>

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/addTemplateToolbar"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_talk_reply.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/paper_color"
android:elevation="12dp"/>
android:elevation="12dp"
app:headingsEnable="false"/>

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/replyToolbar"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<attr name="centerDrawable" format="reference" />
</declare-styleable>

<declare-styleable name="WikitextKeyboardView">
<attr name="headingsEnable" format="boolean" />
</declare-styleable>

<declare-styleable name="WikitextKeyboardButtonView">
<attr name="buttonImage" format="reference" />
<attr name="buttonText" format="string" />
Expand Down

0 comments on commit 9392739

Please sign in to comment.