Skip to content

Commit

Permalink
Merge pull request getodk#284 from mapkon/master
Browse files Browse the repository at this point in the history
Migrate hard-coded string values to translatable resource strings; other minor changes.
  • Loading branch information
batkinson authored Jan 17, 2017
2 parents 21748b5 + 52df623 commit 0dd5605
Show file tree
Hide file tree
Showing 27 changed files with 141 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void buildMenuList() {
ArrayList<Uri> commands = new ArrayList<Uri>();

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select ODK Shortcut");
builder.setTitle(R.string.select_odk_shortcut);

Cursor c = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,4 @@ public void updatedCredentials() {
public void cancelledUpdatingCredentials() {
finish();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public void onClick(View v) {
instanceCursor = getContentResolver().query(uri,
null, null, null, null);
if (instanceCursor.getCount() != 1) {
this.createErrorDialog("Bad URI: " + uri, EXIT);
this.createErrorDialog(getString(R.string.bad_uri, uri), EXIT);
return;
} else {
instanceCursor.moveToFirst();
Expand All @@ -375,7 +375,7 @@ public void onClick(View v) {

jrVersion = instanceCursor.isNull(idxJrVersion) ? null
: instanceCursor
.getString(idxJrVersion);
.getString(idxJrVersion);
}
} finally {
if (instanceCursor != null) {
Expand Down Expand Up @@ -415,9 +415,9 @@ public void onClick(View v) {
jrFormId)
+ ((jrVersion == null) ? ""
: "\n"
+ getString(R.string.version)
+ " "
+ jrVersion),
+ getString(R.string.version)
+ " "
+ jrVersion),
EXIT);
return;
} else if (formCursor.getCount() > 1) {
Expand Down Expand Up @@ -445,7 +445,7 @@ public void onClick(View v) {
c = getContentResolver().query(uri, null, null, null,
null);
if (c.getCount() != 1) {
this.createErrorDialog("Bad URI: " + uri, EXIT);
this.createErrorDialog(getString(R.string.bad_uri, uri), EXIT);
return;
} else {
c.moveToFirst();
Expand Down Expand Up @@ -508,7 +508,7 @@ public boolean accept(File pathname) {
}
} else {
Log.e(t, "unrecognized URI");
this.createErrorDialog("Unrecognized URI: " + uri, EXIT);
this.createErrorDialog(getString(R.string.unrecognized_uri, uri), EXIT);
return;
}

Expand Down Expand Up @@ -561,7 +561,7 @@ protected void onSaveInstanceState(Bundle outState) {

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
FormController formController = Collect.getInstance()
.getFormController();
Expand Down Expand Up @@ -623,12 +623,12 @@ protected void onActivityResult(int requestCode, int resultCode,
case SIGNATURE_CAPTURE:
case IMAGE_CAPTURE:
/*
* We saved the image to the tempfile_path, but we really want it to
* be in: /sdcard/odk/instances/[current instnace]/something.jpg so
* we move it there before inserting it into the content provider.
* Once the android image capture bug gets fixed, (read, we move on
* from Android 1.6) we want to handle images the audio and video
*/
* We saved the image to the tempfile_path, but we really want it to
* be in: /sdcard/odk/instances/[current instnace]/something.jpg so
* we move it there before inserting it into the content provider.
* Once the android image capture bug gets fixed, (read, we move on
* from Android 1.6) we want to handle images the audio and video
*/
// The intent is empty, but we know we saved the image to the temp
// file
File fi = new File(Collect.TMPFILE_PATH);
Expand All @@ -650,11 +650,11 @@ protected void onActivityResult(int requestCode, int resultCode,
saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS);
break;
case ALIGNED_IMAGE:
/*
* We saved the image to the tempfile_path; the app returns the full
* path to the saved file in the EXTRA_OUTPUT extra. Take that file
* and move it into the instance folder.
*/
/*
* We saved the image to the tempfile_path; the app returns the full
* path to the saved file in the EXTRA_OUTPUT extra. Take that file
* and move it into the instance folder.
*/
String path = intent
.getStringExtra(android.provider.MediaStore.EXTRA_OUTPUT);
fi = new File(path);
Expand All @@ -675,13 +675,13 @@ protected void onActivityResult(int requestCode, int resultCode,
saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS);
break;
case IMAGE_CHOOSER:
/*
* We have a saved image somewhere, but we really want it to be in:
* /sdcard/odk/instances/[current instnace]/something.jpg so we move
* it there before inserting it into the content provider. Once the
* android image capture bug gets fixed, (read, we move on from
* Android 1.6) we want to handle images the audio and video
*/
/*
* We have a saved image somewhere, but we really want it to be in:
* /sdcard/odk/instances/[current instnace]/something.jpg so we move
* it there before inserting it into the content provider. Once the
* android image capture bug gets fixed, (read, we move on from
* Android 1.6) we want to handle images the audio and video
*/

// get gp of chosen file
Uri selectedImage = intent.getData();
Expand Down Expand Up @@ -917,7 +917,7 @@ private void clearAnswer(QuestionWidget qw) {

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
Collect.getInstance().getActivityLogger()
.logInstanceAction(this, "onCreateContextMenu", "show");
Expand Down Expand Up @@ -1038,7 +1038,7 @@ private View createView(int event, boolean advancingPage) {
// disallow carriage returns in the name
InputFilter returnFilter = new InputFilter() {
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (Character.getType((source.charAt(i))) == Character.CONTROL) {
return "";
Expand Down Expand Up @@ -1212,7 +1212,7 @@ public void onClick(View v) {
}

private View createViewForFormBeginning(int event, boolean advancingPage,
FormController formController) {
FormController formController) {
try {
event = formController.stepToNextScreenEvent();

Expand Down Expand Up @@ -1469,14 +1469,14 @@ public void showView(View next, AnimationType from) {
}

// Hopefully someday we can use managed dialogs when the bugs are fixed
/*
* Ideally, we'd like to use Android to manage dialogs with onCreateDialog()
* and onPrepareDialog(), but dialogs with dynamic content are broken in 1.5
* (cupcake). We do use managed dialogs for our static loading
* ProgressDialog. The main issue we noticed and are waiting to see fixed
* is: onPrepareDialog() is not called after a screen orientation change.
* http://code.google.com/p/android/issues/detail?id=1639
*/
/*
* Ideally, we'd like to use Android to manage dialogs with onCreateDialog()
* and onPrepareDialog(), but dialogs with dynamic content are broken in 1.5
* (cupcake). We do use managed dialogs for our static loading
* ProgressDialog. The main issue we noticed and are waiting to see fixed
* is: onPrepareDialog() is not called after a screen orientation change.
* http://code.google.com/p/android/issues/detail?id=1639
*/

//

Expand Down Expand Up @@ -1770,7 +1770,7 @@ private boolean saveDataToDisk(boolean exit, boolean complete, String updatedSav

// but if you want save in the background, can't be current screen
private boolean saveDataToDisk(boolean exit, boolean complete, String updatedSaveName,
boolean current) {
boolean current) {
// save current answer
if (current) {
if (!saveAnswersForCurrentScreen(complete)) {
Expand Down Expand Up @@ -1803,7 +1803,7 @@ private void createQuitDialog() {
FormController formController = Collect.getInstance().getFormController();
title = (formController == null) ? null : formController.getFormTitle();
if (title == null) {
title = "<no form loaded>";
title = getString(R.string.no_form_loaded);
}
}

Expand Down Expand Up @@ -2037,7 +2037,7 @@ private void createLanguageDialog() {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
int whichButton) {
FormController formController = Collect
.getInstance().getFormController();
// Update the language in the content provider
Expand Down Expand Up @@ -2077,7 +2077,7 @@ public void onClick(DialogInterface dialog,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
int whichButton) {
Collect.getInstance()
.getActivityLogger()
.logInstanceAction(this,
Expand Down Expand Up @@ -2584,7 +2584,7 @@ public void onProgressStep(String stepMessage) {
* @return status as determined in FormEntryController
*/
public int saveAnswer(IAnswerData answer, FormIndex index,
boolean evaluateConstraints) throws JavaRosaException {
boolean evaluateConstraints) throws JavaRosaException {
FormController formController = Collect.getInstance()
.getFormController();
if (evaluateConstraints) {
Expand Down Expand Up @@ -2691,7 +2691,7 @@ public boolean onDown(MotionEvent e) {

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
float velocityY) {
// only check the swipe if it's enabled in preferences
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(this);
Expand Down Expand Up @@ -2773,7 +2773,7 @@ public void onLongPress(MotionEvent e) {

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
float distanceY) {
// The onFling() captures the 'up' event so our view thinks it gets long
// pressed.
// We don't wnat that, so cancel it.
Expand Down Expand Up @@ -2832,4 +2832,4 @@ public EmptyView(Context context) {
super(context);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,7 @@ protected HashMap<String, Object> doInBackground(ArrayList<DriveListItem>... par
} while (request.getPageToken() != null && request.getPageToken().length() > 0);

if (driveFileList.size() > 1) {
results.put(fileItem.getName(),
"More than one media folder detected, please remove one and try again");
results.put(fileItem.getName(), getString(R.string.multiple_media_folders_detected_notification));
return results;
} else if (driveFileList.size() == 1) {
requestString = "'" + driveFileList.get(0).getId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ protected void onCreate(Bundle savedInstanceState) {
boolean success = loadSharedPreferencesFromFile(f);
if (success) {
Toast.makeText(this,
"Settings successfully loaded from file",
getString(R.string.settings_successfully_loaded_file_notification),
Toast.LENGTH_LONG).show();
f.delete();
} else {
Toast.makeText(
this,
"Sorry, settings file is corrupt and should be deleted or replaced",
Toast.makeText(this,
getString(R.string.corrupt_settings_file_notification),
Toast.LENGTH_LONG).show();
}
}
Expand Down Expand Up @@ -428,7 +427,7 @@ protected Dialog onCreateDialog(int id) {
getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
int whichButton) {
String value = input.getText().toString();
String pw = mAdminPreferences.getString(
AdminPreferencesActivity.KEY_ADMIN_PW, "");
Expand Down Expand Up @@ -611,4 +610,4 @@ private boolean loadSharedPreferencesFromFile(File src) {
return res;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean setViewValue(View view, Cursor cursor,
String version = cursor.getString(columnIndex);
TextView v = (TextView) view;
if (version != null) {
v.setText(ctxt.getString(R.string.version) + " " + version);
v.setText(String.format(ctxt.getString(R.string.version_number), version));
v.setVisibility(View.VISIBLE);
} else {
v.setText(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public AlignedImageWidget(Context context, FormEntryPrompt prompt) {

mErrorTextView = new TextView(context);
mErrorTextView.setId(QuestionWidget.newUniqueId());
mErrorTextView.setText("Selected file is not a valid image");
mErrorTextView.setText(R.string.selected_invalid_image);

// setup capture button
mCaptureButton = new Button(getContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public AnnotateWidget(Context context, FormEntryPrompt prompt) {

mErrorTextView = new TextView(context);
mErrorTextView.setId(QuestionWidget.newUniqueId());
mErrorTextView.setText("Selected file is not a valid image");
mErrorTextView.setText(R.string.selected_invalid_image);

// setup capture button
mCaptureButton = new Button(getContext());
Expand Down Expand Up @@ -388,4 +388,4 @@ public void cancelLongPress() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public DecimalWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOv
// truncate to 15 digits max...
String dString = nf.format(d);
d = Double.parseDouble(dString.replace(',', '.'));
mAnswer.setText(d.toString());
//mAnswer.setText(d.toString());
mAnswer.setText(String.format(Locale.ENGLISH, "%f", d));
}

// disable if read only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public DrawWidget(Context context, FormEntryPrompt prompt) {

mErrorTextView = new TextView(context);
mErrorTextView.setId(QuestionWidget.newUniqueId());
mErrorTextView.setText("Selected file is not a valid image");
mErrorTextView.setText(R.string.selected_invalid_image);

mInstanceFolder = Collect.getInstance().getFormController()
.getInstancePath().getParent();
Expand Down Expand Up @@ -275,4 +275,4 @@ public void cancelLongPress() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.odk.collect.android.external.ExternalAppsUtils;

import java.text.NumberFormat;
import java.util.Locale;


/**
Expand Down Expand Up @@ -82,7 +83,8 @@ public ExDecimalWidget(Context context, FormEntryPrompt prompt) {
// truncate to 15 digits max...
String dString = nf.format(d);
d = Double.parseDouble(dString.replace(',', '.')); // in case , is decimal pt
mAnswer.setText(d.toString());
//mAnswer.setText(d.toString());
mAnswer.setText(String.format(Locale.ENGLISH, "%f", d));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ExIntegerWidget(Context context, FormEntryPrompt prompt) {
Integer i = getIntegerAnswerValue();

if (i != null) {
mAnswer.setText(i.toString());
mAnswer.setText(String.format("%d", i.toString()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,10 @@ public void setBinaryData(Object answer) {
if (!s.equals("") || s == null) {
mStringAnswer.setText(s);
String[] sa = s.split(" ");
mAnswerDisplay.setText(getContext().getString(R.string.latitude) + ": "
+ formatGps(Double.parseDouble(sa[0]), "lat") + "\n"
+ getContext().getString(R.string.longitude) + ": "
+ formatGps(Double.parseDouble(sa[1]), "lon") + "\n"
+ getContext().getString(R.string.altitude) + ": "
+ truncateDouble(sa[2]) + "m\n"
+ getContext().getString(R.string.accuracy) + ": "
+ truncateDouble(sa[3]) + "m");
mAnswerDisplay.setText(String.format(getContext().getString(R.string.gps_result),
formatGps(Double.parseDouble(sa[0]), "lat"),
formatGps(Double.parseDouble(sa[1]), "lon"), truncateDouble(sa[2]),
truncateDouble(sa[3])));
} else {
mStringAnswer.setText(s);
mAnswerDisplay.setText("");
Expand Down
Loading

0 comments on commit 0dd5605

Please sign in to comment.