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

Fix #5168: appcompat custom view fragment tag usage lint error #5582

Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ android_library(
"//third_party:androidx_databinding_databinding-common",
"//third_party:androidx_databinding_databinding-runtime",
"//third_party:androidx_drawerlayout_drawerlayout",
"//third_party:androidx_fragment_fragment",
"//third_party:androidx_lifecycle_lifecycle-livedata-core",
"//third_party:androidx_recyclerview_recyclerview",
"//third_party:androidx_viewpager2_viewpager2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ class ClassroomListActivity :
title = resourceHandler.getStringInLocale(R.string.classroom_list_activity_title)
}

override fun onRestart() {
super.onRestart()
classroomListActivityPresenter.handleOnRestart()
}

override fun onBackPressed() {
val previousFragment =
supportFragmentManager.findFragmentByTag(TAG_SWITCH_PROFILE_DIALOG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class ClassroomListActivityPresenter @Inject constructor(private val activity: A
}
}

/** Handles the activity restart. Re-initializes the navigation drawer. */
fun handleOnRestart() {
setUpNavigationDrawer()
}

private fun setUpNavigationDrawer() {
val toolbar = activity.findViewById<View>(R.id.classroom_list_activity_toolbar) as Toolbar
activity.setSupportActionBar(toolbar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.KeyEvent.ACTION_UP
import android.view.KeyEvent.KEYCODE_BACK
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.utility.KeyboardHelper.Companion.hideSoftKeyboard
import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
Expand All @@ -20,19 +20,19 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// background="@drawable/edit_text_background"
// maxLength="200".

/** The custom EditText class for fraction input interaction view. */
/** The custom AppCompatEditText class for fraction input interaction view. */
class FractionInputInteractionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), View.OnFocusChangeListener {
) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener {
private var hintText: CharSequence = ""
private val stateKeyboardButtonListener: StateKeyboardButtonListener

init {
onFocusChangeListener = this
// Assume multi-line for the purpose of properly showing long hints.
setSingleLine(hint != null)
isSingleLine = hint != null
stateKeyboardButtonListener = context as StateKeyboardButtonListener
}

Expand Down Expand Up @@ -64,12 +64,12 @@ class FractionInputInteractionView @JvmOverloads constructor(
private fun hideHint() {
hint = ""
typeface = Typeface.DEFAULT
setSingleLine(true)
isSingleLine = true
}

private fun restoreHint() {
hint = hintText
if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC)
setSingleLine(false)
if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC)
isSingleLine = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.util.AttributeSet
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.utility.KeyboardHelper.Companion.hideSoftKeyboard
import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
Expand All @@ -19,7 +19,7 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// maxLength="200".

/**
* The custom [EditText] class for math expression interactions interaction view.
* The custom [AppCompatEditText] class for math expression interactions interaction view.
*
* Note that the hint should be set via [setPlaceholder] to ensure that it's properly initialized if
* using databinding, otherwise setting the hint through android:hint should work fine.
Expand All @@ -28,14 +28,14 @@ class MathExpressionInteractionsView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), View.OnFocusChangeListener {
) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener {
private var hintText: CharSequence = ""
private val stateKeyboardButtonListener: StateKeyboardButtonListener

init {
onFocusChangeListener = this
// Assume multi-line for the purpose of properly showing long hints.
setSingleLine(hint != null)
isSingleLine = hint != null
stateKeyboardButtonListener = context as StateKeyboardButtonListener
}

Expand Down Expand Up @@ -79,12 +79,13 @@ class MathExpressionInteractionsView @JvmOverloads constructor(
private fun hideHint() {
hint = ""
typeface = Typeface.DEFAULT
setSingleLine(true)
isSingleLine = true
}

private fun restoreHint() {
hint = hintText
if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC)
setSingleLine(false)

if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC)
isSingleLine = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.KeyEvent.ACTION_UP
import android.view.KeyEvent.KEYCODE_BACK
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.utility.KeyboardHelper.Companion.hideSoftKeyboard
import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
Expand All @@ -20,19 +20,19 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// background="@drawable/edit_text_background"
// maxLength="200".

/** The custom EditText class for numeric input interaction view. */
/** The custom AppCompatEditText class for numeric input interaction view. */
class NumericInputInteractionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), View.OnFocusChangeListener {
) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener {
private val stateKeyboardButtonListener: StateKeyboardButtonListener
private var hintText: CharSequence = ""

init {
onFocusChangeListener = this
// Assume multi-line for the purpose of properly showing long hints.
setSingleLine(hint != null)
isSingleLine = hint != null
stateKeyboardButtonListener = context as StateKeyboardButtonListener
}

Expand Down Expand Up @@ -64,12 +64,12 @@ class NumericInputInteractionView @JvmOverloads constructor(
private fun hideHint() {
hint = ""
typeface = Typeface.DEFAULT
setSingleLine(true)
isSingleLine = true
}

private fun restoreHint() {
hint = hintText
if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC)
setSingleLine(false)
if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC)
isSingleLine = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import android.util.AttributeSet
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.utility.KeyboardHelper

/** The custom EditText class for ratio input interaction view. */
/** The custom AppCompatEditText class for ratio input interaction view. */
class RatioInputInteractionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), View.OnFocusChangeListener {
) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener {
private var hintText: CharSequence = ""
private val stateKeyboardButtonListener: StateKeyboardButtonListener

init {
onFocusChangeListener = this
// Assume multi-line for the purpose of properly showing long hints.
setSingleLine(hint != null)
isSingleLine = hint != null
stateKeyboardButtonListener = context as StateKeyboardButtonListener
}

Expand Down Expand Up @@ -54,12 +54,12 @@ class RatioInputInteractionView @JvmOverloads constructor(
private fun hideHint() {
hint = ""
typeface = Typeface.DEFAULT
setSingleLine(true)
isSingleLine = true
}

private fun restoreHint() {
hint = hintText
if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC)
setSingleLine(false)
if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC)
isSingleLine = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.util.AttributeSet
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.android.app.utility.KeyboardHelper.Companion.hideSoftKeyboard
import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
Expand All @@ -17,19 +17,19 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// background="@drawable/edit_text_background"
// maxLength="200".

/** The custom EditText class for text input interaction view. */
/** The custom AppCompatEditText class for text input interaction view. */
class TextInputInteractionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = android.R.attr.editTextStyle
) : EditText(context, attrs, defStyle), View.OnFocusChangeListener {
) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener {
private var hintText: CharSequence = ""
private val stateKeyboardButtonListener: StateKeyboardButtonListener

init {
onFocusChangeListener = this
// Assume multi-line for the purpose of properly showing long hints.
setSingleLine(hint != null)
isSingleLine = hint != null
stateKeyboardButtonListener = context as StateKeyboardButtonListener
}

Expand Down Expand Up @@ -61,12 +61,12 @@ class TextInputInteractionView @JvmOverloads constructor(
private fun hideHint() {
hint = ""
typeface = Typeface.DEFAULT
setSingleLine(true)
isSingleLine = true
}

private fun restoreHint() {
hint = hintText
if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC)
setSingleLine(false)
if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC)
isSingleLine = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class NavigationDrawerFragment :
RouteToProfileProgressListener,
ExitProfileDialogInterface {

private lateinit var drawerLayout: DrawerLayout
private lateinit var toolbar: Toolbar
private var menuItemId: Int = 0

@Inject
lateinit var navigationDrawerFragmentPresenter: NavigationDrawerFragmentPresenter

Expand All @@ -33,10 +37,17 @@ class NavigationDrawerFragment :
return navigationDrawerFragmentPresenter.handleCreateView(inflater, container)
}

fun setUpDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
navigationDrawerFragmentPresenter.setUpDrawer(drawerLayout, toolbar, menuItemId)
}

fun setUpDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) {
this.drawerLayout = drawerLayout
this.toolbar = toolbar
this.menuItemId = menuItemId
}

override fun routeToProfileProgress(profileId: Int) {
navigationDrawerFragmentPresenter.openProfileProgress(profileId)
}
Expand Down
Loading
Loading