Skip to content

Commit

Permalink
Merge pull request #151 from BuildmLearn/new-features
Browse files Browse the repository at this point in the history
Update master branch after completion of GSoC EndTerm 2016
  • Loading branch information
opticod authored Aug 22, 2016
2 parents c753602 + 38a6743 commit aa45687
Show file tree
Hide file tree
Showing 314 changed files with 12,468 additions and 3,738 deletions.
4 changes: 2 additions & 2 deletions source-code/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ android {
applicationId "org.buildmlearn.toolkit"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
versionCode 2
versionName "2.0.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.hamcrest.core.IsInstanceOf.instanceOf;

/**
* Espresso test designed to test all the functionalities of Comprehension template
* Created by anupam (opticod) on 7/6/16.
*/

Expand Down
1 change: 1 addition & 0 deletions source-code/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".activity.HomeActivity"
Expand Down
Binary file added source-code/app/src/main/assets/DictationApp.apk
Binary file not shown.
Binary file modified source-code/app/src/main/assets/FlashCardTemplateApp.apk
100755 → 100644
Binary file not shown.
Binary file modified source-code/app/src/main/assets/LearnSpellingsApp.apk
100755 → 100644
Binary file not shown.
Binary file added source-code/app/src/main/assets/MatchApp.apk
Binary file not shown.
Binary file modified source-code/app/src/main/assets/QuizTemplateApp.apk
100755 → 100644
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildmlearn_application type="DictationTemplate">
<author>
<name>Anupam</name>
</author>
<title>Dictation</title>
<data>
<item>
<dictation_title>Dream of the Rarebit Fiend</dictation_title>
<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>
</item>
<item>
<dictation_title>Earthworks</dictation_title>
<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.

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>
</item>
</data>
</buildmlearn_application>
38 changes: 38 additions & 0 deletions source-code/app/src/main/assets/template_assets/match_content.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildmlearn_application type="MatchTemplate">
<author>
<name>Anupam</name>
</author>
<title>Country Match</title>
<data>
<meta_details>
<meta_title>Match the countries</meta_title>
<meta_first_list_title>Country</meta_first_list_title>
<meta_second_list_title>Capital</meta_second_list_title>
</meta_details>
<item>
<first_list_item>India</first_list_item>
<second_list_item>New Delhi</second_list_item>
</item>
<item>
<first_list_item>Bangladesh</first_list_item>
<second_list_item>Dhaka</second_list_item>
</item>
<item>
<first_list_item>Malaysia</first_list_item>
<second_list_item>Kuala Lumpur</second_list_item>
</item>
<item>
<first_list_item>Pakistan</first_list_item>
<second_list_item>Islamabad</second_list_item>
</item>
<item>
<first_list_item>Portugal</first_list_item>
<second_list_item>Lisbon</second_list_item>
</item>
<item>
<first_list_item>Syria</first_list_item>
<second_list_item>Damascus</second_list_item>
</item>
</data>
</buildmlearn_application>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import org.buildmlearn.toolkit.R;

import java.util.Locale;

/**
* @brief Gives brief info about BuildmLearn community and toolkit
*/
Expand All @@ -30,9 +32,10 @@ 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("Version: " + version);
((TextView) findViewById(R.id.app_version)).setText(String.format(Locale.ENGLISH, "Version: %s", 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");
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class HomeActivity extends AppCompatActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks {

private Section currentSection;
private NavigationDrawerFragment mNavigationDrawerFragment;

/**
* {@inheritDoc}
Expand All @@ -37,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
/*
Fragment managing the behaviors, interactions and presentation of the navigation drawer.
*/
NavigationDrawerFragment mNavigationDrawerFragment = (NavigationDrawerFragment)
mNavigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);

// Set up the drawer.
Expand Down Expand Up @@ -81,7 +82,7 @@ public void onNavigationDrawerItemSelected(int position) {
if (currentSection == null || selectedMenuItem != currentSection) {
currentSection = selectedMenuItem;
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null);
Fragment f = fm.findFragmentById(R.id.container);
if (f != null) {
if (currentSection.isKeep()) {
Expand All @@ -104,4 +105,15 @@ public void onNavigationDrawerItemSelected(int position) {
}
}

@Override
public void onBackPressed() {
if (mNavigationDrawerFragment.isDrawerOpen()) {
mNavigationDrawerFragment.closeDrawer();
return;
}
if (getFragmentManager().getBackStackEntryCount() <= 1) {
finish();
}
super.onBackPressed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;

import org.buildmlearn.toolkit.R;
import org.buildmlearn.toolkit.adapter.TemplateAdapter;
Expand All @@ -28,20 +26,21 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_template);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
ListAdapter mAdapter = new TemplateAdapter(this);
AbsListView mListView = (AbsListView) findViewById(android.R.id.list);
mListView.setAdapter(mAdapter);
TemplateAdapter mAdapter = new TemplateAdapter(this);
RecyclerView mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
assert mRecyclerView != null;
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
mAdapter.setOnClickListener(new TemplateAdapter.SetOnClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

public void onItemClick(int position) {
Intent intent = new Intent(getApplicationContext(), TemplateEditor.class);
intent.putExtra(Constants.TEMPLATE_ID, position);
startActivity(intent);

}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.button_add_item).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (templateId == 5 && selectedTemplate.currentMetaEditorAdapter().isEmpty()) {
if ((templateId == 5 || templateId == 7) && selectedTemplate.currentMetaEditorAdapter().isEmpty()) {
selectedTemplate.addMetaData(TemplateEditor.this);
} else {
selectedTemplate.addItem(TemplateEditor.this);
Expand Down Expand Up @@ -301,13 +301,11 @@ private void setUpTemplateEditor() {
selectedTemplate = (TemplateInterface) templateObject;
selectedTemplate.setTemplateId(templateId);
populateListView(selectedTemplate.newTemplateEditorAdapter(this));
if (templateId == 5) {
if (templateId == 5 || templateId == 7) {
populateMetaView(selectedTemplate.newMetaEditorAdapter(this));
}
setUpActionBar();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
Expand All @@ -325,7 +323,7 @@ private void restoreTemplateEditor(Bundle savedInstanceState) {
finish();
} else {
populateListView(selectedTemplate.currentTemplateEditorAdapter());
if (templateId == 5) {
if (templateId == 5 || templateId == 7) {
populateMetaView(selectedTemplate.currentMetaEditorAdapter());
}
setUpActionBar();
Expand Down Expand Up @@ -397,20 +395,36 @@ public void onClick(View v) {
new BottomSheet.Builder(this).sheet(R.menu.bottom_sheet_template).listener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
String savedFilePath;
switch (id) {
case R.id.save_project:
saveProject();
break;

case R.id.share_project:
savedFilePath = saveProject();
if (savedFilePath == null || savedFilePath.length() == 0) {
return;
}
Uri fileUri = Uri.fromFile(new File(savedFilePath));
ArrayList<Uri> uris = new ArrayList<>();
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("application/zip");
uris.add(fileUri);
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(sendIntent, null));
break;

case R.id.share_apk:

String savedFilePath = saveProject();
savedFilePath = saveProject();
if (savedFilePath == null || savedFilePath.length() == 0) {
return;
}
String keyPassword = getString(R.string.key_password);
String aliasName = getString(R.string.alias_name);
String aliaspassword = getString(R.string.alias_password);
KeyStoreDetails keyStoreDetails = new KeyStoreDetails("TestKeyStore.jks", keyPassword, aliasName, aliaspassword);
KeyStoreDetails keyStoreDetails = new KeyStoreDetails(keyPassword, aliasName, aliaspassword);
SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this));

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

mApkGenerationDialog = new MaterialDialog.Builder(TemplateEditor.this)
Expand Down Expand Up @@ -600,8 +614,10 @@ private String saveProject() {
EditText authorEditText = (EditText) findViewById(R.id.author_name);
EditText titleEditText = (EditText) findViewById(R.id.template_title);
assert findViewById(R.id.author_name) != null;
assert ((EditText) findViewById(R.id.author_name)) != null;
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
assert findViewById(R.id.template_title) != null;
assert ((EditText) findViewById(R.id.template_title)) != null;
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();
if ("".equals(author)) {
assert authorEditText != null;
Expand Down Expand Up @@ -637,7 +653,7 @@ private String saveProject() {
doc.appendChild(rootElement);
Element dataElement = doc.createElement("data");
rootElement.appendChild(dataElement);
if (selectedTemplate.getItems(doc).size() == 0 || (selectedTemplate.getItems(doc).size() < 2 && templateId == 5)) {
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();
return null;
}
Expand Down Expand Up @@ -679,9 +695,11 @@ public void onBackPressed() {
* @return Absolute path of the saved file. Null if there is some error.
* @brief Saves the current project into a .buildmlearn file.
*/
protected String saveDraft() {
private String saveDraft() {

assert ((EditText) findViewById(R.id.author_name)) != null;
String author = ((EditText) findViewById(R.id.author_name)).getText().toString();
assert ((EditText) findViewById(R.id.template_title)) != null;
String title = ((EditText) findViewById(R.id.template_title)).getText().toString();


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

Object templateObject = templateClass.newInstance();
selectedTemplate = (TemplateInterface) templateObject;
selectedTemplate.setTemplateId(templateId);
populateListView(selectedTemplate.loadProjectTemplateEditor(this, items));
if (templateId == 5) {
if (templateId == 5 || templateId == 7) {
populateMetaView(selectedTemplate.loadProjectMetaEditor(this, doc));
}
File draftDir = new File(toolkit.getDraftDir());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ protected void onCreate(Bundle savedInstanceState) {
ViewPager mPager = (ViewPager) findViewById(R.id.pager);
// mPager.setAdapter(mAdapter);

assert mPager != null;
mPager.setAdapter(mAdapter);


CirclePageIndicator mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
assert mIndicator != null;
mIndicator.setViewPager(mPager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
import org.buildmlearn.toolkit.views.TextViewPlus;

import java.util.ArrayList;
import java.util.Locale;

/**
* Created by scopeinfinity on 10/3/16.
*/

/**
* @brief Adapter used for DraftsFragment to show the items
*/
public class DraftProjectAdapter extends BaseAdapter {

private Context mContext;
private ArrayList<SavedProject> data;
private final Context mContext;
private final ArrayList<SavedProject> data;

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

SavedProject projectData = getItem(position);
holder.draftSubtitle.setText("Last Modified: " + projectData.getTime() );
holder.draftTitle.setText("Drafted on "+projectData.getDate());
holder.draftSubtitle.setText(String.format(Locale.ENGLISH, "Last Modified: %s", projectData.getTime()));
holder.draftTitle.setText(String.format(Locale.ENGLISH, "Drafted on %s", projectData.getDate()));
holder.draftIcon.setText("D");
convertView.setTag(holder);
return convertView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

public class SavedApiAdapter extends BaseAdapter {

private Context mContext;
private ArrayList<SavedApi> data;
private final Context mContext;
private final ArrayList<SavedApi> data;

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

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

0 comments on commit aa45687

Please sign in to comment.