1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 package org.mozilla.gecko.firstrun;
7 
8 import org.mozilla.gecko.R;
9 import org.mozilla.gecko.Telemetry;
10 import org.mozilla.gecko.TelemetryContract;
11 import org.mozilla.gecko.home.HomePager;
12 
13 import android.app.Activity;
14 import android.os.Bundle;
15 import android.view.LayoutInflater;
16 import android.view.View;
17 import android.view.ViewGroup;
18 
19 import java.util.EnumSet;
20 
21 public class RestrictedWelcomePanel extends FirstrunPanel {
22     public static final int TITLE_RES = R.string.firstrun_panel_title_welcome;
23 
24     private static final String LEARN_MORE_URL = "https://support.mozilla.org/kb/controlledaccess";
25 
26     private HomePager.OnUrlOpenListener onUrlOpenListener;
27 
28     @Override
29     public void onAttach(Activity activity) {
30         super.onAttach(activity);
31 
32         try {
33             onUrlOpenListener = (HomePager.OnUrlOpenListener) activity;
34         } catch (ClassCastException e) {
35             throw new ClassCastException(activity.toString() + " must implement HomePager.OnUrlOpenListener");
36         }
37     }
38 
39     @Override
40     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
41         final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.restricted_firstrun_welcome_fragment, container, false);
42 
43         root.findViewById(R.id.welcome_browse).setOnClickListener(new View.OnClickListener() {
44             @Override
45             public void onClick(View v) {
46                 close();
47             }
48         });
49 
50         root.findViewById(R.id.learn_more_link).setOnClickListener(new View.OnClickListener() {
51             @Override
52             public void onClick(View v) {
53                 onUrlOpenListener.onUrlOpen(LEARN_MORE_URL, EnumSet.of(HomePager.OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));
54 
55                 close();
56             }
57         });
58 
59         return root;
60     }
61 }
62