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 org.connectbot; 19 20 import android.app.Activity; 21 import android.content.Intent; 22 import android.content.res.AssetManager; 23 import android.os.Bundle; 24 import android.text.method.LinkMovementMethod; 25 import android.view.View; 26 import android.view.View.OnClickListener; 27 import android.widget.Button; 28 import android.widget.LinearLayout; 29 import android.widget.TextView; 30 31 import com.googlecode.android_scripting.Log; 32 import com.googlecode.android_scripting.R; 33 import com.googlecode.android_scripting.Version; 34 35 import java.io.IOException; 36 37 /** 38 * @author Kenny Root 39 * 40 */ 41 public class HelpActivity extends Activity { 42 public final static String TAG = "ConnectBot.HelpActivity"; 43 44 public final static String HELPDIR = "help"; 45 public final static String SUFFIX = ".html"; 46 47 @Override onCreate(Bundle icicle)48 public void onCreate(Bundle icicle) { 49 super.onCreate(icicle); 50 setContentView(R.layout.act_help); 51 52 this.setTitle(String.format("%s: %s", getResources().getText(R.string.application_nice_title), 53 getResources().getText(R.string.title_help))); 54 55 TextView subtitle = (TextView) findViewById(R.id.version); 56 subtitle.setText(getText(R.string.application_title) + " r" 57 + Version.getVersion(getApplication())); 58 59 ((TextView) findViewById(R.id.help_acks_text)).setMovementMethod(LinkMovementMethod 60 .getInstance()); 61 62 AssetManager am = getAssets(); 63 LinearLayout content = (LinearLayout) findViewById(R.id.topics); 64 65 try { 66 for (String name : am.list(HELPDIR)) { 67 if (name.endsWith(SUFFIX)) { 68 Button button = new Button(this); 69 final String topic = name.substring(0, name.length() - SUFFIX.length()); 70 button.setText(topic); 71 72 button.setOnClickListener(new OnClickListener() { 73 public void onClick(View v) { 74 Intent intent = new Intent(HelpActivity.this, HelpTopicActivity.class); 75 intent.putExtra(Intent.EXTRA_TITLE, topic); 76 HelpActivity.this.startActivity(intent); 77 } 78 }); 79 80 content.addView(button); 81 } 82 } 83 } catch (IOException e) { 84 // TODO Auto-generated catch block 85 Log.e("couldn't get list of help assets", e); 86 } 87 } 88 } 89