comparison src/com/five_ten_sg/connectbot/HelpActivity.java @ 383:f7e09771172f

wizard and help present help pages in the same order
author Carl Byington <carl@five-ten-sg.com>
date Wed, 06 Aug 2014 11:34:02 -0700
parents 071eccdff8ea
children b919cd3d6e2f
comparison
equal deleted inserted replaced
382:41fa02fdb9c6 383:f7e09771172f
20 import java.io.IOException; 20 import java.io.IOException;
21 21
22 import android.app.Activity; 22 import android.app.Activity;
23 import android.content.Intent; 23 import android.content.Intent;
24 import android.content.pm.PackageManager.NameNotFoundException; 24 import android.content.pm.PackageManager.NameNotFoundException;
25 import android.content.res.AssetManager;
26 import android.os.Bundle; 25 import android.os.Bundle;
27 import android.util.Log; 26 import android.util.Log;
28 import android.view.View; 27 import android.view.View;
29 import android.view.View.OnClickListener; 28 import android.view.View.OnClickListener;
30 import android.widget.Button; 29 import android.widget.Button;
36 * 35 *
37 */ 36 */
38 public class HelpActivity extends Activity { 37 public class HelpActivity extends Activity {
39 public final static String TAG = "ConnectBot.HelpActivity"; 38 public final static String TAG = "ConnectBot.HelpActivity";
40 39
41 public final static String HELPDIR = "help";
42 public final static String SUFFIX = ".html";
43
44 @Override 40 @Override
45 public void onCreate(Bundle icicle) { 41 public void onCreate(Bundle icicle) {
46 super.onCreate(icicle); 42 super.onCreate(icicle);
47 setContentView(R.layout.act_help); 43 setContentView(R.layout.act_help);
48 this.setTitle(String.format("%s: %s", 44 this.setTitle(String.format("%s: %s",
49 getResources().getText(R.string.app_name), 45 getResources().getText(R.string.app_name),
50 getResources().getText(R.string.title_help))); 46 getResources().getText(R.string.title_help)));
51 AssetManager am = this.getAssets();
52 LinearLayout content = (LinearLayout)this.findViewById(R.id.topics); 47 LinearLayout content = (LinearLayout)this.findViewById(R.id.topics);
53 48
54 try { 49 try {
55 for (String name : am.list(HELPDIR)) { 50 String[] topics = getResources().getStringArray(R.array.list_wizard_topics);
56 if (name.endsWith(SUFFIX)) { 51 for (String topic : topics)) {
57 Button button = new Button(this); 52 Button button = new Button(this);
58 final String topic = name.substring(0, name.length() - SUFFIX.length()); 53 button.setText(topic);
59 button.setText(topic); 54 button.setOnClickListener(new OnClickListener() {
60 button.setOnClickListener(new OnClickListener() { 55 public void onClick(View v) {
61 public void onClick(View v) { 56 Intent intent = new Intent(HelpActivity.this, HelpTopicActivity.class);
62 Intent intent = new Intent(HelpActivity.this, HelpTopicActivity.class); 57 intent.putExtra(Intent.EXTRA_TITLE, topic);
63 intent.putExtra(Intent.EXTRA_TITLE, topic); 58 HelpActivity.this.startActivity(intent);
64 HelpActivity.this.startActivity(intent); 59 }
65 } 60 });
66 }); 61 content.addView(button);
67 content.addView(button);
68 }
69 } 62 }
70 } 63 }
71 catch (IOException e) { 64 catch (IOException e) {
72 // TODO Auto-generated catch block 65 // TODO Auto-generated catch block
73 Log.e(TAG, "couldn't get list of help assets", e); 66 Log.e(TAG, "couldn't get list of help assets", e);