mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-16 10:56:50 -04:00
Introduce 'MaterialShowCase' feature to provide user education on the file transfer functionality.
This commit is contained in:
parent
c81ae5d730
commit
a8b41f5b15
@ -11,6 +11,7 @@
|
||||
<ID>MagicNumber:ShareFiles.kt$ShareFiles$24</ID>
|
||||
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$5</ID>
|
||||
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$500</ID>
|
||||
<ID>MagicNumber:LocalFileTransferFragment.kt$LocalFileTransferFragment$500</ID>
|
||||
<ID>NestedBlockDepth:LocalLibraryFragment.kt$LocalLibraryFragment$private fun checkPermissions()</ID>
|
||||
<ID>NestedBlockDepth:PeerGroupHandshake.kt$PeerGroupHandshake$private fun readHandshakeAndExchangeMetaData(): InetAddress?</ID>
|
||||
<ID>NestedBlockDepth:ReceiverHandShake.kt$ReceiverHandShake$override fun exchangeFileTransferMetadata(inputStream: InputStream, outputStream: OutputStream)</ID>
|
||||
|
@ -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 searchView: View? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@ -139,6 +146,11 @@ class LocalFileTransferFragment :
|
||||
object : MenuProvider {
|
||||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||
menuInflater.inflate(R.menu.wifi_file_share_items, menu)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
searchView =
|
||||
fragmentLocalFileTransferBinding?.root?.findViewById(R.id.menu_item_search_devices)
|
||||
showCaseFeatureToUsers()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
@ -154,8 +166,40 @@ class LocalFileTransferFragment :
|
||||
)
|
||||
}
|
||||
|
||||
private fun onSearchMenuClicked(): Boolean {
|
||||
return when {
|
||||
private fun showCaseFeatureToUsers() {
|
||||
searchView?.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)
|
||||
)
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSearchMenuClicked(): Boolean =
|
||||
when {
|
||||
!checkFineLocationAccessPermission() ->
|
||||
true
|
||||
!checkExternalStorageWritePermission() ->
|
||||
@ -175,7 +219,6 @@ class LocalFileTransferFragment :
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPeerDevicesList(activity: CoreMainActivity) {
|
||||
fragmentLocalFileTransferBinding?.listPeerDevices?.apply {
|
||||
@ -413,6 +456,8 @@ class LocalFileTransferFragment :
|
||||
wifiDirectManager.stopWifiDirectManager()
|
||||
wifiDirectManager.callbacks = null
|
||||
fragmentLocalFileTransferBinding = null
|
||||
searchView = null
|
||||
materialShowcaseSequence = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
@ -339,4 +339,9 @@ object Libs {
|
||||
* https://developer.android.com/testing
|
||||
*/
|
||||
const val junit: String = "androidx.test.ext:junit:" + Versions.junit
|
||||
|
||||
/**
|
||||
* https://github.com/deano2390/MaterialShowcaseView
|
||||
*/
|
||||
const val material_show_case_view: String = "com.github.deano2390:MaterialShowcaseView:" + Versions.material_show_case_view
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ object Versions {
|
||||
const val webkit: String = "1.3.0"
|
||||
|
||||
const val junit: String = "1.1.4"
|
||||
|
||||
const val material_show_case_view: String = "1.3.7"
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,6 +207,7 @@ class AllProjectConfigurer {
|
||||
implementation(Libs.rxandroid)
|
||||
implementation(Libs.rxjava)
|
||||
implementation(Libs.preference_ktx)
|
||||
implementation(Libs.material_show_case_view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,4 +342,8 @@
|
||||
<string name="go_to_settings_label">Go to Settings</string>
|
||||
<string name="request_notification_permission_message">To perform this action, please grant notification access</string>
|
||||
<string name="empty_string" />
|
||||
<string name="click_nearby_devices_message">Click here to search for nearby devices.</string>
|
||||
<string name="your_device_name_message">Your device name will appear here.</string>
|
||||
<string name="nearby_devices_list_message">Here, you\'ll find a list of nearby devices. Tap on a device\'s name to initiate file transfer.</string>
|
||||
<string name="transfer_zim_files_list_message">Here, you\'ll find the list of available ZIM files for transfer.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user