Version 0.4 with SD card installation support (FroYo).

This commit is contained in:
Erik C. Thauvin 2010-07-08 09:32:00 +00:00
parent 6cc6bc1a8f
commit 37c85645b3
8 changed files with 179 additions and 69 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.thauvin.erik.android.tiproid" android:versionName="0.3" android:versionCode="3"> package="net.thauvin.erik.android.tiproid" android:installLocation="auto"
android:versionName="0.4" android:versionCode="4">
<application android:icon="@drawable/icon" android:label="@string/app_name"> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="Tiproid"> <activity android:label="@string/app_name" android:name="Tiproid">
<intent-filter> <intent-filter>
@ -9,5 +10,5 @@
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
<uses-sdk android:minSdkVersion="2"></uses-sdk> <uses-sdk android:minSdkVersion="2"></uses-sdk>
</manifest> </manifest>

14
default.properties Normal file
View file

@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-8
apk-configurations=

View file

@ -0,0 +1,87 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package net.thauvin.erik.android.tiproid;
public final class R {
public static final class array {
public static final int main_split_array=0x7f040001;
public static final int main_tip_array=0x7f040000;
}
public static final class attr {
}
public static final class drawable {
public static final int calc=0x7f020000;
public static final int delete=0x7f020001;
public static final int icon=0x7f020002;
}
public static final class id {
public static final int Button0=0x7f060011;
public static final int Button01=0x7f060004;
public static final int Button02=0x7f060005;
public static final int Button03=0x7f060006;
public static final int Button04=0x7f060008;
public static final int Button05=0x7f060009;
public static final int Button06=0x7f06000a;
public static final int Button07=0x7f06000c;
public static final int Button08=0x7f06000d;
public static final int Button09=0x7f06000e;
public static final int ButtonBS=0x7f060012;
public static final int ButtonDot=0x7f060010;
public static final int TableLayout01=0x7f060002;
public static final int TableRow01=0x7f060003;
public static final int TableRow02=0x7f060007;
public static final int TableRow03=0x7f06000b;
public static final int TableRow04=0x7f06000f;
public static final int about_text_fld=0x7f060000;
public static final int calc_edit_fld=0x7f060001;
public static final int main_bill_edit_btn=0x7f060018;
public static final int main_bill_fld=0x7f060017;
public static final int main_bill_lbl=0x7f060016;
public static final int main_calculate_btn=0x7f06001c;
public static final int main_reset_btn=0x7f06001d;
public static final int main_split_spin=0x7f06001b;
public static final int main_tax_edit_btn=0x7f060015;
public static final int main_tax_fld=0x7f060014;
public static final int main_tax_lbl=0x7f060013;
public static final int main_tip_lbl=0x7f060019;
public static final int main_tip_spin=0x7f06001a;
public static final int result_split_fld=0x7f060023;
public static final int result_split_lbl=0x7f060022;
public static final int result_tip_fld=0x7f06001f;
public static final int result_tip_lbl=0x7f06001e;
public static final int result_total_fld=0x7f060021;
public static final int result_total_lbl=0x7f060020;
}
public static final class layout {
public static final int about=0x7f030000;
public static final int calc=0x7f030001;
public static final int main=0x7f030002;
public static final int result=0x7f030003;
}
public static final class string {
public static final int about_menu_txt=0x7f050002;
public static final int about_txt=0x7f050001;
public static final int alert_dialog_cancel=0x7f050004;
public static final int alert_dialog_ok=0x7f050003;
public static final int app_name=0x7f050000;
public static final int error_bill_txt=0x7f050010;
public static final int error_identical_txt=0x7f050011;
public static final int main_bill_lbl_txt=0x7f050005;
public static final int main_calc_btn_txt=0x7f050006;
public static final int main_reset_btn_txt=0x7f050007;
public static final int main_split_lbl_txt=0x7f05000c;
public static final int main_tax_hint_land_txt=0x7f050009;
public static final int main_tax_hint_txt=0x7f05000a;
public static final int main_tax_lbl_txt=0x7f050008;
public static final int main_tip_lbl_txt=0x7f05000b;
public static final int result_split_lbl_txt=0x7f05000e;
public static final int result_tip_lbl_txt=0x7f05000d;
public static final int result_total_lbl_txt=0x7f05000f;
public static final int sample_txt=0x7f050012;
}
}

View file

