Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard Coding the strings from activity to matchTemplate. #280

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ protected void onCreate(Bundle savedInstanceState) {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
assert findViewById(R.id.app_version) != null;
((TextView) findViewById(R.id.app_version)).setText(String.format(Locale.ENGLISH, "Version: %s", version));
((TextView) findViewById(R.id.app_version)).setText(String.format(Locale.ENGLISH, getString(R.string.Version)+ version));
} catch (PackageManager.NameNotFoundException e) {
assert findViewById(R.id.app_version) != null;
assert ((TextView) findViewById(R.id.app_version)) != null;
((TextView) findViewById(R.id.app_version)).setText("Version: 1.0");
((TextView) findViewById(R.id.app_version)).setText(R.string.Version1);
e.printStackTrace();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.util.Log;
import android.widget.Toast;

import org.buildmlearn.toolkit.R;
import org.buildmlearn.toolkit.constant.Constants;
import org.buildmlearn.toolkit.model.SavedProject;
import org.buildmlearn.toolkit.model.Template;
Expand Down Expand Up @@ -57,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}
}
Toast.makeText(this, "Invalid project file", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.InvalidProjectFile, Toast.LENGTH_SHORT).show();
finish();
} catch (ParserConfigurationException | IOException | SAXException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void onBackPressed() {
finish();
}
backPressedOnce=true;
Toast.makeText(this, "Tap back once more to exit.", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.DoubleExit, Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable()
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class TemplateEditor extends AppCompatActivity {
private final Handler handlerToast = new Handler() {
public void handleMessage(Message message) {
if (message.arg1 == -1) {
Toast.makeText(TemplateEditor.this, "Build unsuccessful", Toast.LENGTH_SHORT).show();
Toast.makeText(TemplateEditor.this, R.string.Build_Unsuccessful, Toast.LENGTH_SHORT).show();
}
}
};
Expand Down Expand Up @@ -107,7 +107,7 @@ protected void onCreate(Bundle savedInstanceState) {
toolkit = (ToolkitApplication) getApplicationContext();
templateId = getIntent().getIntExtra(Constants.TEMPLATE_ID, -1);
if (templateId == -1) {
Toast.makeText(this, "Invalid template ID, closing Template Editor activity", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.Invalid_Temp_ID, Toast.LENGTH_LONG).show();
finish();
}

Expand Down Expand Up @@ -421,7 +421,7 @@ public void onClick(DialogInterface dialog, int id) {

case R.id.share_project:
savedFilePath = saveProject();
if(("File already exists".equals(savedFilePath))){
if((getString(R.string.FileAlready).equals(savedFilePath))){
return;
}

Expand All @@ -440,7 +440,7 @@ public void onClick(DialogInterface dialog, int id) {
case R.id.share_apk:

savedFilePath = saveProject();
if(("File already exists".equals(savedFilePath))){
if((getString(R.string.FileAlready).equals(savedFilePath))){
return;
}
if (savedFilePath == null || savedFilePath.length() == 0) {
Expand All @@ -463,7 +463,7 @@ public void onClick(DialogInterface dialog, int id) {
signer.setSignerThreadListener(new SignerThread.OnSignComplete() {
@Override
public void onSuccess(final String path) {
Log.d(TAG, "APK generated");
Log.d(TAG, getString(R.string.APKGenerated));
mApkGenerationDialog.dismiss();

Uri fileUri = Uri.fromFile(new File(path));
Expand Down Expand Up @@ -505,7 +505,7 @@ public void onFail(Exception e) {
break;
case R.id.save_apk:
savedFilePath = saveProject();
if(("File already exists".equals(savedFilePath))){
if((getString(R.string.FileAlready).equals(savedFilePath))){
return;
}
if (savedFilePath == null || savedFilePath.length() == 0) {
Expand All @@ -528,16 +528,16 @@ public void onFail(Exception e) {
signer.setSignerThreadListener(new SignerThread.OnSignComplete() {
@Override
public void onSuccess(final String path) {
Log.d(TAG, "APK generated");
Log.d(TAG, getString(R.string.APKGenerated));
mApkGenerationDialog.dismiss();

runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog dialog = new AlertDialog.Builder(TemplateEditor.this)
.setTitle("Apk Generated")
.setMessage("Apk file saved at " + path)
.setPositiveButton("okay", new DialogInterface.OnClickListener() {
.setTitle(R.string.APKGenerated)
.setMessage(getString(R.string.APK_address) + path)
.setPositiveButton(R.string.quiz_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Expand Down Expand Up @@ -650,7 +650,7 @@ private String saveProject() {
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
if ("".equals(author)) {
assert authorEditText != null;
authorEditText.setError("Author name is required");
authorEditText.setError(getString(R.string.valid_author));
} else if ("".equals(title)) {
assert titleEditText != null;
titleEditText.setError(getResources().getString(R.string.title_error));
Expand Down Expand Up @@ -689,11 +689,11 @@ private String saveProject() {
Element dataElement = doc.createElement("data");
rootElement.appendChild(dataElement);
if (selectedTemplate.getItems(doc).size() == 0 || (selectedTemplate.getItems(doc).size() < 2 && (templateId == 5 || templateId == 7))) {
Toast.makeText(this, "Unable to perform action: No Data", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.NoData, Toast.LENGTH_SHORT).show();
return null;
}
if (selectedTemplate.getItems(doc).get(0).getTagName().equals("item") && (templateId == 5 || templateId == 7)) {
Toast.makeText(this, "Unable to perform action: Add Meta Details", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.AddMetaDetails, Toast.LENGTH_SHORT).show();
return null;
}
for (Element item : selectedTemplate.getItems(doc)) {
Expand All @@ -711,12 +711,12 @@ private String saveProject() {
boolean isSaved=FileUtils.saveXmlFile(toolkit.getSavedDir(), saveFileName, doc);
if(isSaved) {
oldFileName = toolkit.getSavedDir() + saveFileName;
Toast.makeText(this, "Project Successfully Saved!", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.Success_Save_Project, Toast.LENGTH_SHORT).show();
return oldFileName;
}
else {
titleEditText.setError("File Already exists");
return "File already exists";
titleEditText.setError(getString(R.string.FileAlready));
return getString(R.string.FileAlready);
}

} catch (ParserConfigurationException e) {
Expand All @@ -730,7 +730,7 @@ private String saveProject() {
public void onBackPressed() {
super.onBackPressed();
if (saveDraft() != null)
Toast.makeText(getApplicationContext(), "Saved in Draft!", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.Draft_Saved, Toast.LENGTH_SHORT).show();

}

Expand Down Expand Up @@ -776,7 +776,7 @@ private String saveDraft() {
Element dataElement = doc.createElement("data");
rootElement.appendChild(dataElement);
if (selectedTemplate.getItems(doc).size() == 0) {
Toast.makeText(this, "Unable to perform action: No Data", Toast.LENGTH_SHORT).show();
Toast.makeText(this,R.string.NoData, Toast.LENGTH_SHORT).show();
return null;
}
for (Element item : selectedTemplate.getItems(doc)) {
Expand Down Expand Up @@ -827,12 +827,12 @@ private String saveDraft() {
private void startSimulator() {
String message = saveProject();
if (message == null || message.equals("")) {
Toast.makeText(this, "Build unsuccessful", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.Build_Unsuccessful, Toast.LENGTH_SHORT).show();
return;
}
else if("File already exists".equals(message))
else if(getString(R.string.FileAlready).equals(message))
{
titleEditText.setError("Template Already exists");
titleEditText.setError(getString(R.string.TemplateAlready));
return;
}
Intent simulatorIntent = new Intent(getApplicationContext(), Simulator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand All @@ -79,9 +79,9 @@ public boolean onMenuItemClick(MenuItem menuItem) {

db.close();

((TextView) rootView.findViewById(R.id.correct)).setText(String.format(Locale.getDefault(), "Total Correct : %1$d", stat[0]));
((TextView) rootView.findViewById(R.id.wrong)).setText(String.format(Locale.getDefault(), "Total Wrong : %1$d", stat[1]));
((TextView) rootView.findViewById(R.id.un_answered)).setText(String.format(Locale.getDefault(), "Total Unanswered : %1$d", stat[2]));
((TextView) rootView.findViewById(R.id.correct)).setText(String.format(Locale.getDefault(), getString(R.string.correct_total)+ stat[0]));
((TextView) rootView.findViewById(R.id.wrong)).setText(String.format(Locale.getDefault(), getString(R.string.total_wrong)+ stat[1]));
((TextView) rootView.findViewById(R.id.un_answered)).setText(String.format(Locale.getDefault(), getString(R.string.total_unanswered)+ stat[2]));

rootView.findViewById(R.id.restart).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down Expand Up @@ -152,7 +152,7 @@ public boolean onMenuItemClick(MenuItem item) {
});
}

((TextView) rootView.findViewById(R.id.question_title)).setText(String.format(Locale.getDefault(), "Question No : %1$s", questionId));
((TextView) rootView.findViewById(R.id.question_title)).setText(String.format(Locale.getDefault(), getString(R.string.questionNo)+ questionId));
((TextView) rootView.findViewById(R.id.question)).setText(question);
if (option_1 != null) {
rootView.findViewById(R.id.radioButton1).setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.about_text_video));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void onLoadFinished(Loader<Cursor> loader, final Cursor data) {
public void onClick(View v) {
progress = new ProgressDialog(getActivity());
progress.setCancelable(false);
progress.setMessage("Loading TTS Engine...");
progress.setMessage(getString(R.string.TTSLoading));
progress.show();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Expand Down Expand Up @@ -226,10 +226,10 @@ public void onInit(int status) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(getContext(), "US English is not supported. Playing in device's default installed language.", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.USEnglishNotSupported, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getContext(), "Initialization Failed!", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.TTSFAIL, Toast.LENGTH_SHORT).show();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
rootView = inflater.inflate(R.layout.fragment_main_dict, container, false);

Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.card_toolbar);
toolbar.setTitle("List of Passages :");
toolbar.setTitle(R.string.ListPassage);

Toolbar maintoolbar = (Toolbar) rootView.findViewById(R.id.toolbar_main);
final String result[] = DataUtils.readTitleAuthor();
Expand All @@ -98,7 +98,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.about_us_dict)));
builder.setMessage(getResources().getText(R.string.about_text_dict));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.about_text_video));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.quiz_ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down Expand Up @@ -150,7 +150,7 @@ public void onLoadFinished(Loader<Cursor> loader, final Cursor data) {
String result[] = obj.diff_prettyHtml(llDiffs);

int numTWords = passage.split(" ").length;
((TextView) rootView.findViewById(R.id.score)).setText(String.format(Locale.ENGLISH, "SCORE : %s / %d", result[1], numTWords));
((TextView) rootView.findViewById(R.id.score)).setText(String.format(Locale.ENGLISH, R.string.score+result[1]+"/"+numTWords));

((TextView) rootView.findViewById(R.id.checked_text)).setText(Html.fromHtml(result[0]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
new AlertDialog.Builder(getActivity());
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
builder.setPositiveButton("OK", null);
builder.setPositiveButton(R.string.ok, null);
AlertDialog welcomeAlert = builder.create();
welcomeAlert.show();
assert welcomeAlert.findViewById(android.R.id.message) != null;
Expand Down
Loading