Add connect another device dialog (#2803)
parent
2ad3a72f6f
commit
3c84807474
|
@ -65,7 +65,6 @@ class AccountDevicesShareAdapter(
|
|||
|
||||
if (shareableDevices.isEmpty()) {
|
||||
list.add(SyncShareOption.AddNewDevice)
|
||||
actionEmitter.onNext(ShareAction.HideSendTab)
|
||||
}
|
||||
|
||||
val shareOptions = shareableDevices.map {
|
||||
|
|
|
@ -23,7 +23,6 @@ sealed class ShareAction : Action {
|
|||
object Close : ShareAction()
|
||||
object SignInClicked : ShareAction()
|
||||
object AddNewDeviceClicked : ShareAction()
|
||||
object HideSendTab : ShareAction()
|
||||
data class ShareDeviceClicked(val device: Device) : ShareAction()
|
||||
data class SendAllClicked(val devices: List<Device>) : ShareAction()
|
||||
data class ShareAppClicked(val packageName: String) : ShareAction()
|
||||
|
|
|
@ -9,12 +9,13 @@ import android.content.Intent.ACTION_SEND
|
|||
import android.content.Intent.EXTRA_TEXT
|
||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
import android.os.Bundle
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import androidx.navigation.fragment.NavHostFragment.findNavController
|
||||
import kotlinx.android.synthetic.main.component_share.*
|
||||
import kotlinx.android.synthetic.main.fragment_share.view.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -81,12 +82,19 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
|||
ShareAction.SignInClicked -> {
|
||||
val directions = ShareFragmentDirections.actionShareFragmentToTurnOnSyncFragment()
|
||||
findNavController(this@ShareFragment).navigate(directions)
|
||||
dismiss()
|
||||
}
|
||||
ShareAction.AddNewDeviceClicked -> {
|
||||
requireComponents.useCases.tabsUseCases.addTab.invoke(ADD_NEW_DEVICES_URL, true)
|
||||
}
|
||||
ShareAction.HideSendTab -> {
|
||||
send_tab_group.visibility = View.GONE
|
||||
AlertDialog.Builder(
|
||||
ContextThemeWrapper(
|
||||
context,
|
||||
R.style.DialogStyle
|
||||
)
|
||||
).apply {
|
||||
setMessage(R.string.sync_connect_device_dialog)
|
||||
setPositiveButton(R.string.sync_confirmation_button) { dialog, _ -> dialog.cancel() }
|
||||
create()
|
||||
}.show()
|
||||
}
|
||||
is ShareAction.ShareDeviceClicked -> {
|
||||
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
||||
|
@ -96,6 +104,7 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
|||
DeviceEventOutgoing.SendTab(title, url)
|
||||
)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
is ShareAction.SendAllClicked -> {
|
||||
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
||||
|
@ -107,6 +116,7 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
|||
)
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
is ShareAction.ShareAppClicked -> {
|
||||
val intent = Intent(ACTION_SEND).apply {
|
||||
|
@ -116,14 +126,9 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
|||
`package` = it.packageName
|
||||
}
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
// TODO Replace this link with the correct one when provided.
|
||||
const val ADD_NEW_DEVICES_URL = "https://accounts.firefox.com/connect_another_device"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -508,6 +508,10 @@
|
|||
<string name="sync_offline">Offline</string>
|
||||
<!-- An option to connect additional devices -->
|
||||
<string name="sync_connect_device">Connect another device</string>
|
||||
<!-- The dialog text shown when additional devices are not available -->
|
||||
<string name="sync_connect_device_dialog">To send a tab, sign in to Firefox on at least one other device.</string>
|
||||
<!-- Confirmation dialog button -->
|
||||
<string name="sync_confirmation_button">Got it</string>
|
||||
|
||||
<!-- Notifications -->
|
||||
<!-- Text shown in snackbar when user deletes a collection -->
|
||||
|
|
Loading…
Reference in New Issue