1
0
Fork 0

For #7181 - Adjust ETP onboarding for toolbar positions

master
Emily Kager 2019-12-31 12:02:33 -08:00 committed by Emily Kager
parent 31da69a311
commit 7d613b72ae
3 changed files with 28 additions and 3 deletions

View File

@ -13,6 +13,8 @@ import android.view.View.MeasureSpec
import android.view.WindowManager
import android.widget.ImageView
import android.widget.PopupWindow
import androidx.core.view.isGone
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.view.*
import mozilla.components.browser.session.Session
import org.mozilla.fenix.R
@ -44,8 +46,14 @@ class TrackingProtectionOverlay(
private fun showTrackingProtectionOnboarding() {
val layout = LayoutInflater.from(context)
.inflate(R.layout.tracking_protection_onboarding_popup, null)
val isBottomToolbar = Settings.getInstance(context).shouldUseBottomToolbar
layout.drop_down_triangle.isGone = isBottomToolbar
layout.pop_up_triangle.isVisible = isBottomToolbar
layout.onboarding_message.text =
context.getString(R.string.etp_onboarding_message_2, context.getString(R.string.app_name))
context.getString(
R.string.etp_onboarding_message_2,
context.getString(R.string.app_name)
)
val res = context.resources
val trackingOnboarding = PopupWindow(
@ -81,13 +89,18 @@ class TrackingProtectionOverlay(
val xOffset = res.getDimensionPixelSize(R.dimen.tp_onboarding_x_offset)
// Positioning the popup above the tp anchor.
val yOffset = -containerHeight - (toolbar.height / 3 * 2) + triangleHeight
val yOffset = if (isBottomToolbar) {
-containerHeight - (toolbar.height / 3 * 2) + triangleHeight
} else {
CFR_Y_OFFSET
}
trackingOnboarding.showAsDropDown(trackingProtectionIcon, xOffset, yOffset)
settings.incrementTrackingProtectionOnboardingCount()
}
private companion object {
private const val CFR_Y_OFFSET = -24
private const val BUTTON_INCREASE_DPS = 12
}
}

View File

@ -8,6 +8,17 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:visibility="gone"
android:id="@+id/drop_down_triangle"
android:layout_width="16dp"
android:layout_height="@dimen/tp_onboarding_triangle_height"
android:layout_marginStart="16dp"
android:importantForAccessibility="no"
android:rotation="0"
app:srcCompat="@drawable/ic_triangle"
android:layout_gravity="start" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/message"
android:layout_width="@dimen/etp_onboarding_popup_width"
@ -46,6 +57,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/pop_up_triangle"
android:layout_width="16dp"
android:layout_height="@dimen/tp_onboarding_triangle_height"
android:layout_marginStart="16dp"

View File

@ -37,7 +37,7 @@
<dimen name="context_menu_height">48dp</dimen>
<dimen name="context_menu_x_offset">8dp</dimen>
<dimen name="tp_onboarding_width">256dp</dimen>
<dimen name="tp_onboarding_x_offset">0dp</dimen>
<dimen name="tp_onboarding_x_offset">-4dp</dimen>
<dimen name="tp_onboarding_triangle_height">16dp</dimen>
<!--Quick Settings-->