Skip to content

Commit d6987c0

Browse files
authored
Merge branch 'bug-fixes' into lint_issues_2
2 parents 9dc32e7 + b8aa45e commit d6987c0

31 files changed

+212
-77
lines changed

source-code/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
android:name=".activity.HomeActivity"
2424
android:configChanges="orientation|screenSize"
2525
android:label="@string/app_name"
26-
android:theme="@style/NoActionBarThemeTransparentStatusBar"></activity>
26+
android:theme="@style/NoActionBarThemeTransparentStatusBar" />
2727
<activity
2828
android:name=".simulator.Simulator"
2929
android:label="@string/title_activity_simulator"
@@ -42,7 +42,7 @@
4242
android:name=".activity.TemplateEditor"
4343
android:configChanges="orientation|screenSize"
4444
android:label="@string/title_activity_template_editor"
45-
android:theme="@style/AppTheme.NoActionBar"></activity>
45+
android:theme="@style/AppTheme.NoActionBar" />
4646
<activity
4747
android:name=".activity.FirstRunActivity"
4848
android:label="@string/app_name"
@@ -57,7 +57,7 @@
5757
<activity
5858
android:name=".activity.TutorialActivity"
5959
android:label="@string/title_activity_tutorial"
60-
android:theme="@style/Buildmlearn.FullScreen"></activity>
60+
android:theme="@style/Buildmlearn.FullScreen" />
6161
<activity
6262
android:name=".activity.AboutBuildmLearn"
6363
android:label="@string/title_activity_about_buildm_learn"
463 Bytes
Binary file not shown.
640 Bytes
Binary file not shown.

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/activity/HomeActivity.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import android.app.FragmentTransaction;
55
import android.content.Intent;
66
import android.content.SharedPreferences;
7+
import android.graphics.drawable.ColorDrawable;
8+
import android.os.Build;
79
import android.os.Bundle;
810
import android.preference.PreferenceManager;
911
import android.support.design.widget.NavigationView;
1012

1113
import android.app.FragmentManager;
14+
import android.support.v4.content.ContextCompat;
1215
import android.support.v4.view.GravityCompat;
1316
import android.os.Handler;
1417
import android.support.v4.widget.DrawerLayout;
@@ -107,7 +110,7 @@ public boolean onNavigationItemSelected(MenuItem item) {
107110
getSupportActionBar().setDisplayShowHomeEnabled(true);
108111
getSupportActionBar().setDisplayShowTitleEnabled(true);
109112
}
110-
113+
restoreColorScheme();
111114
switch(id){
112115
case R.id.nav_home:
113116
smoothNavigationToggle.runWhenIdle(new Runnable() {
@@ -199,6 +202,16 @@ public void run() {
199202
return true;
200203
}
201204

205+
private void restoreColorScheme() {
206+
int primaryColor = ContextCompat.getColor(HomeActivity.this, R.color.color_primary);
207+
int primaryColorDark = ContextCompat.getColor(HomeActivity.this, R.color.color_primary_dark);
208+
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor));
209+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
210+
getWindow().setStatusBarColor(primaryColorDark);
211+
getWindow().setNavigationBarColor(primaryColor);
212+
}
213+
}
214+
202215
@Override
203216
public void onBackPressed() {
204217
FragmentManager fragmentManager = getFragmentManager();

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import android.Manifest;
44
import android.app.Dialog;
55
import android.app.ProgressDialog;
6+
import android.content.DialogInterface;
7+
import android.support.design.widget.Snackbar;
8+
import android.support.v7.app.AlertDialog;
69
import android.content.Context;
710
import android.content.DialogInterface;
811
import android.content.Intent;
@@ -583,25 +586,19 @@ public boolean onOptionsItemSelected(MenuItem item) {
583586

584587
switch (id) {
585588
case R.id.action_delete:
586-
587-
final AlertDialog dialog = new AlertDialog.Builder(this)
588-
.setTitle(R.string.dialog_delete_title)
589-
.setMessage(R.string.dialog_delete_msg)
590-
.setPositiveButton(R.string.dialog_yes, null)
591-
.setNegativeButton(R.string.dialog_no, null)
592-
.create();
593-
dialog.show();
594-
595-
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
596-
@Override
597-
public void onClick(View v) {
598-
dialog.dismiss();
599-
selectedTemplate.deleteItem(TemplateEditor.this, selectedPosition);
600-
selectedPosition = -1;
601-
restoreSelectedView();
602-
}
603-
});
604-
589+
final int restorePosition = selectedPosition;
590+
final Object object = selectedTemplate.deleteItem(TemplateEditor.this,selectedPosition);
591+
selectedPosition = -1;
592+
restoreSelectedView();
593+
Snackbar.make(findViewById(R.id.relative_layout),
594+
R.string.snackbar_deleted_message,Snackbar.LENGTH_LONG)
595+
.setAction(R.string.snackbar_undo, new View.OnClickListener() {
596+
@Override
597+
public void onClick(View v) {
598+
selectedTemplate.restoreItem(TemplateEditor.this,restorePosition,object);
599+
Snackbar.make(v,R.string.snackbar_restored_message,Snackbar.LENGTH_LONG).show();
600+
}
601+
}).show();
605602
break;
606603
case R.id.action_edit:
607604
selectedTemplate.editItem(this, selectedPosition);

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/fragment/SettingsFragment.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ public boolean onPreferenceClick(Preference preference) {
8787
}
8888
});
8989

90+
Preference tell_friend=findPreference(getString(R.string.pref_tell_key));
91+
tell_friend.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
92+
@Override
93+
public boolean onPreferenceClick(Preference preference) {
94+
Intent shareIntent = new Intent();
95+
shareIntent.setAction(Intent.ACTION_SEND);
96+
shareIntent.putExtra(Intent.EXTRA_TEXT,getString(R.string.pref_tell_message)+" http://play.google.com/store/apps/details?id=" + getActivity().getPackageName());
97+
shareIntent.setType("text/plain");
98+
startActivity(shareIntent);
99+
return true;
100+
}
101+
});
102+
90103
Preference restoreProject = findPreference(getString(R.string.key_restore_project));
91104
restoreProject.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
92105
@Override

source-code/app/src/main/java/org/buildmlearn/toolkit/matchtemplate/fragment/DetailFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,18 @@ public boolean onMenuItemClick(MenuItem menuItem) {
154154

155155
handleListViewListeners();
156156

157-
listViewA.setAdapter(matchListAdapterA);
158-
listViewB.setAdapter(matchListAdapterB);
159157

160158
View header_A = getLayoutInflater(savedInstanceState).inflate(R.layout.match_template_detail_header_a, null);
161159
View footer_A = getLayoutInflater(savedInstanceState).inflate(R.layout.match_template_detail_footer_a, null);
162160
listViewA.addHeaderView(header_A);
163161
listViewA.addFooterView(footer_A);
162+
listViewA.setAdapter(matchListAdapterA);
164163

165164
View header_B = getLayoutInflater(savedInstanceState).inflate(R.layout.match_template_detail_header_b, null);
166165
View footer_B = getLayoutInflater(savedInstanceState).inflate(R.layout.match_template_detail_footer_b, null);
167166
listViewB.addHeaderView(header_B);
168167
listViewB.addFooterView(footer_B);
168+
listViewB.setAdapter(matchListAdapterB);
169169

170170
((TextView) rootView.findViewById(R.id.score)).setText(String.format(Locale.ENGLISH, "Score : %d of %d", countScore, matchListA.size()));
171171

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

0 commit comments

Comments
 (0)