From 17ebf2b38a6d1a3c7779dffc1315c34aedb37520 Mon Sep 17 00:00:00 2001 From: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> Date: Sat, 23 Dec 2023 10:57:21 +0300 Subject: [PATCH] Revert "Fix: #5186: MissingDefaultResource + AppCompatCustomView + FragmentTagUsage (#5191)" This reverts commit 5075c543cdb4ac0a5049f4165c47a8fa7a8b5699. --- app/BUILD.bazel | 1 - .../AdministratorControlsActivityPresenter.kt | 2 +- .../FractionInputInteractionView.kt | 8 +- .../MathExpressionInteractionsView.kt | 8 +- .../NumericInputInteractionView.kt | 8 +- .../interaction/RatioInputInteractionView.kt | 8 +- .../interaction/TextInputInteractionView.kt | 10 +-- .../DeveloperOptionsActivityPresenter.kt | 2 +- .../app/drawer/NavigationDrawerFragment.kt | 4 +- .../NavigationDrawerFragmentPresenter.kt | 14 +--- .../android/app/help/HelpActivityPresenter.kt | 2 +- .../android/app/home/HomeActivityPresenter.kt | 2 +- .../app/options/OptionsActivityPresenter.kt | 2 +- .../administrator_controls_activity.xml | 2 +- .../main/res/layout-sw600dp/help_activity.xml | 2 +- .../res/layout-sw600dp/option_activity.xml | 2 +- .../administrator_controls_activity.xml | 2 +- .../res/layout/developer_options_activity.xml | 2 +- app/src/main/res/layout/help_activity.xml | 2 +- app/src/main/res/layout/home_activity.xml | 2 +- app/src/main/res/layout/option_activity.xml | 2 +- testing/BUILD.bazel | 1 - third_party/maven_install.json | 73 ++----------------- third_party/versions.bzl | 1 - 24 files changed, 44 insertions(+), 118 deletions(-) diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 08a318089e9..32677435108 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -660,7 +660,6 @@ kt_android_library( "//third_party:androidx_core_core-ktx", "//third_party:androidx_databinding_databinding-common", "//third_party:androidx_databinding_databinding-runtime", - "//third_party:androidx_fragment_fragment", "//third_party:circularimageview_circular_image_view", "//utility/src/main/java/org/oppia/android/util/accessibility", "//utility/src/main/java/org/oppia/android/util/parser/html:html_parser", diff --git a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityPresenter.kt index 0c9e3fe7749..0dfe9b50b9c 100644 --- a/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityPresenter.kt @@ -96,7 +96,7 @@ class AdministratorControlsActivityPresenter @Inject constructor( .findFragmentById( R.id.administrator_controls_activity_fragment_navigation_drawer ) as NavigationDrawerFragment - navigationDrawerFragment.initializeDrawer( + navigationDrawerFragment.setUpDrawer( binding.administratorControlsActivityDrawerLayout, toolbar, /* menuItemId= */ 0 ) diff --git a/app/src/main/java/org/oppia/android/app/customview/interaction/FractionInputInteractionView.kt b/app/src/main/java/org/oppia/android/app/customview/interaction/FractionInputInteractionView.kt index 665cacde18d..1fb50be3f5b 100644 --- a/app/src/main/java/org/oppia/android/app/customview/interaction/FractionInputInteractionView.kt +++ b/app/src/main/java/org/oppia/android/app/customview/interaction/FractionInputInteractionView.kt @@ -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 androidx.appcompat.widget.AppCompatEditText +import android.widget.EditText 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 @@ -22,12 +22,12 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard // TODO(#4135): Add a dedicated test suite for this class. -/** The custom [AppCompatEditText] class for fraction input interaction view. */ +/** The custom EditText class for fraction input interaction view. */ class FractionInputInteractionView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = android.R.attr.editTextStyle -) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener { +) : EditText(context, attrs, defStyle), View.OnFocusChangeListener { private var hintText: CharSequence = "" private val stateKeyboardButtonListener: StateKeyboardButtonListener @@ -71,7 +71,7 @@ class FractionInputInteractionView @JvmOverloads constructor( private fun restoreHint() { hint = hintText - if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC) + if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC) setSingleLine(false) } } diff --git a/app/src/main/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsView.kt b/app/src/main/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsView.kt index 34aedfc406c..00de2602d42 100644 --- a/app/src/main/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsView.kt +++ b/app/src/main/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsView.kt @@ -6,7 +6,7 @@ import android.util.AttributeSet import android.view.KeyEvent import android.view.View import android.view.inputmethod.EditorInfo -import androidx.appcompat.widget.AppCompatEditText +import android.widget.EditText 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 @@ -19,7 +19,7 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard // maxLength="200". /** - * The custom [AppCompatEditText] class for math expression interactions interaction view. + * The custom [EditText] 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. @@ -28,7 +28,7 @@ class MathExpressionInteractionsView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = android.R.attr.editTextStyle -) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener { +) : EditText(context, attrs, defStyle), View.OnFocusChangeListener { private var hintText: CharSequence = "" private val stateKeyboardButtonListener: StateKeyboardButtonListener @@ -84,7 +84,7 @@ class MathExpressionInteractionsView @JvmOverloads constructor( private fun restoreHint() { hint = hintText - if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC) + if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC) setSingleLine(false) } } diff --git a/app/src/main/java/org/oppia/android/app/customview/interaction/NumericInputInteractionView.kt b/app/src/main/java/org/oppia/android/app/customview/interaction/NumericInputInteractionView.kt index 247da8ba165..b6745cad7d9 100644 --- a/app/src/main/java/org/oppia/android/app/customview/interaction/NumericInputInteractionView.kt +++ b/app/src/main/java/org/oppia/android/app/customview/interaction/NumericInputInteractionView.kt @@ -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 androidx.appcompat.widget.AppCompatEditText +import android.widget.EditText 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 @@ -20,12 +20,12 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard // background="@drawable/edit_text_background" // maxLength="200". -/** The custom [AppCompatEditText] class for numeric input interaction view. */ +/** The custom EditText class for numeric input interaction view. */ class NumericInputInteractionView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = android.R.attr.editTextStyle -) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener { +) : EditText(context, attrs, defStyle), View.OnFocusChangeListener { private val stateKeyboardButtonListener: StateKeyboardButtonListener private var hintText: CharSequence = "" @@ -69,7 +69,7 @@ class NumericInputInteractionView @JvmOverloads constructor( private fun restoreHint() { hint = hintText - if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC) + if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC) setSingleLine(false) } } diff --git a/app/src/main/java/org/oppia/android/app/customview/interaction/RatioInputInteractionView.kt b/app/src/main/java/org/oppia/android/app/customview/interaction/RatioInputInteractionView.kt index 6b775b469af..fd29579a1fd 100644 --- a/app/src/main/java/org/oppia/android/app/customview/interaction/RatioInputInteractionView.kt +++ b/app/src/main/java/org/oppia/android/app/customview/interaction/RatioInputInteractionView.kt @@ -6,16 +6,16 @@ import android.util.AttributeSet import android.view.KeyEvent import android.view.View import android.view.inputmethod.EditorInfo -import androidx.appcompat.widget.AppCompatEditText +import android.widget.EditText import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener import org.oppia.android.app.utility.KeyboardHelper -/** The custom [AppCompatEditText] class for ratio input interaction view. */ +/** The custom EditText class for ratio input interaction view. */ class RatioInputInteractionView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = android.R.attr.editTextStyle -) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener { +) : EditText(context, attrs, defStyle), View.OnFocusChangeListener { private var hintText: CharSequence = "" private val stateKeyboardButtonListener: StateKeyboardButtonListener @@ -59,7 +59,7 @@ class RatioInputInteractionView @JvmOverloads constructor( private fun restoreHint() { hint = hintText - if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC) + if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC) setSingleLine(false) } } diff --git a/app/src/main/java/org/oppia/android/app/customview/interaction/TextInputInteractionView.kt b/app/src/main/java/org/oppia/android/app/customview/interaction/TextInputInteractionView.kt index 21d278bbdde..10001acd258 100644 --- a/app/src/main/java/org/oppia/android/app/customview/interaction/TextInputInteractionView.kt +++ b/app/src/main/java/org/oppia/android/app/customview/interaction/TextInputInteractionView.kt @@ -6,7 +6,7 @@ import android.util.AttributeSet import android.view.KeyEvent import android.view.View import android.view.inputmethod.EditorInfo -import androidx.appcompat.widget.AppCompatEditText +import android.widget.EditText 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 @@ -17,12 +17,12 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard // background="@drawable/edit_text_background" // maxLength="200". -/** The custom [AppCompatEditText] class for text input interaction view. */ +/** The custom EditText class for text input interaction view. */ class TextInputInteractionView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = android.R.attr.editTextStyle -) : AppCompatEditText(context, attrs, defStyle), View.OnFocusChangeListener { +) : EditText(context, attrs, defStyle), View.OnFocusChangeListener { private var hintText: CharSequence = "" private val stateKeyboardButtonListener: StateKeyboardButtonListener @@ -66,7 +66,7 @@ class TextInputInteractionView @JvmOverloads constructor( private fun restoreHint() { hint = hintText - if (text?.isEmpty() == true) setTypeface(typeface, Typeface.ITALIC) - isSingleLine = false + if (text.isEmpty()) setTypeface(typeface, Typeface.ITALIC) + setSingleLine(false) } } diff --git a/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityPresenter.kt index 8107813bd76..edd4e952711 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityPresenter.kt @@ -41,7 +41,7 @@ class DeveloperOptionsActivityPresenter @Inject constructor( .findFragmentById( R.id.developer_options_activity_fragment_navigation_drawer ) as NavigationDrawerFragment - navigationDrawerFragment.initializeDrawer( + navigationDrawerFragment.setUpDrawer( binding.developerOptionsActivityDrawerLayout, toolbar, menuItemId = -1 ) diff --git a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragment.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragment.kt index 734554fceb4..ee307e47738 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragment.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragment.kt @@ -33,8 +33,8 @@ class NavigationDrawerFragment : return navigationDrawerFragmentPresenter.handleCreateView(inflater, container) } - fun initializeDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) { - navigationDrawerFragmentPresenter.initializeDrawer(drawerLayout, toolbar, menuItemId) + fun setUpDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) { + navigationDrawerFragmentPresenter.setUpDrawer(drawerLayout, toolbar, menuItemId) } override fun routeToProfileProgress(profileId: Int) { diff --git a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt index ecfa05f3782..44fb2ec9945 100644 --- a/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/drawer/NavigationDrawerFragmentPresenter.kt @@ -62,17 +62,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor( private lateinit var drawerLayout: DrawerLayout private lateinit var binding: DrawerFragmentBinding private lateinit var profileId: ProfileId - private lateinit var toolbar: Toolbar private var previousMenuItemId: Int? = null private var internalProfileId: Int = -1 - private var menuItemId: Int = 0 fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? { binding = DrawerFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false) binding.fragmentDrawerNavView.setNavigationItemSelectedListener(this) - setUpDrawer(drawerLayout, toolbar, menuItemId) - fragment.setHasOptionsMenu(true) internalProfileId = activity.intent.getIntExtra(NAVIGATION_PROFILE_ID_ARGUMENT_KEY, -1) @@ -370,17 +366,11 @@ class NavigationDrawerFragmentPresenter @Inject constructor( } } - fun initializeDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) { - this.drawerLayout = drawerLayout - this.toolbar = toolbar - this.menuItemId = menuItemId - } - /** * Initializes the navigation drawer for the specified [DrawerLayout] and [Toolbar], which the host activity is * expected to provide. The [menuItemId] corresponds to the menu ID of the current activity, for navigation purposes. */ - private fun setUpDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) { + fun setUpDrawer(drawerLayout: DrawerLayout, toolbar: Toolbar, menuItemId: Int) { previousMenuItemId = if (activity is TopicActivity) null else menuItemId if (menuItemId != 0 && menuItemId != -1) { getFooterViewModel().isAdministratorControlsSelected.set(false) @@ -417,6 +407,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( true } } + this.drawerLayout = drawerLayout drawerToggle = object : ActionBarDrawerToggle( fragment.activity, drawerLayout, @@ -455,6 +446,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( // For showing navigation drawer in DeveloperOptionsActivity else if (menuItemId == -1) getFooterViewModel().isDeveloperOptionsSelected.set(true) uncheckAllMenuItemsWhenAdministratorControlsOrDeveloperOptionsIsSelected() + this.drawerLayout = drawerLayout drawerToggle = object : ActionBarDrawerToggle( fragment.activity, drawerLayout, diff --git a/app/src/main/java/org/oppia/android/app/help/HelpActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/help/HelpActivityPresenter.kt index c2aefe143bd..29f2aa8123b 100644 --- a/app/src/main/java/org/oppia/android/app/help/HelpActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/help/HelpActivityPresenter.kt @@ -192,7 +192,7 @@ class HelpActivityPresenter @Inject constructor( .findFragmentById( R.id.help_activity_fragment_navigation_drawer ) as NavigationDrawerFragment - navigationDrawerFragment.initializeDrawer( + navigationDrawerFragment.setUpDrawer( activity.findViewById(R.id.help_activity_drawer_layout) as DrawerLayout, toolbar, R.id.nav_help ) diff --git a/app/src/main/java/org/oppia/android/app/home/HomeActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/home/HomeActivityPresenter.kt index 3cfb9401217..83e65950b7f 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeActivityPresenter.kt @@ -49,7 +49,7 @@ class HomeActivityPresenter @Inject constructor(private val activity: AppCompatA navigationDrawerFragment = activity .supportFragmentManager .findFragmentById(R.id.home_activity_fragment_navigation_drawer) as NavigationDrawerFragment - navigationDrawerFragment!!.initializeDrawer( + navigationDrawerFragment!!.setUpDrawer( activity.findViewById(R.id.home_activity_drawer_layout) as DrawerLayout, toolbar, R.id.nav_home ) diff --git a/app/src/main/java/org/oppia/android/app/options/OptionsActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/options/OptionsActivityPresenter.kt index 220a054502b..6193d3a337e 100644 --- a/app/src/main/java/org/oppia/android/app/options/OptionsActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/options/OptionsActivityPresenter.kt @@ -72,7 +72,7 @@ class OptionsActivityPresenter @Inject constructor( .findFragmentById( R.id.options_activity_fragment_navigation_drawer ) as NavigationDrawerFragment - navigationDrawerFragment!!.initializeDrawer( + navigationDrawerFragment!!.setUpDrawer( activity.findViewById(R.id.options_activity_drawer_layout) as DrawerLayout, toolbar, R.id.nav_options ) diff --git a/app/src/main/res/layout-sw600dp/administrator_controls_activity.xml b/app/src/main/res/layout-sw600dp/administrator_controls_activity.xml index e853bff7469..9b778df86f3 100644 --- a/app/src/main/res/layout-sw600dp/administrator_controls_activity.xml +++ b/app/src/main/res/layout-sw600dp/administrator_controls_activity.xml @@ -98,7 +98,7 @@ app:layout_constraintTop_toBottomOf="@id/administrator_controls_activity_toolbar" /> - - - - - - - -