diff --git a/app/detekt_baseline.xml b/app/detekt_baseline.xml index 77857244b0..22d856fb2d 100644 --- a/app/detekt_baseline.xml +++ b/app/detekt_baseline.xml @@ -11,6 +11,7 @@ MagicNumber:ShareFiles.kt$ShareFiles$24 MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$5 MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$500 + MagicNumber:LocalFileTransferFragment.kt$LocalFileTransferFragment$500 NestedBlockDepth:LocalLibraryFragment.kt$LocalLibraryFragment$private fun checkPermissions() NestedBlockDepth:PeerGroupHandshake.kt$PeerGroupHandshake$private fun readHandshakeAndExchangeMetaData(): InetAddress? NestedBlockDepth:ReceiverHandShake.kt$ReceiverHandShake$override fun exchangeFileTransferMetadata(inputStream: InputStream, outputStream: OutputStream) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt index 1a37def4d5..fd987765fc 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt @@ -61,10 +61,12 @@ class DownloadRobot : BaseRobot() { } private fun assertDeleteDialogDisplayed() { + pauseForBetterTestPerformance() onView(withText("DELETE")).check(matches(isDisplayed())) } private fun clickOnDeleteZimFile() { + pauseForBetterTestPerformance() onView(withText("DELETE")).perform(click()) } @@ -73,9 +75,8 @@ class DownloadRobot : BaseRobot() { longClickOnZimFile() clickOnFileDeleteIcon() assertDeleteDialogDisplayed() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOnDeleteZimFile() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + pauseForBetterTestPerformance() } catch (e: Exception) { if (shouldDeleteZimFile) { throw Exception( @@ -122,12 +123,16 @@ class DownloadRobot : BaseRobot() { } } + private fun stopDownload() { + clickOn(ViewId(R.id.stop)) + } + fun pauseDownload() { clickOn(ViewId(R.id.pauseResume)) } fun assertDownloadPaused() { - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + pauseForBetterTestPerformance() onView(withText(org.kiwix.kiwixmobile.core.R.string.paused_state)).check(matches(isDisplayed())) } @@ -136,7 +141,7 @@ class DownloadRobot : BaseRobot() { } fun assertDownloadResumed() { - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + pauseForBetterTestPerformance() onView(withText(org.kiwix.kiwixmobile.core.R.string.paused_state)).check(doesNotExist()) } @@ -150,4 +155,34 @@ class DownloadRobot : BaseRobot() { waitUntilDownloadComplete() } } + + private fun pauseForBetterTestPerformance() { + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + } + + private fun assertStopDownloadDialogDisplayed() { + pauseForBetterTestPerformance() + isVisible(Text("Stop download?")) + } + + private fun clickOnYesButton() { + onView(withText("YES")).perform(click()) + } + + fun stopDownloadIfAlreadyStarted() { + try { + pauseForBetterTestPerformance() + onView(withId(R.id.stop)).check(matches(isDisplayed())) + stopDownload() + assertStopDownloadDialogDisplayed() + clickOnYesButton() + pauseForBetterTestPerformance() + } catch (e: Exception) { + Log.i( + "DOWNLOAD_TEST", + "Failed to stop download with title [" + zimFileTitle + "]... " + + "Probably because it doesn't download the zim file" + ) + } + } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt index f941b4a550..4d2db7b406 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt @@ -88,6 +88,7 @@ class DownloadTest : BaseActivityTest() { deleteZimIfExists(false) clickDownloadOnBottomNav() waitForDataToLoad() + stopDownloadIfAlreadyStarted() downloadZimFile() assertDownloadStart() pauseDownload() diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt index 0bfd9ad1d6..f73a69fb03 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt @@ -66,10 +66,12 @@ class InitialDownloadRobot : BaseRobot() { } private fun assertDeleteDialogDisplayed() { + pauseForBetterTestPerformance() onView(withText("DELETE")).check(matches(isDisplayed())) } private fun clickOnDeleteZimFile() { + pauseForBetterTestPerformance() onView(withText("DELETE")).perform(click()) } @@ -78,9 +80,8 @@ class InitialDownloadRobot : BaseRobot() { longClickOnZimFile() clickOnFileDeleteIcon() assertDeleteDialogDisplayed() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOnDeleteZimFile() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + pauseForBetterTestPerformance() } catch (e: Exception) { Log.i( "TEST_DELETE_ZIM", @@ -144,4 +145,25 @@ class InitialDownloadRobot : BaseRobot() { assertDownloadStop() } } + + private fun pauseForBetterTestPerformance() { + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + } + + fun stopDownloadIfAlreadyStarted() { + try { + pauseForBetterTestPerformance() + onView(withId(R.id.stop)).check(matches(isDisplayed())) + stopDownload() + assertStopDownloadDialogDisplayed() + clickOnYesToConfirm() + pauseForBetterTestPerformance() + } catch (e: Exception) { + Log.i( + "INITIAL_DOWNLOAD_TEST", + "Failed to stop download with title [" + zimFileTitle + "]... " + + "Probably because it doesn't download the zim file" + ) + } + } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt index 826eeed20d..eb7531ec27 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadTest.kt @@ -80,6 +80,7 @@ class InitialDownloadTest : BaseActivityTest() { assertLibraryListDisplayed() refreshList() waitForDataToLoad() + stopDownloadIfAlreadyStarted() downloadZimFile() assertStorageConfigureDialogDisplayed() clickOnYesToConfirm() diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt index 5dff8b703f..3c6506fe49 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt @@ -24,12 +24,14 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.isChecked import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import applyWithViewHierarchyPrinting +import com.adevinta.android.barista.interaction.BaristaSleepInteractions import junit.framework.AssertionFailedError import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable import org.kiwix.kiwixmobile.Findable.Text import org.kiwix.kiwixmobile.Findable.ViewId import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.testutils.TestUtils import org.kiwix.kiwixmobile.utils.RecyclerViewMatcher fun language(func: LanguageRobot.() -> Unit) = LanguageRobot().applyWithViewHierarchyPrinting(func) @@ -54,6 +56,8 @@ class LanguageRobot : BaseRobot() { } fun clickOnLanguageIcon() { + // Wait for a few seconds to properly saved selected language. + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOn(ViewId(R.id.select_language)) } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferRobot.kt index 153c41a8cf..261966fd85 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferRobot.kt @@ -18,11 +18,14 @@ package org.kiwix.kiwixmobile.localFileTransfer +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist +import androidx.test.espresso.matcher.ViewMatchers.withText import applyWithViewHierarchyPrinting import com.adevinta.android.barista.interaction.BaristaSleepInteractions import org.kiwix.kiwixmobile.BaseRobot -import org.kiwix.kiwixmobile.Findable.ViewId import org.kiwix.kiwixmobile.Findable.StringId.TextId +import org.kiwix.kiwixmobile.Findable.ViewId import org.kiwix.kiwixmobile.R import org.kiwix.kiwixmobile.testutils.TestUtils @@ -55,4 +58,38 @@ class LocalFileTransferRobot : BaseRobot() { fun assertLocalLibraryVisible() { isVisible(TextId(R.string.library)) } + + fun assertClickNearbyDeviceMessageVisible() { + pauseForBetterTestPerformance() + isVisible(TextId(R.string.click_nearby_devices_message)) + } + + fun clickOnGotItButton() { + pauseForBetterTestPerformance() + clickOn(TextId(R.string.got_it)) + } + + fun assertDeviceNameMessageVisible() { + pauseForBetterTestPerformance() + isVisible(TextId(R.string.your_device_name_message)) + } + + fun assertNearbyDeviceListMessageVisible() { + pauseForBetterTestPerformance() + isVisible(TextId(R.string.nearby_devices_list_message)) + } + + fun assertTransferZimFilesListMessageVisible() { + pauseForBetterTestPerformance() + isVisible(TextId(R.string.transfer_zim_files_list_message)) + } + + fun assertClickNearbyDeviceMessageNotVisible() { + pauseForBetterTestPerformance() + onView(withText(R.string.click_nearby_devices_message)).check(doesNotExist()) + } + + private fun pauseForBetterTestPerformance() { + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt index 0f88eb81ca..c27e3f0770 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferTest.kt @@ -80,18 +80,14 @@ class LocalFileTransferTest { } waitForIdle() } - PreferenceManager.getDefaultSharedPreferences(context).edit { - putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) - putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) - putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) - } - activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { - moveToState(Lifecycle.State.RESUMED) - } } @Test fun localFileTransfer() { + shouldShowShowCaseFeatureToUser(false) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) { activityScenario.onActivity { it.navigate(R.id.libraryFragment) @@ -111,10 +107,69 @@ class LocalFileTransferTest { } } + @Test + fun showCaseFeature() { + shouldShowShowCaseFeatureToUser(true, isResetShowCaseId = true) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + onActivity { + it.navigate(R.id.libraryFragment) + } + } + library { + assertGetZimNearbyDeviceDisplayed() + clickFileTransferIcon { + assertClickNearbyDeviceMessageVisible() + clickOnGotItButton() + assertDeviceNameMessageVisible() + clickOnGotItButton() + assertNearbyDeviceListMessageVisible() + clickOnGotItButton() + assertTransferZimFilesListMessageVisible() + clickOnGotItButton() + pressBack() + assertGetZimNearbyDeviceDisplayed() + } + } + LeakAssertions.assertNoLeaks() + } + + @Test + fun testShowCaseFeatureShowOnce() { + shouldShowShowCaseFeatureToUser(true) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + onActivity { + it.navigate(R.id.libraryFragment) + } + } + library { + // test show case view show once. + clickFileTransferIcon(LocalFileTransferRobot::assertClickNearbyDeviceMessageNotVisible) + } + } + @After fun setIsTestPreference() { PreferenceManager.getDefaultSharedPreferences(context).edit { putBoolean(SharedPreferenceUtil.PREF_IS_TEST, false) + putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, true) + } + } + + private fun shouldShowShowCaseFeatureToUser( + shouldShowShowCase: Boolean, + isResetShowCaseId: Boolean = false + ) { + PreferenceManager.getDefaultSharedPreferences(context).edit { + putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false) + putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) + putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) + putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, shouldShowShowCase) + } + if (isResetShowCaseId) { + // To clear showCaseID to ensure the showcase view will show. + uk.co.deanwild.materialshowcaseview.PrefsManager.resetAll(context) } } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt index 5aaa492a1d..147dd0313f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt @@ -60,6 +60,7 @@ class TopLevelDestinationTest : BaseActivityTest() { putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true) putBoolean(SharedPreferenceUtil.PREF_EXTERNAL_LINK_POPUP, true) + putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, false) } activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { moveToState(Lifecycle.State.RESUMED) @@ -100,6 +101,7 @@ class TopLevelDestinationTest : BaseActivityTest() { fun setIsTestPreference() { PreferenceManager.getDefaultSharedPreferences(context).edit { putBoolean(SharedPreferenceUtil.PREF_IS_TEST, false) + putBoolean(SharedPreferenceUtil.PREF_SHOW_SHOWCASE, true) } } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryRobot.kt index 4d43e16704..c1691b8eeb 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryRobot.kt @@ -54,6 +54,7 @@ class LibraryRobot : BaseRobot() { } fun assertNoFilesTextDisplayed() { + pauseForBetterTestPerformance() isVisible(ViewId(R.id.file_management_no_files)) } @@ -62,9 +63,8 @@ class LibraryRobot : BaseRobot() { longClickOnZimFile() clickOnFileDeleteIcon() assertDeleteDialogDisplayed() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOnDeleteZimFile() - BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + pauseForBetterTestPerformance() } catch (e: Exception) { Log.i( "TEST_DELETE_ZIM", @@ -79,6 +79,7 @@ class LibraryRobot : BaseRobot() { } private fun assertDeleteDialogDisplayed() { + pauseForBetterTestPerformance() onView(withText("DELETE")) .check(ViewAssertions.matches(isDisplayed())) } @@ -88,6 +89,11 @@ class LibraryRobot : BaseRobot() { } private fun clickOnDeleteZimFile() { + pauseForBetterTestPerformance() onView(withText("DELETE")).perform(click()) } + + private fun pauseForBetterTestPerformance() { + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) + } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferFragment.kt index a5511b6340..ea3211e689 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/localFileTransfer/LocalFileTransferFragment.kt @@ -33,6 +33,8 @@ import android.net.wifi.p2p.WifiP2pDevice import android.net.wifi.p2p.WifiP2pDeviceList import android.os.Build import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.provider.Settings import android.util.Log import android.view.LayoutInflater @@ -67,6 +69,8 @@ import org.kiwix.kiwixmobile.localFileTransfer.WifiDirectManager.Companion.getDe import org.kiwix.kiwixmobile.localFileTransfer.adapter.WifiP2pDelegate import org.kiwix.kiwixmobile.localFileTransfer.adapter.WifiPeerListAdapter import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment.Companion.PERMISSION_REQUEST_CODE_COARSE_LOCATION +import uk.co.deanwild.materialshowcaseview.MaterialShowcaseSequence +import uk.co.deanwild.materialshowcaseview.ShowcaseConfig import javax.inject.Inject /** @@ -84,6 +88,7 @@ import javax.inject.Inject */ const val URIS_KEY = "uris" +const val SHOWCASE_ID = "MaterialShowcaseId" @SuppressLint("GoogleAppIndexingApiWarning", "Registered") class LocalFileTransferFragment : @@ -104,6 +109,8 @@ class LocalFileTransferFragment : private var fileListAdapter: FileListAdapter? = null private var wifiPeerListAdapter: WifiPeerListAdapter? = null private var fragmentLocalFileTransferBinding: FragmentLocalFileTransferBinding? = null + private var materialShowCaseSequence: MaterialShowcaseSequence? = null + private var searchIconView: View? = null override fun onCreateView( inflater: LayoutInflater, @@ -139,31 +146,19 @@ class LocalFileTransferFragment : object : MenuProvider { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { menuInflater.inflate(R.menu.wifi_file_share_items, menu) + if (sharedPreferenceUtil.prefShowShowCaseToUser) { + Handler(Looper.getMainLooper()).post { + searchIconView = + fragmentLocalFileTransferBinding?.root?.findViewById(R.id.menu_item_search_devices) + showCaseFeatureToUsers() + } + } } override fun onMenuItemSelected(menuItem: MenuItem): Boolean { if (menuItem.itemId == R.id.menu_item_search_devices) { /* Permissions essential for this module */ - return when { - !checkFineLocationAccessPermission() -> - true - !checkExternalStorageWritePermission() -> - true - /* Initiate discovery */ - !wifiDirectManager.isWifiP2pEnabled -> { - requestEnableWifiP2pServices() - true - } - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isLocationServiceEnabled -> { - requestEnableLocationServices() - true - } - else -> { - showPeerDiscoveryProgressBar() - wifiDirectManager.discoverPeerDevices() - true - } - } + return onSearchMenuClicked() } return false } @@ -173,6 +168,69 @@ class LocalFileTransferFragment : ) } + private fun showCaseFeatureToUsers() { + searchIconView?.let { + materialShowCaseSequence = MaterialShowcaseSequence(activity, SHOWCASE_ID).apply { + val config = ShowcaseConfig().apply { + delay = 500 // half second between each showcase view + } + setConfig(config) + addSequenceItem( + it, + getString(R.string.click_nearby_devices_message), + getString(R.string.got_it) + ) + addSequenceItem( + fragmentLocalFileTransferBinding?.textViewDeviceName, + getString(R.string.your_device_name_message), + getString(R.string.got_it) + ) + addSequenceItem( + fragmentLocalFileTransferBinding?.listPeerDevices, + getString(R.string.nearby_devices_list_message), + getString(R.string.got_it) + ) + addSequenceItem( + fragmentLocalFileTransferBinding?.recyclerViewTransferFiles, + getString(R.string.transfer_zim_files_list_message), + getString(R.string.got_it) + ) + setOnItemDismissedListener { showcaseView, _ -> + // To fix the memory leak by setting setTarget to null + // because the memory leak occurred inside the library. + // They had forgotten to detach the view after its successful use, + // so it holds the reference of these views in memory. + // By setting these views as null we remove the reference from + // the memory after they are successfully shown. + showcaseView.setTarget(null) + } + start() + } + } + } + + private fun onSearchMenuClicked(): Boolean = + when { + !checkFineLocationAccessPermission() -> + true + !checkExternalStorageWritePermission() -> + true + /* Initiate discovery */ + !wifiDirectManager.isWifiP2pEnabled -> { + requestEnableWifiP2pServices() + true + } + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isLocationServiceEnabled -> { + requestEnableLocationServices() + true + } + else -> { + showPeerDiscoveryProgressBar() + wifiDirectManager.discoverPeerDevices() + true + } + } + private fun setupPeerDevicesList(activity: CoreMainActivity) { fragmentLocalFileTransferBinding?.listPeerDevices?.apply { adapter = wifiPeerListAdapter @@ -343,6 +401,15 @@ class LocalFileTransferFragment : else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults) } + } else if (grantResults[0] == PERMISSION_GRANTED) { + when (requestCode) { + PERMISSION_REQUEST_FINE_LOCATION, + PERMISSION_REQUEST_CODE_STORAGE_WRITE_ACCESS -> { + onSearchMenuClicked() + } + else -> + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + } } } @@ -400,6 +467,8 @@ class LocalFileTransferFragment : wifiDirectManager.stopWifiDirectManager() wifiDirectManager.callbacks = null fragmentLocalFileTransferBinding = null + searchIconView = null + materialShowCaseSequence = null super.onDestroyView() } diff --git a/app/src/main/res/layout/fragment_local_file_transfer.xml b/app/src/main/res/layout/fragment_local_file_transfer.xml index 766b36a3a7..d8eb2e4fa4 100644 --- a/app/src/main/res/layout/fragment_local_file_transfer.xml +++ b/app/src/main/res/layout/fragment_local_file_transfer.xml @@ -50,7 +50,7 @@ Go to Settings To perform this action, please grant notification access + Click here to search for nearby devices. + Your device name will appear here. + Here, you\'ll find a list of nearby devices. Tap on a device\'s name to initiate file transfer. + Here, you\'ll find the list of available ZIM files for transfer.