Skip to content

Commit

Permalink
Added dynamic text titles
Browse files Browse the repository at this point in the history
  • Loading branch information
zh3 committed Nov 13, 2011
1 parent bf666bb commit a668664
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion OpenFridge_ZH/res/layout/item_edit.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="doneBtnCallback" android:onClick="doneBtnCallback"
android:text="@string/Done_button" /> android:text="@string/addButtonTitle" />
</LinearLayout> </LinearLayout>


<TextView <TextView
Expand Down
7 changes: 5 additions & 2 deletions OpenFridge_ZH/res/values/strings.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<item>months</item> <item>months</item>
</string-array> </string-array>
<string name="deleteChecked">Delete Checked</string> <string name="deleteChecked">Delete Checked</string>
<string name="commonItemsTitle">Add Common Item</string> <string name="commonItemsTitle">Favorites</string>
<string name="customItemsTitle">Add Custom Item</string> <string name="customItemsTitle">Add Item</string>
<string name="updateItemTitle">Update Item</string>
<string name="updateButtonTitle">Update</string>
<string name="addButtonTitle">Add</string>
</resources> </resources>
1 change: 1 addition & 0 deletions OpenFridge_ZH/src/com/openfridge/ExpireActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void EditPostponeClick(View view) {
Intent itemEdit = new Intent(this, ItemEditActivity.class); Intent itemEdit = new Intent(this, ItemEditActivity.class);
itemEdit.putExtras(food.bundle()); itemEdit.putExtras(food.bundle());
startActivity(itemEdit); startActivity(itemEdit);
finish();
} }


public void DoneClick(View view) { public void DoneClick(View view) {
Expand Down
16 changes: 15 additions & 1 deletion OpenFridge_ZH/src/com/openfridge/ItemEditActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.widget.DatePicker; import android.widget.DatePicker;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;


//TODO Need to post updates correctly from item edit menu rather than always //TODO Need to post updates correctly from item edit menu rather than always
Expand All @@ -27,13 +28,17 @@ public class ItemEditActivity extends Activity {
private DatePicker datePicker; private DatePicker datePicker;
private FridgeFood food; private FridgeFood food;
private static final int MAX_WIDTH_OFFSET = 10; private static final int MAX_WIDTH_OFFSET = 10;
private boolean isUpdate;


public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);


food = FridgeFood.getFoodFromBundle(getIntent().getExtras()); food = FridgeFood.getFoodFromBundle(getIntent().getExtras());
isUpdate = (food.getId() != -1);


setContentView(R.layout.item_edit); setContentView(R.layout.item_edit);

if (isUpdate) setUpdateText();


descField = (EditText) findViewById(R.id.descriptionEditText); descField = (EditText) findViewById(R.id.descriptionEditText);


Expand All @@ -60,6 +65,15 @@ public void onCreate(Bundle savedInstanceState) {
// add a common item // add a common item
addCommonItemButtons(adapter); 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) { private void addCommonItemButtons(ArrayAdapter<CharSequence> descriptions) {
LinearLayout layout = (LinearLayout) findViewById(R.id.common_items_buttons); LinearLayout layout = (LinearLayout) findViewById(R.id.common_items_buttons);
Expand Down Expand Up @@ -135,7 +149,7 @@ public void doneBtnCallback(View view) {
food.setExpirationDate(getSimpleDateString()); food.setExpirationDate(getSimpleDateString());


DataClient.getInstance().doNetOp(this, DataClient.getInstance().doNetOp(this,
(food.getId() == -1) ? NetOp.PUSH : NetOp.UPDATE, food); (!isUpdate) ? NetOp.PUSH : NetOp.UPDATE, food);


finish(); finish();
} else { } else {
Expand Down

0 comments on commit a668664

Please sign in to comment.