[fenix] Add custom share sheet and send tab support (https://github.com/mozilla-mobile/fenix/pull/2757)
* Closes https://github.com/mozilla-mobile/fenix/issues/2751: Add custom app share sheet * Closes https://github.com/mozilla-mobile/fenix/issues/2753: Add send tab devices to share sheet * Closes https://github.com/mozilla-mobile/fenix/issues/2752: Add build flag for send tab * Replace Context.share with ShareFragmentpull/600/head
parent
b74a413e08
commit
fb1ef670ba
@ -0,0 +1,163 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.share
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observer
|
||||
import kotlinx.android.synthetic.main.account_share_list_item.view.*
|
||||
import mozilla.components.concept.sync.Device
|
||||
import mozilla.components.concept.sync.DeviceCapability
|
||||
import mozilla.components.concept.sync.DeviceType
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
|
||||
class AccountDevicesShareRecyclerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RecyclerView(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
}
|
||||
|
||||
class AccountDevicesShareAdapter(
|
||||
private val context: Context,
|
||||
val actionEmitter: Observer<ShareAction>
|
||||
) : RecyclerView.Adapter<AccountDeviceViewHolder>() {
|
||||
|
||||
private val devices = buildDeviceList()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountDeviceViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(AccountDeviceViewHolder.LAYOUT_ID, parent, false)
|
||||
return AccountDeviceViewHolder(view, actionEmitter)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = devices.size
|
||||
|
||||
override fun onBindViewHolder(holder: AccountDeviceViewHolder, position: Int) {
|
||||
holder.bind(devices[position])
|
||||
}
|
||||
|
||||
private fun buildDeviceList(): List<SyncShareOption> {
|
||||
val list = mutableListOf<SyncShareOption>()
|
||||
val accountManager = context.components.backgroundServices.accountManager
|
||||
|
||||
if (accountManager.authenticatedAccount() == null) {
|
||||
list.add(SyncShareOption.SignIn)
|
||||
return list
|
||||
}
|
||||
|
||||
list.add(SyncShareOption.AddNewDevice)
|
||||
|
||||
accountManager.authenticatedAccount()?.deviceConstellation()?.state()?.otherDevices?.let { devices ->
|
||||
val shareableDevices = devices
|
||||
.filter {
|
||||
it.capabilities.contains(DeviceCapability.SEND_TAB)
|
||||
}
|
||||
val shareOptions = shareableDevices.map {
|
||||
when (it.deviceType) {
|
||||
DeviceType.MOBILE -> SyncShareOption.Mobile(it.displayName, it)
|
||||
else -> SyncShareOption.Desktop(it.displayName, it)
|
||||
}
|
||||
}
|
||||
list.addAll(shareOptions)
|
||||
|
||||
if (shareableDevices.size > 1) {
|
||||
list.add(SyncShareOption.SendAll(shareableDevices))
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
class AccountDeviceViewHolder(
|
||||
itemView: View,
|
||||
actionEmitter: Observer<ShareAction>
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val context: Context = itemView.context
|
||||
private var action: ShareAction? = null
|
||||
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
action?.let { actionEmitter.onNext(it) }
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(option: SyncShareOption) {
|
||||
val (name, drawableRes, colorRes) = when (option) {
|
||||
SyncShareOption.SignIn -> {
|
||||
action = ShareAction.SignInClicked
|
||||
Triple(
|
||||
context.getText(R.string.sync_sign_in),
|
||||
R.drawable.mozac_ic_sync,
|
||||
R.color.default_share_background
|
||||
)
|
||||
}
|
||||
SyncShareOption.AddNewDevice -> {
|
||||
action = ShareAction.AddNewDeviceClicked
|
||||
Triple(
|
||||
context.getText(R.string.sync_connect_device),
|
||||
R.drawable.mozac_ic_new,
|
||||
R.color.default_share_background
|
||||
)
|
||||
}
|
||||
is SyncShareOption.SendAll -> {
|
||||
action = ShareAction.SendAllClicked(option.devices)
|
||||
Triple(
|
||||
context.getText(R.string.sync_send_to_all),
|
||||
R.drawable.mozac_ic_select_all,
|
||||
R.color.default_share_background
|
||||
)
|
||||
}
|
||||
is SyncShareOption.Mobile -> {
|
||||
action = ShareAction.ShareDeviceClicked(option.device)
|
||||
Triple(
|
||||
option.name,
|
||||
R.drawable.mozac_ic_device_mobile,
|
||||
R.color.device_type_mobile_background
|
||||
)
|
||||
}
|
||||
is SyncShareOption.Desktop -> {
|
||||
action = ShareAction.ShareDeviceClicked(option.device)
|
||||
Triple(
|
||||
option.name,
|
||||
R.drawable.mozac_ic_device_desktop,
|
||||
R.color.device_type_desktop_background
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
itemView.device_icon.apply {
|
||||
setImageResource(drawableRes)
|
||||
background.setColorFilter(ContextCompat.getColor(context, colorRes), PorterDuff.Mode.SRC_IN)
|
||||
drawable.setTint(ContextCompat.getColor(context, R.color.device_foreground))
|
||||
}
|
||||
itemView.device_name.text = name
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.account_share_list_item
|
||||
}
|
||||
}
|
||||
|
||||
sealed class SyncShareOption {
|
||||
object SignIn : SyncShareOption()
|
||||
object AddNewDevice : SyncShareOption()
|
||||
data class SendAll(val devices: List<Device>) : SyncShareOption()
|
||||
data class Mobile(val name: String, val device: Device) : SyncShareOption()
|
||||
data class Desktop(val name: String, val device: Device) : SyncShareOption()
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.share
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_SEND
|
||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observer
|
||||
import kotlinx.android.synthetic.main.app_share_list_item.view.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.mozilla.fenix.R
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class AppShareRecyclerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RecyclerView(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
layoutManager = GridLayoutManager(context, 2, GridLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
}
|
||||
|
||||
class AppShareAdapter(
|
||||
private val context: Context,
|
||||
val actionEmitter: Observer<ShareAction>,
|
||||
private val intentType: String = "text/plain"
|
||||
) : RecyclerView.Adapter<AppShareItemViewHolder>(), CoroutineScope {
|
||||
|
||||
private var job: Job = Job()
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.IO + job
|
||||
private var size: Int = 0
|
||||
private val shareItems: MutableList<ShareItem> = mutableListOf()
|
||||
|
||||
init {
|
||||
val testIntent = Intent(ACTION_SEND).apply {
|
||||
type = intentType
|
||||
flags = FLAG_ACTIVITY_NEW_TASK
|
||||
}
|
||||
|
||||
launch {
|
||||
val activities = context.packageManager.queryIntentActivities(testIntent, 0)
|
||||
|
||||
val items = activities.map { resolveInfo ->
|
||||
ShareItem(
|
||||
resolveInfo.loadLabel(context.packageManager).toString(),
|
||||
resolveInfo.loadIcon(context.packageManager),
|
||||
resolveInfo.activityInfo.packageName
|
||||
)
|
||||
}
|
||||
|
||||
size = activities.size
|
||||
shareItems.addAll(items)
|
||||
|
||||
// Notify adapter on the UI thread when the dataset is populated.
|
||||
withContext(Dispatchers.Main) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AppShareItemViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(AppShareItemViewHolder.LAYOUT_ID, parent, false)
|
||||
return AppShareItemViewHolder(view, actionEmitter)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = size
|
||||
|
||||
override fun onBindViewHolder(holder: AppShareItemViewHolder, position: Int) {
|
||||
holder.bind(shareItems[position])
|
||||
}
|
||||
|
||||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView)
|
||||
job = Job()
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView)
|
||||
job.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
class AppShareItemViewHolder(
|
||||
itemView: View,
|
||||
actionEmitter: Observer<ShareAction>
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private var shareItem: ShareItem? = null
|
||||
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
Log.d("Jonathan", "${shareItem?.name} clicked.")
|
||||
shareItem?.let {
|
||||
actionEmitter.onNext(ShareAction.ShareAppClicked(it.packageName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun bind(item: ShareItem) {
|
||||
shareItem = item
|
||||
itemView.app_name.text = item.name
|
||||
itemView.app_icon.setImageDrawable(item.icon)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.app_share_list_item
|
||||
}
|
||||
}
|
||||
|
||||
data class ShareItem(val name: String, val icon: Drawable, val packageName: String)
|
@ -0,0 +1,56 @@
|
||||
package org.mozilla.fenix.share
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import android.view.ViewGroup
|
||||
import mozilla.components.concept.sync.Device
|
||||
import org.mozilla.fenix.mvi.Action
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
import org.mozilla.fenix.mvi.Change
|
||||
import org.mozilla.fenix.mvi.Reducer
|
||||
import org.mozilla.fenix.mvi.UIComponent
|
||||
import org.mozilla.fenix.mvi.UIComponentViewModelBase
|
||||
import org.mozilla.fenix.mvi.UIComponentViewModelProvider
|
||||
import org.mozilla.fenix.mvi.ViewState
|
||||
|
||||
object ShareState : ViewState
|
||||
|
||||
sealed class ShareChange : Change
|
||||
|
||||
sealed class ShareAction : Action {
|
||||
object Close : ShareAction()
|
||||
object SignInClicked : ShareAction()
|
||||
object AddNewDeviceClicked : ShareAction()
|
||||
data class ShareDeviceClicked(val device: Device) : ShareAction()
|
||||
data class SendAllClicked(val devices: List<Device>) : ShareAction()
|
||||
data class ShareAppClicked(val packageName: String) : ShareAction()
|
||||
}
|
||||
|
||||
class ShareComponent(
|
||||
private val container: ViewGroup,
|
||||
bus: ActionBusFactory,
|
||||
viewModelProvider: UIComponentViewModelProvider<ShareState, ShareChange>
|
||||
) : UIComponent<ShareState, ShareAction, ShareChange>(
|
||||
bus.getManagedEmitter(ShareAction::class.java),
|
||||
bus.getSafeManagedObservable(ShareChange::class.java),
|
||||
viewModelProvider
|
||||
) {
|
||||
override fun initView() = ShareUIView(container, actionEmitter, changesObservable)
|
||||
|
||||
init {
|
||||
bind()
|
||||
}
|
||||
}
|
||||
|
||||
class ShareUIViewModel(
|
||||
initialState: ShareState
|
||||
) : UIComponentViewModelBase<ShareState, ShareChange>(
|
||||
initialState,
|
||||
reducer
|
||||
) {
|
||||
companion object {
|
||||
val reducer: Reducer<ShareState, ShareChange> = { _, _ -> ShareState }
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package org.mozilla.fenix.share
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import android.content.Intent
|
||||
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.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import kotlinx.android.synthetic.main.fragment_share.view.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import org.mozilla.fenix.FenixViewModelProvider
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class ShareFragment : DialogFragment(), CoroutineScope {
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.Main + job
|
||||
private lateinit var job: Job
|
||||
private lateinit var component: ShareComponent
|
||||
private lateinit var url: String
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.CreateCollectionDialogStyle)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_share, container, false)
|
||||
val args = ShareFragmentArgs.fromBundle(arguments!!)
|
||||
|
||||
job = Job()
|
||||
url = args.url
|
||||
component = ShareComponent(
|
||||
view.share_wrapper,
|
||||
ActionBusFactory.get(this),
|
||||
FenixViewModelProvider.create(
|
||||
this,
|
||||
ShareUIViewModel::class.java
|
||||
) {
|
||||
ShareUIViewModel(ShareState)
|
||||
}
|
||||
)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
subscribeToActions()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
private fun subscribeToActions() {
|
||||
getAutoDisposeObservable<ShareAction>().subscribe {
|
||||
when (it) {
|
||||
ShareAction.Close -> {
|
||||
dismiss()
|
||||
}
|
||||
ShareAction.AddNewDeviceClicked -> {
|
||||
requireComponents.useCases.tabsUseCases.addTab.invoke(ADD_NEW_DEVICES_URL, true)
|
||||
}
|
||||
is ShareAction.ShareAppClicked -> {
|
||||
val intent = Intent(ACTION_SEND).apply {
|
||||
putExtra(EXTRA_TEXT, url)
|
||||
type = "text/plain"
|
||||
flags = FLAG_ACTIVITY_NEW_TASK
|
||||
`package` = it.packageName
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
// TODO support other actions in a follow-up issue
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ADD_NEW_DEVICES_URL = "https://accounts.firefox.com/connect_another_device"
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.share
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.functions.Consumer
|
||||
import kotlinx.android.synthetic.main.component_share.*
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.mvi.UIView
|
||||
|
||||
class ShareUIView(
|
||||
container: ViewGroup,
|
||||
actionEmitter: Observer<ShareAction>,
|
||||
changesObservable: Observable<ShareChange>
|
||||
) : UIView<ShareState, ShareAction, ShareChange>(
|
||||
container,
|
||||
actionEmitter,
|
||||
changesObservable
|
||||
) {
|
||||
override val view: View = LayoutInflater.from(container.context)
|
||||
.inflate(R.layout.component_share, container, true)
|
||||
|
||||
init {
|
||||
val adapter = AppShareAdapter(view.context, actionEmitter).also {
|
||||
it.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
progress_bar.visibility = View.GONE
|
||||
intent_handler_recyclerview.visibility = View.VISIBLE
|
||||
}
|
||||
})
|
||||
}
|
||||
intent_handler_recyclerview.adapter = adapter
|
||||
|
||||
if (BuildConfig.SEND_TAB_ENABLED) {
|
||||
account_devices_recyclerview.adapter = AccountDevicesShareAdapter(view.context, actionEmitter)
|
||||
} else {
|
||||
send_tab_group.visibility = View.GONE
|
||||
}
|
||||
|
||||
close_button.setOnClickListener { actionEmitter.onNext(ShareAction.Close) }
|
||||
}
|
||||
|
||||
override fun updateView() = Consumer<ShareState> {
|
||||
ShareState
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<size
|
||||
android:height="40dp"
|
||||
android:width="40dp" />
|
||||
</shape>
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="80dp">
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/device_icon"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/device_background"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/device_name"
|
||||
tools:srcCompat="@tools:sample/avatars"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/device_name"
|
||||
android:textSize="10sp"
|
||||
android:textAlignment="gravity"
|
||||
android:gravity="center|top"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/device_icon"
|
||||
tools:text="Firefox on Macbook Pro"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="80dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/app_icon"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/app_name"
|
||||
tools:srcCompat="@tools:sample/avatars"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/app_name"
|
||||
android:textSize="10sp"
|
||||
android:textAlignment="gravity"
|
||||
android:gravity="center|top"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/app_icon"
|
||||
tools:text="Copy to clipboard"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/collection_constraint_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<Button
|
||||
android:id="@+id/close_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:drawableStart="@drawable/mozac_ic_close"
|
||||
android:drawablePadding="8dp"
|
||||
android:text="@string/share_header"
|
||||
android:textAppearance="@style/HeaderTextStyle"
|
||||
android:textColor="@color/neutral_text"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="?above"
|
||||
app:cardCornerRadius="@dimen/tab_corner_radius"
|
||||
app:cardElevation="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/send_tab_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="account_header,account_devices_recyclerview,divider_line"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/share_device_subheader"
|
||||
android:textAllCaps="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?secondaryText"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/account_header"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="12dp"/>
|
||||
|
||||
<org.mozilla.fenix.share.AccountDevicesShareRecyclerView
|
||||
android:id="@+id/account_devices_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:clipToPadding="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/account_header"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider_line"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/account_devices_recyclerview"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/share_link_subheader"
|
||||
android:textAllCaps="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?secondaryText"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:id="@+id/link_header"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider_line"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="76dp"
|
||||
android:layout_height="37dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/link_header"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<org.mozilla.fenix.share.AppShareRecyclerView
|
||||
android:id="@+id/intent_handler_recyclerview"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:clipToPadding="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/link_header"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/share_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/scrim_background"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="org.mozilla.fenix.share.ShareFragment">
|
||||
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue