- Currencies: Added display of table rates - Clean-up: Added Javadoc and NON-NLS tags
/trunk/src/de/pointedears/converter/app/CurrenciesActivity.java |
---|
1,6 → 1,7 |
package de.pointedears.converter.app; |
import java.util.HashMap; |
import java.util.Map.Entry; |
import android.app.Activity; |
import android.os.Bundle; |
17,6 → 18,9 |
import android.widget.Button; |
import android.widget.EditText; |
import android.widget.Spinner; |
import android.widget.TableLayout; |
import android.widget.TableRow; |
import android.widget.TextView; |
import de.pointedears.converter.R; |
import de.pointedears.converter.db.CurrenciesDatabase; |
66,6 → 70,7 |
/* Set up currency database, and retrieve conversion rates */ |
this.db = new CurrenciesDatabase(this); |
this.conversionRates = this.db.getConversionRates(); |
this.fillTableRates(); |
final EditText editValue1 = |
(EditText) this.findViewById(R.id.currencies_edit_value1); |
183,6 → 188,38 |
} |
/** |
* Fills the table with currency conversion rates |
*/ |
private void fillTableRates() |
{ |
TableLayout tableRates = |
(TableLayout) this.findViewById(R.id.currencies_table_rates); |
for (String key : this.conversionRates.keySet()) |
{ |
for (Entry<String, Double> factorEntry : this.conversionRates.get(key) |
.entrySet()) |
{ |
TableRow row = new TableRow(this); |
TextView columnCurrency1 = new TextView(this); |
columnCurrency1.setText(key); |
row.addView(columnCurrency1); |
TextView columnCurrency2 = new TextView(this); |
columnCurrency2.setText(factorEntry.getKey()); |
row.addView(columnCurrency2); |
TextView columnRate = new TextView(this); |
columnRate.setText(factorEntry.getValue().toString()); |
row.addView(columnRate); |
tableRates.addView(row); |
} |
} |
} |
/** |
* @param value |
* @return |
*/ |
/trunk/src/de/pointedears/converter/app/TemperaturesActivity.java |
---|
225,7 → 225,7 |
if (newValue < 0.0) |
{ |
this.textOffScale.setVisibility(View.VISIBLE); |
return "*" + newValue.toString(); |
return "*" + newValue.toString(); //$NON-NLS-1$ |
} |
break; |
} |
244,7 → 244,7 |
if (newValue < 0.0) |
{ |
this.textOffScale.setVisibility(View.VISIBLE); |
return "*" + newValue.toString(); |
return "*" + newValue.toString(); //$NON-NLS-1$ |
} |
break; |
} |
265,7 → 265,7 |
if (value < 0.0) |
{ |
this.textOffScale.setVisibility(View.VISIBLE); |
return "*" + newValue.toString(); |
return "*" + newValue.toString(); //$NON-NLS-1$ |
} |
break; |
} |
/trunk/src/de/pointedears/converter/MenuActivity.java |
---|
33,6 → 33,14 |
import android.widget.ListView; |
import android.widget.SimpleAdapter; |
/** |
* Generates the main menu as a list of activities from the manifest |
* |
* @author |
* Thomas 'PointedEars' Lahn; |
* Class courtesy of The Android Open Source Project |
* (Android 2.2 SDK Examples), slightly adapted |
*/ |
public class MenuActivity extends ListActivity |
{ |
42,19 → 50,23 |
super.onCreate(savedInstanceState); |
Intent intent = this.getIntent(); |
String path = intent.getStringExtra("de.pointedears.converter.Path"); |
String path = intent.getStringExtra("de.pointedears.converter.Path"); //$NON-NLS-1$ |
if (path == null) |
{ |
path = ""; |
path = ""; //$NON-NLS-1$ |
} |
this.setListAdapter(new SimpleAdapter(this, this.getData(path), |
android.R.layout.simple_list_item_1, new String[] { "title" }, |
android.R.layout.simple_list_item_1, new String[] { "title" }, //$NON-NLS-1$ |
new int[] { android.R.id.text1 })); |
this.getListView().setTextFilterEnabled(true); |
} |
/** |
* @param prefix |
* @return |
*/ |
protected List getData(String prefix) |
{ |
List<Map> myData = new ArrayList<Map>(); |
72,13 → 84,13 |
String[] prefixPath; |
if (prefix.equals("")) |
if (prefix.equals("")) //$NON-NLS-1$ |
{ |
prefixPath = null; |
} |
else |
{ |
prefixPath = prefix.split("/"); |
prefixPath = prefix.split("/"); //$NON-NLS-1$ |
} |
int len = list.size(); |
96,7 → 108,7 |
if (prefix.length() == 0 || label.startsWith(prefix)) |
{ |
String[] labelPath = label.split("/"); |
String[] labelPath = label.split("/"); //$NON-NLS-1$ |
String nextLabel = |
prefixPath == null ? labelPath[0] : labelPath[prefixPath.length]; |
114,7 → 126,7 |
this.addItem( |
myData, |
nextLabel, |
this.browseIntent(prefix.equals("") ? nextLabel : prefix + "/" |
this.browseIntent(prefix.equals("") ? nextLabel : prefix + "/" //$NON-NLS-1$//$NON-NLS-2$ |
+ nextLabel)); |
entries.put(nextLabel, true); |
} |
133,10 → 145,15 |
public int compare(Map map1, Map map2) |
{ |
return this.collator.compare(map1.get("title"), map2.get("title")); |
return this.collator.compare(map1.get("title"), map2.get("title")); //$NON-NLS-1$ //$NON-NLS-2$ |
} |
}; |
/** |
* @param pkg |
* @param componentName |
* @return |
*/ |
protected Intent activityIntent(String pkg, String componentName) |
{ |
Intent result = new Intent(); |
144,28 → 161,43 |
return result; |
} |
/** |
* @param path |
* @return |
*/ |
protected Intent browseIntent(String path) |
{ |
Intent result = new Intent(); |
result.setClass(this, MenuActivity.class); |
result.putExtra("de.pointedears.converter.Path", path); |
result.putExtra("de.pointedears.converter.Path", path); //$NON-NLS-1$ |
return result; |
} |
/** |
* @param data |
* @param name |
* @param intent |
*/ |
protected void addItem(List<Map> data, String name, Intent intent) |
{ |
Map<String, Object> temp = new HashMap<String, Object>(); |
temp.put("title", name); |
temp.put("intent", intent); |
temp.put("title", name); //$NON-NLS-1$ |
temp.put("intent", intent); //$NON-NLS-1$ |
data.add(temp); |
} |
/* |
* (non-Javadoc) |
* |
* @see android.app.ListActivity#onListItemClick(android.widget.ListView, |
* android.view.View, int, long) |
*/ |
@Override |
protected void onListItemClick(ListView l, View v, int position, long id) |
{ |
Map map = (Map) l.getItemAtPosition(position); |
Intent intent = (Intent) map.get("intent"); |
Intent intent = (Intent) map.get("intent"); //$NON-NLS-1$ |
this.startActivity(intent); |
} |
/trunk/bin/Converter.apk |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/bin/resources.ap_ |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/bin/classes.dex |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/res/values/strings.xml |
---|
9,6 → 9,10 |
<string name="temperatures_off_scale"><sup>*</sup> Theoretical value off the scale</string> |
<string name="activity_currencies">Currencies</string> |
<string name="currencies_currency1"><b>Currency 1</b></string> |
<string name="currencies_currency2"><b>Currency 2</b></string> |
<string name="currencies_rate"><b>Rate</b></string> |
<string name="caption_update">Update</string> |
<string name="option_quit">Quit</string> |
<string name="bar">Quit</string> |
/trunk/res/layout/activity_currencies.xml |
---|
3,7 → 3,7 |
android:orientation="vertical" android:layout_height="fill_parent" |
android:layout_width="fill_parent"> |
<TableLayout android:id="@+id/TableLayout01" |
<TableLayout android:id="@+id/currencies_table_widget" |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
android:stretchColumns="1,3" android:shrinkColumns="*" |
android:layout_marginTop="10sp"> |
30,4 → 30,14 |
<Button android:text="@string/button_clear" android:id="@+id/currencies_button_clear" |
android:layout_height="wrap_content" android:layout_width="100sp" |
android:layout_gravity="center_horizontal"></Button> |
<TableLayout android:id="@+id/currencies_table_rates" |
android:scrollbars="vertical" android:layout_height="wrap_content" |
android:layout_width="fill_parent" android:stretchColumns="*"> |
<TableRow> |
<TextView android:text="@string/currencies_currency1" /> |
<TextView android:text="@string/currencies_currency2" /> |
<TextView android:text="@string/currencies_rate" /> |
</TableRow> |
</TableLayout> |
</LinearLayout> |