comparison src/com/five_ten_sg/connectbot/HelpActivity.java @ 0:0ce5cc452d02

initial version
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 10:41:19 -0700
parents
children 29a431920007
comparison
equal deleted inserted replaced
-1:000000000000 0:0ce5cc452d02
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 java.io.IOException;
21
22 import android.app.Activity;
23 import android.content.Intent;
24 import android.content.pm.PackageManager.NameNotFoundException;
25 import android.content.res.AssetManager;
26 import android.os.Bundle;
27 import android.util.Log;
28 import android.view.View;
29 import android.view.View.OnClickListener;
30 import android.widget.Button;
31 import android.widget.LinearLayout;
32 import android.widget.TextView;
33
34 /**
35 * @author Kenny Root
36 *
37 */
38 public class HelpActivity extends Activity {
39 public final static String TAG = "ConnectBot.HelpActivity";
40
41 public final static String HELPDIR = "help";
42 public final static String SUFFIX = ".html";
43
44 @Override
45 public void onCreate(Bundle icicle) {
46 super.onCreate(icicle);
47 setContentView(R.layout.act_help);
48 this.setTitle(String.format("%s: %s",
49 getResources().getText(R.string.app_name),
50 getResources().getText(R.string.title_help)));
51 AssetManager am = this.getAssets();
52 LinearLayout content = (LinearLayout)this.findViewById(R.id.topics);
53 TextView appVersionView = (TextView) this.findViewById(R.id.topics).findViewById(R.id.app_version);
54
55 // get package version
56 try {
57 appVersionView.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
58 }
59 catch (NameNotFoundException e) {
60 Log.e(TAG, "Problem retrieving application version", e);
61 }
62
63 try {
64 for (String name : am.list(HELPDIR)) {
65 if (name.endsWith(SUFFIX)) {
66 Button button = new Button(this);
67 final String topic = name.substring(0, name.length() - SUFFIX.length());
68 button.setText(topic);
69 button.setOnClickListener(new OnClickListener() {
70 public void onClick(View v) {
71 Intent intent = new Intent(HelpActivity.this, HelpTopicActivity.class);
72 intent.putExtra(Intent.EXTRA_TITLE, topic);
73 HelpActivity.this.startActivity(intent);
74 }
75 });
76 content.addView(button);
77 }
78 }
79 }
80 catch (IOException e) {
81 // TODO Auto-generated catch block
82 Log.e(TAG, "couldn't get list of help assets", e);
83 }
84 }
85 }