Add connect another device dialog (#2803)
parent
2ad3a72f6f
commit
3c84807474
|
@ -65,7 +65,6 @@ class AccountDevicesShareAdapter(
|
||||||
|
|
||||||
if (shareableDevices.isEmpty()) {
|
if (shareableDevices.isEmpty()) {
|
||||||
list.add(SyncShareOption.AddNewDevice)
|
list.add(SyncShareOption.AddNewDevice)
|
||||||
actionEmitter.onNext(ShareAction.HideSendTab)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val shareOptions = shareableDevices.map {
|
val shareOptions = shareableDevices.map {
|
||||||
|
|
|
@ -23,7 +23,6 @@ sealed class ShareAction : Action {
|
||||||
object Close : ShareAction()
|
object Close : ShareAction()
|
||||||
object SignInClicked : ShareAction()
|
object SignInClicked : ShareAction()
|
||||||
object AddNewDeviceClicked : ShareAction()
|
object AddNewDeviceClicked : ShareAction()
|
||||||
object HideSendTab : ShareAction()
|
|
||||||
data class ShareDeviceClicked(val device: Device) : ShareAction()
|
data class ShareDeviceClicked(val device: Device) : ShareAction()
|
||||||
data class SendAllClicked(val devices: List<Device>) : ShareAction()
|
data class SendAllClicked(val devices: List<Device>) : ShareAction()
|
||||||
data class ShareAppClicked(val packageName: String) : 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.EXTRA_TEXT
|
||||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment
|
import androidx.appcompat.app.AppCompatDialogFragment
|
||||||
import androidx.navigation.fragment.NavHostFragment.findNavController
|
import androidx.navigation.fragment.NavHostFragment.findNavController
|
||||||
import kotlinx.android.synthetic.main.component_share.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_share.view.*
|
import kotlinx.android.synthetic.main.fragment_share.view.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -81,12 +82,19 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
||||||
ShareAction.SignInClicked -> {
|
ShareAction.SignInClicked -> {
|
||||||
val directions = ShareFragmentDirections.actionShareFragmentToTurnOnSyncFragment()
|
val directions = ShareFragmentDirections.actionShareFragmentToTurnOnSyncFragment()
|
||||||
findNavController(this@ShareFragment).navigate(directions)
|
findNavController(this@ShareFragment).navigate(directions)
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
ShareAction.AddNewDeviceClicked -> {
|
ShareAction.AddNewDeviceClicked -> {
|
||||||
requireComponents.useCases.tabsUseCases.addTab.invoke(ADD_NEW_DEVICES_URL, true)
|
AlertDialog.Builder(
|
||||||
}
|
ContextThemeWrapper(
|
||||||
ShareAction.HideSendTab -> {
|
context,
|
||||||
send_tab_group.visibility = View.GONE
|
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 -> {
|
is ShareAction.ShareDeviceClicked -> {
|
||||||
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
||||||
|
@ -96,6 +104,7 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
||||||
DeviceEventOutgoing.SendTab(title, url)
|
DeviceEventOutgoing.SendTab(title, url)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
is ShareAction.SendAllClicked -> {
|
is ShareAction.SendAllClicked -> {
|
||||||
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
val authAccount = requireComponents.backgroundServices.accountManager.authenticatedAccount()
|
||||||
|
@ -107,6 +116,7 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
is ShareAction.ShareAppClicked -> {
|
is ShareAction.ShareAppClicked -> {
|
||||||
val intent = Intent(ACTION_SEND).apply {
|
val intent = Intent(ACTION_SEND).apply {
|
||||||
|
@ -116,14 +126,9 @@ class ShareFragment : AppCompatDialogFragment(), CoroutineScope {
|
||||||
`package` = it.packageName
|
`package` = it.packageName
|
||||||
}
|
}
|
||||||
startActivity(intent)
|
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>
|
<string name="sync_offline">Offline</string>
|
||||||
<!-- An option to connect additional devices -->
|
<!-- An option to connect additional devices -->
|
||||||
<string name="sync_connect_device">Connect another device</string>
|
<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 -->
|
<!-- Notifications -->
|
||||||
<!-- Text shown in snackbar when user deletes a collection -->
|
<!-- Text shown in snackbar when user deletes a collection -->
|
||||||
|
|
Loading…
Reference in New Issue