aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/AboutActivity.java
blob: b330596d8a3f1cebcbf6eebcdd0e3be201a9f322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * Southampton University Map App
 * Copyright (C) 2011  Christopher Baines
 * 
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package net.cbaines.suma;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.TextView;

public class AboutActivity extends Activity implements OnClickListener {

    static final int DONATE_DIALOG_ID = 0;

    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.about_dialog);

	ExpandableListView epView = (ExpandableListView) findViewById(R.id.helpExpandableListView);
	AboutListAdapter mAdapter = new AboutListAdapter(this);
	epView.setAdapter(mAdapter);

	Button donateButton = (Button) findViewById(R.id.donateButton);
	donateButton.setOnClickListener(this);

    }

    class AboutListAdapter extends BaseExpandableListAdapter {
	private String[] groups = { "Map", "Find", "Preferences", "Find my Location", "View", "About", "Favourites", "Licence", "Credits" };
	private LayoutInflater inflater;
	private Context cxt;

	public AboutListAdapter(Context cxt) {
	    inflater = LayoutInflater.from(cxt);
	    this.cxt = cxt;
	}

	public Object getChild(int groupPos, int childPos) {
	    if (groupPos == 0) {
		return cxt.getResources().getString(R.string.map_help_message);
	    } else if (groupPos == 1) {
		return cxt.getResources().getString(R.string.find_help_message);
	    } else if (groupPos == 1) {
		return cxt.getResources().getString(R.string.preferences_help_message);
	    } else if (groupPos == 2) {
		return cxt.getResources().getString(R.string.findmylocation_help_message);
	    } else if (groupPos == 3) {
		return cxt.getResources().getString(R.string.view_help_message);
	    } else if (groupPos == 4) {
		return cxt.getResources().getString(R.string.about_help_message);
	    } else if (groupPos == 5) {
		return cxt.getResources().getString(R.string.favourites_help_message);
	    } else if (groupPos == 6) {
		return cxt.getResources().getString(R.string.favourites_help_message);
	    } else if (groupPos == 7) {
		return cxt.getResources().getString(R.string.licence_help_message);
	    } else if (groupPos == 8) {
		return cxt.getResources().getString(R.string.credits_help_message);
	    }
	    return null;
	}

	public long getChildId(int groupPos, int childPos) {
	    return childPos;
	}

	public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertView, ViewGroup parent) {
	    TextView tv = new TextView(cxt);
	    tv.setText(getChild(groupPos, childPos).toString());
	    return tv;
	}

	public int getChildrenCount(int groupPos) {
	    return 1;
	}

	public Object getGroup(int groupPos) {
	    return groups[groupPos];
	}

	public int getGroupCount() {
	    return groups.length;
	}

	public long getGroupId(int groupPos) {
	    return groupPos;
	}

	public View getGroupView(int groupPos, boolean isExpanded, View convertView, ViewGroup parent) {
	    View v = null;
	    if (convertView != null)
		v = convertView;
	    else
		v = inflater.inflate(R.layout.view_group_row, parent, false);
	    String gt = (String) getGroup(groupPos);
	    TextView colorGroup = (TextView) v.findViewById(R.id.childname);
	    if (gt != null)
		colorGroup.setText(gt);
	    return v;
	}

	public boolean hasStableIds() {
	    return true;
	}

	public boolean isChildSelectable(int groupPos, int childPos) {
	    return true;
	}

    }

    public void onClick(View arg0) {
	showDialog(DONATE_DIALOG_ID);
    }

    protected Dialog onCreateDialog(int id) {
	switch (id) {
	case DONATE_DIALOG_ID:
	    DonateDialog donateDialog = new DonateDialog(this);
	    return donateDialog;

	}
	return null;
    }
}