Skip to content

Commit aa45687

Browse files
authored
Merge pull request #151 from BuildmLearn/new-features
Update master branch after completion of GSoC EndTerm 2016
2 parents c753602 + 38a6743 commit aa45687

File tree

314 files changed

+12468
-3738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+12468
-3738
lines changed

source-code/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ android {
3030
applicationId "org.buildmlearn.toolkit"
3131
minSdkVersion 14
3232
targetSdkVersion 23
33-
versionCode 1
34-
versionName "1.0"
33+
versionCode 2
34+
versionName "2.0.0"
3535

3636
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3737
}

source-code/app/src/androidTest/java/org/buildmlearn/toolkit/espresso/ComprehensionTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static org.hamcrest.core.IsInstanceOf.instanceOf;
5757

5858
/**
59+
* Espresso test designed to test all the functionalities of Comprehension template
5960
* Created by anupam (opticod) on 7/6/16.
6061
*/
6162

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

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
android:allowBackup="true"
1717
android:icon="@mipmap/ic_launcher"
1818
android:label="@string/app_name"
19+
android:supportsRtl="true"
1920
android:theme="@style/AppTheme" >
2021
<activity
2122
android:name=".activity.HomeActivity"
1.33 MB
Binary file not shown.
594 KB
Binary file not shown.

source-code/app/src/main/assets/LearnSpellingsApp.apk

100755100644
808 KB
Binary file not shown.
1.3 MB
Binary file not shown.

source-code/app/src/main/assets/QuizTemplateApp.apk

100755100644
802 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<buildmlearn_application type="DictationTemplate">
3+
<author>
4+
<name>Anupam</name>
5+
</author>
6+
<title>Dictation</title>
7+
<data>
8+
<item>
9+
<dictation_title>Dream of the Rarebit Fiend</dictation_title>
10+
<dictation_passage>Dream of the Rarebit Fiend was a newspaper comic strip by American cartoonist Winsor McCay, begun September 10, 1904, that depicted fantastic bizarre dreams. It was McCay's second successful strip after Little Sammy Sneeze secured him a position on the cartoon staff of the New York Herald. Rarebit Fiend was printed in the Evening Telegram, a newspaper published by the Herald. The strip had no continuity or recurring characters.</dictation_passage>
11+
</item>
12+
<item>
13+
<dictation_title>Earthworks</dictation_title>
14+
<dictation_passage>Bill Bruford's Earthworks were a British jazz band led by drummer Bill Bruford. The band recorded several albums for Editions EG, Discipline Global Mobile and Summerfold Records.
15+
16+
Earthworks went through several line-ups: in addition to the band's accomplishments as a unit, Earthworks was a training ground for Django Bates, Iain Ballamy, Patrick Clahar, Mark Hodgson, Steve Hamilton and Gwilym Simcock. The final band line-up featured previously established jazz musicians in the form of Chick Corea sideman Tim Garland and veteran bass player Laurence Cottle. In interviews during the band's earlier years, Bruford sometimes compared his responsibilities within it as being similar to those of Art Blakey with the Jazz Messengers, in that he was providing an environment for young British jazz players to gain attention and experience before going on to become well-known players and bandleaders in their own right.</dictation_passage>
17+
</item>
18+
</data>
19+
</buildmlearn_application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<buildmlearn_application type="MatchTemplate">
3+
<author>
4+
<name>Anupam</name>
5+
</author>
6+
<title>Country Match</title>
7+
<data>
8+
<meta_details>
9+
<meta_title>Match the countries</meta_title>
10+
<meta_first_list_title>Country</meta_first_list_title>
11+
<meta_second_list_title>Capital</meta_second_list_title>
12+
</meta_details>
13+
<item>
14+
<first_list_item>India</first_list_item>
15+
<second_list_item>New Delhi</second_list_item>
16+
</item>
17+
<item>
18+
<first_list_item>Bangladesh</first_list_item>
19+
<second_list_item>Dhaka</second_list_item>
20+
</item>
21+
<item>
22+
<first_list_item>Malaysia</first_list_item>
23+
<second_list_item>Kuala Lumpur</second_list_item>
24+
</item>
25+
<item>
26+
<first_list_item>Pakistan</first_list_item>
27+
<second_list_item>Islamabad</second_list_item>
28+
</item>
29+
<item>
30+
<first_list_item>Portugal</first_list_item>
31+
<second_list_item>Lisbon</second_list_item>
32+
</item>
33+
<item>
34+
<first_list_item>Syria</first_list_item>
35+
<second_list_item>Damascus</second_list_item>
36+
</item>
37+
</data>
38+
</buildmlearn_application>

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import org.buildmlearn.toolkit.R;
1111

