Skip to content

Commit 95f6c4b

Browse files
rijuldhiropticod
authored andcommitted
Replaced few hardcoded strings (#296)
Replaced few hardCoded strings
1 parent 2c61497 commit 95f6c4b

15 files changed

Lines changed: 67 additions & 37 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
}
@@ -101,7 +101,7 @@ private void restoreTemplateEditor(Bundle savedInstanceState) {
101101
Log.d(TAG, "Activity Restored");
102102
selectedTemplate = (TemplateInterface) savedInstanceState.getSerializable(Constants.TEMPLATE_OBJECT);
103103
if (selectedTemplate == null) {
104-
Toast.makeText(this, "Unable to restore Activity state, finsihing Template Editor activity", Toast.LENGTH_LONG).show();
104+
Toast.makeText(this, getString(R.string.unableToRestore), Toast.LENGTH_LONG).show();
105105
finish();
106106
}
107107
}

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
@@ -82,7 +82,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
8282
holder.edit.setOnClickListener(new View.OnClickListener() {
8383
@Override
8484
public void onClick(View v) {
85-
Toast.makeText(mContext, "Long press to edit this item", Toast.LENGTH_SHORT).show();
85+
Toast.makeText(mContext, R.string.LongPress_toedit, Toast.LENGTH_SHORT).show();
8686
}
8787
});
8888

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
@@ -404,7 +404,7 @@ private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> opt
404404
if (button.getId() == id) {
405405
int index = buttons.indexOf(button);
406406
if ("".equals(options.get(index).getText().toString().trim())) {
407-
options.get(index).setError(context.getString(R.string.valid_before_answer));
407+
options.get(index).setError(context.getString(R.string.enter_valid_option));
408408
options.get(index).setText(null);
409409
button.setChecked(false);
410410
return;

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

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

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

@@ -240,7 +240,7 @@ public void run() {
240240

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

0 commit comments

Comments
 (0)