@ -6,14 +6,13 @@
android:layout_width="wrap_content" android:layout_marginRight="20dip" android:layout_width="wrap_content" android:layout_marginRight="20dip"
android:text="@string/main_tax_lbl_txt" android:gravity="left" android:text="@string/main_tax_lbl_txt" android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/main_tax_lbl" android:layout_marginLeft="20dip" /> android:id="@+id/main_tax_lbl" android:layout_marginLeft="20dip" android:textSize="15px"/>
<LinearLayout android:layout_width="fill_parent" <LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:baselineAligned="false" android:layout_height="wrap_content" android:baselineAligned="false"
android:layout_marginRight="20dip" android:layout_marginLeft="20dip"> android:layout_marginRight="20dip" android:layout_marginLeft="20dip">
<EditText android:layout_height="wrap_content" <EditText android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:numeric="decimal" android:layout_gravity="center_vertical" android:gravity="right" android:id="@+id/main_tax_fld"
android:gravity="right" android:id="@+id/main_tax_fld" android:layout_width="wrap_content" android:minWidth="200dip" android:numeric="decimal"/>
android:layout_width="wrap_content" android:minWidth="200dip" />
<ImageButton android:layout_width="wrap_content" <ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/calc" android:layout_height="wrap_content" android:src="@drawable/calc"
android:id="@+id/main_tax_edit_btn" android:minWidth="81dip"></ImageButton> android:id="@+id/main_tax_edit_btn" android:minWidth="81dip"></ImageButton>
@ -22,14 +21,13 @@
android:layout_width="wrap_content" android:layout_marginRight="20dip" android:layout_width="wrap_content" android:layout_marginRight="20dip"
android:text="@string/main_bill_lbl_txt" android:gravity="left" android:text="@string/main_bill_lbl_txt" android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/main_bill_lbl" android:layout_marginLeft="20dip" /> android:id="@+id/main_bill_lbl" android:layout_marginLeft="20dip" android:textSize="15px"/>
<LinearLayout android:layout_width="fill_parent" <LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:baselineAligned="false" android:layout_height="wrap_content" android:baselineAligned="false"
android:layout_marginRight="20dip" android:layout_marginLeft="20dip"> android:layout_marginRight="20dip" android:layout_marginLeft="20dip">
<EditText android:layout_height="wrap_content" <EditText android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:numeric="decimal" android:layout_gravity="center_vertical" android:gravity="right" android:id="@+id/main_bill_fld"
android:gravity="right" android:id="@+id/main_bill_fld" android:layout_width="wrap_content" android:minWidth="200dip" android:numeric="decimal"/>
android:layout_width="wrap_content" android:minWidth="200dip" />
<ImageButton android:layout_width="wrap_content" <ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/calc" android:layout_height="wrap_content" android:src="@drawable/calc"
android:id="@+id/main_bill_edit_btn" android:minWidth="81dip"></ImageButton> android:id="@+id/main_bill_edit_btn" android:minWidth="81dip"></ImageButton>
@ -43,11 +41,11 @@
android:layout_width="wrap_content" android:gravity="left" android:layout_width="wrap_content" android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/main_tip_lbl" android:text="@string/main_tip_lbl_txt" android:id="@+id/main_tip_lbl" android:text="@string/main_tip_lbl_txt"
android:minWidth="200dip" /> android:minWidth="200dip" android:textSize="15px"/>
<TextView android:layout_height="wrap_content" <TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:gravity="left" android:layout_width="wrap_content" android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/main_tip_lbl" android:text="@string/main_split_lbl_txt" /> android:id="@+id/main_tip_lbl" android:text="@string/main_split_lbl_txt" android:textSize="15px"/>
</TableRow> </TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content" <TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content"
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:layout_marginLeft="20dip" android:layout_marginRight="20dip"
@ -68,10 +66,10 @@
android:layout_height="wrap_content" android:layout_marginTop="20dip"> android:layout_height="wrap_content" android:layout_marginTop="20dip">
<Button android:layout_width="wrap_content" <Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/main_calc_btn_txt" android:layout_height="wrap_content" android:text="@string/main_calc_btn_txt"
android:id="@+id/main_calculate_btn" style="?android:attr/buttonStyleSmall"></Button> android:id="@+id/main_calculate_btn"></Button>
<Button android:layout_width="wrap_content" <Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/main_reset_btn_txt" android:layout_height="wrap_content" android:text="@string/main_reset_btn_txt"
android:id="@+id/main_reset_btn" style="?android:attr/buttonStyleSmall"></Button> android:id="@+id/main_reset_btn"></Button>
</TableRow> </TableRow>
</TableLayout> </TableLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Tiproid</string> <string name="app_name">Tiproid</string>
<string name="about_txt">© 2008-9 Erik C. Thauvin\nAll Rights Reserved\n\nerik@thauvin.net\n\nhttp://mobile.thauvin.net</string> <string name="about_txt">© 2008-10 Erik C. Thauvin\nAll Rights Reserved\n\nerik@thauvin.net\n\nhttp://mobile.thauvin.net/</string>
<string name="about_menu_txt">About</string> <string name="about_menu_txt">About</string>
<string name="alert_dialog_ok">OK</string> <string name="alert_dialog_ok">OK</string>
<string name="alert_dialog_cancel">Cancel</string> <string name="alert_dialog_cancel">Cancel</string>
@ -16,6 +16,7 @@
<string name="result_tip_lbl_txt">Tip ?%:</string> <string name="result_tip_lbl_txt">Tip ?%:</string>
<string name="result_split_lbl_txt">Split x ?:</string> <string name="result_split_lbl_txt">Split x ?:</string>
<string name="result_total_lbl_txt">Total:</string> <string name="result_total_lbl_txt">Total:</string>
<string name="error_bill_txt">Please enter the bill amount...</string> <string name="error_bill_txt">Please enter the bill amount!</string>
<string name="error_identical_txt">Amounts should not be identical!</string>
<string name="sample_txt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string> <string name="sample_txt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
</resources> </resources>

