diff --git a/source-code/app/build.gradle b/source-code/app/build.gradle index 93c39610..2b625be3 100644 --- a/source-code/app/build.gradle +++ b/source-code/app/build.gradle @@ -31,7 +31,7 @@ android { minSdkVersion 14 targetSdkVersion 23 versionCode 2 - versionName "2.0.0" + versionName "2.5.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -51,27 +51,25 @@ android { } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:cardview-v7:23.4.0' compile 'com.android.support:recyclerview-v7:23.4.0' compile 'com.android.support:design:23.4.0' - compile 'com.cocosw:bottomsheet:1.3.0@aar' compile('com.crashlytics.sdk.android:crashlytics:2.3.1@aar') { transitive = true; } - compile files('libs/core-1.51.0.0.jar') - compile files('libs/prov-1.51.0.0.jar') - compile files('libs/zipio-lib-1.8.jar') + compile files('libs/zipsigner-lib-1.17.jar') compile files('libs/zipsigner-lib-optional-1.16.jar') - compile files('libs/pkix-1.51.0.0.jar') compile files('libs/kellinwood-logging-android-1.4.jar') compile files('libs/kellinwood-logging-lib-1.1.jar') compile files('libs/kellinwood-logging-log4j-1.0.jar') compile files('libs/axml.jar') - compile 'com.viewpagerindicator:library:2.4.1@aar' - compile 'com.nineoldandroids:library:2.4.0' + compile files('libs/pkix-1.51.0.0.jar') + compile files('libs/core-1.51.0.0.jar') + compile files('libs/prov-1.51.0.0.jar') + compile files('libs/zipio-lib-1.8.jar') + compile 'com.squareup.picasso:picasso:2.5.2' compile 'org.jsoup:jsoup:1.9.1' androidTestCompile 'com.android.support:support-annotations:23.4.0' diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java index cbc79d14..19296c26 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/ToolkitApplication.java @@ -18,7 +18,7 @@ public class ToolkitApplication extends Application { private static String dir; - private boolean isExternalStorageAvailable = false; + private static boolean isExternalStorageAvailable = false; /** * @return Folder path @@ -31,6 +31,10 @@ public static String getUnZipDir() { @Override public void onCreate() { super.onCreate(); + storagePathsValidate(); + } + + public void storagePathsValidate() { if (checkExternalStorage()) { isExternalStorageAvailable = true; dir = Environment.getExternalStorageDirectory().getAbsolutePath(); @@ -50,8 +54,6 @@ public void onCreate() { f.mkdirs(); } } - - } /** diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/AboutBuildmLearn.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/AboutBuildmLearn.java index 029c9a1f..9fb0d237 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/AboutBuildmLearn.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/AboutBuildmLearn.java @@ -36,7 +36,7 @@ protected void onCreate(Bundle savedInstanceState) { } 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"); + ((TextView) findViewById(R.id.app_version)).setText("Version: 2.5.0"); e.printStackTrace(); } diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java index df1c5da3..1fbf99d9 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java @@ -10,7 +10,6 @@ import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.EditText; -import android.widget.Toast; import com.crashlytics.android.Crashlytics; @@ -58,7 +57,12 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { case KeyEvent.KEYCODE_ENTER: if (name.getText().toString().equals("")) { - Toast.makeText(getApplicationContext(), "Enter name", Toast.LENGTH_SHORT).show(); + name.setError(getApplicationContext().getResources().getString(R.string.enter_name)); + return false; + } + else if(!Character.isLetterOrDigit(name.getText().toString().charAt(0))) + { + name.setError(getApplicationContext().getResources().getString(R.string.valid_msg)); return false; } diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/HomeActivity.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/HomeActivity.java index 64457410..90f7cae1 100755 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/HomeActivity.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/HomeActivity.java @@ -1,37 +1,48 @@ package org.buildmlearn.toolkit.activity; import android.app.Fragment; -import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; -import android.os.Handler; import android.preference.PreferenceManager; +import android.support.design.widget.NavigationView; + +import android.app.FragmentManager; +import android.support.v4.view.GravityCompat; +import android.os.Handler; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import android.support.v7.widget.Toolbar;; +import android.view.MenuItem; +import android.view.View; +import android.widget.TextView; import android.widget.Toast; import org.buildmlearn.toolkit.R; -import org.buildmlearn.toolkit.constant.Constants; +import org.buildmlearn.toolkit.fragment.DraftsFragment; +import org.buildmlearn.toolkit.fragment.HomeFragment; import org.buildmlearn.toolkit.fragment.LoadApkFragment; import org.buildmlearn.toolkit.fragment.LoadProjectFragment; -import org.buildmlearn.toolkit.fragment.NavigationDrawerFragment; import org.buildmlearn.toolkit.fragment.SettingsFragment; -import org.buildmlearn.toolkit.model.Section; +import org.buildmlearn.toolkit.utilities.SmoothNavigationToggle; /** * @brief Home screen of the application containg all the menus and settings. */ + public class HomeActivity extends AppCompatActivity - implements NavigationDrawerFragment.NavigationDrawerCallbacks { + implements NavigationView.OnNavigationItemSelectedListener { - private Section currentSection; - private NavigationDrawerFragment mNavigationDrawerFragment; - private boolean atHome = true; + private final String FRAGMENT_TAG_HOME = "Home"; + private final String FRAGMENT_TAG_PROJECT = "Project"; + private final String FRAGMENT_TAG_APK = "Apk"; private boolean backPressedOnce = false; + private SmoothNavigationToggle smoothNavigationToggle; + + NavigationView navigationView; + /** * {@inheritDoc} */ @@ -39,108 +50,163 @@ public class HomeActivity extends AppCompatActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("SkipTutorial", true); editor.apply(); setContentView(R.layout.activity_home); - setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); - /* - Fragment managing the behaviors, interactions and presentation of the navigation drawer. - */ - mNavigationDrawerFragment = (NavigationDrawerFragment) - getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); - - // Set up the drawer. - mNavigationDrawerFragment.setUp( - R.id.navigation_drawer, - (DrawerLayout) findViewById(R.id.drawer_layout)); - if (getIntent().hasExtra(Constants.START_FRAGMENT) && getIntent().getIntExtra(Constants.START_FRAGMENT, 0) == 3) { - currentSection.setIsSelected(false); - Section[] menuItem = Section.values(); - Section selectedMenuItem = menuItem[3]; - selectedMenuItem.setIsSelected(true); - currentSection = selectedMenuItem; - FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.replace(R.id.container, new SettingsFragment()); - ft.commit(); + navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + View menuHeaderView = navigationView.getHeaderView(0); + final TextView name = (TextView) menuHeaderView.findViewById(R.id.name); + name.setText(String.format(" %s", prefs.getString(getString(R.string.key_user_name), ""))); + + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + smoothNavigationToggle = new SmoothNavigationToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ + @Override + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + name.setText(String.format(" %s", prefs.getString(getString(R.string.key_user_name), ""))); + LoadProjectFragment f = (LoadProjectFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG_PROJECT); + if (f != null) + f.closeSearch(); + + LoadApkFragment f2 = (LoadApkFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG_APK); + if (f2 != null) + f2.closeSearch(); + } + }; + drawer.addDrawerListener(smoothNavigationToggle); + smoothNavigationToggle.syncState(); + + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction() + .replace(R.id.container, new HomeFragment(), FRAGMENT_TAG_HOME).commit(); + navigationView.setCheckedItem(R.id.nav_home); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.app_name); } } - /** - * {@inheritDoc} - */ + @SuppressWarnings("StatementWithEmptyBody") @Override - public void onNavigationDrawerItemSelected(int position) { - if (position == -1) { - if (currentSection != null) { - if (currentSection.toString().equals("OPEN_PROJECT")) { - LoadProjectFragment f = (LoadProjectFragment) getFragmentManager().findFragmentByTag(currentSection.getViewName()); - if (f != null) - f.closeSearch(); - } else if (currentSection.toString().equals("OPEN_APK")) { - LoadApkFragment f = (LoadApkFragment) getFragmentManager().findFragmentByTag(currentSection.getViewName()); - if (f != null) - f.closeSearch(); - } - } - return; - } - Section[] menuItem = Section.values(); - Section selectedMenuItem = menuItem[position]; + public boolean onNavigationItemSelected(MenuItem item) { + // Handle navigation view item clicks here. + final FragmentManager fragmentManager = getFragmentManager(); + int id = item.getItemId(); + if (getSupportActionBar() != null) { - getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowCustomEnabled(false); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setDisplayShowTitleEnabled(true); } - if (selectedMenuItem.getType() == Section.ACTIVITY) { - Class c; - if (selectedMenuItem.getViewName() != null) { - try { - c = Class.forName(selectedMenuItem.getViewName()); - Intent intent = new Intent(this, c); - startActivity(intent); - - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - } else if (selectedMenuItem.getType() == Section.FRAGMENT) { - if (currentSection == null || !selectedMenuItem.equals(currentSection)) { - currentSection = selectedMenuItem; - FragmentManager fm = getFragmentManager(); - FragmentTransaction ft = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).addToBackStack(null); - Fragment f = fm.findFragmentById(R.id.container); - if (f != null) { - if (currentSection.isKeep()) { - ft.detach(f); - } else { - ft.remove(f); + + switch(id){ + case R.id.nav_home: + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new HomeFragment(), FRAGMENT_TAG_HOME).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.app_name); + } } - } - String fragmentClassName = currentSection.getViewName(); - if (currentSection.isKeep() && ((f = fm.findFragmentByTag(fragmentClassName)) != null)) { - ft.attach(f); - } else { - f = Fragment.instantiate(this, fragmentClassName); - ft.add(R.id.container, f, fragmentClassName); - } - ft.commit(); + }); + break; + case R.id.nav_saved_projects: + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new LoadProjectFragment(),FRAGMENT_TAG_PROJECT).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.menu_load_project); + } + } + }); + break; - } + case R.id.nav_saved_apks: + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new LoadApkFragment(),FRAGMENT_TAG_APK).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.menu_load_apks); + } + } + }); + break; + + case R.id.nav_drafts: + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new DraftsFragment()).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.menu_drafts); + } + } + }); + break; + + case R.id.nav_settings: + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new SettingsFragment()).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.menu_settings); + } + } + }); + break; + + case R.id.nav_howto: + final Intent intent = new Intent(this, TutorialActivity.class); + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + startActivity(intent); + } + }); + break; + case R.id.nav_about: + final Intent intent2 = new Intent(this, AboutBuildmLearn.class); + smoothNavigationToggle.runWhenIdle(new Runnable() { + @Override + public void run() { + startActivity(intent2); + } + }); + break; } + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; } @Override public void onBackPressed() { - - if (mNavigationDrawerFragment.isDrawerOpen()) { - mNavigationDrawerFragment.closeDrawer(); - return; - } - if(atHome){ + FragmentManager fragmentManager = getFragmentManager(); + Fragment fragment = fragmentManager.findFragmentByTag(FRAGMENT_TAG_HOME); + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else if (fragment != null && fragment.isVisible()) { if(backPressedOnce){ finish(); } @@ -154,10 +220,16 @@ public void run() backPressedOnce= false; } }, 2000); - } - else if(!atHome){ - onNavigationDrawerItemSelected(0); - atHome = true; + } else { + fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .replace(R.id.container, new HomeFragment(), FRAGMENT_TAG_HOME).commit(); + if (getSupportActionBar() != null) { + getSupportActionBar().setTitle(R.string.app_name); + } + navigationView.setCheckedItem(R.id.nav_home); } } } + + + diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java index 5fd37f73..c4a8541e 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java @@ -1,9 +1,13 @@ package org.buildmlearn.toolkit.activity; import android.Manifest; + +import android.app.Dialog; import android.app.ProgressDialog; -import android.content.Context; import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; +import android.content.Context; + import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -15,7 +19,6 @@ import android.os.Handler; import android.os.Message; import android.preference.PreferenceManager; -import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; @@ -24,6 +27,7 @@ import android.support.v7.widget.CardView; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -31,11 +35,10 @@ import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; - -import com.cocosw.bottomsheet.BottomSheet; - import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.ToolkitApplication; import org.buildmlearn.toolkit.constant.Constants; @@ -87,10 +90,207 @@ public void handleMessage(Message message) { private int selectedPosition = -1; private boolean showTemplateSelectedMenu; private View selectedView; + private EditText titleEditText; private ToolkitApplication toolkit; private String oldFileName; private ProgressDialog mApkGenerationDialog; + + public void openBottomSheet (View v) { + + View view = getLayoutInflater ().inflate (R.layout.bottom_sheet_view, null); + TextView txt_save_apk = (TextView)view.findViewById( R.id.txt_save_apk); + TextView txt_save_project = (TextView)view.findViewById( R.id.txt_save_project); + TextView txt_share_apk = (TextView)view.findViewById( R.id.txt_share_apk); + final TextView txt_shareProject = (TextView)view.findViewById( R.id.txt_share_project); + + final Dialog mBottomSheetDialog = new Dialog (TemplateEditor.this, + R.style.MaterialDialogSheet); + mBottomSheetDialog.setContentView (view); + mBottomSheetDialog.setCancelable (true); + mBottomSheetDialog.getWindow ().setLayout (LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + mBottomSheetDialog.getWindow ().setGravity (Gravity.BOTTOM); + mBottomSheetDialog.show (); + + + //save project + txt_save_project.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + saveProject(); + mBottomSheetDialog.dismiss(); + } + }); + + //share project + txt_shareProject.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + shareProject(); + mBottomSheetDialog.dismiss(); + } + }); + + txt_share_apk.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + share_apk(); + mBottomSheetDialog.dismiss(); + } + }); + + txt_save_apk.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + save_apk(); + mBottomSheetDialog.dismiss(); + } + }); + } + + private void save_apk() { + String savedFilePath; + 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(keyPassword, aliasName, aliaspassword); + SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this)); + + mApkGenerationDialog = new ProgressDialog(TemplateEditor.this, R.style.AppDialogTheme); + mApkGenerationDialog.setTitle(R.string.apk_progress_dialog); + mApkGenerationDialog.setMessage(getString(R.string.apk_msg)); + mApkGenerationDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); + mApkGenerationDialog.setCancelable(false); + mApkGenerationDialog.setProgress(0); + mApkGenerationDialog.show(); + + signer.setSignerThreadListener(new SignerThread.OnSignComplete() { + @Override + public void onSuccess(final String path) { + Log.d(TAG, "APK generated"); + mApkGenerationDialog.dismiss(); + runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog dialog = new AlertDialog.Builder(TemplateEditor.this) + .setTitle("Apk Generated") + .setMessage("Apk file saved at " + path) + .setPositiveButton("okay", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }) + .create(); + dialog.show(); + } + }); + + + } + + @Override + public void onFail(Exception e) { + if (e != null) { + e.printStackTrace(); + mApkGenerationDialog.dismiss(); + Message message = handlerToast.obtainMessage(); + message.arg1 = -1; + handlerToast.sendMessage(message); + } + } + }); + + signer.start(); + } + + private void share_apk() { + String savedFilePath; + 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(keyPassword, aliasName, aliaspassword); + SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this)); + + mApkGenerationDialog = new ProgressDialog(TemplateEditor.this, R.style.AppDialogTheme); + mApkGenerationDialog.setTitle(R.string.apk_progress_dialog); + mApkGenerationDialog.setMessage(getString(R.string.apk_msg)); + mApkGenerationDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); + mApkGenerationDialog.setCancelable(false); + mApkGenerationDialog.setProgress(0); + mApkGenerationDialog.show(); + + signer.setSignerThreadListener(new SignerThread.OnSignComplete() { + @Override + public void onSuccess(final String path) { + Log.d(TAG, "APK generated"); + mApkGenerationDialog.dismiss(); + + Uri fileUri = Uri.fromFile(new File(path)); + try { + ArrayList uris = new ArrayList<>(); + Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); + sendIntent.setType("application/vnd.android.package-archive"); + uris.add(fileUri); + sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); + startActivity(Intent.createChooser(sendIntent, null)); + + + } catch (Exception e) { + + ArrayList 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)); + } + + } + + @Override + public void onFail(Exception e) { + if (e != null) { + e.printStackTrace(); + mApkGenerationDialog.dismiss(); + Message message = handlerToast.obtainMessage(); + message.arg1 = -1; + handlerToast.sendMessage(message); + } + } + }); + + signer.start(); + } + + private void shareProject() { + String savedFilePath; + savedFilePath = saveProject(); + if (savedFilePath == null || savedFilePath.length() == 0) { + return; + } + Uri fileUri = Uri.fromFile(new File(savedFilePath)); + ArrayList 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)); + } + /** * {@inheritDoc} */ @@ -142,6 +342,22 @@ public void onClick(View v) { } } + @Override + public void onRequestPermissionsResult(int requestCode, + String permissions[], int[] grantResults) { + switch (requestCode) { + case PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE_RESULT: { + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + ToolkitApplication mToolkitApplication = new ToolkitApplication(); + mToolkitApplication.storagePathsValidate(); + } + return; + } + + } + } + /** * {@inheritDoc} */ @@ -304,11 +520,14 @@ private void setUpTemplateEditor() { populateMetaView(selectedTemplate.newMetaEditorAdapter(this)); } setUpActionBar(); - } catch (IllegalAccessException e) { - e.printStackTrace(); + } catch (InstantiationException e) { e.printStackTrace(); } + catch ( IllegalAccessException e) + { + e.printStackTrace(); + } } /** @@ -366,19 +585,25 @@ public boolean onOptionsItemSelected(MenuItem item) { switch (id) { case R.id.action_delete: - final int restorePosition = selectedPosition; - final Object object = selectedTemplate.deleteItem(TemplateEditor.this, selectedPosition); - selectedPosition = -1; - restoreSelectedView(); - Snackbar.make(findViewById(R.id.relative_layout), - R.string.snackbar_deleted_message,Snackbar.LENGTH_LONG) - .setAction(R.string.snackbar_undo, new View.OnClickListener() { + + final AlertDialog dialog = new AlertDialog.Builder(this) + .setTitle(R.string.dialog_delete_title) + .setMessage(R.string.dialog_delete_msg) + .setPositiveButton(R.string.dialog_yes, null) + .setNegativeButton(R.string.dialog_no, null) + .create(); + dialog.show(); + + dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - selectedTemplate.restoreItem(TemplateEditor.this,restorePosition,object); - Snackbar.make(v,R.string.snackbar_restored_message,Snackbar.LENGTH_LONG).show(); + dialog.dismiss(); + selectedTemplate.deleteItem(TemplateEditor.this, selectedPosition); + selectedPosition = -1; + restoreSelectedView(); } - }).show(); + }); + break; case R.id.action_edit: selectedTemplate.editItem(this, selectedPosition); @@ -386,153 +611,7 @@ public void onClick(View v) { restoreSelectedView(); break; case R.id.action_save: - 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 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: - - 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(keyPassword, aliasName, aliaspassword); - SignerThread signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this)); - - mApkGenerationDialog = new ProgressDialog(TemplateEditor.this, R.style.AppDialogTheme); - mApkGenerationDialog.setTitle(R.string.apk_progress_dialog); - mApkGenerationDialog.setMessage(getString(R.string.apk_msg)); - mApkGenerationDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); - mApkGenerationDialog.setCancelable(false); - mApkGenerationDialog.setProgress(0); - mApkGenerationDialog.show(); - - signer.setSignerThreadListener(new SignerThread.OnSignComplete() { - @Override - public void onSuccess(final String path) { - Log.d(TAG, "APK generated"); - mApkGenerationDialog.dismiss(); - - Uri fileUri = Uri.fromFile(new File(path)); - try { - ArrayList uris = new ArrayList<>(); - Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); - sendIntent.setType("application/vnd.android.package-archive"); - uris.add(fileUri); - sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); - startActivity(Intent.createChooser(sendIntent, null)); - - - } catch (Exception e) { - - ArrayList 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)); - } - - } - - @Override - public void onFail(Exception e) { - if (e != null) { - e.printStackTrace(); - mApkGenerationDialog.dismiss(); - Message message = handlerToast.obtainMessage(); - message.arg1 = -1; - handlerToast.sendMessage(message); - } - } - }); - - signer.start(); - - break; - case R.id.save_apk: - savedFilePath = saveProject(); - if (savedFilePath == null || savedFilePath.length() == 0) { - return; - } - keyPassword = getString(R.string.key_password); - aliasName = getString(R.string.alias_name); - aliaspassword = getString(R.string.alias_password); - keyStoreDetails = new KeyStoreDetails(keyPassword, aliasName, aliaspassword); - signer = new SignerThread(getApplicationContext(), selectedTemplate.getApkFilePath(), saveProject(), keyStoreDetails, selectedTemplate.getAssetsFilePath(), selectedTemplate.getAssetsFileName(TemplateEditor.this)); - - mApkGenerationDialog = new ProgressDialog(TemplateEditor.this, R.style.AppDialogTheme); - mApkGenerationDialog.setTitle(R.string.apk_progress_dialog); - mApkGenerationDialog.setMessage(getString(R.string.apk_msg)); - mApkGenerationDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); - mApkGenerationDialog.setCancelable(false); - mApkGenerationDialog.setProgress(0); - mApkGenerationDialog.show(); - - signer.setSignerThreadListener(new SignerThread.OnSignComplete() { - @Override - public void onSuccess(final String path) { - Log.d(TAG, "APK generated"); - mApkGenerationDialog.dismiss(); - - runOnUiThread(new Runnable() { - @Override - public void run() { - AlertDialog dialog = new AlertDialog.Builder(TemplateEditor.this) - .setTitle("Apk Generated") - .setMessage("Apk file saved at " + path) - .setPositiveButton("okay", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }) - .create(); - dialog.show(); - } - }); - - - } - - @Override - public void onFail(Exception e) { - if (e != null) { - e.printStackTrace(); - mApkGenerationDialog.dismiss(); - Message message = handlerToast.obtainMessage(); - message.arg1 = -1; - handlerToast.sendMessage(message); - } - } - }); - - signer.start(); - } - } - }).show(); + openBottomSheet(LayoutInflater.from(TemplateEditor.this).inflate(R.layout.bottom_sheet_view, null)); break; case R.id.action_simulate: startSimulator(); @@ -607,7 +686,7 @@ private void restoreColorScheme() { private String saveProject() { EditText authorEditText = (EditText) findViewById(R.id.author_name); - EditText titleEditText = (EditText) findViewById(R.id.template_title); + 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(); @@ -619,7 +698,13 @@ private String saveProject() { authorEditText.setError("Author name is required"); } else if ("".equals(title)) { assert titleEditText != null; - titleEditText.setError("Title is required"); + titleEditText.setError(getResources().getString(R.string.title_error)); + } else if (!Character.isLetterOrDigit(author.charAt(0))) { + assert authorEditText != null; + authorEditText.setError(getResources().getString(R.string.valid_msg)); + } else if (!Character.isLetterOrDigit(title.charAt(0))) { + assert titleEditText != null; + titleEditText.setError(getString(R.string.title_valid)); } else { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); @@ -652,6 +737,10 @@ private String saveProject() { Toast.makeText(this, "Unable to perform action: No Data", Toast.LENGTH_SHORT).show(); return null; } + if (selectedTemplate.getItems(doc).get(0).getTagName().equals("item") && (templateId == 5 || templateId == 7)) { + Toast.makeText(this, "Unable to perform action: Add Meta Details", Toast.LENGTH_SHORT).show(); + return null; + } for (Element item : selectedTemplate.getItems(doc)) { dataElement.appendChild(item); } @@ -664,10 +753,17 @@ private String saveProject() { saveFileName = saveFileName.replaceAll(" ", "-"); - FileUtils.saveXmlFile(toolkit.getSavedDir(), saveFileName, doc); - oldFileName = toolkit.getSavedDir() + saveFileName; - Toast.makeText(this, "Project Successfully Saved!", Toast.LENGTH_SHORT).show(); - return oldFileName; + boolean isSaved=FileUtils.saveXmlFile(toolkit.getSavedDir(), saveFileName, doc); + if(isSaved) { + oldFileName = toolkit.getSavedDir() + saveFileName; + Toast.makeText(this, "Project Successfully Saved!", Toast.LENGTH_SHORT).show(); + return oldFileName; + } + else { + titleEditText.setError("File Already exists"); + return "File already exists"; + } + } catch (ParserConfigurationException e) { e.printStackTrace(); } @@ -771,16 +867,22 @@ private String saveDraft() { * @brief Start the simulator activity *

* Start the simulator with the fragment returned by the selected template. Simulator is started as a new activity. + * String message contains file response which will be filepath if successfully saved and otherwise error message. */ private void startSimulator() { - String filePath = saveProject(); - if (filePath == null || filePath.equals("")) { + String message = saveProject(); + if (message == null || message.equals("")) { Toast.makeText(this, "Build unsuccessful", Toast.LENGTH_SHORT).show(); return; } + else if("File already exists".equals(message)) + { + titleEditText.setError("Template Already exists"); + return; + } Intent simulatorIntent = new Intent(getApplicationContext(), Simulator.class); simulatorIntent.putExtra(Constants.TEMPLATE_ID, templateId); - simulatorIntent.putExtra(Constants.SIMULATOR_FILE_PATH, filePath); + simulatorIntent.putExtra(Constants.SIMULATOR_FILE_PATH, message); startActivity(simulatorIntent); } @@ -849,7 +951,7 @@ private void parseSavedFile(String path) { */ private void updateHeaderDetails(String name, String title) { EditText authorEditText = (EditText) findViewById(R.id.author_name); - EditText titleEditText = (EditText) findViewById(R.id.template_title); + titleEditText = (EditText) findViewById(R.id.template_title); assert authorEditText != null; authorEditText.setText(name); assert titleEditText != null; @@ -882,3 +984,4 @@ protected void onStop() { } } + diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TutorialActivity.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TutorialActivity.java index a11fe203..c3393514 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TutorialActivity.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TutorialActivity.java @@ -3,18 +3,26 @@ import android.os.Bundle; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; +import android.text.Html; +import android.util.TypedValue; + +import android.widget.LinearLayout; +import android.widget.TextView; -import com.viewpagerindicator.CirclePageIndicator; import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.adapter.TutorialAdapter; import org.buildmlearn.toolkit.constant.Constants; +import org.buildmlearn.toolkit.model.Tutorial; /** * @brief Shows the tutorial related to BuildmLearn toolkit usage. */ public class TutorialActivity extends AppCompatActivity { + + private LinearLayout indicatingDotsContainer; + /** * {@inheritDoc} */ @@ -27,14 +35,57 @@ protected void onCreate(Bundle savedInstanceState) { ViewPager mPager = (ViewPager) findViewById(R.id.pager); // mPager.setAdapter(mAdapter); + indicatingDotsContainer = (LinearLayout) findViewById(R.id.layoutDots); + addBottomDots(0); //adds indicating dots to given slide i.e current slide assert mPager != null; mPager.setAdapter(mAdapter); + mPager.addOnPageChangeListener(viewPagerPageChangeListener); + } + private void addBottomDots(int current_slide) { + TextView[] dots = new TextView[Tutorial.values().length]; + int dot_colorActive = getResources().getColor(R.color.selected_dot); - CirclePageIndicator mIndicator = (CirclePageIndicator) findViewById(R.id.indicator); - assert mIndicator != null; - mIndicator.setViewPager(mPager); + indicatingDotsContainer.removeAllViews(); + + //number of dots added to container equals number of slides + for (int i = 0; i < dots.length; i++) { + dots[i] = new TextView(this); + dots[i].setText(Html.fromHtml("○")); + dots[i].setTextSize(TypedValue.COMPLEX_UNIT_SP,15); + indicatingDotsContainer.addView(dots[i]); + } + + //dot corresponding to current slide is given active color i.e white color + if (dots.length > 0) { + dots[current_slide].setTextColor(dot_colorActive); + dots[current_slide].setText(Html.fromHtml("•")); + dots[current_slide].setTextSize(TypedValue.COMPLEX_UNIT_SP,32); + } } -} + ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() { + + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + //do nothing + + } + + //invoked when slide is changed + @Override + public void onPageSelected(int position) { + addBottomDots(position); + } + + @Override + public void onPageScrollStateChanged(int state) { + + //do nothing + } + + + }; +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/NavigationDrawerMenuAdapter.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/NavigationDrawerMenuAdapter.java deleted file mode 100644 index e0eb04ce..00000000 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/NavigationDrawerMenuAdapter.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.buildmlearn.toolkit.adapter; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.support.v4.content.ContextCompat; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.style.ForegroundColorSpan; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; - -import org.buildmlearn.toolkit.R; -import org.buildmlearn.toolkit.model.Section; - -/** - * @brief Adapter used for showing menus in the side panel - *

- * Created by Abhishek on 21/04/15. - */ -public class NavigationDrawerMenuAdapter extends BaseAdapter { - - private final Section[] sections = Section.values(); - private final LayoutInflater inflater; - private final Context context; - private int currentSectionForegroundColor; - private int currentSectionBackgroundColor; - - public NavigationDrawerMenuAdapter(Context context, LayoutInflater inflater) { - this.inflater = inflater; - this.context = context; - // Select the primary color to tint the current section - TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{R.attr.colorPrimary}); - try { - currentSectionForegroundColor = a.getColor(0, ContextCompat.getColor(context, R.color.color_primary)); - } finally { - a.recycle(); - } - currentSectionBackgroundColor = ContextCompat.getColor(context, R.color.translucent_grey); - } - - /** - * {@inheritDoc} - */ - @Override - public int getCount() { - return sections.length; - } - - /** - * {@inheritDoc} - */ - @Override - public Section getItem(int position) { - return sections[position]; - } - - /** - * {@inheritDoc} - */ - @Override - public long getItemId(int position) { - return position; - } - - /** - * {@inheritDoc} - */ - @Override - public View getView(int position, View convertView, ViewGroup parent) { - - Section menu = getItem(position); - if (menu.getType() == Section.ACTIVITY || menu.getType() == Section.FRAGMENT) { - if (convertView == null) { - convertView = inflater.inflate(R.layout.item_main_menu, parent, false); - } - TextView tv = (TextView) convertView.findViewById(R.id.section_text); - SpannableString sectionTitle = new SpannableString(context.getString(menu.getTitleResId())); - Drawable sectionIcon; - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - sectionIcon = context.getDrawable(menu.getIconResId()); - } else { - sectionIcon = ContextCompat.getDrawable(context, menu.getIconResId()); - } - int backgroundColor; - if (menu.isSelected()) { - // Special color for the current section -// sectionTitle.setSpan(new StyleSpan(Typeface.BOLD), 0, sectionTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - sectionTitle.setSpan(new ForegroundColorSpan(currentSectionForegroundColor), 0, sectionTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - // We need to mutate the drawable before applying the ColorFilter, or else all the similar drawable instances will be tinted. - assert sectionIcon != null; - sectionIcon.mutate().setColorFilter(currentSectionForegroundColor, PorterDuff.Mode.SRC_IN); - backgroundColor = currentSectionBackgroundColor; - } else { - backgroundColor = Color.TRANSPARENT; - } - tv.setText(sectionTitle); - tv.setCompoundDrawablesWithIntrinsicBounds(sectionIcon, null, null, null); - tv.setBackgroundColor(backgroundColor); - } else if (menu.getType() == Section.SECTION_DIVIDER && convertView == null) { - convertView = inflater.inflate(R.layout.item_section_divider, parent, false); - } - return convertView; - } -} - diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/TutorialAdapter.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/TutorialAdapter.java index 4310ef24..2b27a849 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/TutorialAdapter.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/adapter/TutorialAdapter.java @@ -96,11 +96,7 @@ public void onClick(View v) { title.setText(tutorial.getTitle()); description.setText(tutorial.getDescription()); if(!SkipTutorial) { - if ("Welcome to BuildmLearn Toolkit".equals(title.getText().toString())) { - skip_button.setVisibility(View.VISIBLE); - } else { - skip_button.setVisibility(View.GONE); - } + skip_button.setVisibility(View.VISIBLE); } convertView.findViewById(R.id.skip_button).setOnClickListener(new View.OnClickListener() { @Override @@ -110,7 +106,7 @@ public void onClick(View v) { } mActivity.finish(); } - }); + }); } container.addView(convertView, 0); @@ -137,7 +133,10 @@ private enum ListColor { BLUE("#29A6D4"), GREEN("#1C7D6C"), ORANGE("#F77400"), - RED("#F53B3C"); + RED("#F53B3C"), + GRAYISH("#78909C"), + PURPLE("#AB47BC"), + YELLOW("#F9A01E"); private @ColorRes diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensiontemplate/fragment/MainFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensiontemplate/fragment/MainFragment.java index 1e2ada4a..6f02992d 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensiontemplate/fragment/MainFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/comprehensiontemplate/fragment/MainFragment.java @@ -117,9 +117,10 @@ public void onFinish() { Fragment frag = QuestionFragment.newInstance(); frag.setArguments(arguments); - getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); - - getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit(); + if(getActivity()!=null) { + getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); + getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit(); + } } }.start(); diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/LastFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/LastFragment.java index 7a554fd4..ed5c30ec 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/LastFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/LastFragment.java @@ -35,7 +35,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, View rootView = inflater.inflate(R.layout.fragment_last_flash, container, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar_main); - toolbar.setTitle(getResources().getString(R.string.main_title_spell)); + toolbar.setTitle(getResources().getString(R.string.main_title_flash)); toolbar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary_comprehension)); toolbar.inflateMenu(R.menu.menu_main_white); diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/MainFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/MainFragment.java index b3159b63..a42819a6 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/MainFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/flashcardtemplate/fragment/MainFragment.java @@ -67,7 +67,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); toolbar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary_comprehension)); toolbar.inflateMenu(R.menu.menu_main_white); - toolbar.setTitle(getResources().getString(R.string.main_title_spell)); + toolbar.setTitle(getResources().getString(R.string.main_title_flash)); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/DraftsFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/DraftsFragment.java index 46b4a321..4b5519f2 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/DraftsFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/DraftsFragment.java @@ -11,6 +11,7 @@ import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -117,6 +118,21 @@ public boolean onItemLongClick(AdapterView parent, View view, int position, l return true; } }); + + getView().setFocusableInTouchMode(true); + getView().requestFocus(); + getView().setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (mAdapter.selectedPositionsSize() > 0) { + unselectAll(); + return true; + } + } + return false; + } + }); } /** @@ -179,6 +195,7 @@ public void onResume() { if (mAdapter != null) { reloadContent(); } + setEmptyText(); super.onResume(); } @@ -315,12 +332,7 @@ public void onClick(View v) { break; case R.id.action_unselect_all: - for(int i=0;i parent, View view, int position, l return true; } }); + + getView().setFocusableInTouchMode(true); + getView().requestFocus(); + getView().setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (mAdapter.selectedPositionsSize() > 0) { + unselectAll(); + return true; + } + } + return false; + } + }); } /** @@ -224,7 +239,7 @@ public void onResume() { File apkFile = new File(aFile.getAbsolutePath()); PackageInfo info = getActivity().getPackageManager().getPackageArchiveInfo(apkFile.getAbsolutePath(), 0); if (info != null && info.packageName != null && info.packageName.startsWith("org.buildmlearn.")) { - if (apkFile.getName().startsWith(specificApis)) + if (apkFile.getName().contains(specificApis)) savedApis.add(new SavedApi(apkFile, apkFile.getName(), apkFile.lastModified())); allsavedApis.add(new SavedApi(apkFile, apkFile.getName(), apkFile.lastModified())); } @@ -349,7 +364,7 @@ public void onClick(View v) { actionBar.setCustomView(R.layout.search_bar); actionBar.setDisplayShowTitleEnabled(false); editSearch = (EditText) actionBar.getCustomView().findViewById(R.id.editSearch); - editSearch.setHint("Enter name of Apk"); + editSearch.setHint("Enter Apk name"); editSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -365,11 +380,9 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { public void afterTextChanged(Editable s) { String text = s.toString().trim(); savedApis.clear(); - SavedApi tempApi; for (int i = 0; i < allsavedApis.size(); i++) { - if (allsavedApis.get(i).getName().startsWith(text)) { - tempApi = new SavedApi(allsavedApis.get(i).getFile(), allsavedApis.get(i).getName(), allsavedApis.get(i).getUnformattedDate()); - savedApis.add(tempApi); + if (allsavedApis.get(i).getName().toLowerCase().contains(text.toLowerCase())) { + savedApis.add(allsavedApis.get(i)); } } mAdapter.notifyDataSetChanged(); @@ -383,6 +396,11 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { editSearch.onKeyPreIme(keyCode, event); if (isSearchOpened) { closeSearch(); + savedApis.clear(); + for (int i = 0; i < allsavedApis.size(); i++) { + savedApis.add(allsavedApis.get(i)); + } + mAdapter.notifyDataSetChanged(); } return true; } @@ -406,12 +424,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { break; case R.id.action_unselect_all: - for(int i=0;i selectedPositions = mAdapter.getSelectedPositions(); boolean deleted = false; + for(int selectedPosition : selectedPositions) { SavedApi apk = savedApis.get(selectedPosition); File file = new File(apk.getFile().getPath()); deleted = file.delete(); if (deleted) { + int selectedPos = -1; + for (int i = 0; i < allsavedApis.size(); i++) { + SavedApi sApi = allsavedApis.get(i); + if (sApi.getName().equals(apk.getName())) { + selectedPos = i; + break; + } + } + if (selectedPos != -1) { + allsavedApis.remove(selectedPos); + } savedApis.remove(selectedPosition); mAdapter.removeSelectedPosition(selectedPosition); mAdapter.notifyDataSetChanged(); @@ -438,7 +472,10 @@ private void deleteItems() { } } if(deleted) - Toast.makeText(activity, "Project Successfully Deleted!", Toast.LENGTH_SHORT).show(); + if(selectedPositions.size()==1) + Toast.makeText(activity,"Project Successfully Deleted", Toast.LENGTH_SHORT).show(); + else + Toast.makeText(activity,selectedPositions.size()+" Projects Successfully Deleted", Toast.LENGTH_SHORT).show(); else Toast.makeText(activity, "Project Deletion Failed!", Toast.LENGTH_SHORT).show(); } @@ -458,8 +495,6 @@ public void closeSearch() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editSearch.getWindowToken(), 0); isSearchOpened = false; - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowCustomEnabled(false); actionBar.setDisplayShowTitleEnabled(true); } diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/LoadProjectFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/LoadProjectFragment.java index 76ff6e69..810b6ce4 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/LoadProjectFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/LoadProjectFragment.java @@ -29,7 +29,6 @@ import android.widget.EditText; import android.widget.Toast; - import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.ToolkitApplication; import org.buildmlearn.toolkit.activity.TemplateActivity; @@ -133,7 +132,8 @@ public int compare(SavedProject f1, SavedProject f2) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_loadproject, container, false); + View view = inflater.inflate(R.layout.fragment_loadproject, container, false); + return view; } /** @@ -162,6 +162,21 @@ public boolean onItemLongClick(AdapterView parent, View view, int position, l return true; } }); + + getView().setFocusableInTouchMode(true); + getView().requestFocus(); + getView().setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (mAdapter.selectedPositionsSize() > 0) { + unselectAll(); + return true; + } + } + return false; + } + }); } /** @@ -261,7 +276,7 @@ public void onResume() { Document doc = dBuilder.parse(fXmlFile); doc.getDocumentElement().normalize(); Log.d("Files", "Root element :" + doc.getDocumentElement().getAttribute("type")); - if (fXmlFile.getName().startsWith(specificApis)) + if (fXmlFile.getName().contains(specificApis)) savedProjects.add(new SavedProject(fXmlFile, fXmlFile.getName(), fXmlFile.lastModified(), doc.getDocumentElement().getAttribute("type"), fXmlFile.getAbsolutePath())); allsavedProjects.add(new SavedProject(fXmlFile, fXmlFile.getName(), fXmlFile.lastModified(), doc.getDocumentElement().getAttribute("type"), fXmlFile.getAbsolutePath())); } catch (ParserConfigurationException | DOMException | IOException | SAXException e) { @@ -404,11 +419,9 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { public void afterTextChanged(Editable s) { String text = s.toString().trim(); savedProjects.clear(); - SavedProject tempProject; for (int i = 0; i < allsavedProjects.size(); i++) { - if (allsavedProjects.get(i).getName().startsWith(text)) { - tempProject = new SavedProject(allsavedProjects.get(i).getFile(), allsavedProjects.get(i).getName(), allsavedProjects.get(i).getUnformattedDate(), allsavedProjects.get(i).getType(), allsavedProjects.get(i).getFullPath()); - savedProjects.add(tempProject); + if (allsavedProjects.get(i).getName().toLowerCase().contains(text.toLowerCase())) { + savedProjects.add(allsavedProjects.get(i)); } } mAdapter.notifyDataSetChanged(); @@ -422,12 +435,18 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { editSearch.onKeyPreIme(keyCode, event); if (isSearchOpened) { closeSearch(); + savedProjects.clear(); + for (int i = 0; i < allsavedProjects.size(); i++) { + savedProjects.add(allsavedProjects.get(i)); + } + mAdapter.notifyDataSetChanged(); } return true; } return false; } }); + editSearch.requestFocus(); InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editSearch, InputMethodManager.SHOW_IMPLICIT); @@ -445,12 +464,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { break; case R.id.action_unselect_all: - for(int i=0;i selectedPositions = mAdapter.getSelectedPositions(); boolean deleted = false; + for(int selectedPosition : selectedPositions) { SavedProject project = savedProjects.get(selectedPosition); File file = new File(project.getFile().getPath()); deleted = file.delete(); if (deleted) { + int selectedPos = -1; + for (int i = 0; i < allsavedProjects.size(); i++) { + SavedProject sProject = allsavedProjects.get(i); + if (sProject.getName().equals(project.getName())) { + selectedPos = i; + break; + } + } + if (selectedPos != -1) { + allsavedProjects.remove(selectedPos); + } savedProjects.remove(selectedPosition); mAdapter.removeSelectedPosition(selectedPosition); mAdapter.notifyDataSetChanged(); @@ -479,7 +514,10 @@ private void deleteItems() { } } if(deleted) - Toast.makeText(activity, "Project Successfully Deleted!", Toast.LENGTH_SHORT).show(); + if(selectedPositions.size()==1) + Toast.makeText(activity,"Project Successfully Deleted", Toast.LENGTH_SHORT).show(); + else + Toast.makeText(activity,selectedPositions.size()+" Projects Successfully Deleted", Toast.LENGTH_SHORT).show(); else Toast.makeText(activity, "Project Deletion Failed!", Toast.LENGTH_SHORT).show(); } @@ -499,8 +537,6 @@ public void closeSearch() { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editSearch.getWindowToken(), 0); isSearchOpened = false; - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowCustomEnabled(false); actionBar.setDisplayShowTitleEnabled(true); } diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/NavigationDrawerFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/NavigationDrawerFragment.java deleted file mode 100644 index 993dbabf..00000000 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/NavigationDrawerFragment.java +++ /dev/null @@ -1,367 +0,0 @@ -package org.buildmlearn.toolkit.fragment; - - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.app.AppCompatActivity; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.TextView; - -import org.buildmlearn.toolkit.R; -import org.buildmlearn.toolkit.adapter.NavigationDrawerMenuAdapter; -import org.buildmlearn.toolkit.model.Section; - -import java.util.Locale; - -/** - * Fragment used for managing interactions for and presentation of a navigation drawer. - * See the - * design guidelines for a complete explanation of the behaviors implemented here. - */ -public class NavigationDrawerFragment extends Fragment { - - /** - * Remember the position of the selected item. - */ - private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; - - /** - * Per the design guidelines, you should show the drawer on launch until the user manually - * expands it. This shared preference tracks this. - */ - private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; - - /** - * A pointer to the current callbacks instance (the Activity). - */ - private NavigationDrawerCallbacks mCallbacks; - - /** - * Helper component that ties the action bar to the navigation drawer. - */ - private ActionBarDrawerToggle mDrawerToggle; - - private DrawerLayout mDrawerLayout; - private ListView mDrawerListView; - private View mFragmentContainerView; - - private boolean mFromSavedInstanceState; - private boolean mUserLearnedDrawer; - private boolean isClicked = false; - private Section[] menus; - - private int selectedSectionMenu = 0; - - /** - * {@inheritDoc} - */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Read in the flag indicating whether or not the user has demonstrated awareness of the - // drawer. See PREF_USER_LEARNED_DRAWER for details. - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); - mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); - - if (savedInstanceState != null) { - selectedSectionMenu = savedInstanceState.getInt(STATE_SELECTED_POSITION); - mFromSavedInstanceState = true; - } - - // Select either the default item (0) or the last selected item. - - selectItem(selectedSectionMenu); - } - - /** - * {@inheritDoc} - */ - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - // Indicate that this fragment would like to influence the set of actions in the action bar. - setHasOptionsMenu(true); - - setLayoutParamsForListView(); - } - - private void setLayoutParamsForListView() { - int deviceWidth = getResources().getDisplayMetrics().widthPixels; - int dimen56 = getResources().getDimensionPixelSize(R.dimen.material_navigation_drawer_right_margin); - int widthOfNavDrawer = deviceWidth - dimen56; - if (widthOfNavDrawer > 5 * dimen56) - widthOfNavDrawer = 5 * dimen56; - ViewGroup.LayoutParams params = mDrawerListView.getLayoutParams(); - params.width = widthOfNavDrawer; - mDrawerListView.setLayoutParams(params); - } - - - /** - * {@inheritDoc} - */ - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - mDrawerListView = (ListView) inflater.inflate( - R.layout.fragment_navigation_drawer, container, false); - View menuHeaderView = inflater.inflate(R.layout.listview_header_navigation_drawer, mDrawerListView, false); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - TextView name = (TextView) menuHeaderView.findViewById(R.id.name); - name.setText(String.format(Locale.ENGLISH, "Welcome %s", prefs.getString(getString(R.string.key_user_name), ""))); - mDrawerListView.addHeaderView(menuHeaderView, null, false); - mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - - position--; - - if (menus[position].getType() == Section.FRAGMENT) { - for (Section menu : menus) { - menu.setIsSelected(false); - } - menus[position].setIsSelected(true); - } - isClicked = true; - selectItem(position); - } - }); - NavigationDrawerMenuAdapter adapter = new NavigationDrawerMenuAdapter(getActivity().getApplicationContext(), inflater); - menus = Section.values(); - for (Section menu : menus) { - menu.setIsSelected(false); - } - if (menus.length > 0) { - menus[selectedSectionMenu].setIsSelected(true); - } - mDrawerListView.setAdapter(adapter); - mDrawerListView.setItemChecked(selectedSectionMenu, true); - return mDrawerListView; - } - - public boolean isDrawerOpen() { - return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); - } - - /** - * Users of this fragment must call this method to set up the navigation drawer interactions. - * - * @param fragmentId The android:id of this fragment in its activity's layout. - * @param drawerLayout The DrawerLayout containing this fragment's UI. - */ - public void setUp(int fragmentId, DrawerLayout drawerLayout) { - mFragmentContainerView = getActivity().findViewById(fragmentId); - mDrawerLayout = drawerLayout; - - // set a custom shadow that overlays the main content when the drawer opens - mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); - // set up the drawer's list view with items and click listener - - ActionBar actionBar = getActionBar(); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setHomeButtonEnabled(true); - - // ActionBarDrawerToggle ties together the the proper interactions - // between the navigation drawer and the action bar app icon. - mDrawerToggle = new ActionBarDrawerToggle( - getActivity(), /* host Activity */ - mDrawerLayout, /* DrawerLayout object */ - null, /* nav drawer image to replace 'Up' caret */ - R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ - R.string.navigation_drawer_close /* "close drawer" description for accessibility */ - ) { - /** - * {@inheritDoc} - */ - @Override - public void onDrawerClosed(View drawerView) { - super.onDrawerClosed(drawerView); - if (!isAdded()) { - return; - } - if (mCallbacks != null && isClicked) { - mCallbacks.onNavigationDrawerItemSelected(selectedSectionMenu); - isClicked = false; - } - - getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() - } - - /** - * {@inheritDoc} - */ - @Override - public void onDrawerOpened(View drawerView) { - super.onDrawerOpened(drawerView); - if (!isAdded()) { - return; - } - if (mCallbacks != null) - mCallbacks.onNavigationDrawerItemSelected(-1); - - if (!mUserLearnedDrawer) { - // The user manually opened the drawer; store this flag to prevent auto-showing - // the navigation drawer automatically in the future. - mUserLearnedDrawer = true; - SharedPreferences sp = PreferenceManager - .getDefaultSharedPreferences(getActivity()); - sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); - } - - getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() - } - - @Override - public void onDrawerStateChanged(int newState) { - super.onDrawerStateChanged(newState); - SharedPreferences sp = PreferenceManager - .getDefaultSharedPreferences(getActivity()); - TextView name = (TextView) mFragmentContainerView.findViewById(R.id.name); - name.setText(String.format(Locale.ENGLISH, "Welcome %s", sp.getString(getString(R.string.key_user_name), ""))); - } - }; - - // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, - // per the navigation drawer design guidelines. - if (!mUserLearnedDrawer && !mFromSavedInstanceState) { - mDrawerLayout.openDrawer(mFragmentContainerView); - } - - // Defer code dependent on restoration of previous instance state. - mDrawerLayout.post(new Runnable() { - @Override - public void run() { - mDrawerToggle.syncState(); - } - }); - - mDrawerLayout.addDrawerListener(mDrawerToggle); - } - - private void selectItem(int position) { - selectedSectionMenu = position; - if (mDrawerListView != null) { - mDrawerListView.setItemChecked(position, true); - } - - if ((mDrawerLayout == null || !isDrawerOpen()) && mCallbacks != null) { - mCallbacks.onNavigationDrawerItemSelected(position); - } - if (mDrawerLayout != null) { - mDrawerLayout.closeDrawer(mFragmentContainerView); - } - - } - - /** - * {@inheritDoc} - */ - @Override - public void onAttach(Context context) { - super.onAttach(context); - try { - mCallbacks = (NavigationDrawerCallbacks) context; - } catch (ClassCastException e) { - throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void onDetach() { - super.onDetach(); - mCallbacks = null; - } - - /** - * {@inheritDoc} - */ - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt(STATE_SELECTED_POSITION, selectedSectionMenu); - } - - /** - * {@inheritDoc} - */ - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - // Forward the new configuration the drawer toggle component. - mDrawerToggle.onConfigurationChanged(newConfig); - } - - /** - * {@inheritDoc} - */ - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - // If the drawer is open, show the global app actions in the action bar. See also - // showGlobalContextActionBar, which controls the top-left area of the action bar. - if (mDrawerLayout != null && isDrawerOpen()) { - showGlobalContextActionBar(); - } - super.onCreateOptionsMenu(menu, inflater); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onOptionsItemSelected(MenuItem item) { - return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); - - - } - - /** - * Per the navigation drawer design guidelines, updates the action bar to show the global app - * 'context', rather than just what's in the current screen. - */ - private void showGlobalContextActionBar() { - ActionBar actionBar = getActionBar(); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - actionBar.setDisplayShowCustomEnabled(false); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - actionBar.setTitle(R.string.app_name); - } - - private ActionBar getActionBar() { - return ((AppCompatActivity) getActivity()).getSupportActionBar(); - } - - public void closeDrawer() { - mDrawerLayout.closeDrawers(); - } - - /** - * Callbacks interface that all activities using this fragment must implement. - */ - public interface NavigationDrawerCallbacks { - /** - * Called when an item in the navigation drawer is selected. - */ - void onNavigationDrawerItemSelected(int position); - } - -} diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java index ced321d9..2e61f7b5 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java @@ -2,17 +2,19 @@ import android.app.Activity; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.support.v7.app.AlertDialog; -import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -88,6 +90,20 @@ public boolean onPreferenceClick(Preference preference) { return true; } }); + prefUsername.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if ("".equals(newValue)) { + Toast.makeText(getActivity(), R.string.enter, Toast.LENGTH_LONG).show(); + return false; + } else if (newValue != null && !Character.isLetterOrDigit(((String) newValue).charAt(0))) { + Toast.makeText(getActivity(), R.string.name_valid_msg, Toast.LENGTH_LONG).show(); + return false; + } + prefUsername.setSummary((String) newValue); + return true; + } + }); prefUsername.setSummary(preferences.getString(getString(R.string.key_user_name), "")); } @@ -97,28 +113,52 @@ public void initRestoreProjectDialog() { startActivityForResult(intent, REQUEST_PICK_APK); } - public void resetUserName(){ + public void resetUserName() { LayoutInflater inflater = getActivity().getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_settings_your_name, null); final EditText editInput = (EditText) dialogView.findViewById(R.id.et_dialog_settings_your_name); editInput.setText(prefUsername.getSummary()); + final AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.title_user_name) .setView(dialogView) .setNegativeButton(R.string.dialog_no, null) - .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - String enteredName = editInput.getText().toString(); - if (!TextUtils.isEmpty(enteredName)){ - prefUsername.getEditor().putString(getString(R.string.key_user_name), enteredName).commit(); - prefUsername.setSummary(editInput.getText().toString()); - } - dialog.dismiss(); - } - }).create(); + .setPositiveButton(R.string.dialog_yes, null).create(); + dialog.show(); + + dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + if (validated(editInput)) { + String enteredName = editInput.getText().toString(); + prefUsername.getEditor().putString(getString(R.string.key_user_name), enteredName).commit(); + prefUsername.setSummary(editInput.getText().toString()); + dialog.dismiss(); + } + + } + }); + } + + private boolean validated(EditText editInput) { + if (editInput == null) { + return false; + } + + String authorText = editInput.getText().toString().trim(); + Context mContext = getActivity(); + + if ("".equals(authorText)) { + editInput.setError(mContext.getString(R.string.valid_msg_name)); + return false; + } else if (!Character.isLetterOrDigit(authorText.charAt(0))) { + editInput.setError(mContext.getString(R.string.title_valid)); + return false; + } + return true; } @Override @@ -143,18 +183,28 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { RestoreThread restore = new RestoreThread(getActivity(), inputStream); restore.setRestoreListener(new RestoreThread.OnRestoreComplete() { + Handler mHandler =new Handler(Looper.getMainLooper()); @Override - public void onSuccess(File assetFile) { - processDialog.dismiss(); - Intent intentProject = new Intent(getActivity(), DeepLinkerActivity.class); - intentProject.setData(Uri.fromFile(assetFile)); - getActivity().startActivity(intentProject); + public void + onSuccess(final File assetFile) { + mHandler.post(new Runnable() { + @Override + public void run() { + processDialog.dismiss(); + Intent intentProject = new Intent(getActivity(), DeepLinkerActivity.class); + intentProject.setData(Uri.fromFile(assetFile)); + getActivity().startActivity(intentProject); + } + }); } @Override public void onFail() { - processDialog.dismiss(); - final AlertDialog dialog = new AlertDialog.Builder(getActivity()) + mHandler.post(new Runnable() { + @Override + public void run() { + processDialog.dismiss(); + final AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.dialog_restore_title) .setMessage(R.string.dialog_restore_failed) .setPositiveButton(R.string.info_template_ok, new DialogInterface.OnClickListener() { @@ -163,13 +213,18 @@ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); - dialog.show(); + dialog.show(); + } + }); } @Override public void onFail(Exception e) { - processDialog.dismiss(); - final AlertDialog dialog = new AlertDialog.Builder(getActivity()) + mHandler.post(new Runnable() { + @Override + public void run() { + processDialog.dismiss(); + final AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.dialog_restore_title) .setMessage(R.string.dialog_restore_failed) .setPositiveButton(R.string.info_template_ok, new DialogInterface.OnClickListener() { @@ -178,7 +233,9 @@ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); - dialog.show(); + dialog.show(); + } + }); } }); @@ -188,14 +245,14 @@ public void onClick(DialogInterface dialog, int which) { e.printStackTrace(); final AlertDialog dialog = new AlertDialog.Builder(getActivity()) - .setTitle(R.string.dialog_restore_title) - .setMessage(R.string.dialog_restore_fileerror) - .setPositiveButton(R.string.info_template_ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }).create(); + .setTitle(R.string.dialog_restore_title) + .setMessage(R.string.dialog_restore_fileerror) + .setPositiveButton(R.string.info_template_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }).create(); dialog.show(); } @@ -208,12 +265,13 @@ public void onClick(DialogInterface dialog, int which) { } } - private class AsyncTaskRunner extends AsyncTask { + + private class AsyncTaskRunner extends AsyncTask { private ProgressDialog progressDialog; @Override protected void onPreExecute() { - progressDialog=new ProgressDialog(getActivity()); + progressDialog = new ProgressDialog(getActivity()); progressDialog.setTitle("Deleting..."); progressDialog.setMessage("Deleting Temporary file"); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Section.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Section.java deleted file mode 100644 index 9df4e535..00000000 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Section.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.buildmlearn.toolkit.model; - -import android.app.Activity; -import android.app.Fragment; -import android.support.annotation.DrawableRes; -import android.support.annotation.StringRes; - -import org.buildmlearn.toolkit.R; -import org.buildmlearn.toolkit.activity.AboutBuildmLearn; -import org.buildmlearn.toolkit.activity.TutorialActivity; -import org.buildmlearn.toolkit.fragment.DraftsFragment; -import org.buildmlearn.toolkit.fragment.HomeFragment; -import org.buildmlearn.toolkit.fragment.LoadApkFragment; -import org.buildmlearn.toolkit.fragment.LoadProjectFragment; -import org.buildmlearn.toolkit.fragment.SettingsFragment; - -/** - * @brief Enum for navigation drawer menus - *

- * Created by Abhishek on 08-05-2015. - */ -public enum Section { - - HOME(HomeFragment.class, R.string.menu_home, R.drawable.menu_home, false), - OPEN_PROJECT(LoadProjectFragment.class, R.string.menu_load_project, R.drawable.menu_open, false), - // UPLOAD(TestFragment.class, R.string.menu_my_uploads, R.drawable.menu_upload, false), - OPEN_APK(LoadApkFragment.class, R.string.menu_load_apks, R.drawable.ic_android, false), - DRAFTS(DraftsFragment.class, R.string.menu_drafts, R.drawable.menu_drafts, false), - DIVIDER(), - SETTINGS(SettingsFragment.class, R.string.menu_settings, R.drawable.menu_settings, false), - HOW_TO(TutorialActivity.class, R.string.menu_how_to, R.drawable.menu_how_to), - ABOUT_US(AboutBuildmLearn.class, R.string.menu_about_us, R.drawable.menu_info); -// PRIVACY_POLICY(TestActivity.class, R.string.menu_privacy_policy, R.drawable.menu_privacy_policy); - - - public final static int ACTIVITY = 0; - public final static int FRAGMENT = 1; - public final static int SECTION_DIVIDER = 2; - - private final String viewName; - private final int titleResId; - private final int iconResId; - private final int type; - private final boolean keep; - private boolean isSelected; - - - Section(Class fragmentClass, @StringRes int titleResId, - @DrawableRes int iconResId, boolean keep) { - this.viewName = fragmentClass.getName(); - this.titleResId = titleResId; - this.iconResId = iconResId; - this.type = FRAGMENT; - this.keep = keep; - this.isSelected = false; - } - - Section(Class activityClass, @StringRes int titleResId, - @DrawableRes int iconResId) { - this.viewName = activityClass.getName(); - this.titleResId = titleResId; - this.iconResId = iconResId; - this.type = ACTIVITY; - this.keep = false; - this.isSelected = false; - } - - Section() { - this.viewName = null; - this.titleResId = 0; - this.iconResId = 0; - this.type = SECTION_DIVIDER; - this.keep = false; - this.isSelected = false; - } - - public boolean isSelected() { - return isSelected; - } - - public void setIsSelected(boolean isSelected) { - if (type == FRAGMENT) { - this.isSelected = isSelected; - } - } - - public int getTitleResId() { - return titleResId; - } - - public int getIconResId() { - return iconResId; - } - - public int getType() { - return type; - } - - public boolean isKeep() { - return keep; - } - - public String getViewName() { - return viewName; - } -} diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Tutorial.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Tutorial.java index 655ca5d3..5208fedf 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Tutorial.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/model/Tutorial.java @@ -14,9 +14,11 @@ public enum Tutorial { START(R.drawable.app_splash_screen_framed, R.string.screen_1_title, R.string.screen_1_desc), FIRST(R.drawable.main_screen_framed, R.string.screen_2_title, R.string.screen_2_desc), SECOND(R.drawable.template_list_framed, R.string.screen_3_title, R.string.screen_3_desc), - THIRD(R.drawable.quiz_template_framed, R.string.screen_4_title, R.string.screen_4_desc), + THIRD(R.drawable.comprehension_template_framed, R.string.screen_4_title, R.string.screen_4_desc), FOURTH(R.drawable.simulator_without_any_template_framed, R.string.screen_5_title, R.string.screen_5_desc), FIFTH(R.drawable.load_saved_projects_framed, R.string.screen_6_title, R.string.screen_6_desc), + SIXTH(R.drawable.load_saved_apks_framed, R.string.screen_7_title, R.string.screen_7_desc), + SEVENTH(R.drawable.load_saved_drafts_framed, R.string.screen_8_title, R.string.screen_8_desc), LAST(true); diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/ComprehensionTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/ComprehensionTemplate.java index 469aac80..7deff8d2 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/ComprehensionTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/ComprehensionTemplate.java @@ -5,6 +5,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Build; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.BaseAdapter; @@ -19,7 +20,6 @@ import org.buildmlearn.toolkit.model.TemplateInterface; import org.buildmlearn.toolkit.utilities.FileDialog; import org.buildmlearn.toolkit.views.TextViewPlus; -import android.support.v7.app.AlertDialog; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -49,26 +49,29 @@ public ComprehensionTemplate() { metaData = new ArrayList<>(); } - private static boolean validated(Context context, EditText title, EditText passage, EditText timer) { + private static boolean validated( Context context, EditText title, EditText passage, EditText timer) { if (title == null || passage == null || timer == null) { return false; } - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); - String timerText = timer.getText().toString(); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); + String timerText = timer.getText().toString().trim(); - if (timerText.length() > 9) { - Toast.makeText(context, R.string.comprehension_template_timer_correct_hint, Toast.LENGTH_SHORT).show(); + if ("".equals(titleText)) { + title.setError(context.getString(R.string.comprehension_template_title_hint)); + return false; + } else if ("".equals(passageText)) { + passage.setError(context.getString(R.string.comprehension_template_passage_hint)); return false; - } else if ("".equals(titleText)) { - Toast.makeText(context, R.string.comprehension_template_title_hint, Toast.LENGTH_SHORT).show(); + }else if (timerText.length() > 9) { + timer.setError(context.getString(R.string.comprehension_template_timer_correct_hint)); return false; - } else if (passageText.equals("")) { - Toast.makeText(context, R.string.comprehension_template_passage_hint, Toast.LENGTH_SHORT).show(); + }else if ("0".equals(timerText)) { + timer.setError((context.getString(R.string.time_zero_error))); return false; - } else if (timerText.equals("")) { - Toast.makeText(context, R.string.comprehension_template_timer_hint, Toast.LENGTH_SHORT).show(); + } else if ("".equals(timerText)) { + timer.setError(context.getString(R.string.comprehension_template_timer_hint)); return false; } @@ -137,8 +140,8 @@ private void checkButton(ArrayList buttons, ArrayList opt for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); - if (options.get(index).getText().toString().equals("")) { - Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show(); + if ("".equals(options.get(index).getText().toString().trim())) { + options.get(index).setError(context.getString(R.string.valid_before_setting_answer)); button.setChecked(false); return; } else { @@ -200,42 +203,77 @@ public void onClick(View v) { dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + boolean isValidated = true; - int checkedAns = getCheckedAnswer(buttons); - if (checkedAns < 0) { - Toast.makeText(activity, "Choose a correct option", Toast.LENGTH_SHORT).show(); + + if ("".equals(question.getText().toString().trim())) { + question.setError(activity.getString(R.string.enter_question)); isValidated = false; + return; } - if (question.getText().toString().equals("")) { - question.setError("Question is required"); + if(options.get(0).getText().toString().trim().equals("")){ + options.get(0).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(1).getText().toString().trim().equals("")){ + options.get(1).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(2).getText().toString().trim().equals("") && !options.get(3).getText().toString().trim().equals("")){ + options.get(2).hasFocus(); + options.get(2).setError(activity.getString(R.string.comprehension_select_option_3_first)); isValidated = false; + return; } - int optionCount = 0; - for (EditText option : options) { - if (!option.getText().toString().equals("")) { - optionCount++; + for(int i=0;i answerOptions = new ArrayList<>(); - int correctAnswer = 0; + correctAnswer = 0; for (int i = 0; i < buttons.size(); i++) { - if (buttons.get(i).isChecked() && !options.get(i).getText().toString().equals("")) { + if (buttons.get(i).isChecked() && !"".equals(options.get(i).getText().toString().trim())) { correctAnswer = answerOptions.size(); - answerOptions.add(options.get(i).getText().toString()); - } else if (!options.get(i).getText().toString().equals("")) { - answerOptions.add(options.get(i).getText().toString()); + answerOptions.add(options.get(i).getText().toString().trim()); + } else if (!"".equals(options.get(i).getText().toString().trim())) { + answerOptions.add(options.get(i).getText().toString().trim()); } } - String questionText = question.getText().toString(); + String questionText = question.getText().toString().trim(); comprehensionData.add(new ComprehensionModel(questionText, answerOptions, correctAnswer)); setEmptyView(activity); adapter.notifyDataSetChanged(); @@ -283,11 +321,11 @@ public void fileSelected(File file) { @Override public void onClick(View v) { - if (validated(activity, title, passage, timer)) { + if (validated(activity,title, passage, timer)) { - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); - long timerLong = Long.parseLong(timer.getText().toString()); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); + long timerLong = Long.parseLong(timer.getText().toString().trim()); ComprehensionMetaModel temp = new ComprehensionMetaModel(titleText, passageText, timerLong); metaData.add(temp); setEmptyView(activity); @@ -321,8 +359,8 @@ public void editItem(final Activity activity, final int position) { final EditText passage = (EditText) dialogView.findViewById(R.id.meta_passage); final EditText timer = (EditText) dialogView.findViewById(R.id.meta_timer); title.setText(data.getTitle()); - passage.setText(data.getPassage()); - timer.setText(String.valueOf(data.getTime())); + passage.setText(data.getPassage().trim()); + timer.setText(String.valueOf(data.getTime()).trim()); dialogView.findViewById(R.id.upload).setOnClickListener(new View.OnClickListener() { @Override @@ -343,11 +381,11 @@ public void fileSelected(File file) { @Override public void onClick(View v) { - if (validated(activity, title, passage, timer)) { + if (validated(activity,title, passage, timer)) { - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); - long timerLong = Long.parseLong(timer.getText().toString()); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); + long timerLong = Long.parseLong(timer.getText().toString().trim()); data.setTitle(titleText); data.setPassage(passageText); @@ -392,7 +430,7 @@ public void onClick(View v) { options.get(i).setText(data.getOptions().get(i)); } - question.setText(data.getQuestion()); + question.setText(data.getQuestion().trim()); buttons.get(data.getCorrectAnswer()).setChecked(true); for (final RadioButton button : buttons) { @@ -409,45 +447,67 @@ public void onClick(View v) { public void onClick(View v) { boolean isValidated = true; - int checkedAns = getCheckedAnswer(buttons); - if (checkedAns < 0) { - Toast.makeText(activity, "Choose a correct option", Toast.LENGTH_SHORT).show(); + + if ("".equals(question.getText().toString().trim())) { + question.setError(activity.getString(R.string.enter_question)); + isValidated = false; + } + + if(options.get(0).getText().toString().trim().equals("")){ + options.get(0).setError(activity.getString(R.string.cannot_be_empty)); isValidated = false; + return; } - if (question.getText().toString().equals("")) { + if(options.get(1).getText().toString().trim().equals("")){ + options.get(1).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(2).getText().toString().trim().equals("") && !options.get(3).getText().toString().trim().equals("")){ + options.get(2).hasFocus(); + options.get(2).setError(activity.getString(R.string.comprehension_select_option_3_first)); + isValidated = false; + return; + } + + int correctAnswer = 0; + int checkedAns = getCheckedAnswer(buttons); - question.setError("Question is required"); + if (checkedAns < 0) { + Toast.makeText(activity, R.string.comprehension_template_choose_correct_option, Toast.LENGTH_SHORT).show(); isValidated = false; + return; } - int optionCount = 0; for (EditText option : options) { - if (!option.getText().toString().equals("")) { - optionCount++; + if ("".equals(option.getText().toString().trim())){ + option.setText(""); + continue; + } + if (option.getText().toString()!= null && "".equals(option.getText().toString().trim())) { + option.getText().clear(); + option.setError(activity.getString(R.string.comprehension_template_valid_option)); + isValidated = false; + return; } - } - if (optionCount < 2) { - Toast.makeText(activity, "Minimum two multiple answers are required.", Toast.LENGTH_SHORT).show(); - isValidated = false; } if (isValidated) { dialog.dismiss(); ArrayList answerOptions = new ArrayList<>(); - int correctAnswer = 0; + correctAnswer = 0; for (int i = 0; i < buttons.size(); i++) { - if (buttons.get(i).isChecked() && !options.get(i).getText().toString().equals("")) { + if (buttons.get(i).isChecked() && !"".equals(options.get(i).getText().toString().trim())) { correctAnswer = answerOptions.size(); - answerOptions.add(options.get(i).getText().toString()); - } else if (!options.get(i).getText().toString().equals("")) { - answerOptions.add(options.get(i).getText().toString()); + answerOptions.add(options.get(i).getText().toString().trim()); + } else if (!"".equals(options.get(i).getText().toString().trim())) { + answerOptions.add(options.get(i).getText().toString().trim()); } } - String questionText = question.getText().toString(); + String questionText = question.getText().toString().trim(); comprehensionData.set(position, new ComprehensionModel(questionText, answerOptions, correctAnswer)); adapter.notifyDataSetChanged(); } - } }); } @@ -591,4 +651,4 @@ private String readFile(File file) { } return ""; } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/DictationTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/DictationTemplate.java index 16ca1d8a..975a8a73 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/DictationTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/DictationTemplate.java @@ -10,11 +10,10 @@ import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.TextView; -import android.widget.Toast; + import org.buildmlearn.toolkit.R; -import org.buildmlearn.toolkit.dictationtemplate.data.DictModel; import org.buildmlearn.toolkit.dictationtemplate.fragment.SplashFragment; import org.buildmlearn.toolkit.model.Template; import org.buildmlearn.toolkit.model.TemplateInterface; @@ -49,14 +48,14 @@ private boolean validated(Context context, EditText title, EditText passage) { return false; } - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); if ("".equals(titleText)) { - Toast.makeText(context, R.string.dictation_template_title_hint, Toast.LENGTH_SHORT).show(); + title.setError(context.getString(R.string.dictation_template_title_hint)); return false; } else if ("".equals(passageText)) { - Toast.makeText(context, R.string.dictation_template_passage_hint, Toast.LENGTH_SHORT).show(); + passage.setError(context.getString(R.string.dictation_template_passage_hint)); return false; } return true; @@ -148,8 +147,8 @@ public void fileSelected(File file) { public void onClick(View v) { if (validated(activity, title, passage)) { - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); DictationModel temp = new DictationModel(titleText, passageText); dictData.add(temp); @@ -190,8 +189,8 @@ public void editItem(final Activity activity, final int position) { final EditText title = (EditText) dialogView.findViewById(R.id.dict_title); final EditText passage = (EditText) dialogView.findViewById(R.id.dict_passage); - title.setText(data.getTitle()); - passage.setText(data.getPassage()); + title.setText(data.getTitle().trim()); + passage.setText(data.getPassage().trim()); dialogView.findViewById(R.id.upload).setOnClickListener(new View.OnClickListener() { @Override @@ -214,8 +213,8 @@ public void onClick(View v) { if (validated(activity, title, passage)) { - String titleText = title.getText().toString(); - String passageText = passage.getText().toString(); + String titleText = title.getText().toString().trim(); + String passageText = passage.getText().toString().trim(); data.setTitle(titleText); data.setPassage(passageText); @@ -317,4 +316,4 @@ private String readFile(File file) { } return ""; } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashCardAdapter.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashCardAdapter.java index 876ad5e4..c6524e62 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashCardAdapter.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashCardAdapter.java @@ -1,9 +1,8 @@ package org.buildmlearn.toolkit.templates; import android.content.Context; -import android.content.DialogInterface; import android.support.design.widget.Snackbar; -import android.support.v7.app.AlertDialog; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashTemplate.java index 9b9235e0..376848ff 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/FlashTemplate.java @@ -154,12 +154,12 @@ public void onClick(View v) { dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (validateData(question, answer, answerHint, activity)) { + if (validateData(question, answer, activity)) { dialog.dismiss(); Bitmap bitmap = ((BitmapDrawable) mBannerImage.getDrawable()).getBitmap(); - String questionText = question.getText().toString(); - String answerText = answer.getText().toString(); - String hintText = answerHint.getText().toString(); + String questionText = question.getText().toString().trim(); + String answerText = answer.getText().toString().trim(); + String hintText = answerHint.getText().toString().trim(); mData.add(new FlashCardModel(questionText, answerText, hintText, bitmap)); setEmptyView(activity); mAdapter.notifyDataSetChanged(); @@ -198,9 +198,9 @@ public void editItem(final Activity activity, final int position) { final EditText answer = (EditText) dialogView.findViewById(R.id.flash_answer); final EditText answerHint = (EditText) dialogView.findViewById(R.id.flash_hint); mBannerImage = (ImageView) dialogView.findViewById(R.id.banner_image); - question.setText(data.getQuestion()); - answer.setText(data.getAnswer()); - answerHint.setText(data.getHint()); + question.setText(data.getQuestion().trim()); + answer.setText(data.getAnswer().trim()); + answerHint.setText(data.getHint().trim()); mBannerImage.setImageBitmap(data.getImageBitmap()); @@ -229,12 +229,12 @@ public void onClick(View v) { dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (validateData(question, answer, answerHint, activity)) { + if (validateData(question, answer, activity)) { dialog.dismiss(); Bitmap bitmap = ((BitmapDrawable) mBannerImage.getDrawable()).getBitmap(); - String questionText = question.getText().toString(); - String answerText = answer.getText().toString(); - String hintText = answerHint.getText().toString(); + String questionText = question.getText().toString().trim(); + String answerText = answer.getText().toString().trim(); + String hintText = answerHint.getText().toString().trim(); mData.set(position, new FlashCardModel(questionText, answerText, hintText, bitmap)); mAdapter.notifyDataSetChanged(); } @@ -242,22 +242,18 @@ public void onClick(View v) { }); } - private boolean validateData(EditText question, EditText answer, EditText answerHint, Context context) { - String questionText = question.getText().toString(); - String answerText = answer.getText().toString(); - String hintText = answerHint.getText().toString(); + private boolean validateData(EditText question, EditText answer, Context context) { + String questionText = question.getText().toString().trim(); + String answerText = answer.getText().toString().trim(); - if (questionText.isEmpty()) { - Toast.makeText(context, "Enter question", Toast.LENGTH_SHORT).show(); + if ("".equals(questionText)) { + question.setError(context.getString(R.string.enter_question)); return false; - } else if (answerText.isEmpty()) { - Toast.makeText(context, "Enter answer", Toast.LENGTH_SHORT).show(); - return false; - } else if (hintText.isEmpty()) { - Toast.makeText(context, "Enter hint", Toast.LENGTH_SHORT).show(); + } else if ("".equals(answerText)) { + answer.setError(context.getString(R.string.enter_answer)); return false; } else if (!mIsPhotoAttached) { - Toast.makeText(context, "Attach an image", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(R.string.flash_template_attach_image), Toast.LENGTH_SHORT).show(); return false; } @@ -397,7 +393,7 @@ private Intent makePhotoIntent(String title, Context context) { photo.delete(); } catch (Exception e) { Log.d(TAG, e.getMessage()); - Toast.makeText(context, "Please check SD card! Image shot is impossible!", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, R.string.check_sd_card, Toast.LENGTH_SHORT).show(); } cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); @@ -432,4 +428,4 @@ private void setEmptyView(Activity activity) { } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/InfoTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/InfoTemplate.java index 0a3af0e2..00d77f2d 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/InfoTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/InfoTemplate.java @@ -9,8 +9,6 @@ import android.view.View; import android.widget.BaseAdapter; import android.widget.EditText; -import android.widget.Toast; - import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.infotemplate.fragment.SplashFragment; @@ -41,14 +39,14 @@ public static boolean validated(Context context, EditText word, EditText meaning return false; } - String wordText = word.getText().toString(); - String meaningText = meaning.getText().toString(); + String wordText = word.getText().toString().trim(); + String meaningText = meaning.getText().toString().trim(); if ("".equals(wordText)) { - Toast.makeText(context, "Enter word", Toast.LENGTH_SHORT).show(); + word.setError(context.getString(R.string.enter_word)); return false; } else if ("".equals(meaningText)) { - Toast.makeText(context, "Enter meaning", Toast.LENGTH_SHORT).show(); + meaning.setError(context.getString(R.string.enter_description)); return false; } return true; @@ -130,8 +128,8 @@ public void addItem(final Activity activity) { public void onClick(View v) { if (validated(activity, word, meaning)) { - String wordText = word.getText().toString(); - String meaningText = meaning.getText().toString(); + String wordText = word.getText().toString().trim(); + String meaningText = meaning.getText().toString().trim(); InfoModel temp = new InfoModel(wordText, meaningText); infoData.add(temp); @@ -169,16 +167,16 @@ public void editItem(final Activity activity, int position) { final EditText word = (EditText) dialogView.findViewById(R.id.info_word); final EditText meaning = (EditText) dialogView.findViewById(R.id.info_meaning); - word.setText(data.getInfoObject()); - meaning.setText(data.getInfoDescription()); + word.setText(data.getInfoObject().trim()); + meaning.setText(data.getInfoDescription().trim()); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validated(activity, word, meaning)) { - String wordText = word.getText().toString(); - String meaningText = meaning.getText().toString(); + String wordText = word.getText().toString().trim(); + String meaningText = meaning.getText().toString().trim(); data.setWord(wordText); data.setInfoDescription(meaningText); @@ -262,4 +260,4 @@ private void setEmptyView(Activity activity) { activity.findViewById(R.id.empty).setVisibility(View.GONE); } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/LearnSpellingTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/LearnSpellingTemplate.java index 41e36e84..8566d942 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/LearnSpellingTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/LearnSpellingTemplate.java @@ -9,8 +9,6 @@ import android.view.View; import android.widget.BaseAdapter; import android.widget.EditText; -import android.widget.Toast; - import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.learnspelling.fragment.SplashFragment; @@ -41,14 +39,14 @@ private static boolean validated(Context context, EditText word, EditText meanin return false; } - String wordText = word.getText().toString(); - String meaningText = meaning.getText().toString(); + String wordText = word.getText().toString().trim(); + String meaningText = meaning.getText().toString().trim(); if ("".equals(wordText)) { - Toast.makeText(context, "Enter word", Toast.LENGTH_SHORT).show(); + word.setError(context.getString(R.string.enter_word)); return false; } else if ("".equals(meaningText)) { - Toast.makeText(context, "Enter meaning", Toast.LENGTH_SHORT).show(); + meaning.setError(context.getString(R.string.enter_meaning)); return false; } return true; @@ -169,16 +167,16 @@ public void editItem(final Activity activity, int position) { final EditText word = (EditText) dialogView.findViewById(R.id.info_word); final EditText meaning = (EditText) dialogView.findViewById(R.id.info_meaning); - word.setText(data.getWord()); - meaning.setText(data.getMeaning()); + word.setText(data.getWord().trim()); + meaning.setText(data.getMeaning().trim()); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validated(activity, word, meaning)) { - String wordText = word.getText().toString(); - String meaningText = meaning.getText().toString(); + String wordText = word.getText().toString().trim(); + String meaningText = meaning.getText().toString().trim(); data.setWord(wordText); data.setMeaning(meaningText); @@ -262,4 +260,4 @@ private void setEmptyView(Activity activity) { activity.findViewById(R.id.empty).setVisibility(View.GONE); } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/MatchTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/MatchTemplate.java index a63cb64f..14dedfed 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/MatchTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/MatchTemplate.java @@ -10,7 +10,7 @@ import android.view.View; import android.widget.BaseAdapter; import android.widget.EditText; -import android.widget.Toast; + import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.matchtemplate.fragment.SplashFragment; @@ -45,18 +45,21 @@ private static boolean validated(Context context, EditText title, EditText first return false; } - String titleText = title.getText().toString(); - String first_list_titleText = first_list_title.getText().toString(); - String second_list_titleText = second_list_title.getText().toString(); + String titleText = title.getText().toString().trim(); + String first_list_titleText = first_list_title.getText().toString().trim(); + String second_list_titleText = second_list_title.getText().toString().trim(); if ("".equals(titleText)) { - Toast.makeText(context, R.string.comprehension_template_title_hint, Toast.LENGTH_SHORT).show(); + title.hasFocus(); + title.setError(context.getString(R.string.match_main_title)); return false; } else if ("".equals(first_list_titleText)) { - Toast.makeText(context, R.string.match_first_list_title, Toast.LENGTH_SHORT).show(); + first_list_title.hasFocus(); + first_list_title.setError(context.getString(R.string.match_first_list_title)); return false; } else if ("".equals(second_list_titleText)) { - Toast.makeText(context, R.string.match_second_list_title, Toast.LENGTH_SHORT).show(); + second_list_title.hasFocus(); + second_list_title.setError(context.getString(R.string.match_second_list_title)); return false; } @@ -68,14 +71,16 @@ private static boolean validated(Context context, EditText first_list_title, Edi return false; } - String first_list_titleText = first_list_title.getText().toString(); - String second_list_titleText = second_list_title.getText().toString(); + String first_list_titleText = first_list_title.getText().toString().trim(); + String second_list_titleText = second_list_title.getText().toString().trim(); if (first_list_titleText.equals("")) { - Toast.makeText(context, R.string.match_first_list_title, Toast.LENGTH_SHORT).show(); + first_list_title.hasFocus(); + first_list_title.setError(context.getString(R.string.match_first_list_title)); return false; } else if (second_list_titleText.equals("")) { - Toast.makeText(context, R.string.match_second_list_title, Toast.LENGTH_SHORT).show(); + second_list_title.hasFocus(); + second_list_title.setError(context.getString(R.string.match_second_list_title)); return false; } @@ -160,8 +165,8 @@ public void addItem(final Activity activity) { public void onClick(View v) { if (validated(activity, first_list_item, second_list_item)) { - String first_list_itemText = first_list_item.getText().toString(); - String second_list_itemText = second_list_item.getText().toString(); + String first_list_itemText = first_list_item.getText().toString().trim(); + String second_list_itemText = second_list_item.getText().toString().trim(); MatchModel temp = new MatchModel(first_list_itemText, second_list_itemText); matchData.add(temp); @@ -200,9 +205,9 @@ public void onClick(View v) { if (validated(activity, title, first_list_title, second_list_title)) { - String titleText = title.getText().toString(); - String first_list_titleText = first_list_title.getText().toString(); - String second_list_titleText = second_list_title.getText().toString(); + String titleText = title.getText().toString().trim(); + String first_list_titleText = first_list_title.getText().toString().trim(); + String second_list_titleText = second_list_title.getText().toString().trim(); MatchMetaModel temp = new MatchMetaModel(titleText, first_list_titleText, second_list_titleText); metaData.add(temp); setEmptyView(activity); @@ -236,9 +241,9 @@ public void editItem(final Activity activity, final int position) { final EditText first_list_title = (EditText) dialogView.findViewById(R.id.meta_first_list_title); final EditText second_list_title = (EditText) dialogView.findViewById(R.id.meta_second_list_title); - title.setText(data.getTitle()); - first_list_title.setText(data.getFirstListTitle()); - second_list_title.setText(data.getSecondListTitle()); + title.setText(data.getTitle().trim()); + first_list_title.setText(data.getFirstListTitle().trim()); + second_list_title.setText(data.getSecondListTitle().trim()); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override @@ -246,9 +251,9 @@ public void onClick(View v) { if (validated(activity, title, first_list_title, second_list_title)) { - String titleText = title.getText().toString(); - String first_list_titleText = first_list_title.getText().toString(); - String second_list_titleText = second_list_title.getText().toString(); + String titleText = title.getText().toString().trim(); + String first_list_titleText = first_list_title.getText().toString().trim(); + String second_list_titleText = second_list_title.getText().toString().trim(); data.setTitle(titleText); data.setFirstListTitle(first_list_titleText); @@ -280,8 +285,8 @@ public void onClick(View v) { final EditText first_list_item = (EditText) dialogView.findViewById(R.id.first_list_item); final EditText second_list_item = (EditText) dialogView.findViewById(R.id.second_list_item); - first_list_item.setText(data.getMatchA()); - second_list_item.setText(data.getMatchB()); + first_list_item.setText(data.getMatchA().trim()); + second_list_item.setText(data.getMatchB().trim()); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override @@ -289,8 +294,8 @@ public void onClick(View v) { if (validated(activity, first_list_item, second_list_item)) { - String first_list_itemText = first_list_item.getText().toString(); - String second_list_itemText = second_list_item.getText().toString(); + String first_list_itemText = first_list_item.getText().toString().trim(); + String second_list_itemText = second_list_item.getText().toString().trim(); data.setMatchA(first_list_itemText); data.setMatchB(second_list_itemText); @@ -419,4 +424,4 @@ private void setEmptyView(Activity activity) { activity.findViewById(R.id.empty).setVisibility(View.GONE); } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizTemplate.java index 89bd7845..36eb4eb1 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/QuizTemplate.java @@ -12,7 +12,6 @@ import android.widget.RadioButton; import android.widget.Toast; - import org.buildmlearn.toolkit.R; import org.buildmlearn.toolkit.model.Template; import org.buildmlearn.toolkit.model.TemplateInterface; @@ -39,6 +38,8 @@ public QuizTemplate() { this.quizData = new ArrayList<>(); } + + @Override public BaseAdapter newTemplateEditorAdapter(Context context) { mAdapter = new QuizAdapter(context, quizData); @@ -137,46 +138,78 @@ public void onClick(View v) { public void onClick(View v) { boolean isValidated = true; - int checkedAns = getCheckedAnswer(buttons); - if (checkedAns < 0) { - Toast.makeText(activity, "Choose a correct option", Toast.LENGTH_SHORT).show(); + + if ("".equals(question.getText().toString().trim())) { + question.setError(activity.getString(R.string.enter_question)); isValidated = false; + return; } - if (question.getText().toString().equals("")) { - question.setError("Question is required"); + if(options.get(0).getText().toString().trim().equals("")){ + options.get(0).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(1).getText().toString().trim().equals("")){ + options.get(1).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(2).getText().toString().trim().equals("") && !options.get(3).getText().toString().trim().equals("")){ + options.get(2).hasFocus(); + options.get(2).setError(activity.getString(R.string.comprehension_select_option_3_first)); isValidated = false; + return; } - int optionCount = 0; - for (EditText option : options) { - if (!option.getText().toString().equals("")) { - optionCount++; + for(int i=0;i answerOptions = new ArrayList<>(); - int correctAnswer = 0; + correctAnswer = 0; for (int i = 0; i < buttons.size(); i++) { - if (buttons.get(i).isChecked() && !options.get(i).getText().toString().equals("")) { + if (buttons.get(i).isChecked() && !"".equals(options.get(i).getText().toString().trim())) { correctAnswer = answerOptions.size(); - answerOptions.add(options.get(i).getText().toString()); - } else if (!options.get(i).getText().toString().equals("")) { - answerOptions.add(options.get(i).getText().toString()); + answerOptions.add(options.get(i).getText().toString().trim()); + } else if (!"".equals(options.get(i).getText().toString().trim())) { + answerOptions.add(options.get(i).getText().toString().trim()); } } - String questionText = question.getText().toString(); + String questionText = question.getText().toString().trim(); quizData.add(new QuizModel(questionText, answerOptions, correctAnswer)); setEmptyView(activity); mAdapter.notifyDataSetChanged(); } - } }); @@ -218,7 +251,7 @@ public void editItem(final Activity activity, final int position) { buttons.add((RadioButton) dialogView.findViewById(R.id.quiz_radio_4)); for (int i = 0; i < data.getOptions().size(); i++) { - options.get(i).setText(data.getOptions().get(i)); + options.get(i).setText(data.getOptions().get(i).trim()); } question.setText(data.getQuestion()); @@ -238,45 +271,67 @@ public void onClick(View v) { public void onClick(View v) { boolean isValidated = true; - int checkedAns = getCheckedAnswer(buttons); - if (checkedAns < 0) { - Toast.makeText(activity, "Choose a correct option", Toast.LENGTH_SHORT).show(); + + if ("".equals(question.getText().toString().trim())) { + question.setError(activity.getString(R.string.enter_question)); + isValidated = false; + } + + if(options.get(0).getText().toString().trim().equals("")){ + options.get(0).setError(activity.getString(R.string.cannot_be_empty)); + isValidated = false; + return; + } + if(options.get(1).getText().toString().trim().equals("")){ + options.get(1).setError(activity.getString(R.string.cannot_be_empty)); isValidated = false; + return; + } + if(options.get(2).getText().toString().trim().equals("") && !options.get(3).getText().toString().trim().equals("")){ + options.get(2).hasFocus(); + options.get(2).setError(activity.getString(R.string.comprehension_select_option_3_first)); + isValidated = false; + return; } - if (question.getText().toString().equals("")) { - question.setError("Question is required"); + int correctAnswer = 0; + int checkedAns = getCheckedAnswer(buttons); + + if (checkedAns < 0) { + Toast.makeText(activity, activity.getString(R.string.comprehension_template_choose_correct_option), Toast.LENGTH_SHORT).show(); isValidated = false; + return; } - int optionCount = 0; for (EditText option : options) { - if (!option.getText().toString().equals("")) { - optionCount++; + if ("".equals(option.getText().toString().trim())){ + option.setText(""); + continue; + } + if (option.getText().toString()!= null && "".equals(option.getText().toString().trim())) { + option.getText().clear(); + option.setError(activity.getString(R.string.comprehension_template_valid_option)); + isValidated = false; + return; } - } - if (optionCount < 2) { - Toast.makeText(activity, "Minimum two multiple answers are required.", Toast.LENGTH_SHORT).show(); - isValidated = false; } if (isValidated) { dialog.dismiss(); ArrayList answerOptions = new ArrayList<>(); - int correctAnswer = 0; + correctAnswer = 0; for (int i = 0; i < buttons.size(); i++) { - if (buttons.get(i).isChecked() && !options.get(i).getText().toString().equals("")) { + if (buttons.get(i).isChecked() && !"".equals(options.get(i).getText().toString().trim())) { correctAnswer = answerOptions.size(); - answerOptions.add(options.get(i).getText().toString()); - } else if (!options.get(i).getText().toString().equals("")) { - answerOptions.add(options.get(i).getText().toString()); + answerOptions.add(options.get(i).getText().toString().trim()); + } else if (!"".equals(options.get(i).getText().toString().trim())) { + answerOptions.add(options.get(i).getText().toString().trim()); } } - String questionText = question.getText().toString(); + String questionText = question.getText().toString().trim(); quizData.set(position, new QuizModel(questionText, answerOptions, correctAnswer)); mAdapter.notifyDataSetChanged(); } - } }); } @@ -347,8 +402,9 @@ private void checkButton(ArrayList buttons, ArrayList opt for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); - if (options.get(index).getText().toString().equals("")) { - Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show(); + if ("".equals(options.get(index).getText().toString().trim())) { + options.get(index).setError(context.getString(R.string.valid_before_answer)); + options.get(index).setText(null); button.setChecked(false); return; } else { @@ -379,4 +435,4 @@ private void setEmptyView(Activity activity) { activity.findViewById(R.id.empty).setVisibility(View.GONE); } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/VideoCollectionTemplate.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/VideoCollectionTemplate.java index 1d9b7550..04f1c87e 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/VideoCollectionTemplate.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/templates/VideoCollectionTemplate.java @@ -8,6 +8,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.support.v7.app.AlertDialog; +import android.util.Patterns; import android.view.LayoutInflater; import android.view.View; import android.widget.BaseAdapter; @@ -65,13 +66,13 @@ private static boolean validated(Context context, EditText link) { return false; } - String linkText = link.getText().toString(); + String linkText = link.getText().toString().trim(); if ("".equals(linkText)) { - Toast.makeText(context, R.string.video_collection_template_link_hint, Toast.LENGTH_SHORT).show(); + link.setError(context.getString(R.string.video_collection_template_link_hint)); return false; } else if (!(linkText.contains(YOUTUBE + ".com") || linkText.contains(YOUTUBE_SHORT) || linkText.contains(DAILYMOTION + ".com") || linkText.contains(VIMEO + ".com"))) { - Toast.makeText(context, R.string.video_support_error, Toast.LENGTH_SHORT).show(); + link.setError(context.getString(R.string.video_collection_template_linited_links)); return false; } return true; @@ -83,21 +84,23 @@ private static boolean validated(Context context, EditText title, EditText descr return false; } - String titleText = title.getText().toString(); - String descriptionText = description.getText().toString(); - String linkText = link.getText().toString(); + String titleText = title.getText().toString().trim(); + String descriptionText = description.getText().toString().trim(); + String linkText = link.getText().toString().trim(); if ("".equals(titleText)) { - Toast.makeText(context, R.string.video_collection_template_title_hint, Toast.LENGTH_SHORT).show(); + title.setError(context.getString(R.string.enter_title)); return false; } else if ("".equals(descriptionText)) { - Toast.makeText(context, R.string.video_collection_template_description_hint, Toast.LENGTH_SHORT).show(); + description.setError(context.getString(R.string.enter_description)); return false; } else if ("".equals(linkText)) { - Toast.makeText(context, R.string.video_collection_template_link_hint, Toast.LENGTH_SHORT).show(); + link.setError(context.getString(R.string.video_collection_template_link_hint)); return false; + } else if(!Patterns.WEB_URL.matcher(linkText).matches()){ + link.setError(context.getString(R.string.video_collection_template_link_valid_hint)); } else if (!(linkText.contains(YOUTUBE + ".com") || linkText.contains(YOUTUBE_SHORT) || linkText.contains(DAILYMOTION + ".com") || linkText.contains(VIMEO + ".com"))) { - Toast.makeText(context, R.string.video_support_error, Toast.LENGTH_SHORT).show(); + link.setError(context.getString(R.string.video_collection_template_linited_links)); return false; } return true; @@ -217,7 +220,7 @@ public void addItem(final Activity activity) { public void onClick(View v) { if (validated(activity, link)) { - String linkText = link.getText().toString(); + String linkText = link.getText().toString().trim(); String convertedLink = convertLink(linkText); if (NetworkUtils.isNetworkAvailable(mContext)) { @@ -274,9 +277,9 @@ public void editItem(final Activity activity, final int position) { thumb.setAdjustViewBounds(true); - title.setText(data.getTitle()); - description.setText(data.getDescription()); - link.setText(data.getLink()); + title.setText(data.getTitle().trim()); + description.setText(data.getDescription().trim()); + link.setText(data.getLink().trim()); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override @@ -284,9 +287,9 @@ public void onClick(View v) { if (validated(activity, title, description, link)) { - String titleText = title.getText().toString(); - String descriptionText = description.getText().toString(); - String linkText = link.getText().toString(); + String titleText = title.getText().toString().trim(); + String descriptionText = description.getText().toString().trim(); + String linkText = link.getText().toString().trim(); setEmptyView(activity); @@ -532,4 +535,4 @@ protected void onPostExecute(String result) { progress.dismiss(); } } -} +} \ No newline at end of file diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/FileUtils.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/FileUtils.java index 0ba36072..7ba8f495 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/FileUtils.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/FileUtils.java @@ -66,7 +66,9 @@ public static void unZip(InputStream zipInputStream, String destinationFolder) { f.mkdirs(); } - try (ZipInputStream zin = new ZipInputStream(new BufferedInputStream(zipInputStream, BUFFER_SIZE))) { + ZipInputStream zin = null; + try { + zin = new ZipInputStream(new BufferedInputStream(zipInputStream, BUFFER_SIZE)); ZipEntry ze; while ((ze = zin.getNextEntry()) != null) { String path = destinationFolder + ze.getName(); @@ -97,6 +99,10 @@ public static void unZip(InputStream zipInputStream, String destinationFolder) { } } } + } finally { + if (zin != null) { + zin.close(); + } } } catch (Exception e) { e.printStackTrace(); @@ -194,7 +200,7 @@ public static boolean equalContent(File file1, File file2) { * @return Returns true if successfully converted * @brief Converts a given Document object to xml format file */ - public static void saveXmlFile(String destinationFolder, String fileName, Document doc) { + public static boolean saveXmlFile(String destinationFolder, String fileName, Document doc) { File f = new File(destinationFolder); if (!f.isDirectory()) { @@ -203,13 +209,18 @@ public static void saveXmlFile(String destinationFolder, String fileName, Docume TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer; try { + File newTemplateFile=new File(destinationFolder + fileName); + if(newTemplateFile.exists()) + return false; transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); - StreamResult result = new StreamResult(new File(destinationFolder + fileName)); + StreamResult result = new StreamResult(newTemplateFile); transformer.transform(source, result); + } catch (TransformerException e) { e.printStackTrace(); } + return true; } /** @@ -312,3 +323,4 @@ public static void copy(File src, File dst) throws IOException { out.close(); } } + diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/SmoothNavigationToggle.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/SmoothNavigationToggle.java new file mode 100644 index 00000000..37c754d2 --- /dev/null +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/SmoothNavigationToggle.java @@ -0,0 +1,32 @@ +package org.buildmlearn.toolkit.utilities; + +import android.app.Activity; +import android.support.annotation.StringRes; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.widget.Toolbar; + +/** + * User: chiragw15 + * Date: 29-08-2016 + */ +public class SmoothNavigationToggle extends ActionBarDrawerToggle { + + private Runnable runnable; + + public SmoothNavigationToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) { + super(activity, drawerLayout, toolbar, openDrawerContentDescRes, closeDrawerContentDescRes); + } + + @Override + public void onDrawerStateChanged(int newState) { + if (runnable != null && newState == DrawerLayout.STATE_IDLE) { + runnable.run(); + runnable = null; + } + } + + public void runWhenIdle(Runnable runnable) { + this.runnable = runnable; + } +} \ No newline at end of file diff --git a/source-code/app/src/main/res/anim/popup_hide.xml b/source-code/app/src/main/res/anim/popup_hide.xml new file mode 100644 index 00000000..82436856 --- /dev/null +++ b/source-code/app/src/main/res/anim/popup_hide.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/source-code/app/src/main/res/anim/popup_show.xml b/source-code/app/src/main/res/anim/popup_show.xml new file mode 100644 index 00000000..23b5defa --- /dev/null +++ b/source-code/app/src/main/res/anim/popup_show.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/source-code/app/src/main/res/drawable-hdpi/bottom.9.png b/source-code/app/src/main/res/drawable-hdpi/bottom.9.png deleted file mode 100644 index c9f609aa..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/bottom.9.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/collapse.png b/source-code/app/src/main/res/drawable-hdpi/collapse.png deleted file mode 100755 index a313f2be..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/collapse.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/expand.png b/source-code/app/src/main/res/drawable-hdpi/expand.png deleted file mode 100755 index d0f9d7e2..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/expand.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..4a9f7694 Binary files /dev/null and b/source-code/app/src/main/res/drawable-hdpi/ic_delete_white_24dp.png differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_group_work_black_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_group_work_black_24dp.png deleted file mode 100755 index 994667bd..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_group_work_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_home_white_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_home_white_24dp.png deleted file mode 100644 index 1e5b80e2..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_home_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_info_outline_white_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_info_outline_white_24dp.png deleted file mode 100644 index c7b1113c..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_info_outline_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_input_white_48dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_input_white_48dp.png old mode 100755 new mode 100644 diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_24dp.png deleted file mode 100644 index 7f0d75c1..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_down_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_down_24dp.png deleted file mode 100644 index 2ff816d0..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_keyboard_capslock_black_down_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_local_library_black_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_local_library_black_24dp.png deleted file mode 100755 index 6b644640..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_local_library_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_record_voice_over_black_36dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_record_voice_over_black_36dp.png deleted file mode 100755 index b65995d9..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_record_voice_over_black_36dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_select_all_white_24dp.png deleted file mode 100644 index 2d971a94..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png b/source-code/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png deleted file mode 100644 index b09a6926..00000000 Binary files a/source-code/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/bottom.9.png b/source-code/app/src/main/res/drawable-mdpi/bottom.9.png deleted file mode 100644 index a12083e0..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/bottom.9.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/collapse.png b/source-code/app/src/main/res/drawable-mdpi/collapse.png deleted file mode 100755 index b6678c64..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/collapse.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/expand.png b/source-code/app/src/main/res/drawable-mdpi/expand.png deleted file mode 100755 index bf074745..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/expand.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..e2f5f355 Binary files /dev/null and b/source-code/app/src/main/res/drawable-mdpi/ic_delete_white_24dp.png differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_group_work_black_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_group_work_black_24dp.png deleted file mode 100755 index 7f523caf..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_group_work_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_home_white_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_home_white_24dp.png deleted file mode 100644 index c5441fa2..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_home_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_info_outline_white_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_info_outline_white_24dp.png deleted file mode 100644 index 353e0649..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_info_outline_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_input_white_48dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_input_white_48dp.png old mode 100755 new mode 100644 diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_24dp.png deleted file mode 100644 index aa6d98ec..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_down_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_down_24dp.png deleted file mode 100644 index 9c4e8ada..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_keyboard_capslock_black_down_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_local_library_black_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_local_library_black_24dp.png deleted file mode 100755 index 696b79d8..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_local_library_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_record_voice_over_black_36dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_record_voice_over_black_36dp.png deleted file mode 100755 index 04cbe6a0..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_record_voice_over_black_36dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_select_all_white_24dp.png deleted file mode 100644 index 966938b9..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png b/source-code/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png deleted file mode 100644 index e944fd70..00000000 Binary files a/source-code/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/collapse.png b/source-code/app/src/main/res/drawable-xhdpi/collapse.png deleted file mode 100755 index 0c00b302..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/collapse.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/expand.png b/source-code/app/src/main/res/drawable-xhdpi/expand.png deleted file mode 100755 index 2a349b63..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/expand.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..388b5b06 Binary files /dev/null and b/source-code/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_group_work_black_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_group_work_black_24dp.png deleted file mode 100755 index 68553c64..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_group_work_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_home_white_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_home_white_24dp.png deleted file mode 100644 index 0a645bef..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_home_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_info_outline_white_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_info_outline_white_24dp.png deleted file mode 100644 index c571b2e3..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_info_outline_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_input_white_48dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_input_white_48dp.png old mode 100755 new mode 100644 diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_24dp.png deleted file mode 100644 index 3e23246a..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_down_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_down_24dp.png deleted file mode 100644 index 0f81bfc0..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_keyboard_capslock_black_down_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_local_library_black_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_local_library_black_24dp.png deleted file mode 100755 index 9bbc03f8..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_local_library_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_record_voice_over_black_36dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_record_voice_over_black_36dp.png deleted file mode 100755 index f598c878..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_record_voice_over_black_36dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_select_all_white_24dp.png deleted file mode 100644 index b99012a3..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png b/source-code/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png deleted file mode 100644 index 22a8783e..00000000 Binary files a/source-code/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/collapse.png b/source-code/app/src/main/res/drawable-xxhdpi/collapse.png deleted file mode 100755 index 5745f198..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/collapse.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/expand.png b/source-code/app/src/main/res/drawable-xxhdpi/expand.png deleted file mode 100755 index 45ab0e43..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/expand.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..3fcdfdb5 Binary files /dev/null and b/source-code/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_group_work_black_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_group_work_black_24dp.png deleted file mode 100755 index 25642318..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_group_work_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_home_white_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_home_white_24dp.png deleted file mode 100644 index f7dc554c..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_home_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_info_outline_white_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_info_outline_white_24dp.png deleted file mode 100644 index c41a5fcf..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_info_outline_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_input_white_48dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_input_white_48dp.png old mode 100755 new mode 100644 diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_24dp.png deleted file mode 100644 index 72ad88ce..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_down_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_down_24dp.png deleted file mode 100644 index 15bc2389..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_keyboard_capslock_black_down_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_local_library_black_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_local_library_black_24dp.png deleted file mode 100755 index c7b4e263..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_local_library_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_record_voice_over_black_36dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_record_voice_over_black_36dp.png deleted file mode 100755 index b0abe0ad..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_record_voice_over_black_36dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_select_all_white_24dp.png deleted file mode 100644 index 162ab984..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png b/source-code/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png deleted file mode 100644 index a35b3cd1..00000000 Binary files a/source-code/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/collapse.png b/source-code/app/src/main/res/drawable-xxxhdpi/collapse.png deleted file mode 100755 index d83837e9..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/collapse.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/expand.png b/source-code/app/src/main/res/drawable-xxxhdpi/expand.png deleted file mode 100755 index 772f61ae..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/expand.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png deleted file mode 100644 index d64c22e9..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..8d322aa9 Binary files /dev/null and b/source-code/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_group_work_black_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_group_work_black_24dp.png deleted file mode 100755 index 30e47e5e..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_group_work_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_home_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_home_white_24dp.png deleted file mode 100644 index 6f8464af..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_home_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_info_outline_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_info_outline_white_24dp.png deleted file mode 100644 index 3a82cab3..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_info_outline_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_input_white_48dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_input_white_48dp.png old mode 100755 new mode 100644 diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_24dp.png deleted file mode 100644 index f85fcc7e..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_down_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_down_24dp.png deleted file mode 100644 index d9a21e0f..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_keyboard_capslock_black_down_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_local_library_black_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_local_library_black_24dp.png deleted file mode 100755 index a627e45a..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_local_library_black_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_record_voice_over_black_36dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_record_voice_over_black_36dp.png deleted file mode 100755 index 82c2d84a..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_record_voice_over_black_36dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_select_all_white_24dp.png deleted file mode 100644 index 896e1ac2..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png b/source-code/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png deleted file mode 100644 index e351c7be..00000000 Binary files a/source-code/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable/app_splash_screen_framed.png b/source-code/app/src/main/res/drawable/app_splash_screen_framed.png index c5462dd1..c3f20083 100644 Binary files a/source-code/app/src/main/res/drawable/app_splash_screen_framed.png and b/source-code/app/src/main/res/drawable/app_splash_screen_framed.png differ diff --git a/source-code/app/src/main/res/drawable/bg_card.jpg b/source-code/app/src/main/res/drawable/bg_card.jpg index b8a53c78..63f4b1bc 100644 Binary files a/source-code/app/src/main/res/drawable/bg_card.jpg and b/source-code/app/src/main/res/drawable/bg_card.jpg differ diff --git a/source-code/app/src/main/res/drawable/bg_navigation_drawer_header.jpg b/source-code/app/src/main/res/drawable/bg_navigation_drawer_header.jpg index 0e7a16b1..be2cb423 100644 Binary files a/source-code/app/src/main/res/drawable/bg_navigation_drawer_header.jpg and b/source-code/app/src/main/res/drawable/bg_navigation_drawer_header.jpg differ diff --git a/source-code/app/src/main/res/drawable/collapse.xml b/source-code/app/src/main/res/drawable/collapse.xml new file mode 100644 index 00000000..5c01cdda --- /dev/null +++ b/source-code/app/src/main/res/drawable/collapse.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/comprehension.png b/source-code/app/src/main/res/drawable/comprehension.png index 8b73de95..befdfa9c 100755 Binary files a/source-code/app/src/main/res/drawable/comprehension.png and b/source-code/app/src/main/res/drawable/comprehension.png differ diff --git a/source-code/app/src/main/res/drawable/comprehension_template_framed.png b/source-code/app/src/main/res/drawable/comprehension_template_framed.png new file mode 100644 index 00000000..b68d4903 Binary files /dev/null and b/source-code/app/src/main/res/drawable/comprehension_template_framed.png differ diff --git a/source-code/app/src/main/res/drawable/dictation.png b/source-code/app/src/main/res/drawable/dictation.png index d037e85c..4dfb48f0 100755 Binary files a/source-code/app/src/main/res/drawable/dictation.png and b/source-code/app/src/main/res/drawable/dictation.png differ diff --git a/source-code/app/src/main/res/drawable/expand.xml b/source-code/app/src/main/res/drawable/expand.xml new file mode 100644 index 00000000..53bd1136 --- /dev/null +++ b/source-code/app/src/main/res/drawable/expand.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/first_run_bg.jpg b/source-code/app/src/main/res/drawable/first_run_bg.jpg index 6b0cf172..61e272eb 100644 Binary files a/source-code/app/src/main/res/drawable/first_run_bg.jpg and b/source-code/app/src/main/res/drawable/first_run_bg.jpg differ diff --git a/source-code/app/src/main/res/drawable/flash.png b/source-code/app/src/main/res/drawable/flash.png index 779f7892..f8529409 100755 Binary files a/source-code/app/src/main/res/drawable/flash.png and b/source-code/app/src/main/res/drawable/flash.png differ diff --git a/source-code/app/src/main/res/drawable/ic_add_white_24dp.xml b/source-code/app/src/main/res/drawable/ic_add_white_24dp.xml new file mode 100644 index 00000000..52adbb69 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_add_white_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_group_work_black_24dp.xml b/source-code/app/src/main/res/drawable/ic_group_work_black_24dp.xml new file mode 100644 index 00000000..2302d296 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_group_work_black_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_home_white_24dp.xml b/source-code/app/src/main/res/drawable/ic_home_white_24dp.xml new file mode 100644 index 00000000..84a9f2bf --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_home_white_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_info_outline_white_24dp.xml b/source-code/app/src/main/res/drawable/ic_info_outline_white_24dp.xml new file mode 100644 index 00000000..1259b194 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_info_outline_white_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_24dp.xml b/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_24dp.xml new file mode 100644 index 00000000..79a3e556 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_down_24dp.xml b/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_down_24dp.xml new file mode 100644 index 00000000..2e369086 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_keyboard_capslock_black_down_24dp.xml @@ -0,0 +1,7 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_local_library_black_24dp.xml b/source-code/app/src/main/res/drawable/ic_local_library_black_24dp.xml new file mode 100644 index 00000000..587a8e33 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_local_library_black_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_record_voice_over_black_36dp.xml b/source-code/app/src/main/res/drawable/ic_record_voice_over_black_36dp.xml new file mode 100644 index 00000000..e3471f09 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_record_voice_over_black_36dp.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.png b/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.png deleted file mode 100644 index 966938b9..00000000 Binary files a/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.xml b/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.xml new file mode 100644 index 00000000..e22a61c6 --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_select_all_white_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/ic_share_white_24dp.xml b/source-code/app/src/main/res/drawable/ic_share_white_24dp.xml new file mode 100644 index 00000000..09838a3d --- /dev/null +++ b/source-code/app/src/main/res/drawable/ic_share_white_24dp.xml @@ -0,0 +1,4 @@ + + + + diff --git a/source-code/app/src/main/res/drawable/info_template.png b/source-code/app/src/main/res/drawable/info_template.png index 2311ef18..cdb8156c 100755 Binary files a/source-code/app/src/main/res/drawable/info_template.png and b/source-code/app/src/main/res/drawable/info_template.png differ diff --git a/source-code/app/src/main/res/drawable/load_saved_apks_framed.png b/source-code/app/src/main/res/drawable/load_saved_apks_framed.png new file mode 100644 index 00000000..5b0a1c05 Binary files /dev/null and b/source-code/app/src/main/res/drawable/load_saved_apks_framed.png differ diff --git a/source-code/app/src/main/res/drawable/load_saved_drafts_framed.png b/source-code/app/src/main/res/drawable/load_saved_drafts_framed.png new file mode 100644 index 00000000..4db1a740 Binary files /dev/null and b/source-code/app/src/main/res/drawable/load_saved_drafts_framed.png differ diff --git a/source-code/app/src/main/res/drawable/load_saved_projects_framed.png b/source-code/app/src/main/res/drawable/load_saved_projects_framed.png index 0ad32a80..a43f07e5 100644 Binary files a/source-code/app/src/main/res/drawable/load_saved_projects_framed.png and b/source-code/app/src/main/res/drawable/load_saved_projects_framed.png differ diff --git a/source-code/app/src/main/res/drawable/main_screen_framed.png b/source-code/app/src/main/res/drawable/main_screen_framed.png index c84b21a0..796222cd 100644 Binary files a/source-code/app/src/main/res/drawable/main_screen_framed.png and b/source-code/app/src/main/res/drawable/main_screen_framed.png differ diff --git a/source-code/app/src/main/res/drawable/match_template.png b/source-code/app/src/main/res/drawable/match_template.png index 4f2a8460..1a6c1173 100755 Binary files a/source-code/app/src/main/res/drawable/match_template.png and b/source-code/app/src/main/res/drawable/match_template.png differ diff --git a/source-code/app/src/main/res/drawable/quiz.png b/source-code/app/src/main/res/drawable/quiz.png index 4d63358f..c483ac37 100755 Binary files a/source-code/app/src/main/res/drawable/quiz.png and b/source-code/app/src/main/res/drawable/quiz.png differ diff --git a/source-code/app/src/main/res/drawable/quiz_template_framed.png b/source-code/app/src/main/res/drawable/quiz_template_framed.png deleted file mode 100644 index 5f2d8c00..00000000 Binary files a/source-code/app/src/main/res/drawable/quiz_template_framed.png and /dev/null differ diff --git a/source-code/app/src/main/res/drawable/simulator_without_any_template_framed.png b/source-code/app/src/main/res/drawable/simulator_without_any_template_framed.png index c015d629..6f797d01 100644 Binary files a/source-code/app/src/main/res/drawable/simulator_without_any_template_framed.png and b/source-code/app/src/main/res/drawable/simulator_without_any_template_framed.png differ diff --git a/source-code/app/src/main/res/drawable/spelling.png b/source-code/app/src/main/res/drawable/spelling.png index dcb6cc0f..5029548f 100755 Binary files a/source-code/app/src/main/res/drawable/spelling.png and b/source-code/app/src/main/res/drawable/spelling.png differ diff --git a/source-code/app/src/main/res/drawable/template_list_framed.png b/source-code/app/src/main/res/drawable/template_list_framed.png index a5eccb65..45ff3e6a 100644 Binary files a/source-code/app/src/main/res/drawable/template_list_framed.png and b/source-code/app/src/main/res/drawable/template_list_framed.png differ diff --git a/source-code/app/src/main/res/drawable/touch_selector_white.xml b/source-code/app/src/main/res/drawable/touch_selector_white.xml new file mode 100644 index 00000000..4dfa49c4 --- /dev/null +++ b/source-code/app/src/main/res/drawable/touch_selector_white.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/source-code/app/src/main/res/drawable/video_collection.png b/source-code/app/src/main/res/drawable/video_collection.png index b24a42bb..434de325 100755 Binary files a/source-code/app/src/main/res/drawable/video_collection.png and b/source-code/app/src/main/res/drawable/video_collection.png differ diff --git a/source-code/app/src/main/res/layout/activity_home.xml b/source-code/app/src/main/res/layout/activity_home.xml index f5c855ca..696a7428 100644 --- a/source-code/app/src/main/res/layout/activity_home.xml +++ b/source-code/app/src/main/res/layout/activity_home.xml @@ -1,9 +1,12 @@ + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:openDrawer="start"> @@ -24,13 +27,12 @@ - - - + app:headerLayout="@layout/listview_header_navigation_drawer" + app:menu="@menu/nav_drawer" /> + \ No newline at end of file diff --git a/source-code/app/src/main/res/layout/activity_tutorial.xml b/source-code/app/src/main/res/layout/activity_tutorial.xml index 41234f4b..27eef14d 100644 --- a/source-code/app/src/main/res/layout/activity_tutorial.xml +++ b/source-code/app/src/main/res/layout/activity_tutorial.xml @@ -8,10 +8,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - + > \ No newline at end of file diff --git a/source-code/app/src/main/res/layout/bottom_sheet_view.xml b/source-code/app/src/main/res/layout/bottom_sheet_view.xml new file mode 100644 index 00000000..c69cc1b6 --- /dev/null +++ b/source-code/app/src/main/res/layout/bottom_sheet_view.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/source-code/app/src/main/res/layout/fragment_navigation_drawer.xml b/source-code/app/src/main/res/layout/fragment_navigation_drawer.xml deleted file mode 100644 index 5143e4b9..00000000 --- a/source-code/app/src/main/res/layout/fragment_navigation_drawer.xml +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/source-code/app/src/main/res/layout/item_main_menu.xml b/source-code/app/src/main/res/layout/item_main_menu.xml deleted file mode 100644 index ccc5113e..00000000 --- a/source-code/app/src/main/res/layout/item_main_menu.xml +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/source-code/app/src/main/res/layout/item_section_divider.xml b/source-code/app/src/main/res/layout/item_section_divider.xml deleted file mode 100644 index a578a216..00000000 --- a/source-code/app/src/main/res/layout/item_section_divider.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/source-code/app/src/main/res/layout/listview_header_navigation_drawer.xml b/source-code/app/src/main/res/layout/listview_header_navigation_drawer.xml index 442b8c55..a3422881 100644 --- a/source-code/app/src/main/res/layout/listview_header_navigation_drawer.xml +++ b/source-code/app/src/main/res/layout/listview_header_navigation_drawer.xml @@ -15,14 +15,13 @@ - + android:id="@+id/nav_text"> + + + + \ No newline at end of file diff --git a/source-code/app/src/main/res/layout/tutorial_layout.xml b/source-code/app/src/main/res/layout/tutorial_layout.xml index 96a7854c..f8be17ae 100644 --- a/source-code/app/src/main/res/layout/tutorial_layout.xml +++ b/source-code/app/src/main/res/layout/tutorial_layout.xml @@ -14,8 +14,7 @@ android:padding="16dp" android:text="@string/screen_1_title" android:textSize="@dimen/headline" /> - - +