Skip to content

Commit f81ca28

Browse files
rijuldhiropticod
authored andcommitted
Replaced few hardcoded strings (#296)
Replaced few hardCoded strings
1 parent c11ad58 commit f81ca28

16 files changed

Lines changed: 72 additions & 40 deletions

File tree

source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String getApkDir() {
104104
public boolean checkExternalStorage() {
105105

106106
boolean result = false;
107-
File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/BuildmLearn123/");
107+
File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + Constants.BUILD_M_LEARN_PATH_123);
108108
if (!f.isDirectory()) {
109109
result = f.mkdirs();
110110
f.delete();

source-code/app/src/main/java/org/buildmlearn/toolkit/constant/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
public final static String PROJECT_FILE_PATH = "PROJECT_FILE_PATH";
2020
public final static String START_ACTIVITY = "START_ACTIVITY";
2121
public final static String START_FRAGMENT = "START_FRAGMENT";
22+
public final static String BUILD_M_LEARN_PATH_123 = "/BuildmLearn123/";
2223

2324

2425
}

source-code/app/src/main/java/org/buildmlearn/toolkit/quiztemplate/fragment/LastFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
5656
new AlertDialog.Builder(getActivity());
5757
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
5858
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
59-
builder.setPositiveButton("OK", null);
59+
builder.setPositiveButton(getString(R.string.info_template_ok), null);
6060
AlertDialog welcomeAlert = builder.create();
6161
welcomeAlert.show();
6262
assert welcomeAlert.findViewById(android.R.id.message) != null;
@@ -72,9 +72,9 @@ public boolean onMenuItemClick(MenuItem menuItem) {
7272
});
7373

7474
((TextView) rootView.findViewById(R.id.text)).setText(getResources().getString(R.string.completed_message_quiz));
75-
((TextView) rootView.findViewById(R.id.correct)).setText(String.format(Locale.getDefault(), "Total Correct : %1$d", stat[0]));
76-
((TextView) rootView.findViewById(R.id.wrong)).setText(String.format(Locale.getDefault(), "Total Wrong : %1$d", stat[1]));
77-
((TextView) rootView.findViewById(R.id.un_answered)).setText(String.format(Locale.getDefault(), "Total Unanswered : %1$d", stat[2]));
75+
((TextView) rootView.findViewById(R.id.correct)).setText(String.format(Locale.getDefault(), getString(R.string.total_correct),stat[0]));
76+
((TextView) rootView.findViewById(R.id.wrong)).setText(String.format(Locale.getDefault(), getString(R.string.total_wrong),stat[1]));
77+
((TextView) rootView.findViewById(R.id.un_answered)).setText(String.format(Locale.getDefault(), getString(R.string.total_unanswered), stat[2]));
7878

7979
rootView.findViewById(R.id.restart).setOnClickListener(new View.OnClickListener() {
8080
@Override

source-code/app/src/main/java/org/buildmlearn/toolkit/quiztemplate/fragment/QuestionFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
6464
new AlertDialog.Builder(getActivity());
6565
builder.setTitle(String.format("%1$s", getString(R.string.comprehension_about_us)));
6666
builder.setMessage(getResources().getText(R.string.comprehension_about_text));
67-
builder.setPositiveButton("OK", null);
67+
builder.setPositiveButton(getString(R.string.info_template_ok), null);
6868
AlertDialog welcomeAlert = builder.create();
6969
welcomeAlert.show();
7070
assert welcomeAlert.findViewById(android.R.id.message) != null;
@@ -110,7 +110,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
110110
toolbar.setTitle(getResources().getString(R.string.app_name_quiz));
111111

112112
Menu m = navigationView.getMenu();
113-
SubMenu topChannelMenu = m.addSubMenu("Questions");
113+
SubMenu topChannelMenu = m.addSubMenu(getString(R.string.quiz_new_question));
114114
long numQues = db.getCountQuestions();
115115

116116
final String finalQuestionId = questionId;
@@ -122,7 +122,7 @@ public boolean onMenuItemClick(MenuItem menuItem) {
122122
rg.check(rg.getChildAt(Integer.parseInt(answered)).getId());
123123
}
124124
for (int i = 1; i <= numQues; i++) {
125-
topChannelMenu.add(String.format(Locale.getDefault(), "Question %1$d", i));
125+
topChannelMenu.add(String.format(Locale.getDefault(), getString(R.string.question), i));
126126
topChannelMenu.getItem(i - 1).setIcon(R.drawable.ic_assignment_black_24dp);
127127
final int finalI = i;
128128
topChannelMenu.getItem(i - 1).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@@ -150,7 +150,7 @@ public boolean onMenuItemClick(MenuItem item) {
150150
});
151151
}
152152

153-
((TextView) rootView.findViewById(R.id.question_title)).setText(String.format(Locale.getDefault(), "Question No : %1$s", questionId));
153+
((TextView) rootView.findViewById(R.id.question_title)).setText(String.format(Locale.getDefault(), getString(R.string.quiz_question_no), questionId));
154154
((TextView) rootView.findViewById(R.id.question)).setText(question);
155155
if (option_1 != null) {
156156
rootView.findViewById(R.id.radioButton1).setVisibility(View.VISIBLE);

source-code/app/src/main/java/org/buildmlearn/toolkit/simulator/Simulator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
3939
actionBar.setDisplayHomeAsUpEnabled(true);
4040
templateId = getIntent().getIntExtra(Constants.TEMPLATE_ID, -1);
4141
if (templateId == -1) {
42-
Toast.makeText(this, "Invalid template ID, closing Template Editor activity", Toast.LENGTH_LONG).show();
42+
Toast.makeText(this, getString(R.string.invalidTemplate), Toast.LENGTH_LONG).show();
4343
finish();
4444
return;
4545
}
@@ -98,7 +98,7 @@ private void restoreTemplateEditor(Bundle savedInstanceState) {
9898
Log.d(TAG, "Activity Restored");
9999
selectedTemplate = (TemplateInterface) savedInstanceState.getSerializable(Constants.TEMPLATE_OBJECT);
100100
if (selectedTemplate == null) {
101-
Toast.makeText(this, "Unable to restore Activity state, finsihing Template Editor activity", Toast.LENGTH_LONG).show();
101+
Toast.makeText(this, getString(R.string.unableToRestore), Toast.LENGTH_LONG).show();
102102
finish();
103103
}
104104
}

source-code/app/src/main/java/org/buildmlearn/toolkit/templates/ComprehensionAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ public void onClick(View v) {
204204
boolean isValidated = true;
205205
int checkedAns = getCheckedAnswer(buttons);
206206
if (checkedAns < 0) {
207-
Toast.makeText(context, "Choose a correct option", Toast.LENGTH_SHORT).show();
207+
Toast.makeText(context, R.string.choose_correct_option, Toast.LENGTH_SHORT).show();
208208
isValidated = false;
209209
}
210210
if (question.getText().toString().equals("")) {
211211

212-
question.setError("Question is required");
212+
question.setError(context.getString(R.string.ques_required));
213213
isValidated = false;
214214
}
215215

@@ -220,7 +220,7 @@ public void onClick(View v) {
220220
}
221221
}
222222
if (optionCount < 2) {
223-
Toast.makeText(context, "Minimum two multiple answers are required.", Toast.LENGTH_SHORT).show();
223+
Toast.makeText(context, R.string.min_answers_required, Toast.LENGTH_SHORT).show();
224224
isValidated = false;
225225
}
226226

@@ -258,7 +258,7 @@ private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> opt
258258
if (button.getId() == id) {
259259
int index = buttons.indexOf(button);
260260
if (options.get(index).getText().toString().equals("")) {
261-
Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show();
261+
Toast.makeText(context, R.string.enter_valid_option, Toast.LENGTH_LONG).show();
262262
button.setChecked(false);
263263
return;
264264
} else {

source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashCardAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
8181
holder.edit.setOnClickListener(new View.OnClickListener() {
8282
@Override
8383
public void onClick(View v) {
84-
Toast.makeText(mContext, "Long press to edit this item", Toast.LENGTH_SHORT).show();
84+
Toast.makeText(mContext, R.string.LongPress_toedit, Toast.LENGTH_SHORT).show();
8585
}
8686
});
8787

source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public void onClick(View v) {
201201
boolean isValidated = true;
202202
int checkedAns = getCheckedAnswer(buttons);
203203
if (checkedAns < 0) {
204-
Toast.makeText(context, "Choose a correct option", Toast.LENGTH_SHORT).show();
204+
Toast.makeText(context, R.string.choose_correct_option, Toast.LENGTH_SHORT).show();
205205
isValidated = false;
206206
}
207207
if (question.getText().toString().equals("")) {
208208

209-
question.setError("Question is required");
209+
question.setError(context.getString(R.string.ques_required));
210210
isValidated = false;
211211
}
212212

@@ -217,7 +217,7 @@ public void onClick(View v) {
217217
}
218218
}
219219
if (optionCount < 2) {
220-
Toast.makeText(context, "Minimum two multiple answers are required.", Toast.LENGTH_SHORT).show();
220+
Toast.makeText(context, R.string.min_answers_required, Toast.LENGTH_SHORT).show();
221221
isValidated = false;
222222
}
223223

@@ -256,7 +256,7 @@ private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> opt
256256
if (button.getId() == id) {
257257
int index = buttons.indexOf(button);
258258
if (options.get(index).getText().toString().equals("")) {
259-
Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show();
259+
Toast.makeText(context, R.string.enter_valid_option, Toast.LENGTH_LONG).show();
260260
button.setChecked(false);
261261
return;
262262
} else {

source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> opt
405405
if (button.getId() == id) {
406406
int index = buttons.indexOf(button);
407407
if ("".equals(options.get(index).getText().toString().trim())) {
408-
options.get(index).setError(context.getString(R.string.valid_before_answer));
408+
options.get(index).setError(context.getString(R.string.enter_valid_option));
409409
options.get(index).setText(null);
410410
button.setChecked(false);
411411
return;

source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/SignerThread.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public NodeVisitor child(String ns, String name) {
131131
}
132132

133133
private String getFinalApkPath(String buildmlearnPath) {
134-
int index = buildmlearnPath.lastIndexOf("buildmlearn");
134+
int index = buildmlearnPath.lastIndexOf(context.getString(R.string.main_title));
135135
return buildmlearnPath.substring(0, index) + "apk";
136136
}
137137

@@ -238,15 +238,15 @@ public void run() {
238238

239239
if (zipSigner.isCanceled()) {
240240
Log.d(TAG, "Signing cancelled");
241-
Toast.makeText(toolkit, "APK file not generated", Toast.LENGTH_SHORT).show();
241+
Toast.makeText(toolkit, R.string.apk_not_generated, Toast.LENGTH_SHORT).show();
242242
} else {
243243
Log.d(TAG, "Signing Complete");
244244
listener.onSuccess(finalApk);
245245

246246
if (toolkit.isExternalStorageAvailable()) {
247-
showNotification("APK file saved in Downloads folder");
247+
showNotification(context.getString(R.string.apk_file_saved));
248248
} else {
249-
showNotification("SD card not found. APK file saved in internal storage.");
249+
showNotification(context.getString(R.string.sd_card_notfound));
250250
}
251251
}
252252

@@ -278,7 +278,7 @@ private void showNotification(String description) {
278278
NotificationCompat.Builder mBuilder =
279279
new NotificationCompat.Builder(toolkit)
280280
.setSmallIcon(R.drawable.ic_stat_toggle_check_box)
281-
.setContentTitle("APK Generated")
281+
.setContentTitle(context.getString(R.string.apk_generated))
282282
.setContentText(description)
283283
.setContentIntent(pendingIntent)
284284
.setAutoCancel(true);

0 commit comments

Comments
 (0)