Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In app callout android (uplift to 1.20.x) #7755

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ brave_java_resources = [
"java/res/drawable/ic_setbraveasdefault.xml",
"java/res/drawable/ic_setbraveasdefault_dark.xml",
"java/res/drawable/ic_shield_done_filled.xml",
"java/res/drawable/ic_shield_done_filled_20dp.xml",
"java/res/drawable/ic_sort.xml",
"java/res/drawable/ic_spot_graphic.xml",
"java/res/drawable/ic_spot_graphic_dark.xml",
Expand Down Expand Up @@ -712,12 +713,14 @@ brave_java_resources = [
"java/res/drawable/rounded_holo_button.xml",
"java/res/drawable/rounded_shape.xml",
"java/res/drawable/selected_indicator.xml",
"java/res/drawable/shields_tooltip_background.xml",
"java/res/drawable/shields_tooltip_background_1.xml",
"java/res/drawable/shields_tooltip_background_2.xml",
"java/res/drawable/sync_icon.xml",
"java/res/drawable/tip_amount.xml",
"java/res/drawable/transparent_bg_bordered.xml",
"java/res/drawable/wallet_disconnected_button.xml",
"java/res/drawable/wallet_verify_button.xml",
"java/res/drawable/white_rounded_holo_button.xml",
"java/res/font/poppins_light.ttf",
"java/res/font/poppins_medium.ttf",
"java/res/layout-land/brave_rewards_site_banner.xml",
Expand Down
4 changes: 4 additions & 0 deletions android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/HeightWrappingViewPager.java",
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/NonSwipeableViewPager.java",
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/VerticalViewPager.java",
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/popup_window_tooltip/ArrowColorDrawable.java",
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/popup_window_tooltip/PopupWindowTooltip.java",
"../../brave/android/java/org/chromium/chrome/browser/custom_layout/popup_window_tooltip/PopupWindowTooltipUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/document/BraveLauncherActivity.java",
"../../brave/android/java/org/chromium/chrome/browser/download/BraveMimeUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/download/settings/BraveDownloadSettings.java",
Expand Down Expand Up @@ -149,6 +152,7 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java",
"../../brave/android/java/org/chromium/chrome/browser/shields/BraveShieldsMenuObserver.java",
"../../brave/android/java/org/chromium/chrome/browser/shields/BraveShieldsUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/shields/ShieldsTooltipEnum.java",
"../../brave/android/java/org/chromium/chrome/browser/signin/BraveSigninManager.java",
"../../brave/android/java/org/chromium/chrome/browser/site_settings/DesktopModePreferences.java",
"../../brave/android/java/org/chromium/chrome/browser/site_settings/PlayYTVideoInBrowserPreferences.java",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* Copyright (c) 2021 The Brave Authors. All rights reserved.
* 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.chromium.chrome.browser.custom_layout.popup_window_tooltip;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;

import androidx.annotation.ColorInt;

public class ArrowColorDrawable extends ColorDrawable {
public static final int LEFT = 0, TOP = 1, RIGHT = 2, BOTTOM = 3, AUTO = 4;

private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final int mBackgroundColor;
private Path mPath;
private final int mDirection;

ArrowColorDrawable(@ColorInt int foregroundColor, int direction) {
this.mBackgroundColor = Color.TRANSPARENT;
this.mPaint.setColor(foregroundColor);
this.mDirection = direction;
}

@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
updatePath(bounds);
}

private synchronized void updatePath(Rect bounds) {
mPath = new Path();

switch (mDirection) {
case LEFT:
mPath.moveTo(bounds.width(), bounds.height());
mPath.lineTo(0, (float) bounds.height() / 2);
mPath.lineTo(bounds.width(), 0);
mPath.lineTo(bounds.width(), bounds.height());
break;
case TOP:
mPath.moveTo(0, bounds.height());
mPath.lineTo((float) bounds.width() / 2, 0);
mPath.lineTo(bounds.width(), bounds.height());
mPath.lineTo(0, bounds.height());
break;
case RIGHT:
mPath.moveTo(0, 0);
mPath.lineTo(bounds.width(), (float) bounds.height() / 2);
mPath.lineTo(0, bounds.height());
mPath.lineTo(0, 0);
break;
case BOTTOM:
mPath.moveTo(0, 0);
mPath.lineTo((float) bounds.width() / 2, bounds.height());
mPath.lineTo(bounds.width(), 0);
mPath.lineTo(0, 0);
break;
}

mPath.close();
}

@Override
public void draw(Canvas canvas) {
canvas.drawColor(mBackgroundColor);
if (mPath == null) updatePath(getBounds());
canvas.drawPath(mPath, mPaint);
}

@Override
public void setAlpha(int alpha) {
mPaint.setAlpha(alpha);
}

public void setColor(@ColorInt int color) {
mPaint.setColor(color);
}

@Override
public void setColorFilter(ColorFilter colorFilter) {
mPaint.setColorFilter(colorFilter);
}

@Override
public int getOpacity() {
if (mPaint.getColorFilter() != null) {
return PixelFormat.TRANSLUCENT;
}

switch (mPaint.getColor() >>> 24) {
case 255:
return PixelFormat.OPAQUE;
case 0:
return PixelFormat.TRANSPARENT;
}
return PixelFormat.TRANSLUCENT;
}
}
Loading