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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/page_info/PageInfoPopup.java

Issue 2847523002: Android: Remove GetApplicationContext part 4 (Closed)
Patch Set: Rebase and fix build Created 3 years, 7 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.page_info; 5 package org.chromium.chrome.browser.page_info;
6 6
7 import android.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.animation.AnimatorSet; 9 import android.animation.AnimatorSet;
10 import android.animation.ObjectAnimator; 10 import android.animation.ObjectAnimator;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (mInstantAppIntent == null) mInstantAppButton.setVisibility(View.GONE ); 426 if (mInstantAppIntent == null) mInstantAppButton.setVisibility(View.GONE );
427 427
428 // Create the dialog. 428 // Create the dialog.
429 mDialog = new Dialog(mContext) { 429 mDialog = new Dialog(mContext) {
430 private void superDismiss() { 430 private void superDismiss() {
431 super.dismiss(); 431 super.dismiss();
432 } 432 }
433 433
434 @Override 434 @Override
435 public void dismiss() { 435 public void dismiss() {
436 if (DeviceFormFactor.isTablet(mContext) || mDismissWithoutAnimat ion) { 436 if (DeviceFormFactor.isTablet() || mDismissWithoutAnimation) {
437 // Dismiss the dialog without any custom animations on table t. 437 // Dismiss the dialog without any custom animations on table t.
438 super.dismiss(); 438 super.dismiss();
439 } else { 439 } else {
440 Animator animator = createAllAnimations(false); 440 Animator animator = createAllAnimations(false);
441 animator.addListener(new AnimatorListenerAdapter() { 441 animator.addListener(new AnimatorListenerAdapter() {
442 @Override 442 @Override
443 public void onAnimationEnd(Animator animation) { 443 public void onAnimationEnd(Animator animation) {
444 // onAnimationEnd is called during the final frame o f the animation. 444 // onAnimationEnd is called during the final frame o f the animation.
445 // Delay the cleanup by a tiny amount to give this f rame a chance to be 445 // Delay the cleanup by a tiny amount to give this f rame a chance to be
446 // displayed before we destroy the dialog. 446 // displayed before we destroy the dialog.
447 mContainer.postDelayed(new Runnable() { 447 mContainer.postDelayed(new Runnable() {
448 @Override 448 @Override
449 public void run() { 449 public void run() {
450 superDismiss(); 450 superDismiss();
451 } 451 }
452 }, CLOSE_CLEANUP_DELAY); 452 }, CLOSE_CLEANUP_DELAY);
453 } 453 }
454 }); 454 });
455 animator.start(); 455 animator.start();
456 } 456 }
457 } 457 }
458 }; 458 };
459 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 459 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
460 mDialog.setCanceledOnTouchOutside(true); 460 mDialog.setCanceledOnTouchOutside(true);
461 461
462 // On smaller screens, place the dialog at the top of the screen, and re move its border. 462 // On smaller screens, place the dialog at the top of the screen, and re move its border.
463 if (!DeviceFormFactor.isTablet(mContext)) { 463 if (!DeviceFormFactor.isTablet()) {
464 Window window = mDialog.getWindow(); 464 Window window = mDialog.getWindow();
465 window.setGravity(Gravity.TOP); 465 window.setGravity(Gravity.TOP);
466 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 466 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
467 } 467 }
468 468
469 // This needs to come after other member initialization. 469 // This needs to come after other member initialization.
470 mNativePageInfoPopup = nativeInit(this, mTab.getWebContents()); 470 mNativePageInfoPopup = nativeInit(this, mTab.getWebContents());
471 final WebContentsObserver webContentsObserver = 471 final WebContentsObserver webContentsObserver =
472 new WebContentsObserver(mTab.getWebContents()) { 472 new WebContentsObserver(mTab.getWebContents()) {
473 @Override 473 @Override
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 messageBuilder.append(detailsText); 705 messageBuilder.append(detailsText);
706 } 706 }
707 mConnectionMessage.setText(messageBuilder); 707 mConnectionMessage.setText(messageBuilder);
708 if (isConnectionDetailsLinkVisible()) mConnectionMessage.setOnClickListe ner(this); 708 if (isConnectionDetailsLinkVisible()) mConnectionMessage.setOnClickListe ner(this);
709 } 709 }
710 710
711 /** 711 /**
712 * Displays the PageInfoPopup. 712 * Displays the PageInfoPopup.
713 */ 713 */
714 private void showDialog() { 714 private void showDialog() {
715 if (!DeviceFormFactor.isTablet(mContext)) { 715 if (!DeviceFormFactor.isTablet()) {
716 // On smaller screens, make the dialog fill the width of the screen. 716 // On smaller screens, make the dialog fill the width of the screen.
717 ScrollView scrollView = new ScrollView(mContext) { 717 ScrollView scrollView = new ScrollView(mContext) {
718 @Override 718 @Override
719 protected void onMeasure(int widthMeasureSpec, int heightMeasure Spec) { 719 protected void onMeasure(int widthMeasureSpec, int heightMeasure Spec) {
720 int dialogMaxHeight = mTab.getHeight(); 720 int dialogMaxHeight = mTab.getHeight();
721 if (mIsBottomPopup) { 721 if (mIsBottomPopup) {
722 // In Chrome Home, the full URL is showing at all times; give the scroll 722 // In Chrome Home, the full URL is showing at all times; give the scroll
723 // view a max height so long URLs don't consume the enti re screen. 723 // view a max height so long URLs don't consume the enti re screen.
724 dialogMaxHeight -= 724 dialogMaxHeight -=
725 mContext.getResources().getDimension(R.dimen.min _touch_target_size); 725 mContext.getResources().getDimension(R.dimen.min _touch_target_size);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 761 }
762 762
763 mDialog.show(); 763 mDialog.show();
764 } 764 }
765 765
766 /** 766 /**
767 * Dismiss the popup, and then run a task after the animation has completed (if there is one). 767 * Dismiss the popup, and then run a task after the animation has completed (if there is one).
768 */ 768 */
769 private void runAfterDismiss(Runnable task) { 769 private void runAfterDismiss(Runnable task) {
770 mDialog.dismiss(); 770 mDialog.dismiss();
771 if (DeviceFormFactor.isTablet(mContext)) { 771 if (DeviceFormFactor.isTablet()) {
772 task.run(); 772 task.run();
773 } else { 773 } else {
774 mContainer.postDelayed(task, FADE_DURATION + CLOSE_CLEANUP_DELAY); 774 mContainer.postDelayed(task, FADE_DURATION + CLOSE_CLEANUP_DELAY);
775 } 775 }
776 } 776 }
777 777
778 @Override 778 @Override
779 public void onClick(View view) { 779 public void onClick(View view) {
780 if (view == mSiteSettingsButton) { 780 if (view == mSiteSettingsButton) {
781 // Delay while the PageInfoPopup closes. 781 // Delay while the PageInfoPopup closes.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 /** 931 /**
932 * Create animations for showing/hiding the popup. 932 * Create animations for showing/hiding the popup.
933 * 933 *
934 * Tablets use the default Dialog fade-in instead of sliding in manually. 934 * Tablets use the default Dialog fade-in instead of sliding in manually.
935 */ 935 */
936 private Animator createAllAnimations(boolean isEnter) { 936 private Animator createAllAnimations(boolean isEnter) {
937 AnimatorSet animation = new AnimatorSet(); 937 AnimatorSet animation = new AnimatorSet();
938 AnimatorSet.Builder builder = null; 938 AnimatorSet.Builder builder = null;
939 Animator startAnim; 939 Animator startAnim;
940 940
941 if (DeviceFormFactor.isTablet(mContext)) { 941 if (DeviceFormFactor.isTablet()) {
942 // The start time of the entire AnimatorSet is the start time of the first animation 942 // The start time of the entire AnimatorSet is the start time of the first animation
943 // added to the Builder. We use a blank AnimatorSet on tablet as an easy way to 943 // added to the Builder. We use a blank AnimatorSet on tablet as an easy way to
944 // co-ordinate this start time. 944 // co-ordinate this start time.
945 startAnim = new AnimatorSet(); 945 startAnim = new AnimatorSet();
946 } else { 946 } else {
947 startAnim = createDialogSlideAnimator(isEnter); 947 startAnim = createDialogSlideAnimator(isEnter);
948 } 948 }
949 949
950 if (isEnter) startAnim.setStartDelay(ENTER_START_DELAY); 950 if (isEnter) startAnim.setStartDelay(ENTER_START_DELAY);
951 builder = animation.play(startAnim); 951 builder = animation.play(startAnim);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 new PageInfoPopup(activity, tab, offlinePageCreationDate, contentPublish er); 1014 new PageInfoPopup(activity, tab, offlinePageCreationDate, contentPublish er);
1015 } 1015 }
1016 1016
1017 private static native long nativeInit(PageInfoPopup popup, WebContents webCo ntents); 1017 private static native long nativeInit(PageInfoPopup popup, WebContents webCo ntents);
1018 1018
1019 private native void nativeDestroy(long nativePageInfoPopupAndroid); 1019 private native void nativeDestroy(long nativePageInfoPopupAndroid);
1020 1020
1021 private native void nativeRecordPageInfoAction( 1021 private native void nativeRecordPageInfoAction(
1022 long nativePageInfoPopupAndroid, int action); 1022 long nativePageInfoPopupAndroid, int action);
1023 } 1023 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698