mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-17 11:25:34 -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:ShareFiles.kt$ShareFiles$24</ID>
|
||||||
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$5</ID>
|
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$5</ID>
|
||||||
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$500</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:LocalLibraryFragment.kt$LocalLibraryFragment$private fun checkPermissions()</ID>
|
||||||
<ID>NestedBlockDepth:PeerGroupHandshake.kt$PeerGroupHandshake$private fun readHandshakeAndExchangeMetaData(): InetAddress?</ID>
|
<ID>NestedBlockDepth:PeerGroupHandshake.kt$PeerGroupHandshake$private fun readHandshakeAndExchangeMetaData(): InetAddress?</ID>
|
||||||
<ID>NestedBlockDepth:ReceiverHandShake.kt$ReceiverHandShake$override fun exchangeFileTransferMetadata(inputStream: InputStream, outputStream: OutputStream)</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.net.wifi.p2p.WifiP2pDeviceList
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
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.WifiP2pDelegate
|
||||||
import org.kiwix.kiwixmobile.localFileTransfer.adapter.WifiPeerListAdapter
|
import org.kiwix.kiwixmobile.localFileTransfer.adapter.WifiPeerListAdapter
|
||||||
import org.kiwix.kiwixmobile.core.webserver.ZimHostFragment.Companion.PERMISSION_REQUEST_CODE_COARSE_LOCATION
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +88,7 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const val URIS_KEY = "uris"
|
const val URIS_KEY = "uris"
|
||||||
|
const val SHOWCASE_ID = "MaterialShowcaseId"
|
||||||
|
|
||||||
@SuppressLint("GoogleAppIndexingApiWarning", "Registered")
|
@SuppressLint("GoogleAppIndexingApiWarning", "Registered")
|
||||||
class LocalFileTransferFragment :
|
class LocalFileTransferFragment :
|
||||||
@ -104,6 +109,8 @@ class LocalFileTransferFragment :
|
|||||||
private var fileListAdapter: FileListAdapter? = null
|
private var fileListAdapter: FileListAdapter? = null
|
||||||
private var wifiPeerListAdapter: WifiPeerListAdapter? = null
|
private var wifiPeerListAdapter: WifiPeerListAdapter? = null
|
||||||
private var fragmentLocalFileTransferBinding: FragmentLocalFileTransferBinding? = null
|
private var fragmentLocalFileTransferBinding: FragmentLocalFileTransferBinding? = null
|
||||||
|
private var materialShowcaseSequence: MaterialShowcaseSequence? = null
|
||||||
|
private var searchView: View? = null
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
@ -139,6 +146,11 @@ class LocalFileTransferFragment :
|
|||||||
object : MenuProvider {
|
object : MenuProvider {
|
||||||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
menuInflater.inflate(R.menu.wifi_file_share_items, menu)
|
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 {
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
@ -154,8 +166,40 @@ class LocalFileTransferFragment :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onSearchMenuClicked(): Boolean {
|
private fun showCaseFeatureToUsers() {
|
||||||
return when {
|
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() ->
|
!checkFineLocationAccessPermission() ->
|
||||||
true
|
true
|
||||||
!checkExternalStorageWritePermission() ->
|
!checkExternalStorageWritePermission() ->
|
||||||
@ -175,7 +219,6 @@ class LocalFileTransferFragment :
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupPeerDevicesList(activity: CoreMainActivity) {
|
private fun setupPeerDevicesList(activity: CoreMainActivity) {
|
||||||
fragmentLocalFileTransferBinding?.listPeerDevices?.apply {
|
fragmentLocalFileTransferBinding?.listPeerDevices?.apply {
|
||||||
@ -413,6 +456,8 @@ class LocalFileTransferFragment :
|
|||||||
wifiDirectManager.stopWifiDirectManager()
|
wifiDirectManager.stopWifiDirectManager()
|
||||||
wifiDirectManager.callbacks = null
|
wifiDirectManager.callbacks = null
|
||||||
fragmentLocalFileTransferBinding = null
|
fragmentLocalFileTransferBinding = null
|
||||||
|
searchView = null
|
||||||
|
materialShowcaseSequence = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,4 +339,9 @@ object Libs {
|
|||||||
* https://developer.android.com/testing
|
* https://developer.android.com/testing
|
||||||
*/
|
*/
|
||||||
const val junit: String = "androidx.test.ext:junit:" + Versions.junit
|
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 webkit: String = "1.3.0"
|
||||||
|
|
||||||
const val junit: String = "1.1.4"
|
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.rxandroid)
|
||||||
implementation(Libs.rxjava)
|
implementation(Libs.rxjava)
|
||||||
implementation(Libs.preference_ktx)
|
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="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="request_notification_permission_message">To perform this action, please grant notification access</string>
|
||||||
<string name="empty_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>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user