From 42b1c8fe7accd0f2207c1e4ac60f705b5fbc3335 Mon Sep 17 00:00:00 2001 From: Tobiloba Oyelekan Date: Thu, 5 Dec 2024 08:50:31 +0100 Subject: [PATCH] Fix #5168: appcompat custom view fragment tag usage lint error (#5582) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Explanation Fixes [#5168](https://github.com/oppia/oppia-android/issues/5186) 1. For `AppCompatCustomView`, replaced it with AppCompat Views 2. For `FragmentTagUsage`, replaced `` with . Made some changes to `NavigationDrawerFragment` to: - ensured `setUpDrawer()` is called first to initialize the `drawerLayout`, `toolbar` and `menuItemId` - followed by `onCreateView()` ensuring to bind the fragment - followed on `onViewCreated()` to setup drawer functions/listeners 3. Faced an issue similar to [drawer not working](https://github.com/oppia/oppia-android/issues/5266), by minimising and resuming the app, (the drawer button stopped working). - Fixed this by removing `onRestart()` from respective Activies making a call to `setUpNavigationDrawer()` which at that point is not necessary, since the fragment has been inflated initially, and would be re-inflated if the fragment is recreated. 4. Also tested this [bug](https://github.com/oppia/oppia-android/issues/5284) following the steps to reproduce. No issues encountered **Lint report (Before):** ![Screenshot 2024-11-24 at 6 11 50 AM](https://github.com/user-attachments/assets/479da7e9-ea3d-47d5-9c69-ff5c97992750) **Lint report (After):** ![Screenshot 2024-11-24 at 8 06 27 AM](https://github.com/user-attachments/assets/68ef6cb9-b9b6-45ac-a901-ed64540ee674) ## Screen Record https://github.com/user-attachments/assets/6db98657-d470-4263-a5ac-d055f4d64e66 ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). --- app/BUILD.bazel | 1 + .../app/classroom/ClassroomListActivity.kt | 17 ++++++++-- .../ClassroomListActivityPresenter.kt | 5 --- .../FractionInputInteractionView.kt | 14 ++++---- .../MathExpressionInteractionsView.kt | 15 ++++---- .../NumericInputInteractionView.kt | 14 ++++---- .../interaction/RatioInputInteractionView.kt | 14 ++++---- .../interaction/TextInputInteractionView.kt | 14 ++++---- .../app/drawer/NavigationDrawerFragment.kt | 13 ++++++- .../NavigationDrawerFragmentPresenter.kt | 34 +++++++++---------- .../oppia/android/app/home/HomeActivity.kt | 5 --- .../android/app/home/HomeActivityPresenter.kt | 4 --- .../testing/NavigationDrawerTestActivity.kt | 5 --- .../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/classroom_list_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 | 3 +- third_party/versions.bzl | 1 + 25 files changed, 93 insertions(+), 85 deletions(-) diff --git a/app/BUILD.bazel b/app/BUILD.bazel index cbeefc86af0..7405410cf3e 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -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", diff --git a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt index a158e5adc4a..f6160ec4ba7 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt @@ -72,9 +72,20 @@ 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) + if (previousFragment != null) { + supportFragmentManager.beginTransaction().remove(previousFragment).commitNow() + } + val exitProfileDialogArguments = + ExitProfileDialogArguments + .newBuilder() + .setHighlightItem(HighlightItem.NONE) + .build() + val dialogFragment = ExitProfileDialogFragment + .newInstance(exitProfileDialogArguments = exitProfileDialogArguments) + dialogFragment.showNow(supportFragmentManager, TAG_SWITCH_PROFILE_DIALOG) } override fun routeToRecentlyPlayed(recentlyPlayedActivityTitle: RecentlyPlayedActivityTitle) { diff --git a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivityPresenter.kt index ea6a0d8df3f..0b8c1d78f1e 100644 --- a/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivityPresenter.kt @@ -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(R.id.classroom_list_activity_toolbar) as Toolbar activity.setSupportActionBar(toolbar) 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 eec5f745241..547b38feaf2 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 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 @@ -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 } @@ -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 } } 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 00de2602d42..63416dd5196 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 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 @@ -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. @@ -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 } @@ -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 } } 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 b6745cad7d9..9af64db917a 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 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 @@ -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 } @@ -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 } } 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 fd29579a1fd..1ad77b316b2 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,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 } @@ -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 } } 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 10001acd258..56217ef9fa4 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 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 @@ -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 } @@ -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 } } 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 ee307e47738..9408ebe67df 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 @@ -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 @@ -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) } 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 f606bafca88..e2a6e44d157 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 @@ -109,13 +109,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor( drawerLayout.closeDrawers() footerViewModel.isDeveloperOptionsSelected.set(true) val intent = starter.createIntent(activity, profileId) - fragment.activity!!.startActivity(intent) - if (previousMenuItemId == 0) fragment.activity!!.finish() + fragment.requireActivity().startActivity(intent) + if (previousMenuItemId == 0) fragment.requireActivity().finish() else if (previousMenuItemId != null && NavigationDrawerItem.valueFromNavId(previousMenuItemId!!) != NavigationDrawerItem.HOME ) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } drawerLayout.closeDrawers() } @@ -148,13 +148,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor( activity, profileId ) - fragment.activity!!.startActivity(intent) - if (previousMenuItemId == -1) fragment.activity!!.finish() + fragment.requireActivity().startActivity(intent) + if (previousMenuItemId == -1) fragment.requireActivity().finish() else if (previousMenuItemId != null && NavigationDrawerItem.valueFromNavId(previousMenuItemId!!) != NavigationDrawerItem.HOME ) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } drawerLayout.closeDrawers() } @@ -240,7 +240,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( ClassroomListActivity.createClassroomListActivity(activity, profileId) else HomeActivity.createHomeActivity(activity, profileId) - fragment.activity!!.startActivity(intent) + fragment.requireActivity().startActivity(intent) drawerLayout.closeDrawers() } NavigationDrawerItem.OPTIONS -> { @@ -248,9 +248,9 @@ class NavigationDrawerFragmentPresenter @Inject constructor( activity, profileId, /* isFromNavigationDrawer= */ true ) - fragment.activity!!.startActivity(intent) + fragment.requireActivity().startActivity(intent) if (checkIfPreviousActivityShouldGetFinished(menuItemId)) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } drawerLayout.closeDrawers() } @@ -259,18 +259,18 @@ class NavigationDrawerFragmentPresenter @Inject constructor( activity, profileId, /* isFromNavigationDrawer= */ true ) - fragment.activity!!.startActivity(intent) + fragment.requireActivity().startActivity(intent) if (checkIfPreviousActivityShouldGetFinished(menuItemId)) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } drawerLayout.closeDrawers() } NavigationDrawerItem.DOWNLOADS -> { val intent = MyDownloadsActivity.createMyDownloadsActivityIntent(activity, internalProfileId) - fragment.activity!!.startActivity(intent) + fragment.requireActivity().startActivity(intent) if (checkIfPreviousActivityShouldGetFinished(menuItemId)) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } drawerLayout.closeDrawers() } @@ -412,7 +412,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( ) { override fun onDrawerOpened(drawerView: View) { super.onDrawerOpened(drawerView) - fragment.activity!!.invalidateOptionsMenu() + fragment.requireActivity().invalidateOptionsMenu() StatusBarColor.statusBarColorUpdate( R.color.component_color_shared_slide_drawer_open_status_bar_color, activity, @@ -451,7 +451,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( ) { override fun onDrawerOpened(drawerView: View) { super.onDrawerOpened(drawerView) - fragment.activity!!.invalidateOptionsMenu() + fragment.requireActivity().invalidateOptionsMenu() StatusBarColor.statusBarColorUpdate( R.color.component_color_shared_slide_drawer_open_status_bar_color, activity, @@ -461,7 +461,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( override fun onDrawerClosed(drawerView: View) { super.onDrawerClosed(drawerView) - fragment.activity!!.invalidateOptionsMenu() + fragment.requireActivity().invalidateOptionsMenu() StatusBarColor.statusBarColorUpdate( R.color.component_color_shared_activity_status_bar_color, activity, @@ -473,7 +473,7 @@ class NavigationDrawerFragmentPresenter @Inject constructor( /* Synchronize the state of the drawer indicator/affordance with the linked [drawerLayout]. */ drawerLayout.post { drawerToggle.syncState() } if (previousMenuItemId != NavigationDrawerItem.HOME.ordinal && previousMenuItemId != -1) { - fragment.activity!!.finish() + fragment.requireActivity().finish() } } } diff --git a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt index a0ce5607f6d..3858d9872d8 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt @@ -69,11 +69,6 @@ class HomeActivity : title = resourceHandler.getStringInLocale(R.string.home_activity_title) } - override fun onRestart() { - super.onRestart() - homeActivityPresenter.handleOnRestart() - } - override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) { startActivity( TopicActivity.createTopicActivityIntent(this, internalProfileId, classroomId, topicId) 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 83e65950b7f..b2d6990a902 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 @@ -38,10 +38,6 @@ class HomeActivityPresenter @Inject constructor(private val activity: AppCompatA } } - fun handleOnRestart() { - setUpNavigationDrawer() - } - private fun setUpNavigationDrawer() { val toolbar = activity.findViewById(R.id.home_activity_toolbar) as Toolbar activity.setSupportActionBar(toolbar) diff --git a/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt b/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt index 57e9f72bc8b..ba9d5751e76 100644 --- a/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt +++ b/app/src/main/java/org/oppia/android/app/testing/NavigationDrawerTestActivity.kt @@ -59,11 +59,6 @@ class NavigationDrawerTestActivity : title = resourceHandler.getStringInLocale(R.string.home_activity_title) } - override fun onRestart() { - super.onRestart() - homeActivityPresenter.handleOnRestart() - } - override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) { startActivity( TopicActivity.createTopicActivityIntent(this, internalProfileId, classroomId, topicId) 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 9b778df86f3..e853bff7469 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" /> - - - - - - - - -