Permalink
Browse files

Added dynamic text titles

  • Loading branch information...
1 parent bf666bb commit a6686644d3b15a9e92ecb369a74a4128257e23ff @zh3 committed Nov 13, 2011
@@ -58,7 +58,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="doneBtnCallback"
- android:text="@string/Done_button" />
+ android:text="@string/addButtonTitle" />
</LinearLayout>
<TextView
@@ -27,6 +27,9 @@
<item>months</item>
</string-array>
<string name="deleteChecked">Delete Checked</string>
- <string name="commonItemsTitle">Add Common Item</string>
- <string name="customItemsTitle">Add Custom Item</string>
+ <string name="commonItemsTitle">Favorites</string>
+ <string name="customItemsTitle">Add Item</string>
+ <string name="updateItemTitle">Update Item</string>
+ <string name="updateButtonTitle">Update</string>
+ <string name="addButtonTitle">Add</string>
</resources>
@@ -31,6 +31,7 @@ public void EditPostponeClick(View view) {
Intent itemEdit = new Intent(this, ItemEditActivity.class);
itemEdit.putExtras(food.bundle());
startActivity(itemEdit);
+ finish();
}
public void DoneClick(View view) {
@@ -15,6 +15,7 @@
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
+import android.widget.TextView;
import android.widget.Toast;
//TODO Need to post updates correctly from item edit menu rather than always
@@ -27,13 +28,17 @@
private DatePicker datePicker;
private FridgeFood food;
private static final int MAX_WIDTH_OFFSET = 10;
+ private boolean isUpdate;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
food = FridgeFood.getFoodFromBundle(getIntent().getExtras());
+ isUpdate = (food.getId() != -1);
setContentView(R.layout.item_edit);
+
+ if (isUpdate) setUpdateText();
descField = (EditText) findViewById(R.id.descriptionEditText);
@@ -60,6 +65,15 @@ public void onCreate(Bundle savedInstanceState) {
// add a common item
addCommonItemButtons(adapter);
}
+
+ private void setUpdateText() {
+ TextView customItemsTitle
+ = (TextView) findViewById(R.id.custom_items_title);
+ customItemsTitle.setText(R.string.updateItemTitle);
+
+ Button apply = (Button) findViewById(R.id.button1);
+ apply.setText(R.string.updateButtonTitle);
+ }
private void addCommonItemButtons(ArrayAdapter<CharSequence> descriptions) {
LinearLayout layout = (LinearLayout) findViewById(R.id.common_items_buttons);
@@ -135,7 +149,7 @@ public void doneBtnCallback(View view) {
food.setExpirationDate(getSimpleDateString());
DataClient.getInstance().doNetOp(this,
- (food.getId() == -1) ? NetOp.PUSH : NetOp.UPDATE, food);
+ (!isUpdate) ? NetOp.PUSH : NetOp.UPDATE, food);
finish();
} else {

0 comments on commit a668664

Please sign in to comment.