BIN
screenshots/0.3/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
screenshots/0.3/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -249,66 +249,76 @@ public class Tiproid extends Activity
taxTotal = parseInt(taxTxt); taxTotal = parseInt(taxTxt);
} }
final int subTotal = parseInt(billTxt) - taxTotal; final int billTotal = parseInt(billTxt);
final int tipRate = Integer.parseInt(tipTxt);
final int splitCount = Integer.parseInt(splitTxt);
int tipTotal = (subTotal * tipRate) / 100;
int billTotal = subTotal + tipTotal + taxTotal;
if ((billTotal % 100) < 50) if (taxTotal == billTotal)
{ {
while ((billTotal % 100) != 0) Toast.makeText(Tiproid.this, R.string.error_identical_txt, Toast.LENGTH_SHORT).show();
{
tipTotal--;
billTotal = subTotal + tipTotal + taxTotal;
}
} }
else else
{ {
while ((billTotal % 100) != 0)
final int subTotal = billTotal - taxTotal;
final int tipRate = Integer.parseInt(tipTxt);
final int splitCount = Integer.parseInt(splitTxt);
int tipSum = (subTotal * tipRate) / 100;
int billSum = subTotal + tipSum + taxTotal;
if ((billSum % 100) < 50)
{ {
tipTotal++; while ((billSum % 100) != 0)
billTotal = subTotal + tipTotal + taxTotal;
}
}
final LayoutInflater factory = LayoutInflater.from(this);
final View resultView = factory.inflate(R.layout.result, null);
final TextView tipFld = (TextView) resultView.findViewById(R.id.result_tip_fld);
final TextView totalFld = (TextView) resultView.findViewById(R.id.result_total_fld);
final TextView tipLbl = (TextView) resultView.findViewById(R.id.result_tip_lbl);
final TextView splitFld = (TextView) resultView.findViewById(R.id.result_split_fld);
final TextView splitLbl = (TextView) resultView.findViewById(R.id.result_split_lbl);
tipLbl.setText(tipLbl.getText().toString().replace("?", tipTxt));
tipFld.setText(parseStr(tipTotal));
totalFld.setText(parseStr(billTotal));
if (splitCount == 1)
{
splitFld.setText("");
splitLbl.setText("");
}
else
{
splitLbl.setText(splitLbl.getText().toString().replace("?", splitTxt));
int split = billTotal / splitCount;
if ((split * splitCount) < billTotal)
{
split += 1;
}
splitFld.setText(parseStr(split));
}
new AlertDialog.Builder(this).setView(resultView).setPositiveButton(R.string.alert_dialog_ok,
new DialogInterface.OnClickListener()
{ {
public void onClick(DialogInterface dialog, int whichButton) tipSum--;
billSum = subTotal + tipSum + taxTotal;
}
}
else
{
while ((billSum % 100) != 0)
{
tipSum++;
billSum = subTotal + tipSum + taxTotal;
}
}
final LayoutInflater factory = LayoutInflater.from(this);
final View resultView = factory.inflate(R.layout.result, null);
final TextView tipFld = (TextView) resultView.findViewById(R.id.result_tip_fld);
final TextView totalFld = (TextView) resultView.findViewById(R.id.result_total_fld);
final TextView tipLbl = (TextView) resultView.findViewById(R.id.result_tip_lbl);
final TextView splitFld = (TextView) resultView.findViewById(R.id.result_split_fld);
final TextView splitLbl = (TextView) resultView.findViewById(R.id.result_split_lbl);
tipLbl.setText(tipLbl.getText().toString().replace("?", tipTxt));
tipFld.setText(parseStr(tipSum));
totalFld.setText(parseStr(billSum));
if (splitCount == 1)
{
splitFld.setText("");
splitLbl.setText("");
}
else
{
splitLbl.setText(splitLbl.getText().toString().replace("?", splitTxt));
int split = billSum / splitCount;
if ((split * splitCount) < billSum)
{
split += 1;
}
splitFld.setText(parseStr(split));
}
new AlertDialog.Builder(this).setView(resultView).setPositiveButton(R.string.alert_dialog_ok,
new DialogInterface.OnClickListener()
{ {
// do nothing public void onClick(DialogInterface dialog, int whichButton)
} {
}).show(); // do nothing
}
}).show();
}
} }
} }
@ -358,7 +368,6 @@ public class Tiproid extends Activity
else else
{ {
taxFld.setHint(getString(R.string.main_tax_hint_txt)); taxFld.setHint(getString(R.string.main_tax_hint_txt));
} }
final ArrayAdapter<CharSequence> tipAdapter = ArrayAdapter.createFromResource(this, R.array.main_tip_array, final ArrayAdapter<CharSequence> tipAdapter = ArrayAdapter.createFromResource(this, R.array.main_tip_array,