-
Notifications
You must be signed in to change notification settings - Fork 0
Issue #6: String resource conversion #7
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ else if (mDestination == GuideDestination.ATMs) | |
|
||
if (item == null) { | ||
Log.w("GuideDetailFragment.onLoadFinished no data loaded from cursor"); | ||
Toast.makeText(getActivity(), "Error: No data was loaded.", Toast.LENGTH_SHORT).show(); | ||
Toast.makeText(getActivity(), R.string.error_no_data_loaded, Toast.LENGTH_SHORT).show(); | ||
return; | ||
} | ||
|
||
|
@@ -180,26 +180,26 @@ public View getView(int position, View convertView, ViewGroup parent) { | |
text2.setText(sb); | ||
break; | ||
case ROW_PHONE: | ||
text1.setText("Call " + item.getPhone()); | ||
text1.setText(getString(R.string.call_number) + item.getPhone()); | ||
text1.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.ic_menu_call, 0); | ||
break; | ||
case ROW_CATEGORY: | ||
text1.setText("Category"); | ||
text1.setText(R.string.row_category); | ||
text2.setText(item.getCategory()); | ||
break; | ||
case ROW_RATING: | ||
text1.setText("Rating"); | ||
text2.setText(rItem.getRating() + " stars"); | ||
text1.setText(R.string.row_rating); | ||
text2.setText(rItem.getRating() + getString(R.string.rating_stars)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use string formatting. |
||
break; | ||
case ROW_COST: | ||
text1.setText("Cost"); | ||
text1.setText(R.string.row_cost); | ||
text2.setText(rItem.getDollarsAsSigns()); | ||
break; | ||
case ROW_DELIVERY: | ||
text1.setText("Has delivery"); | ||
text1.setText(R.string.row_has_delivery); | ||
break; | ||
case ROW_COMMENTS: | ||
text1.setText("Review/comments"); | ||
text1.setText(R.string.row_comments); | ||
text2.setText(item.getComments()); | ||
break; | ||
case ROW_HOURS: | ||
|
@@ -214,15 +214,15 @@ public View getView(int position, View convertView, ViewGroup parent) { | |
tvSunday.setText(GuideBaseItem.getTimeText(item.getSundayHours())); | ||
break; | ||
case ROW_URL: | ||
text1.setText("Open website"); | ||
text1.setText(R.string.open_website); | ||
text1.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.ic_menu_directions, 0); | ||
break; | ||
case ROW_GOOGLE: | ||
text1.setText("Open in Google Maps"); | ||
text1.setText(R.string.open_in_maps); | ||
text1.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.ic_menu_mapmode, 0); | ||
break; | ||
case ROW_YELP: | ||
text1.setText("Open on Yelp"); | ||
text1.setText(R.string.open_in_yelp); | ||
text1.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.ic_menu_directions, 0); | ||
break; | ||
default: | ||
|
@@ -276,7 +276,7 @@ private void showError(String message) { | |
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); | ||
alert.setMessage(message) | ||
.setCancelable(true) | ||
.setNegativeButton("Close", new DialogInterface.OnClickListener() { | ||
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int id) { | ||
dialog.dismiss(); | ||
|
@@ -286,23 +286,23 @@ public void onClick(DialogInterface dialog, int id) { | |
|
||
private void showLocation(final GuideBaseItem<?> item) { | ||
if (item.getPlaceId().equals("")) { | ||
String message = "This location could not be found in Google Maps."; | ||
String message = getString(R.string.not_found_on_maps); | ||
|
||
if ((mDestination == GuideDestination.Restaurants) || (mDestination == GuideDestination.RestaurantsOpenNow)) { | ||
// Special 'closed' checks | ||
RestaurantListItem restaurant = (RestaurantListItem) item; | ||
RestaurantOpenStatus openStatus = restaurant.getOpenStatus(); | ||
|
||
if (openStatus == RestaurantOpenStatus.Closed) { | ||
message = "This location could not be found in Google Maps, and may be closed."; | ||
message = getString(R.string.not_found_on_maps_closed); | ||
} else if (openStatus == RestaurantOpenStatus.VerifiedOpen) { | ||
message = "This location could not be found in Google Maps, but it was verified to be open by MyConbook."; | ||
message = getString(R.string.not_found_on_maps_verified_open); | ||
} | ||
} | ||
|
||
AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); | ||
dialog.setCancelable(true).setTitle("Location not found").setMessage(message) | ||
.setNegativeButton("Cancel", new android.content.DialogInterface.OnClickListener() { | ||
dialog.setCancelable(true).setTitle(R.string.location_not_found).setMessage(message) | ||
.setNegativeButton(android.R.string.cancel, new android.content.DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
dialog.cancel(); | ||
|
@@ -316,15 +316,15 @@ public void onClick(DialogInterface dialog, int which) { | |
|
||
if (openStatus == RestaurantOpenStatus.Closed) { | ||
AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); | ||
dialog.setCancelable(true).setTitle("Location may be closed") | ||
.setMessage("This location was marked as closed according to Google, but was still in the conbook. It may or may not still be open.") | ||
.setPositiveButton("Continue", new android.content.DialogInterface.OnClickListener() { | ||
dialog.setCancelable(true).setTitle(R.string.location_may_be_closed) | ||
.setMessage(R.string.location_may_be_closed_message) | ||
.setPositiveButton(R.string.continue, new android.content.DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
showPlaceInMaps(item); | ||
} | ||
}) | ||
.setNegativeButton("Cancel", new android.content.DialogInterface.OnClickListener() { | ||
.setNegativeButton(android.R.string.cancel, new android.content.DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
dialog.cancel(); | ||
|
@@ -347,7 +347,7 @@ private void showPlaceInMaps(GuideBaseItem<?> item) { | |
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
Log.w("GuideDetailFragment.showPlaceInMaps error launching Places link", e); | ||
showError("Unable to launch Google Maps."); | ||
showError(getString(R.string.unable_to_launch_maps)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should make showError take ints and resolve string at display time. |
||
} | ||
} | ||
|
||
|
@@ -359,7 +359,7 @@ private void launchBrowser(String url) { | |
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
Log.w("GuideDetailFragment.launchBrowser error launching browser for url " + url, e); | ||
showError("Unable to launch browser for link " + url + "."); | ||
showError(R.string.cant_open_link + url + "."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use string formatting. |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ public void onListItemClick(ListView l, View v, int position, long id) { | |
return; | ||
} | ||
|
||
String items[] = {"Call " + hli.getPhone(), "Open in Google Maps"}; | ||
String items[] = {getString(R.string.call_number) + hli.getPhone(), getString(R.string.open_in_maps)}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use string formatting. |
||
|
||
AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); | ||
dialog.setCancelable(true).setTitle(hli.getName()).setItems(items, new OnClickListener() { | ||
|
@@ -66,7 +66,7 @@ public void onClick(DialogInterface dialog, int which) { | |
try { | ||
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
showError("Could not find an application to handle the request."); | ||
showError(getString(R.string.activity_not_found)); | ||
} | ||
} else if (which == 1) { | ||
// Open place | ||
|
@@ -75,7 +75,7 @@ public void onClick(DialogInterface dialog, int which) { | |
try { | ||
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
showError("Could not find an application to handle the request."); | ||
showError(getString(R.string.activity_not_found)); | ||
} | ||
} else { | ||
dialog.cancel(); | ||
|
@@ -90,7 +90,7 @@ private void showError(String message) { | |
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); | ||
alert.setMessage(message) | ||
.setCancelable(false) | ||
.setNegativeButton("Close", new DialogInterface.OnClickListener() { | ||
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
dialog.dismiss(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,7 +222,7 @@ public void onClick(View v) { | |
i.setData(Uri.parse(mDbInfo.get(DbLoader.INFO_GUIDE_URL))); | ||
startSafeActivity(i); | ||
} else { | ||
showError("This convention does not support the guide feature.", false); | ||
showError(getString(R.string.con_no_guide_feature), false); | ||
return; | ||
} | ||
} else { | ||
|
@@ -281,7 +281,7 @@ public void startSafeActivity(Intent i) { | |
try { | ||
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
showError("Could not find an application to handle the request.", false); | ||
showError(getString(R.string.activity_not_found), false); | ||
} | ||
} | ||
|
||
|
@@ -332,7 +332,7 @@ public void onCancel(DialogInterface dialog) { | |
alert.setMessage(message).setCancelable(false).setOnCancelListener(cancelListener); | ||
|
||
if (!fatal) { | ||
alert.setPositiveButton("Retry", new DialogInterface.OnClickListener() { | ||
alert.setPositiveButton(R.string.retry, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
mAlertShown = false; | ||
startListUpdate(true); | ||
|
@@ -341,7 +341,7 @@ public void onClick(DialogInterface dialog, int id) { | |
}); | ||
} | ||
|
||
alert.setNegativeButton(fatal ? "Exit" : "Cancel", new DialogInterface.OnClickListener() { | ||
alert.setNegativeButton(fatal ? R.string.exit : android.R.string.cancel, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
mAlertShown = false; | ||
dialog.cancel(); | ||
|
@@ -354,7 +354,7 @@ public void onClick(DialogInterface dialog, int id) { | |
|
||
private void populateConList(List<UpdaterInfo.ConventionInfo> cons) { | ||
if (cons == null || cons.isEmpty()) { | ||
showError("No conventions are currently listed.", true); | ||
showError(getString(R.string.no_conventions_listed), true); | ||
return; | ||
} | ||
|
||
|
@@ -446,7 +446,7 @@ private void refreshFromDb() { | |
|
||
if (mDbInfo == null) { | ||
Log.w("MainActivity.refreshFromDb dbInfo is still null"); | ||
showError("The database could not be loaded.", true); | ||
showError(getString(R.string.error_database_not_loaded), true); | ||
return; | ||
} else { | ||
toggleButtons(true); | ||
|
@@ -476,7 +476,7 @@ private void updateInfoDisplays() { | |
if (mDbInfo.containsKey(DbLoader.INFO_CONVENTION)) { | ||
getSupportActionBar().setTitle(mDbInfo.get(DbLoader.INFO_CONVENTION)); | ||
} else { | ||
getSupportActionBar().setTitle("Error: Reload DB!"); | ||
getSupportActionBar().setTitle(getString(R.string.error_reload_db)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ActionBar.setTitle takes resource string ints. |
||
} | ||
} | ||
|
||
|
@@ -485,7 +485,7 @@ private void updateInfoDisplays() { | |
public void onNewerApp() { | ||
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); | ||
|
||
alert.setMessage("A new version of MyConbook is available. Do you want to go to the Play Store to upgrade?") | ||
alert.setMessage(R.string.new_version_available) | ||
.setCancelable(true) | ||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int which) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,7 @@ public boolean onContextItemSelected(MenuItem item) { | |
try { | ||
startActivity(i); | ||
} catch (ActivityNotFoundException e) { | ||
showError("Could not find an application to handle the request."); | ||
showError(getString(R.string.activity_not_found)); | ||
} | ||
|
||
return true; | ||
|
@@ -296,11 +296,11 @@ public void onListItemClick(ListView l, View v, int position, long id) { | |
} | ||
|
||
if (details.trim().equals("")) { | ||
details = "(No description given)"; | ||
details = getString(R.string.no_description); | ||
} | ||
|
||
if (cli.getCategory() != null && !"".equals(cli.getCategory())) { | ||
details += "\n\nCategory: " + cli.getCategory(); | ||
details += "\n\n" + getString(R.string.details_category) + cli.getCategory(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use string formatting after the line breaks |
||
} | ||
|
||
// Show details dialog | ||
|
@@ -314,7 +314,7 @@ private void showError(String message) { | |
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); | ||
alert.setMessage(message) | ||
.setCancelable(false) | ||
.setNegativeButton("Close", new DialogInterface.OnClickListener() { | ||
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
dialog.dismiss(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use string formatting instead of compounding the string.