diff options
author | Kenny Root <kenny@the-b.org> | 2008-11-16 13:45:08 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2008-11-16 13:45:08 +0000 |
commit | 047edeadfc88bd9d7add4d6383f7cfce253a1f9a (patch) | |
tree | f12b0c15554741f5850b0173bf48a61cdad5c407 /src | |
parent | f4e0616cd657d85e7045a78832db91405dc9a6af (diff) | |
download | connectbot-047edeadfc88bd9d7add4d6383f7cfce253a1f9a.tar.gz connectbot-047edeadfc88bd9d7add4d6383f7cfce253a1f9a.tar.bz2 connectbot-047edeadfc88bd9d7add4d6383f7cfce253a1f9a.zip |
* Add rudimentary help system.
Diffstat (limited to 'src')
-rw-r--r-- | src/org/connectbot/HelpActivity.java | 77 | ||||
-rw-r--r-- | src/org/connectbot/HelpTopicActivity.java | 49 | ||||
-rw-r--r-- | src/org/connectbot/HostListActivity.java | 7 | ||||
-rw-r--r-- | src/org/connectbot/WizardActivity.java | 27 | ||||
-rw-r--r-- | src/org/connectbot/util/HelpTopicView.java | 56 |
5 files changed, 197 insertions, 19 deletions
diff --git a/src/org/connectbot/HelpActivity.java b/src/org/connectbot/HelpActivity.java new file mode 100644 index 0000000..c04127f --- /dev/null +++ b/src/org/connectbot/HelpActivity.java @@ -0,0 +1,77 @@ +/* + ConnectBot: simple, powerful, open-source SSH client for Android + Copyright (C) 2007-2008 Kenny Root, Jeffrey Sharkey + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +package org.connectbot; + +import java.io.IOException; + +import android.app.Activity; +import android.content.Intent; +import android.content.res.AssetManager; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.LinearLayout; + +/** + * @author Kenny Root + * + */ +public class HelpActivity extends Activity { + public final static String TAG = HelpActivity.class.toString(); + + public final static String HELPDIR = "help"; + public final static String SUFFIX = ".html"; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.act_help); + + this.setTitle(String.format("%s: %s", + getResources().getText(R.string.app_name), + getResources().getText(R.string.title_help))); + + AssetManager am = this.getAssets(); + LinearLayout content = (LinearLayout)this.findViewById(R.id.topics); + + try { + for (String name : am.list(HELPDIR)) { + if (name.endsWith(SUFFIX)) { + Button button = new Button(this); + final String topic = name.substring(0, name.length() - SUFFIX.length()); + button.setText(topic); + + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + Intent intent = new Intent(HelpActivity.this, HelpTopicActivity.class); + intent.putExtra(Intent.EXTRA_TITLE, topic); + HelpActivity.this.startActivity(intent); + } + }); + + content.addView(button); + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + Log.e(TAG, "couldn't get list of help assets", e); + } + } +} diff --git a/src/org/connectbot/HelpTopicActivity.java b/src/org/connectbot/HelpTopicActivity.java new file mode 100644 index 0000000..35e23f5 --- /dev/null +++ b/src/org/connectbot/HelpTopicActivity.java @@ -0,0 +1,49 @@ +/* + ConnectBot: simple, powerful, open-source SSH client for Android + Copyright (C) 2007-2008 Kenny Root, Jeffrey Sharkey + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +package org.connectbot; + +import org.connectbot.util.HelpTopicView; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +/** + * @author Kenny Root + * + */ +public class HelpTopicActivity extends Activity { + public final static String TAG = HelpActivity.class.toString(); + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.act_help_topic); + + String topic = getIntent().getStringExtra(Intent.EXTRA_TITLE); + + this.setTitle(String.format("%s: %s - %s", + getResources().getText(R.string.app_name), + getResources().getText(R.string.title_help), + topic)); + + HelpTopicView helpTopic = (HelpTopicView) findViewById(R.id.topic_text); + + helpTopic.setTopic(topic); + } +} diff --git a/src/org/connectbot/HostListActivity.java b/src/org/connectbot/HostListActivity.java index 86769b4..d7b6372 100644 --- a/src/org/connectbot/HostListActivity.java +++ b/src/org/connectbot/HostListActivity.java @@ -331,9 +331,9 @@ public class HostListActivity extends ListActivity { settings.setIcon(android.R.drawable.ic_menu_preferences); settings.setIntent(new Intent(HostListActivity.this, SettingsActivity.class)); - MenuItem about = menu.add(R.string.list_menu_about); - about.setIcon(android.R.drawable.ic_menu_help); - about.setIntent(new Intent(HostListActivity.this, WizardActivity.class)); + MenuItem help = menu.add(R.string.list_menu_help); + help.setIcon(android.R.drawable.ic_menu_help); + help.setIntent(new Intent(HostListActivity.this, HelpActivity.class)); return true; @@ -472,7 +472,6 @@ public class HostListActivity extends ListActivity { TextView caption = (TextView)view.findViewById(android.R.id.text2); ImageView icon = (ImageView)view.findViewById(android.R.id.icon); - Log.d("HostAdapter", String.format("Checking position %d", position)); HostBean host = hosts.get(position); if (host == null) { Log.e("HostAdapter", "What the fuck, host bean is null!"); diff --git a/src/org/connectbot/WizardActivity.java b/src/org/connectbot/WizardActivity.java index 4758fb5..12941e6 100644 --- a/src/org/connectbot/WizardActivity.java +++ b/src/org/connectbot/WizardActivity.java @@ -18,6 +18,8 @@ package org.connectbot; +import org.connectbot.util.HelpTopicView; + import android.app.Activity; import android.content.Context; import android.os.Bundle; @@ -34,12 +36,6 @@ import android.widget.ViewFlipper; * @author jsharkey */ public class WizardActivity extends Activity { - - /** - * In-order list of wizard steps to present to user. These are layout resource ids. - */ - public final static int[] STEPS = new int[] { R.layout.wiz_eula, R.layout.wiz_features, R.layout.wiz_keyboard }; - protected ViewFlipper flipper = null; protected Button next, prev; @@ -48,13 +44,17 @@ public class WizardActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.act_wizard); - this.flipper = (ViewFlipper)this.findViewById(R.id.wizard_flipper); + this.flipper = (ViewFlipper) findViewById(R.id.wizard_flipper); - // inflate the layouts for each step + // inflate the layout for EULA step LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - for(int layout : STEPS) { - View step = inflater.inflate(layout, this.flipper, false); - this.flipper.addView(step); + this.flipper.addView(inflater.inflate(R.layout.wiz_eula, this.flipper, false)); + + // Add a view for each help topic we want the user to see. + String[] topics = getResources().getStringArray(R.array.list_wizard_topics); + for (String topic : topics) { + View step = new HelpTopicView(this, topic); + flipper.addView(step); } next = (Button)this.findViewById(R.id.action_next); @@ -87,8 +87,7 @@ public class WizardActivity extends Activity { } }); - this.updateButtons(); - + this.updateButtons(); } protected boolean isFirstDisplayed() { @@ -104,7 +103,5 @@ public class WizardActivity extends Activity { next.setText(eula ? getString(R.string.wizard_agree) : getString(R.string.wizard_next)); prev.setText(eula ? getString(R.string.wizard_cancel) : getString(R.string.wizard_back)); - } - } diff --git a/src/org/connectbot/util/HelpTopicView.java b/src/org/connectbot/util/HelpTopicView.java new file mode 100644 index 0000000..2a163cc --- /dev/null +++ b/src/org/connectbot/util/HelpTopicView.java @@ -0,0 +1,56 @@ +/* + ConnectBot: simple, powerful, open-source SSH client for Android + Copyright (C) 2007-2008 Kenny Root, Jeffrey Sharkey + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +package org.connectbot.util; + +import org.connectbot.HelpActivity; + +import android.content.Context; +import android.webkit.WebSettings; +import android.webkit.WebView; + +/** + * @author Kenny Root + * + */ +public class HelpTopicView extends WebView { + + /** + * @param context + */ + public HelpTopicView(Context context) { + super(context); + + WebSettings wSet = getSettings(); + wSet.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); + wSet.setUseWideViewPort(false); + } + + public HelpTopicView(Context context, String topic) { + this(context); + + this.setTopic(topic); + } + + public void setTopic(String topic) { + String path = String.format("file:///android_asset/%s/%s%s", + HelpActivity.HELPDIR, topic, HelpActivity.SUFFIX); + loadUrl(path); + + computeScroll(); + } +} |