Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarLayout.java

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Support setting mouse cursor icon in Android N Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.infobar; 5 package org.chromium.chrome.browser.infobar;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Resources; 8 import android.content.res.Resources;
9 import android.content.res.TypedArray; 9 import android.content.res.TypedArray;
10 import android.graphics.Bitmap; 10 import android.graphics.Bitmap;
11 import android.graphics.drawable.Drawable; 11 import android.graphics.drawable.Drawable;
12 import android.os.Build;
12 import android.support.annotation.Nullable; 13 import android.support.annotation.Nullable;
13 import android.text.SpannableString; 14 import android.text.SpannableString;
14 import android.text.SpannableStringBuilder; 15 import android.text.SpannableStringBuilder;
15 import android.text.Spanned; 16 import android.text.Spanned;
16 import android.text.TextUtils; 17 import android.text.TextUtils;
17 import android.util.TypedValue; 18 import android.util.TypedValue;
19 import android.view.PointerIcon;
18 import android.view.View; 20 import android.view.View;
19 import android.view.ViewGroup; 21 import android.view.ViewGroup;
20 import android.widget.Button; 22 import android.widget.Button;
21 import android.widget.ImageButton; 23 import android.widget.ImageButton;
22 import android.widget.ImageView; 24 import android.widget.ImageView;
23 import android.widget.TextView; 25 import android.widget.TextView;
24 26
25 import org.chromium.base.ApiCompatibilityUtils; 27 import org.chromium.base.ApiCompatibilityUtils;
26 import org.chromium.chrome.R; 28 import org.chromium.chrome.R;
27 import org.chromium.chrome.browser.widget.DualControlLayout; 29 import org.chromium.chrome.browser.widget.DualControlLayout;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Button primaryButton = DualControlLayout.createButtonForLayout( 239 Button primaryButton = DualControlLayout.createButtonForLayout(
238 getContext(), true, primaryText, this); 240 getContext(), true, primaryText, this);
239 241
240 assert mButtonRowLayout == null; 242 assert mButtonRowLayout == null;
241 mButtonRowLayout = new DualControlLayout(getContext(), null); 243 mButtonRowLayout = new DualControlLayout(getContext(), null);
242 mButtonRowLayout.setAlignment(alignment); 244 mButtonRowLayout.setAlignment(alignment);
243 mButtonRowLayout.setStackedMargin(getResources().getDimensionPixelSize( 245 mButtonRowLayout.setStackedMargin(getResources().getDimensionPixelSize(
244 R.dimen.infobar_margin_between_stacked_buttons)); 246 R.dimen.infobar_margin_between_stacked_buttons));
245 247
246 mButtonRowLayout.addView(primaryButton); 248 mButtonRowLayout.addView(primaryButton);
247 if (secondaryView != null) mButtonRowLayout.addView(secondaryView); 249 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Jinsuk Kim 2017/07/17 04:45:18 Version check is repeated more often than necessar
jaebaek 2017/07/18 07:48:21 This is for PointerIcon.TYPE_HAND, but I will move
250 setPointerIcon(primaryButton, PointerIcon.TYPE_HAND);
251 }
252 if (secondaryView != null) {
253 mButtonRowLayout.addView(secondaryView);
254 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
255 setPointerIcon(secondaryView, PointerIcon.TYPE_HAND);
256 }
257 }
248 } 258 }
249 259
250 /** 260 /**
251 * Adjusts styling to account for the big icon layout. 261 * Adjusts styling to account for the big icon layout.
252 */ 262 */
253 public void setIsUsingBigIcon() { 263 public void setIsUsingBigIcon() {
254 if (mIconView == null) return; 264 if (mIconView == null) return;
255 265
256 LayoutParams lp = (LayoutParams) mIconView.getLayoutParams(); 266 LayoutParams lp = (LayoutParams) mIconView.getLayoutParams();
257 lp.width = mBigIconSize; 267 lp.width = mBigIconSize;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 Drawable closeButtonBackground = a.getDrawable(0); 553 Drawable closeButtonBackground = a.getDrawable(0);
544 a.recycle(); 554 a.recycle();
545 555
546 ImageButton closeButton = new ImageButton(context); 556 ImageButton closeButton = new ImageButton(context);
547 closeButton.setId(R.id.infobar_close_button); 557 closeButton.setId(R.id.infobar_close_button);
548 closeButton.setImageResource(R.drawable.btn_close); 558 closeButton.setImageResource(R.drawable.btn_close);
549 closeButton.setBackground(closeButtonBackground); 559 closeButton.setBackground(closeButtonBackground);
550 closeButton.setContentDescription(context.getString(R.string.infobar_clo se)); 560 closeButton.setContentDescription(context.getString(R.string.infobar_clo se));
551 closeButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 561 closeButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
552 562
563 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
564 setPointerIcon(closeButton, PointerIcon.TYPE_HAND);
565 }
566
553 return closeButton; 567 return closeButton;
554 } 568 }
569
570 private static void setPointerIcon(View view, int type) {
571 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
572 PointerIcon icon = PointerIcon.getSystemIcon(view.getContext(), type );
573 view.setPointerIcon(icon);
574 }
575 }
555 } 576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698