12+
import java.util.Locale;
13+
1214
/**
1315
* @brief Gives brief info about BuildmLearn community and toolkit
1416
*/
@@ -30,9 +32,10 @@ protected void onCreate(Bundle savedInstanceState) {
3032
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
3133
String version = pInfo.versionName;
3234
assert findViewById(R.id.app_version) != null;
33-
((TextView)findViewById(R.id.app_version)).setText("Version: " + version);
35+
((TextView) findViewById(R.id.app_version)).setText(String.format(Locale.ENGLISH, "Version: %s", version));
3436
} catch (PackageManager.NameNotFoundException e) {
3537
assert findViewById(R.id.app_version) != null;
38+
assert ((TextView) findViewById(R.id.app_version)) != null;
3639
((TextView)findViewById(R.id.app_version)).setText("Version: 1.0");
3740
e.printStackTrace();
3841
}

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class HomeActivity extends AppCompatActivity
2222
implements NavigationDrawerFragment.NavigationDrawerCallbacks {
2323

2424
private Section currentSection;
25+
private NavigationDrawerFragment mNavigationDrawerFragment;
2526

2627
/**
2728
* {@inheritDoc}
@@ -37,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
3738
/*
3839
Fragment managing the behaviors, interactions and presentation of the navigation drawer.
3940
*/
40-
NavigationDrawerFragment mNavigationDrawerFragment = (NavigationDrawerFragment)
41+
mNavigationDrawerFragment = (NavigationDrawerFragment)
4142
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
4243

4344
// Set up the drawer.
@@ -81,7 +82,7 @@ public void onNavigationDrawerItemSelected(int position) {
8182
if (currentSection == null || selectedMenuItem != currentSection) {
8283
currentSection = selectedMenuItem;
8384
FragmentManager fm = getFragmentManager();
84-
FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
85+
FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null);
8586
Fragment f = fm.findFragmentById(R.id.container);
8687
if (f != null) {
8788
if (currentSection.isKeep()) {
@@ -104,4 +105,15 @@ public void onNavigationDrawerItemSelected(int position) {
104105
}
105106
}
106107

108+
@Override
109+
public void onBackPressed() {
110+
if (mNavigationDrawerFragment.isDrawerOpen()) {
111+
mNavigationDrawerFragment.closeDrawer();
112+
return;
113+
}
114+
if (getFragmentManager().getBackStackEntryCount() <= 1) {
115+
finish();
116+
}
117+
super.onBackPressed();
118+
}
107119
}

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

+10-11
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
import android.os.Bundle;
55
import android.support.v7.app.ActionBar;
66
import android.support.v7.app.AppCompatActivity;
7+
import android.support.v7.widget.LinearLayoutManager;
8+
import android.support.v7.widget.RecyclerView;
79
import android.support.v7.widget.Toolbar;
8-
import android.view.View;
9-
import android.widget.AbsListView;
10-
import android.widget.AdapterView;
11-
import android.widget.ListAdapter;
1210

1311
import org.buildmlearn.toolkit.R;
1412
import org.buildmlearn.toolkit.adapter.TemplateAdapter;
@@ -28,20 +26,21 @@ protected void onCreate(Bundle savedInstanceState) {
2826
setContentView(R.layout.activity_template);
2927
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
3028
ActionBar actionBar = getSupportActionBar();
29+
assert actionBar != null;
3130
actionBar.setDisplayHomeAsUpEnabled(true);
3231
actionBar.setHomeButtonEnabled(true);
33-
ListAdapter mAdapter = new TemplateAdapter(this);
34-
AbsListView mListView = (AbsListView) findViewById(android.R.id.list);
35-
mListView.setAdapter(mAdapter);
32+
TemplateAdapter mAdapter = new TemplateAdapter(this);
33+
RecyclerView mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
34+
assert mRecyclerView != null;
35+
mRecyclerView.setAdapter(mAdapter);
36+
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
3637

37-
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
38+
mAdapter.setOnClickListener(new TemplateAdapter.SetOnClickListener() {
3839
@Override
39-
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
40-
40+
public void onItemClick(int position) {
4141
Intent intent = new Intent(getApplicationContext(), TemplateEditor.class);
4242
intent.putExtra(Constants.TEMPLATE_ID, position);
4343
startActivity(intent);
44-
4544
}
4645
});
4746
}

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

+31-12
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected void onCreate(Bundle savedInstanceState) {
127127
findViewById(R.id.button_add_item).setOnClickListener(new View.OnClickListener() {
128128
@Override
129129
public void onClick(View v) {
130-
if (templateId == 5 && selectedTemplate.currentMetaEditorAdapter().isEmpty()) {
130+
if ((templateId == 5 || templateId == 7) && selectedTemplate.currentMetaEditorAdapter().isEmpty()) {
131131
selectedTemplate.addMetaData(TemplateEditor.this);
132132
} else {
133133
selectedTemplate.addItem(TemplateEditor.this);
@@ -301,13 +301,11 @@ private void setUpTemplateEditor() {
301301
selectedTemplate = (TemplateInterface) templateObject;
302302
selectedTemplate.setTemplateId(templateId);
303303
populateListView(selectedTemplate.newTemplateEditorAdapter(this));
304-
if (templateId == 5) {
304+
if (templateId == 5 || templateId == 7) {
305305
populateMetaView(selectedTemplate.newMetaEditorAdapter(this));
306306
}
307307
setUpActionBar();
308-
} catch (InstantiationException e) {
309-
e.printStackTrace();
310-
} catch (IllegalAccessException e) {
308+
} catch (InstantiationException | IllegalAccessException e) {
311309
e.printStackTrace();
312310
}
313311
}
@@ -325,7 +323,7 @@ private void restoreTemplateEditor(Bundle savedInstanceState) {
325323
finish();
326324
} else {
327325
populateListView(selectedTemplate.currentTemplateEditorAdapter());
328-
if (templateId == 5) {
326+
if (templateId == 5 || templateId == 7) {
329327
populateMetaView(selectedTemplate.currentMetaEditorAdapter());
330328
}
331329
setUpActionBar();
@@ -397,20 +395,36 @@ public void onClick(View v) {
397395
new BottomSheet.Builder(this).sheet(R.menu.bottom_sheet_template).listener(new DialogInterface.OnClickListener() {
398396
@Override
399397
public void onClick(DialogInterface dialog, int id) {
398+
String savedFilePath;
400399
switch (id) {
401400
case R.id.save_project:
402401
saveProject();
403402
break;
403+
404+
case R.id.share_project:
405+
savedFilePath = saveProject();
406+
if (savedFilePath == null || savedFilePath.length() == 0) {
407+
return;
408+
}
409+
Uri fileUri = Uri.fromFile(new File(savedFilePath));
410+
ArrayList<Uri> uris = new ArrayList<>();
411+
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
412+
sendIntent.setType("application/zip");
413+
uris.add(fileUri);
414+
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
415+
startActivity(Intent.createChooser(sendIntent, null));
416+
break;
417+
404418
case R.id.share_apk:
405419

406-
String savedFilePath = saveProject();
420+
savedFilePath = saveProject();
407421
if (savedFilePath == null || savedFilePath.length() == 0) {
408422
return;
409423
}
410424
String keyPassword = getString(R.string.key_password);
411425
String aliasName = getString(R.string.alias_name);
412426
String aliaspassword = getString(R.string.alias_password);
413-
KeyStoreDetails keyStoreDetails = new KeyStoreDetails("TestKeyStore.jks", keyPassword, aliasName, aliaspassword);
427+
KeyStoreDetails keyStoreDetails = new KeyStoreDetails(keyPassword, aliasName, aliaspassword);
414428
SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this));
415429

416430
mApkGenerationDialog = new MaterialDialog.Builder(TemplateEditor.this)
@@ -471,7 +485,7 @@ public void onFail(Exception e) {
471485
keyPassword = getString(R.string.key_password);
472486
aliasName = getString(R.string.alias_name);
473487
aliaspassword = getString(R.string.alias_password);
474-
keyStoreDetails = new KeyStoreDetails("TestKeyStore.jks", keyPassword, aliasName, aliaspassword);
488+
keyStoreDetails = new KeyStoreDetails(keyPassword, aliasName, aliaspassword);
475489
signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this));
476490

477491
mApkGenerationDialog = new MaterialDialog.Builder(TemplateEditor.this)
@@ -600,8 +614,10 @@ private String saveProject() {
600614
EditText authorEditText = (EditText) findViewById(R.id.author_name);
601615
EditText titleEditText = (EditText) findViewById(R.id.template_title);
602616
assert findViewById(R.id.author_name) != null;
617+
assert ((EditText) findViewById(R.id.author_name)) != null;
603618
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
604619
assert findViewById(R.id.template_title) != null;
620+
assert ((EditText) findViewById(R.id.template_title)) != null;
605621
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
606622
if ("".equals(author)) {
607623
assert authorEditText != null;
@@ -637,7 +653,7 @@ private String saveProject() {
637653
doc.appendChild(rootElement);
638654
Element dataElement = doc.createElement("data");
639655
rootElement.appendChild(dataElement);
640-
if (selectedTemplate.getItems(doc).size() == 0 || (selectedTemplate.getItems(doc).size() < 2 && templateId == 5)) {
656+
if (selectedTemplate.getItems(doc).size() == 0 || (selectedTemplate.getItems(doc).size() < 2 && (templateId == 5 || templateId == 7))) {
641657
Toast.makeText(this, "Unable to perform action: No Data", Toast.LENGTH_SHORT).show();
642658
return null;
643659
}
@@ -679,9 +695,11 @@ public void onBackPressed() {
679695
* @return Absolute path of the saved file. Null if there is some error.
680696
* @brief Saves the current project into a .buildmlearn file.
681697
*/
682-
protected String saveDraft() {
698+
private String saveDraft() {
683699

700+
assert ((EditText) findViewById(R.id.author_name)) != null;
684701
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
702+
assert ((EditText) findViewById(R.id.template_title)) != null;
685703
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
686704

687705

@@ -808,8 +826,9 @@ private void parseSavedFile(String path) {
808826

809827
Object templateObject = templateClass.newInstance();
810828
selectedTemplate = (TemplateInterface) templateObject;
829+
selectedTemplate.setTemplateId(templateId);
811830
populateListView(selectedTemplate.loadProjectTemplateEditor(this, items));
812-
if (templateId == 5) {
831+
if (templateId == 5 || templateId == 7) {
813832
populateMetaView(selectedTemplate.loadProjectMetaEditor(this, doc));
814833
}
815834
File draftDir = new File(toolkit.getDraftDir());

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

+2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ protected void onCreate(Bundle savedInstanceState) {
2828
ViewPager mPager = (ViewPager) findViewById(R.id.pager);
2929
// mPager.setAdapter(mAdapter);
3030

31+
assert mPager != null;
3132
mPager.setAdapter(mAdapter);
3233

3334

3435
CirclePageIndicator mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
36+
assert mIndicator != null;
3537
mIndicator.setViewPager(mPager);
3638
}
3739

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
import org.buildmlearn.toolkit.views.TextViewPlus;
1212

1313
import java.util.ArrayList;
14+
import java.util.Locale;
1415

1516
/**
1617
* Created by scopeinfinity on 10/3/16.
1718
*/
19+
20+
/**
21+
* @brief Adapter used for DraftsFragment to show the items
22+
*/
1823
public class DraftProjectAdapter extends BaseAdapter {
1924

20-
private Context mContext;
21-
private ArrayList<SavedProject> data;
25+
private final Context mContext;
26+
private final ArrayList<SavedProject> data;
2227

2328
public DraftProjectAdapter(Context mContext, ArrayList<SavedProject> data) {
2429
this.mContext = mContext;
@@ -68,8 +73,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
6873
}
6974

7075
SavedProject projectData = getItem(position);
71-
holder.draftSubtitle.setText("Last Modified: " + projectData.getTime() );
72-
holder.draftTitle.setText("Drafted on "+projectData.getDate());
76+
holder.draftSubtitle.setText(String.format(Locale.ENGLISH, "Last Modified: %s", projectData.getTime()));
77+
holder.draftTitle.setText(String.format(Locale.ENGLISH, "Drafted on %s", projectData.getDate()));
7378
holder.draftIcon.setText("D");
7479
convertView.setTag(holder);
7580
return convertView;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
public class SavedApiAdapter extends BaseAdapter {
2323

24-
private Context mContext;
25-
private ArrayList<SavedApi> data;
24+
private final Context mContext;
25+
private final ArrayList<SavedApi> data;
2626

2727
public SavedApiAdapter(Context mContext, ArrayList<SavedApi> data) {
2828
this.mContext = mContext;
@@ -72,7 +72,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
7272
}
7373

7474
SavedApi apiData = getItem(position);
75-
holder.details.setText("Modified: " + apiData.getDate() + ", Author: " + apiData.getAuthor());
75+
holder.details.setText(String.format(Locale.ENGLISH, "Modified: %s, Author: ", apiData.getDate(), apiData.getAuthor()));
7676
holder.apkName.setText(apiData.getName());
7777
holder.projectIcon.setText(apiData.getName().substring(0, 1).toUpperCase(Locale.US));
7878
convertView.setTag(holder);

0 commit comments

Comments
 (0)