OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.ntp; |
| 6 |
| 7 import android.app.Dialog; |
| 8 import android.content.Context; |
| 9 import android.os.Bundle; |
| 10 import android.view.LayoutInflater; |
| 11 import android.view.View; |
| 12 import android.view.ViewGroup.LayoutParams; |
| 13 import android.view.WindowManager; |
| 14 import android.widget.FrameLayout; |
| 15 import android.widget.ImageButton; |
| 16 import android.widget.TextView; |
| 17 |
| 18 import com.google.android.apps.chrome.R; |
| 19 |
| 20 import org.chromium.chrome.browser.NativePage; |
| 21 |
| 22 /** |
| 23 * Displays a NativePage in a full screen dialog instead of like a regular Chrom
e page. |
| 24 */ |
| 25 public class NativePageDialog extends Dialog { |
| 26 private final NativePage mPage; |
| 27 |
| 28 public NativePageDialog(Context context, NativePage page) { |
| 29 super(context, R.style.DialogWhenLarge); |
| 30 mPage = page; |
| 31 } |
| 32 |
| 33 @Override |
| 34 protected void onCreate(Bundle savedInstanceState) { |
| 35 super.onCreate(savedInstanceState); |
| 36 |
| 37 FrameLayout view = (FrameLayout) LayoutInflater.from(getContext()).infla
te( |
| 38 R.layout.dialog_with_titlebar, null); |
| 39 view.addView(mPage.getView(), 0); |
| 40 setContentView(view); |
| 41 |
| 42 getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARE
NT); |
| 43 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
| 44 |
| 45 TextView title = (TextView) view.findViewById(R.id.title); |
| 46 title.setText(mPage.getTitle()); |
| 47 |
| 48 ImageButton closeButton = (ImageButton) view.findViewById(R.id.close_but
ton); |
| 49 closeButton.setOnClickListener(new View.OnClickListener() { |
| 50 @Override |
| 51 public void onClick(View v) { |
| 52 dismiss(); |
| 53 } |
| 54 }); |
| 55 } |
| 56 |
| 57 @Override |
| 58 public void dismiss() { |
| 59 super.dismiss(); |
| 60 if (mPage != null) mPage.destroy(); |
| 61 } |
| 62 } |
OLD | NEW |