Mercurial > 510Connectbot
comparison app/src/main/java/com/five_ten_sg/connectbot/WizardActivity.java @ 438:d29cce60f393
migrate from Eclipse to Android Studio
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 03 Dec 2015 11:23:55 -0800 |
parents | src/com/five_ten_sg/connectbot/WizardActivity.java@071eccdff8ea |
children |
comparison
equal
deleted
inserted
replaced
437:208b31032318 | 438:d29cce60f393 |
---|---|
1 /* | |
2 * ConnectBot: simple, powerful, open-source SSH client for Android | |
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey | |
4 * | |
5 * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 * you may not use this file except in compliance with the License. | |
7 * You may obtain a copy of the License at | |
8 * | |
9 * http://www.apache.org/licenses/LICENSE-2.0 | |
10 * | |
11 * Unless required by applicable law or agreed to in writing, software | |
12 * distributed under the License is distributed on an "AS IS" BASIS, | |
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 * See the License for the specific language governing permissions and | |
15 * limitations under the License. | |
16 */ | |
17 | |
18 package com.five_ten_sg.connectbot; | |
19 | |
20 import com.five_ten_sg.connectbot.util.HelpTopicView; | |
21 import android.app.Activity; | |
22 import android.content.pm.PackageManager.NameNotFoundException; | |
23 import android.os.Bundle; | |
24 import android.util.Log; | |
25 import android.view.LayoutInflater; | |
26 import android.view.View; | |
27 import android.view.View.OnClickListener; | |
28 import android.widget.Button; | |
29 import android.widget.TextView; | |
30 import android.widget.ViewFlipper; | |
31 | |
32 /** | |
33 * Show a series of wizard-like steps to the user, which might include an EULA, | |
34 * program credits, and helpful hints. | |
35 * | |
36 * @author jsharkey | |
37 */ | |
38 public class WizardActivity extends Activity { | |
39 protected ViewFlipper flipper = null; | |
40 private Button next, prev; | |
41 private static final String TAG = "ConnectBot.WizardActivity"; | |
42 | |
43 @Override | |
44 public void onCreate(Bundle savedInstanceState) { | |
45 super.onCreate(savedInstanceState); | |
46 setContentView(R.layout.act_wizard); | |
47 this.flipper = (ViewFlipper) findViewById(R.id.wizard_flipper); | |
48 // inflate the layout for EULA step | |
49 LayoutInflater inflater = LayoutInflater.from(this); | |
50 View helpView = inflater.inflate(R.layout.wiz_eula, this.flipper, false); | |
51 this.flipper.addView(helpView); | |
52 // Add a view for each help topic we want the user to see. | |
53 String[] topics = getResources().getStringArray(R.array.list_wizard_topics); | |
54 | |
55 for (String topic : topics) { | |
56 flipper.addView(new HelpTopicView(this).setTopic(topic)); | |
57 } | |
58 | |
59 next = (Button)this.findViewById(R.id.action_next); | |
60 next.setOnClickListener(new OnClickListener() { | |
61 public void onClick(View v) { | |
62 if (isLastDisplayed()) { | |
63 // user walked past end of wizard, so return okay | |
64 WizardActivity.this.setResult(Activity.RESULT_OK); | |
65 WizardActivity.this.finish(); | |
66 } | |
67 else { | |
68 // show next step and update buttons | |
69 flipper.showNext(); | |
70 updateButtons(); | |
71 } | |
72 } | |
73 }); | |
74 prev = (Button)this.findViewById(R.id.action_prev); | |
75 prev.setOnClickListener(new OnClickListener() { | |
76 public void onClick(View v) { | |
77 if (isFirstDisplayed()) { | |
78 // user walked past beginning of wizard, so return that they cancelled | |
79 WizardActivity.this.setResult(Activity.RESULT_CANCELED); | |
80 WizardActivity.this.finish(); | |
81 } | |
82 else { | |
83 // show previous step and update buttons | |
84 flipper.showPrevious(); | |
85 updateButtons(); | |
86 } | |
87 } | |
88 }); | |
89 this.updateButtons(); | |
90 } | |
91 | |
92 protected boolean isFirstDisplayed() { | |
93 return (flipper.getDisplayedChild() == 0); | |
94 } | |
95 | |
96 protected boolean isLastDisplayed() { | |
97 return (flipper.getDisplayedChild() == flipper.getChildCount() - 1); | |
98 } | |
99 | |
100 protected void updateButtons() { | |
101 boolean eula = (flipper.getDisplayedChild() == 0); | |
102 next.setText(eula ? getString(R.string.wizard_agree) : getString(R.string.wizard_next)); | |
103 prev.setText(eula ? getString(R.string.delete_neg) : getString(R.string.wizard_back)); | |
104 } | |
105 } |