forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mozilla-mobile#6607 Add button to no tab content pane
- Loading branch information
mcarare
committed
Feb 28, 2020
1 parent
0def456
commit ed291ef
Showing
8 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...org/mozilla/fenix/home/sessioncontrol/viewholders/NoContentMessageWithActionViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.home.sessioncontrol.viewholders | ||
|
||
import android.view.View | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.core.view.isVisible | ||
import kotlinx.android.synthetic.main.no_content_message_with_action.view.button_icon | ||
import kotlinx.android.synthetic.main.no_content_message_with_action.view.button_layout | ||
import kotlinx.android.synthetic.main.no_content_message_with_action.view.button_text | ||
import org.mozilla.fenix.R | ||
|
||
class NoContentMessageWithActionViewHolder( | ||
private val view: View | ||
) : NoContentMessageViewHolder(view) { | ||
|
||
/** | ||
* @param icon The visible label for header text this menu item. | ||
* @param header ID of string resource for title text. | ||
* @param description ID of string resource for description text. | ||
* @param buttonIcon Optional ID of drawable resource for button icon. | ||
* @param buttonText Optional ID of string resource for button text. | ||
* @param listener Optional Callback to be invoked when the button is clicked. | ||
*/ | ||
@Suppress("LongParameterList") | ||
fun bind( | ||
@DrawableRes icon: Int, | ||
@StringRes header: Int, | ||
@StringRes description: Int, | ||
@DrawableRes buttonIcon: Int = 0, | ||
@StringRes buttonText: Int = 0, | ||
listener: (() -> Unit)? = null | ||
) { | ||
super.bind(icon, header, description) | ||
with(view.context) { | ||
|
||
if (buttonIcon != 0 || buttonText != 0) { | ||
view.button_layout.isVisible = true | ||
view.button_icon.setImageDrawable(getDrawable(buttonIcon)) | ||
view.button_text.text = getString(buttonText) | ||
view.button_layout.setOnClickListener { | ||
listener?.invoke() | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
const val LAYOUT_ID = R.layout.no_content_message_with_action | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
app/src/main/res/layout/no_content_message_with_action.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?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/. --> | ||
<LinearLayout 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:id="@+id/no_content_wrapper" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="12dp" | ||
android:background="@drawable/empty_session_control_background" | ||
android:orientation="vertical" | ||
android:padding="8dp"> | ||
|
||
<TextView | ||
android:id="@+id/no_content_header" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="4dp" | ||
android:drawablePadding="8dp" | ||
android:textAppearance="@style/HeaderTextStyle" | ||
android:textSize="16sp" | ||
app:drawableTint="?primaryText" | ||
tools:drawableEnd="@drawable/ic_tabs" | ||
tools:text="@tools:sample/lorem" /> | ||
|
||
<TextView | ||
android:id="@+id/no_content_description" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:textAlignment="viewStart" | ||
android:textColor="?primaryText" | ||
android:textSize="14sp" | ||
android:textStyle="normal" | ||
tools:text="@tools:sample/lorem" /> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/button_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="36dp" | ||
android:layout_marginTop="6dp" | ||
android:layout_marginBottom="4dp" | ||
android:background="@drawable/button_background_grey" | ||
android:clickable="true" | ||
android:focusable="true" | ||
android:visibility="gone" | ||
tools:visibility="visible"> | ||
|
||
<ImageView | ||
android:id="@+id/button_icon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="5dp" | ||
android:importantForAccessibility="no" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@id/button_text" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:srcCompat="@drawable/ic_new" /> | ||
|
||
<TextView | ||
android:id="@+id/button_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:importantForAccessibility="no" | ||
android:textColor="?primaryText" | ||
android:textSize="14sp" | ||
android:textStyle="bold" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="@string/home_screen_shortcut_open_new_tab_2" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</LinearLayout> |