From 71a8aa613d63be10f44bc7b666302680f8090234 Mon Sep 17 00:00:00 2001 From: Leonard Maximus Irenous Mensah Date: Mon, 25 Sep 2017 09:23:42 +0000 Subject: [PATCH] L10n crowdin translation (#96) --- .gitignore | 1 + .../offline/ole/org/pbell/Dashboard.java | 506 ++++---- .../offline/ole/org/pbell/DemoDataLoader.java | 346 +++-- .../ole/org/pbell/Fragm_myCourses.java | 25 +- .../ole/org/pbell/Fragm_myLibrary.java | 32 +- .../ole/org/pbell/FullscreenLogin.java | 1152 ++++++++++------- .../org/pbell/ListViewAdapter_myLibrary.java | 316 ++++- .../offline/ole/org/pbell/Loading_Screen.java | 15 +- .../offline/ole/org/pbell/ResourcesJson.java | 31 +- .../main/res/layout/new_activity_login.xml | 3 +- app/src/main/res/values-af-rZA/strings.xml | 87 ++ app/src/main/res/values-ar-rSA/strings.xml | 87 ++ app/src/main/res/values-de-rDE/strings.xml | 87 ++ app/src/main/res/values-el-rGR/strings.xml | 87 ++ app/src/main/res/values-en-rUS/strings.xml | 85 ++ app/src/main/res/values-es-rES/strings.xml | 87 ++ app/src/main/res/values-fr-rFR/strings.xml | 85 ++ app/src/main/res/values-it-rIT/strings.xml | 87 ++ app/src/main/res/values-iw-rIL/strings.xml | 87 ++ app/src/main/res/values-ja-rJP/strings.xml | 87 ++ app/src/main/res/values-ko-rKR/strings.xml | 87 ++ app/src/main/res/values-pl-rPL/strings.xml | 87 ++ app/src/main/res/values-pt-rPT/strings.xml | 87 ++ app/src/main/res/values-ru-rRU/strings.xml | 87 ++ app/src/main/res/values-tr-rTR/strings.xml | 87 ++ app/src/main/res/values-vi-rVN/strings.xml | 87 ++ app/src/main/res/values-zh-rCN/strings.xml | 87 ++ app/src/main/res/values-zh-rTW/strings.xml | 87 ++ crowdin.yml | 6 + 29 files changed, 3036 insertions(+), 959 deletions(-) create mode 100644 app/src/main/res/values-af-rZA/strings.xml create mode 100644 app/src/main/res/values-ar-rSA/strings.xml create mode 100644 app/src/main/res/values-de-rDE/strings.xml create mode 100644 app/src/main/res/values-el-rGR/strings.xml create mode 100644 app/src/main/res/values-en-rUS/strings.xml create mode 100644 app/src/main/res/values-es-rES/strings.xml create mode 100644 app/src/main/res/values-fr-rFR/strings.xml create mode 100644 app/src/main/res/values-it-rIT/strings.xml create mode 100644 app/src/main/res/values-iw-rIL/strings.xml create mode 100644 app/src/main/res/values-ja-rJP/strings.xml create mode 100644 app/src/main/res/values-ko-rKR/strings.xml create mode 100644 app/src/main/res/values-pl-rPL/strings.xml create mode 100644 app/src/main/res/values-pt-rPT/strings.xml create mode 100644 app/src/main/res/values-ru-rRU/strings.xml create mode 100644 app/src/main/res/values-tr-rTR/strings.xml create mode 100644 app/src/main/res/values-vi-rVN/strings.xml create mode 100644 app/src/main/res/values-zh-rCN/strings.xml create mode 100644 app/src/main/res/values-zh-rTW/strings.xml create mode 100644 crowdin.yml diff --git a/.gitignore b/.gitignore index 18454e5..bf1a40a 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ adobe_reader.apk *firefox_49_0_multi_android.apk firefox_49_0_multi_android.apk +assets/ # Android Studio Navigation editor temp files .navigation/ diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/Dashboard.java b/app/src/main/java/pbell/offline/ole/org/pbell/Dashboard.java index bf8ec5e..08fb5b1 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/Dashboard.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/Dashboard.java @@ -3,292 +3,286 @@ /** * Created by leonardmensah on 19/05/16. */ - import android.app.Dialog; - import android.content.Context; - import android.content.DialogInterface; - import android.content.Intent; - import android.content.SharedPreferences; - import android.os.Bundle; - import android.support.annotation.IdRes; - import android.support.v4.app.Fragment; - import android.support.v4.app.FragmentManager; - import android.support.v4.app.FragmentPagerAdapter; - import android.support.v4.app.FragmentTransaction; - import android.support.v4.content.ContextCompat; - import android.support.v4.view.ViewPager; - import android.support.v7.app.AlertDialog; - import android.support.v7.app.AppCompatActivity; - import android.support.v7.widget.Toolbar; - import android.util.Log; - import android.view.Menu; - import android.view.MenuItem; - import android.view.View; - import android.widget.Button; - import android.widget.EditText; - import android.widget.TextView; - import android.widget.Toast; - - import com.roughike.bottombar.BottomBar; - import com.roughike.bottombar.OnMenuTabClickListener; - - import java.text.SimpleDateFormat; - import java.util.Calendar; - import java.util.Date; - import java.util.Set; + +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.StrictMode; +import android.support.annotation.IdRes; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.roughike.bottombar.BottomBar; +import com.roughike.bottombar.OnMenuTabClickListener; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Set; @SuppressWarnings("ALL") public class Dashboard extends AppCompatActivity { - private BottomBar mBottomBar; - private TextView mMessageView; - final Context context = this; - private EditText txtSuncURL = null; - - - private ViewPager mViewPager; - private SectionsPagerAdapter mySectionsPagerAdapter; - TabFragment0 tab0 = new TabFragment0(); - TabFragment1 tab1= new TabFragment1(); - TabFragment2 tab2= new TabFragment2(); - TabFragment3 tab3= new TabFragment3(); - - public static final String PREFS_NAME = "MyPrefsFile"; - SharedPreferences settings; + private BottomBar mBottomBar; + private TextView mMessageView; + final Context context = this; + private EditText txtSuncURL = null; - String sys_oldSyncServerURL,sys_username,sys_lastSyncDate, - sys_password,sys_usercouchId,sys_userfirstname,sys_userlastname, - sys_usergender, sys_uservisits= ""; - int sys_uservisits_Int=0; - Object[] sys_membersWithResource; - boolean userShelfSynced =false; + private ViewPager mViewPager; + private SectionsPagerAdapter mySectionsPagerAdapter; + TabFragment0 tab0 = new TabFragment0(); + TabFragment1 tab1 = new TabFragment1(); + TabFragment2 tab2 = new TabFragment2(); + TabFragment3 tab3 = new TabFragment3(); + public static final String PREFS_NAME = "MyPrefsFile"; + SharedPreferences settings; + String sys_oldSyncServerURL, sys_username, sys_lastSyncDate, + sys_password, sys_usercouchId, sys_userfirstname, sys_userlastname, + sys_usergender, sys_uservisits = ""; + int sys_uservisits_Int = 0; + Object[] sys_membersWithResource; + boolean userShelfSynced = false; FragmentManager fragMgr = getSupportFragmentManager(); - FragmentTransaction fragTrans = fragMgr.beginTransaction(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_dashboard); - - Toolbar toolbar = (Toolbar) findViewById(R.id.mytoolbar); - setSupportActionBar(toolbar); - - ///settings = context.getSharedPreferences("PREFS_NAME", Context.MODE_PRIVATE); - settings = getSharedPreferences(PREFS_NAME, 0); - sys_username = settings.getString("pf_username",""); - sys_oldSyncServerURL = settings.getString("pf_sysncUrl",""); - sys_lastSyncDate = settings.getString("pf_lastSyncDate",""); - sys_password = settings.getString("pf_password",""); - sys_usercouchId = settings.getString("pf_usercouchId",""); - sys_userfirstname = settings.getString("pf_userfirstname",""); - sys_userlastname = settings.getString("pf_userlastname",""); - sys_usergender = settings.getString("pf_usergender",""); - sys_uservisits = settings.getString("pf_uservisits",""); - - try { - Set mwr = settings.getStringSet("membersWithResource", null); - sys_membersWithResource = mwr.toArray(); - for (int cnt = 0; cnt < sys_membersWithResource.length; cnt++) { - - Log.e("MYAPP", " members With Resource Synced = " + sys_membersWithResource[cnt]); - if (sys_membersWithResource[cnt].equals(sys_usercouchId)) { - userShelfSynced = true; - break; - } + FragmentTransaction fragTrans = fragMgr.beginTransaction(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_dashboard); + + Toolbar toolbar = (Toolbar) findViewById(R.id.mytoolbar); + setSupportActionBar(toolbar); + StrictMode.VmPolicy.Builder stModeBuilder = new StrictMode.VmPolicy.Builder(); + StrictMode.setVmPolicy(stModeBuilder.build()); + + ///settings = context.getSharedPreferences("PREFS_NAME", Context.MODE_PRIVATE); + settings = getSharedPreferences(PREFS_NAME, 0); + sys_username = settings.getString("pf_username", ""); + sys_oldSyncServerURL = settings.getString("pf_sysncUrl", ""); + sys_lastSyncDate = settings.getString("pf_lastSyncDate", ""); + sys_password = settings.getString("pf_password", ""); + sys_usercouchId = settings.getString("pf_usercouchId", ""); + sys_userfirstname = settings.getString("pf_userfirstname", ""); + sys_userlastname = settings.getString("pf_userlastname", ""); + sys_usergender = settings.getString("pf_usergender", ""); + sys_uservisits = settings.getString("pf_uservisits", ""); + + try { + Set mwr = settings.getStringSet("membersWithResource", null); + sys_membersWithResource = mwr.toArray(); + for (int cnt = 0; cnt < sys_membersWithResource.length; cnt++) { + + Log.e("MYAPP", " members With Resource Synced = " + sys_membersWithResource[cnt]); + if (sys_membersWithResource[cnt].equals(sys_usercouchId)) { + userShelfSynced = true; + break; } - }catch(Exception err){ - - Log.e("TakeHome", " MembersWithResource Array" + err.getMessage()); } + } catch (Exception err) { - if (!userShelfSynced){ - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("Materials on your shelf are NOT yet synchronized unto this device. " + - "You can only view title of items on your shelf BUT you can not launch or read them." + - "To access your materials on this device, please sync device with server.") - .setCancelable(false) - .setPositiveButton("Okay", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }); - - AlertDialog closeDialogue = builder.create(); - closeDialogue.show(); - } - - /// Log.e("MYAPP", " membersWithResource = "+sys_membersWithResource.length); - - - TextView lbldate = (TextView) findViewById(R.id.lblDate); + Log.e("TakeHome", " MembersWithResource Array" + err.getMessage()); + } - Calendar cal= Calendar.getInstance(); - Date d = new Date(); + if (!userShelfSynced) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage("Materials on your shelf are NOT yet synchronized unto this device. " + + "You can only view title of items on your shelf BUT you can not launch or read them." + + "To access your materials on this device, please sync device with server.") + .setCancelable(false) + .setPositiveButton("Okay", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + + AlertDialog closeDialogue = builder.create(); + closeDialogue.show(); + } - SimpleDateFormat s_df = new SimpleDateFormat("EEEE"); - String dayOfTheWeek = s_df.format(d); - SimpleDateFormat date_df = new SimpleDateFormat("d"); - String dayNumber = date_df.format(d); - SimpleDateFormat month_df = new SimpleDateFormat("MMMM"); - String month_name = month_df.format(cal.getTime()); - SimpleDateFormat year_df = new SimpleDateFormat("yyyy"); - String year = year_df.format(d); - String displayedDate = dayOfTheWeek + " | "+dayNumber+" " + month_name+" "+year; - lbldate.setText(displayedDate); + /// Log.e("MYAPP", " membersWithResource = "+sys_membersWithResource.length); + TextView lbldate = (TextView) findViewById(R.id.lblDate); - mySectionsPagerAdapter = new SectionsPagerAdapter(fragMgr); - mViewPager = (ViewPager) findViewById(R.id.container); - mViewPager.setAdapter(mySectionsPagerAdapter); + Calendar cal = Calendar.getInstance(); + Date d = new Date(); - mBottomBar = BottomBar.attach(this, savedInstanceState); - mBottomBar.useOnlyStatusBarTopOffset(); - //mBottomBar.setMaxFixedTabs(n-1); - //mBottomBar.noNavBarGoodness(); - // mBottomBar = BottomBar.attachShy((CoordinatorLayout) findViewById(R.id.main_content),findViewById(R.id.container), savedInstanceState); + SimpleDateFormat s_df = new SimpleDateFormat("EEEE"); + String dayOfTheWeek = s_df.format(d); + SimpleDateFormat date_df = new SimpleDateFormat("d"); + String dayNumber = date_df.format(d); + SimpleDateFormat month_df = new SimpleDateFormat("MMMM"); + String month_name = month_df.format(cal.getTime()); + SimpleDateFormat year_df = new SimpleDateFormat("yyyy"); + String year = year_df.format(d); + String displayedDate = dayOfTheWeek + " | " + dayNumber + " " + month_name + " " + year; + lbldate.setText(displayedDate); - mBottomBar.noTabletGoodness(); - mBottomBar.setItemsFromMenu(R.menu.bottombar_menu, new OnMenuTabClickListener() { - @Override - public void onMenuTabSelected(@IdRes int menuItemId) { - /// mMessageView.setText(getMessage(menuItemId, false)); - } - @Override - public void onMenuTabReSelected(@IdRes int menuItemId) { - Toast.makeText(getApplicationContext(), getMessage(menuItemId, true), Toast.LENGTH_SHORT).show(); - } - }); + mySectionsPagerAdapter = new SectionsPagerAdapter(fragMgr); + mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager.setAdapter(mySectionsPagerAdapter); + mBottomBar = BottomBar.attach(this, savedInstanceState); + mBottomBar.useOnlyStatusBarTopOffset(); + //mBottomBar.setMaxFixedTabs(n-1); + //mBottomBar.noNavBarGoodness(); + // mBottomBar = BottomBar.attachShy((CoordinatorLayout) findViewById(R.id.main_content),findViewById(R.id.container), savedInstanceState); + mBottomBar.noTabletGoodness(); + mBottomBar.setItemsFromMenu(R.menu.bottombar_menu, new OnMenuTabClickListener() { + @Override + public void onMenuTabSelected(@IdRes int menuItemId) { + /// mMessageView.setText(getMessage(menuItemId, false)); + } - // Setting colors for different tabs when there's more than three of them. - // You can set colors for tabs in three different ways as shown below. - mBottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorAccent)); - mBottomBar.mapColorForTab(1, 0xFF5D4037); - mBottomBar.mapColorForTab(2, "#7B1FA2"); - mBottomBar.mapColorForTab(3, "#FF5252"); + @Override + public void onMenuTabReSelected(@IdRes int menuItemId) { + Toast.makeText(getApplicationContext(), getMessage(menuItemId, true), Toast.LENGTH_SHORT).show(); + } + }); + // Setting colors for different tabs when there's more than three of them. + // You can set colors for tabs in three different ways as shown below. + mBottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorAccent)); + mBottomBar.mapColorForTab(1, 0xFF5D4037); + mBottomBar.mapColorForTab(2, "#7B1FA2"); + mBottomBar.mapColorForTab(3, "#FF5252"); + //mBottomBar.hide(); + } - //mBottomBar.hide(); - } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); + //noinspection SimplifiableIfStatement + if (id == R.id.action_syncserverUrl) { + SyncDialog(sys_oldSyncServerURL); + return true; + } else if (id == R.id.action_syncNow) { + Intent syncdeviceIntent = new Intent(this, SyncDevice.class); + ///intent.putExtra(EXTRA_MESSAGE, message); + startActivity(syncdeviceIntent); + return true; + } else if (id == R.id.action_about) { + return true; + } else if (id == R.id.action_help) { + return true; + } else if (id == R.id.action_profile) { return true; } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_syncserverUrl) { - SyncDialog(sys_oldSyncServerURL); - return true; - }else if (id == R.id.action_syncNow) { - Intent syncdeviceIntent = new Intent(this,SyncDevice.class); - ///intent.putExtra(EXTRA_MESSAGE, message); - startActivity(syncdeviceIntent); - return true; - }else if (id == R.id.action_about) { - return true; - }else if (id == R.id.action_help) { - return true; - }else if (id == R.id.action_profile) { - return true; - } - - return super.onOptionsItemSelected(item); - } - - - - private String getMessage(int menuItemId, boolean isReselection) { - String message = "Content for "; + return super.onOptionsItemSelected(item); + } - switch (menuItemId) { - case R.id.bb_menu_friends: - mViewPager.setCurrentItem(0); - message += "Achievements"; - break; - case R.id.bb_menu_favorites: - mViewPager.setCurrentItem(2); - message += "My Library"; - break; - case R.id.bb_menu_recents: - mViewPager.setCurrentItem(1); - message += ""; - break; - case R.id.bb_menu_food: - mViewPager.setCurrentItem(3); - message += ""; - break; - } - if (isReselection) { + private String getMessage(int menuItemId, boolean isReselection) { + String message = "Content for "; + + switch (menuItemId) { + case R.id.bb_menu_friends: + mViewPager.setCurrentItem(0); + message += "Achievements"; + break; + case R.id.bb_menu_favorites: + mViewPager.setCurrentItem(2); + message += "My Library"; + break; + case R.id.bb_menu_recents: + mViewPager.setCurrentItem(1); message += ""; - } + break; + case R.id.bb_menu_food: + mViewPager.setCurrentItem(3); + message += ""; + break; + } - return message; + if (isReselection) { + message += ""; } - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); + return message; + } - // Necessary to restore the BottomBar's state, otherwise we would - // lose the current tab on orientation change. - mBottomBar.onSaveInstanceState(outState); - } + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + // Necessary to restore the BottomBar's state, otherwise we would + // lose the current tab on orientation change. + mBottomBar.onSaveInstanceState(outState); + } - public class SectionsPagerAdapter extends FragmentPagerAdapter { - public SectionsPagerAdapter(FragmentManager fm) { + public class SectionsPagerAdapter extends FragmentPagerAdapter { - super(fm); - } + public SectionsPagerAdapter(FragmentManager fm) { - @Override - public Fragment getItem(int position) { - - switch (position) { - case 0: - return tab0; - case 1: - return tab1; - case 2: - return tab2; - case 3: - return tab3; - default: - return null; - } - } + super(fm); + } - @Override - public int getCount() { - // Show 3 total pages. - return 4; + @Override + public Fragment getItem(int position) { + + switch (position) { + case 0: + return tab0; + case 1: + return tab1; + case 2: + return tab2; + case 3: + return tab3; + default: + return null; } + } + @Override + public int getCount() { + // Show 3 total pages. + return 4; } + } + /* public static class PlaceholderFragment extends Fragment { //The fragment argument representing the section number for this fragment. @@ -316,30 +310,30 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, } */ - public void SyncDialog(String oldSyncURL){ - // custom dialog - final Dialog dialog = new Dialog(context); - dialog.setContentView(R.layout.syncurl_dialog); - dialog.setTitle("Synchronization Server Url"); - - txtSuncURL = (EditText)dialog.findViewById(R.id.txtsyncURL); - txtSuncURL.setText(oldSyncURL); - Button dialogButton = (Button) dialog.findViewById(R.id.btnSaveSyncURL); - dialogButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - sys_oldSyncServerURL = txtSuncURL.getText().toString(); - SharedPreferences.Editor editor = settings.edit(); - editor.putString("pf_sysncUrl", sys_oldSyncServerURL); - editor.commit(); - - dialog.dismiss(); - } - }); + public void SyncDialog(String oldSyncURL) { + // custom dialog + final Dialog dialog = new Dialog(context); + dialog.setContentView(R.layout.syncurl_dialog); + dialog.setTitle("Synchronization Server Url"); + + txtSuncURL = (EditText) dialog.findViewById(R.id.txtsyncURL); + txtSuncURL.setText(oldSyncURL); + Button dialogButton = (Button) dialog.findViewById(R.id.btnSaveSyncURL); + dialogButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sys_oldSyncServerURL = txtSuncURL.getText().toString(); + SharedPreferences.Editor editor = settings.edit(); + editor.putString("pf_sysncUrl", sys_oldSyncServerURL); + editor.commit(); - dialog.show(); + dialog.dismiss(); + } + }); - } + dialog.show(); } +} + diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/DemoDataLoader.java b/app/src/main/java/pbell/offline/ole/org/pbell/DemoDataLoader.java index c8f666e..7d59757 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/DemoDataLoader.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/DemoDataLoader.java @@ -5,10 +5,13 @@ import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.database.Cursor; import android.graphics.drawable.LayerDrawable; import android.os.AsyncTask; import android.os.Environment; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -24,7 +27,9 @@ import com.couchbase.lite.android.AndroidContext; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -57,18 +62,18 @@ public class DemoDataLoader { AndroidContext androidContext; String OneByOneResID, OneByOneResTitle, OneByOneCourseId; - int courseStepsCounter =0; + int courseStepsCounter = 0; int action_button_id = 0; SharedPreferences settings; List resIDArrayList = new ArrayList<>(); View vi; - TextView title,description,ratingAvgNum,totalNum; + TextView title, description, ratingAvgNum, totalNum; Button open; RatingBar ratingStars; LayerDrawable stars; ProgressBar femalerating, malerating; - String activityName ="myCourses"; + String activityName = "myCourses"; protected int _splashTime = 5000; @@ -79,12 +84,13 @@ public class DemoDataLoader { Cursor c; LogHouse logHouse = new LogHouse(); private ListViewAdapter_myCourses.OnCourseListListener mListener; - + Button SignInButton; String[] databaseList = {"members", "meetups", "usermeetups", "assignments", - "assignmentpaper","courseanswer","coursequestion","courses","courseschedule","coursestep","membercourseprogress", + "assignmentpaper", "courseanswer", "coursequestion", "courses", "courseschedule", "coursestep", "membercourseprogress", "calendar", "groups", "invitations", "configurations", "requests", "shelf", "languages"}; - public DemoDataLoader(Context context){ + public DemoDataLoader(Context context, Button btn) { + SignInButton = btn; this.context = context; androidContext = new AndroidContext(this.context); @@ -107,20 +113,21 @@ public void restorePreferences() { sys_servername = settings.getString("pf_server_name", "demo"); sys_serverversion = settings.getString("pf_server_version", " "); sys_serverversion = settings.getString("pf_server_code", "demo"); - sys_demoMode = settings.getBoolean("sys_demoMode",true); + sys_demoMode = settings.getBoolean("sys_demoMode", true); sys_oldSyncServerURL = "http://demo:oleoleole@demo.ole.org:5995"; SharedPreferences.Editor editor = settings.edit(); editor.putString("pf_sysncUrl", sys_oldSyncServerURL); editor.commit(); } - private class startHere extends AsyncTask - { + + private class startHere extends AsyncTask { @Override protected Void doInBackground(Void... params) { emptyAllDbs(); return null; } + @Override protected void onPostExecute(Void result) { ResourcesJson rsj = new ResourcesJson(); @@ -131,68 +138,105 @@ protected void onPostExecute(Void result) { createCourses(); createCoursestep(); createMembercourseprogress(); - if(rsj.ResourcesJson(sys_oldSyncServerURL,"resources",androidContext)){ - - } + shadowresources_demo(); + listAssetFiles(); + //if(rsj.ResourcesJson(sys_oldSyncServerURL,"resources",androidContext)){ + //} + SignInButton.performClick(); } } - public void emptyAllDbs() { - for (int cnt = 0; cnt < databaseList.length; cnt++) { + private boolean listAssetFiles() { + try { + String[] list = context.getAssets().list(""); + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp"); + if (!myDir.exists()) { + myDir.mkdirs(); + Log.v(TAG, "Had to create ole tamp folder " + myDir.getAbsolutePath()); + } + for (String file : list) { + Log.v(TAG, "Files in assets folder include " + file); + InputStream in = context.getAssets().open(file); + File dst = new File(myDir, file); try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - Database db = manager.getDatabase(databaseList[cnt]); - Log.e("MYAPP","Deleting "+databaseList[cnt]); - db.delete(); - } catch (Exception e) { - e.printStackTrace(); + FileOutputStream out = new FileOutputStream(dst); + byte[] buff = new byte[1024]; + int read = 0; + while ((read = in.read(buff)) > 0) { + out.write(buff, 0, read); + } + in.close(); + out.close(); + Log.e("tag", file + " Copied " + dst.toString()); + } catch (Exception err) { + err.printStackTrace(); } } - //// Delete Device Created Databases - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - Database dbResources = manager.getDatabase("resources"); - dbResources.delete(); - }catch(Exception err){ - err.printStackTrace(); - } - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - Database dbResources = manager.getDatabase("shadowresources"); - dbResources.delete(); - }catch(Exception err){ - err.printStackTrace(); - } + } catch (IOException e) { + return false; + } + + return true; + } + + + public void emptyAllDbs() { + for (int cnt = 0; cnt < databaseList.length; cnt++) { try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - Database dbOffline_courses = manager.getDatabase("offline_courses"); - dbOffline_courses.delete(); - }catch(Exception err){ - err.printStackTrace(); + Database db = manager.getDatabase(databaseList[cnt]); + Log.e("MYAPP", "Deleting " + databaseList[cnt]); + db.delete(); + } catch (Exception e) { + e.printStackTrace(); } + } + //// Delete Device Created Databases + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Database dbResources = manager.getDatabase("resources"); + dbResources.delete(); + } catch (Exception err) { + err.printStackTrace(); + } + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Database dbResources = manager.getDatabase("shadowresources"); + dbResources.delete(); + } catch (Exception err) { + err.printStackTrace(); + } + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Database dbOffline_courses = manager.getDatabase("offline_courses"); + dbOffline_courses.delete(); + } catch (Exception err) { + err.printStackTrace(); + } - try{ - String root = Environment.getExternalStorageDirectory().toString(); - File myDir = new File(root + "/ole_temp"); - String[] flist = myDir.list(); - for (int i = 0; i < flist.length; i++) { - System.out.println(" " + myDir.getAbsolutePath()); - File temp = new File(myDir.getAbsolutePath() + "/" + flist[i]); - if (temp.isDirectory()) { - Log.d("Delete ", " Deleting " + temp.getName()); - temp.delete(); - } else { - temp.delete(); - } + try { + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp"); + String[] flist = myDir.list(); + for (int i = 0; i < flist.length; i++) { + System.out.println(" " + myDir.getAbsolutePath()); + File temp = new File(myDir.getAbsolutePath() + "/" + flist[i]); + if (temp.isDirectory()) { + Log.d("Delete ", " Deleting " + temp.getName()); + temp.delete(); + } else { + temp.delete(); } - }catch (Exception err){ - Log.e("MYAPP", " Deleting materials from ole_temp directory "); } + } catch (Exception err) { + Log.e("MYAPP", " Deleting materials from ole_temp directory "); + } } - public void createConfigurations(){ + public void createConfigurations() { Manager manager = null; Database configuration; try { @@ -216,7 +260,7 @@ public void createConfigurations(){ } } - public void createMembers(){ + public void createMembers() { Manager manager = null; Database members; ArrayList rolesList = new ArrayList(); @@ -233,20 +277,20 @@ public void createMembers(){ newProperties.put("password", ""); newProperties.put("phone", "234562345"); newProperties.put("kind", "Member"); - newProperties.put("language","English"); + newProperties.put("language", "English"); newProperties.put("BirthDate", "1988-04-20T00:00:00.000Z"); newProperties.put("visits", 5); newProperties.put("Gender", "Female"); newProperties.put("levels", "Higher"); newProperties.put("community", "demo"); newProperties.put("nation", "earthbell"); - newProperties.put("login","learner"); + newProperties.put("login", "learner"); rolesList.add("Learner"); rolesList.add("Leader"); newProperties.put("roles", rolesList); - credentialMap.put("salt","c0a24b98e089b6b0f5d3674430cebe0c"); - credentialMap.put("value","53580b4213093aa7bda95c597d3eddfd7d5005d5"); - credentialMap.put("login","learner"); + credentialMap.put("salt", "c0a24b98e089b6b0f5d3674430cebe0c"); + credentialMap.put("value", "53580b4213093aa7bda95c597d3eddfd7d5005d5"); + credentialMap.put("login", "learner"); newProperties.put("credentials", credentialMap); newdocument.putProperties(newProperties); } catch (Exception e) { @@ -254,7 +298,7 @@ public void createMembers(){ } } - public void createShelf(){ + public void createShelf() { Manager manager = null; Database shelf; try { @@ -327,7 +371,6 @@ public void createShelf(){ newProperties9.put("resourceTitle", "Gender Awareness Workshop (en)"); newdocument9.putProperties(newProperties9); - Document newdocument10 = shelf.getDocument("e3d7ca503eef922213e36bf3d601c3c5"); Map newProperties10 = new HashMap(); newProperties10.put("memberId", "e3d7ca503eef922213e36bf3d60080c2"); @@ -340,9 +383,127 @@ public void createShelf(){ } } + public void shadowresources_demo() { + Manager manager = null; + Database shadowresources_demo; + try { + manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + shadowresources_demo = manager.getDatabase("shadowresources_demo"); + Document newdocument1 = shadowresources_demo.getDocument("d3f3756c79722902f983267053025c21"); + Map newProperties1 = new HashMap(); + newProperties1.put("author", "كامل كيلاني"); + newProperties1.put("language", "Arabic"); + newProperties1.put("Medium", "النص"); + newProperties1.put("uploadDate", "2015-12-02T05:00:00.000Z"); + newProperties1.put("averageRating", ""); + newProperties1.put("openWith", "PDF.js"); + newdocument1.putProperties(newProperties1); + Document newdocument2 = shadowresources_demo.getDocument("3a162fea1d56beb7a4441a4a8018e5b0"); + Map newProperties2 = new HashMap(); + newProperties2.put("author", "Clea McNeely, et al."); + newProperties2.put("language", "English"); + newProperties2.put("Medium", "Text"); + newProperties2.put("uploadDate", "2014-08-14T04:00:00.000Z"); + newProperties2.put("averageRating", ""); + newProperties2.put("openWith", "PDF.js"); + newdocument2.putProperties(newProperties2); + + Document newdocument3 = shadowresources_demo.getDocument("61461c3cf80877891652a143c3c77fed"); + Map newProperties3 = new HashMap(); + newProperties3.put("title", "Education in Emergency"); + newProperties3.put("author", ""); + newProperties3.put("language", "English"); + newProperties3.put("Medium", "Text"); + newProperties3.put("uploadDate", "2014-08-27T04:00:00.000Z"); + newProperties3.put("averageRating", ""); + newProperties3.put("openWith", "PDF.js"); + newdocument3.putProperties(newProperties3); + + Document newdocument4 = shadowresources_demo.getDocument("a28c81eac20e23529a5eda8e850eaeb3"); + Map newProperties4 = new HashMap(); + newProperties4.put("title", "Emergency Preparedness Plans"); + newProperties4.put("author", ""); + newProperties4.put("language", "English"); + newProperties4.put("Medium", "Text"); + newProperties4.put("uploadDate", "2015-05-01T04:00:00.000Z"); + newProperties4.put("averageRating", ""); + newProperties4.put("openWith", "PDF.js"); + newdocument4.putProperties(newProperties4); + + Document newdocument5 = shadowresources_demo.getDocument("68ec3d6c83989920cb75df8e5d01c449"); + Map newProperties5 = new HashMap(); + newProperties5.put("title", "Healthy Child Uganda VHT Training Manual: Paring a Community Emergency Transport Plan (CETP)"); + newProperties5.put("author", ""); + newProperties5.put("language", "English"); + newProperties5.put("Medium", "Text"); + newProperties5.put("uploadDate", "2015-05-01T04:00:00.000Z"); + newProperties5.put("averageRating", ""); + newProperties5.put("openWith", "PDF.js"); + newdocument5.putProperties(newProperties5); + + /* Document newdocument6 = shadowresources_demo.getDocument("68ec3d6c83989920cb75df8e5d01c449"); + Map newProperties6 = new HashMap(); + newProperties6.put("title", "Healthy Child Uganda VHT Training Manual: Paring a Community Emergency Transport Plan (CETP)"); + newProperties6.put("author", ""); + newProperties6.put("language", "English"); + newProperties6.put("Medium", "Text"); + newProperties6.put("uploadDate", "2015-05-01T04:00:00.000Z"); + newProperties6.put("averageRating", ""); + newdocument6.putProperties(newProperties6);*/ + + Document newdocument7 = shadowresources_demo.getDocument("86ba8cb7d819aa7068748640fb347ab1"); + Map newProperties7 = new HashMap(); + newProperties7.put("title", "Children in War: The role of Child to Child Activities in the Therapy and Care of Displaced Unaccompanied Children"); + newProperties7.put("author", ""); + newProperties7.put("language", "English"); + newProperties7.put("Medium", "Text"); + newProperties7.put("uploadDate", "2014-05-19T04:00:00.000Z"); + newProperties7.put("averageRating", ""); + newProperties7.put("openWith", "PDF.js"); + newdocument7.putProperties(newProperties7); + + Document newdocument8 = shadowresources_demo.getDocument("326b61c2ae2be1b31cb65891cbbf1536"); + Map newProperties8 = new HashMap(); + newProperties8.put("title", "Because I Am a Girl"); + newProperties8.put("author", ""); + newProperties8.put("language", "English"); + newProperties8.put("Medium", "Text"); + newProperties8.put("uploadDate", "2014-08-27T04:00:00.000Z"); + newProperties8.put("averageRating", ""); + newProperties8.put("openWith", "PDF.js"); + newdocument8.putProperties(newProperties8); - public void createMeetups(){ + Document newdocument9 = shadowresources_demo.getDocument("78c923afd67a7dc59b3f68b03b63bb17"); + Map newProperties9 = new HashMap(); + newProperties9.put("title", "Because I Am a Girl: A Year of Action and Innovation / Parce que je suis une fille: Une annee d’action et d’innovation (French)"); + newProperties9.put("author", ""); + newProperties9.put("language", "English"); + newProperties9.put("Medium", "Text"); + newProperties9.put("uploadDate", "2014-08-20T04:00:00.000Z"); + newProperties9.put("averageRating", ""); + newProperties9.put("openWith", "PDF.js"); + newdocument9.putProperties(newProperties9); + + Document newdocument10 = shadowresources_demo.getDocument("242a13d826420075a3ece5f0ea31b1fb"); + Map newProperties10 = new HashMap(); + newProperties10.put("title", "Gender Awareness Workshop (en)"); + newProperties10.put("author", ""); + newProperties10.put("language", "English"); + newProperties10.put("Medium", "Text"); + newProperties10.put("uploadDate", "2014-08-20T04:00:00.000Z"); + newProperties10.put("averageRating", ""); + newProperties10.put("openWith", "PDF.js"); + newdocument10.putProperties(newProperties10); + + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public void createMeetups() { /*AndroidContext androidContext = new AndroidContext(context); Manager manager = null; Database resourceRating; @@ -382,22 +543,27 @@ public void createMeetups(){ Log.e("MyCouch", "ERR : " + err.getMessage()); }*/ } - public void createUsermeetups(){ + public void createUsermeetups() { } - public void createAssignments(){ + + public void createAssignments() { } - public void createAssignmentpaper(){ + + public void createAssignmentpaper() { } - public void createCourseanswer(){ + + public void createCourseanswer() { } - public void createCoursequestion(){ + + public void createCoursequestion() { } - public void createCourses(){ + + public void createCourses() { Manager manager = null; Database course; ArrayList courseLeaderList = new ArrayList(); @@ -468,10 +634,12 @@ public void createCourses(){ }*/ } - public void createCourseschedule(){ + + public void createCourseschedule() { } - public void createCoursestep(){ + + public void createCoursestep() { Manager manager = null; Database coursestep; ArrayList resourceIdList = new ArrayList(); @@ -491,7 +659,7 @@ public void createCoursestep(){ newProperties.put("description", "This is Ekua. She was born a few weeks early and is very small. What can you do to improve Ekua’s chances?"); newProperties.put("stepGoals", ""); newProperties.put("step", "1"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -508,7 +676,7 @@ public void createCoursestep(){ newProperties.put("description", "In this learning object you will practice identifying babies that need kangaroo mother care and describe components of kangaroo mother care.\\n\\nThis lesson supports Physiology and Management of the High Risk Neonate in the Nursing Midwifery course."); newProperties.put("stepGoals", ""); newProperties.put("step", "2"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -526,7 +694,7 @@ public void createCoursestep(){ newProperties.put("stepGoals", ""); newProperties.put("step", "3"); resourceIdList.add("58a9ffe3ead5d4f48866867f02002dc6"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); resourceTitlesList.add("KMC_WHO_What_is_KMC"); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); @@ -545,7 +713,7 @@ public void createCoursestep(){ newProperties.put("stepGoals", ""); newProperties.put("step", "4"); resourceIdList.add("58a9ffe3ead5d4f48866867f0200385d"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); resourceTitlesList.add("Kangaroo Mother Care job"); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); @@ -563,7 +731,7 @@ public void createCoursestep(){ newProperties.put("description", "Low birth weight (LBW) is defined as birth weight of less than 2500 grams. There are three types of LBW babies: \\nPreterm: born before 37 completed weeks\\nVery preterm: born before 32 completed weeks\\nSmall for Gestational Age (SGA) or Small For Date (SFD): birth weight lower than expected for gestational age (may be term or preterm).\\nLBW infants may be born at any term."); newProperties.put("stepGoals", ""); newProperties.put("step", "5"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -580,7 +748,7 @@ public void createCoursestep(){ newProperties.put("description", "Remember the main components of KMC from the video and job aid? What are the three main components?"); newProperties.put("stepGoals", ""); newProperties.put("step", "6"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -597,7 +765,7 @@ public void createCoursestep(){ newProperties.put("description", "What did you say were the main components? Your answer should have included the following: \\nskin-to-skin positioning of a baby on the mother’s chest;\\nadequate nutrition through breastfeeding;\\nambulatory care as a result of earlier discharge from hospital; and support for the mother and her family in caring for the baby."); newProperties.put("stepGoals", ""); newProperties.put("step", "7"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -614,7 +782,7 @@ public void createCoursestep(){ newProperties.put("description", "Practice assessing a baby for gestational age and size in the simulation lab, use this checklist.\\n\\nNEED TO GET NEWBORN ASSESSMENT CHECKLIST FROM NMC"); newProperties.put("stepGoals", ""); newProperties.put("step", "8"); - newProperties.put("resourceId",resourceIdList ); + newProperties.put("resourceId", resourceIdList); newProperties.put("resourceTitles", resourceTitlesList); newProperties.put("questionslist", null); newProperties.put("passingPercentage", "10"); @@ -625,7 +793,8 @@ public void createCoursestep(){ } } - public void createMembercourseprogress(){ + + public void createMembercourseprogress() { Manager manager = null; Database membercourseprogress; ArrayList stepsIdsList = new ArrayList(); @@ -825,20 +994,25 @@ public void createMembercourseprogress(){ e.printStackTrace(); } } - public void createCalendar(){ + + + public void createCalendar() { } - public void createGroups(){ + + public void createGroups() { } - public void createInvitations(){ + + public void createInvitations() { } - public void createRequests(){ + + public void createRequests() { } - public void createLanguages(){ + public void createLanguages() { } diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myCourses.java b/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myCourses.java index 6c3e430..10724bd 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myCourses.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myCourses.java @@ -69,7 +69,7 @@ public class Fragm_myCourses extends Fragment { Manager manager; CouchViews chViews = new CouchViews(); - String resourceIdList[], resourceTitleList[],courseIdList[],courseTitleList[]; + String resourceIdList[], resourceTitleList[], courseIdList[], courseTitleList[]; int rsLstCnt, csLstCnt = 0; static Intent intent; Database database; @@ -187,6 +187,7 @@ public interface OnFragmentInteractionListener { // TODO: Update argument type and name void onFragmentInteraction(Uri uri); } + public void LoadMyCourses() { try { /// Todo remove bellow code @@ -210,7 +211,6 @@ public void LoadMyCourses() { }*/ - //maximus manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database course_db = manager.getExistingDatabase("courses"); @@ -220,10 +220,10 @@ public void LoadMyCourses() { courseIdList = new String[results.getCount()]; courseTitleList = new String[results.getCount()]; csLstCnt = 0; - String mycourseId=""; + String mycourseId = ""; String mycourseTitile; - String mycourseForgndColor="#000000"; - String mycourseBackgndColor="#FFFFFF"; + String mycourseForgndColor = "#000000"; + String mycourseBackgndColor = "#FFFFFF"; for (Iterator it = results; it.hasNext(); ) { QueryRow row = it.next(); String docId = (String) row.getValue(); @@ -251,8 +251,8 @@ public void LoadMyCourses() { doc = coursestep_Db.getExistingDocument(docId); Map coursestep_properties = doc.getProperties(); if (mycourseId.equals((String) coursestep_properties.get("courseId"))) { - course_step_resourceId = (ArrayList) coursestep_properties.get("resourceId"); - Log.e(TAG, "Course Step title " + ((String) coursestep_properties.get("title")) + " Step ID "+ docId); + course_step_resourceId = (ArrayList) coursestep_properties.get("resourceId"); + Log.e(TAG, "Course Step title " + ((String) coursestep_properties.get("title")) + " Step ID " + docId); Log.e(TAG, "Course Step Resources - " + course_step_resourceId.size() + " "); courseStepsCounter++; } @@ -308,10 +308,10 @@ public void LoadMyCourses() { if (local_downloaded_doc != null) { map.put(KEY_RESOURCE_STATUS, "downloaded"); } else { - if(course_step_resourceId.size()<1) { + if (course_step_resourceId.size() < 1) { map.put(KEY_RESOURCE_STATUS, "downloaded"); createCourseDoc((String) properties.get("_id"), course_step_resourceId.size()); - }else{ + } else { map.put(KEY_RESOURCE_STATUS, "not downloaded"); } } @@ -329,6 +329,7 @@ public void LoadMyCourses() { e.printStackTrace(); } } + public int getIconType(String myresExt) { int img = R.drawable.web; @@ -354,6 +355,7 @@ public int getIconType(String myresExt) { } return img; } + public void createCourseDoc(String manualCourseId, int numberOfSteps) { Database database = null; try { @@ -367,13 +369,14 @@ public void createCourseDoc(String manualCourseId, int numberOfSteps) { try { document.putProperties(properties); } catch (CouchbaseLiteException e) { - Log.e(TAG, "Cannot course details in offline courses"+ e.getMessage()); + Log.e(TAG, "Cannot course details in offline courses" + e.getMessage()); } } catch (Exception e) { e.printStackTrace(); } } + public void restorePref() { // Restore preferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0); @@ -393,7 +396,7 @@ public void restorePref() { sys_serverversion = settings.getString("pf_server_version", " "); } - private void crossfadeShowLoading(final View fromView,View toView) { + private void crossfadeShowLoading(final View fromView, View toView) { // Set the content view to 0% opacity but visible, so that it is visible // (but fully transparent) during the animation. diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myLibrary.java b/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myLibrary.java index 0dbfb47..2d1d146 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myLibrary.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/Fragm_myLibrary.java @@ -53,6 +53,7 @@ public class Fragm_myLibrary extends Fragment { sys_password, sys_usercouchId, sys_userfirstname, sys_userlastname, sys_usergender, sys_uservisits, sys_servername, sys_serverversion = ""; Boolean sys_singlefilestreamdownload, sys_multiplefilestreamdownload; + Boolean sys_appInDemoMode; int sys_uservisits_Int = 0; AndroidContext androidContext; Manager manager; @@ -117,7 +118,12 @@ public void LoadMyLibraryList() { try { manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database shelf_db = manager.getExistingDatabase("shelf"); - Database shadowresources_db = manager.getExistingDatabase("shadowresources"); + Database shadowresources_db; + if (sys_appInDemoMode) { + shadowresources_db = manager.getExistingDatabase("shadowresources_demo"); + } else { + shadowresources_db = manager.getExistingDatabase("shadowresources"); + } Database local_downloaded_resources = manager.getDatabase("resources"); Query orderedQuery = chViews.ReadShelfByIdView(shelf_db).createQuery(); orderedQuery.setDescending(true); @@ -140,7 +146,7 @@ public void LoadMyLibraryList() { Log.e(TAG, "Resource Title " + (String) shelf_properties.get("resourceTitle")); String buildDecript = "Description not available."; String buildRating = "0"; - String avgRating ="0"; + String avgRating = "0"; Boolean resourceDownloaded = false; HashMap map = new HashMap<>(); map.put(KEY_ID, myresId); @@ -151,13 +157,13 @@ public void LoadMyLibraryList() { Document local_downloaded_doc = local_downloaded_resources.getExistingDocument(myresId); Log.e(TAG, "Completed going to if " + myresTitile); - if(shadowresources_doc!=null){ + if (shadowresources_doc != null) { Map shadowresources_properties = shadowresources_doc.getProperties(); buildDecript = "Author : " + (String) shadowresources_properties.get("author") + " Language : " + (String) shadowresources_properties.get("language") + " \n" + " Resource Type : " + (String) shadowresources_properties.get("Medium") + " \n" + "Date Uploaded : " + (String) shadowresources_properties.get("uploadDate") + " "; buildRating = (((String) shadowresources_properties.get("averageRating")) == "") ? "2.2" : (String) shadowresources_properties.get("averageRating"); - avgRating =shadowresources_properties.get("averageRating").toString(); + avgRating = shadowresources_properties.get("averageRating").toString(); Log.e(TAG, "OBJECT FOUND - Item found in shadow resources " + myresTitile); } if (local_downloaded_doc != null) { @@ -173,18 +179,22 @@ public void LoadMyLibraryList() { } catch (Exception err) { Log.e(TAG, "ERROR NOT Found in shadow resources" + err.getMessage()); err.printStackTrace(); - // rsLstCnt++; + // rsLstCnt++; } Document local_downloaded_doc = local_downloaded_resources.getExistingDocument(myresId); - if(resourceDownloaded){ - map.put(KEY_RESOURCE_STATUS,"downloaded"); - }else{ - map.put(KEY_RESOURCE_STATUS,"not downloaded"); + if (resourceDownloaded) { + map.put(KEY_RESOURCE_STATUS, "downloaded"); + } else { + if (sys_appInDemoMode) { + map.put(KEY_RESOURCE_STATUS, "downloaded"); + } else { + map.put(KEY_RESOURCE_STATUS, "not downloaded"); + } } map.put(KEY_DESCRIPTION, buildDecript); map.put(KEY_DETAILS, myresId); - map.put(KEY_FEEDBACK,myresId); + map.put(KEY_FEEDBACK, myresId); map.put(KEY_DELETE, myresId); map.put(KEY_RATING, buildRating); map.put(KEY_TOTALNUM_RATING, "Rating (" + avgRating + ")"); @@ -241,6 +251,7 @@ public void restorePref() { sys_usergender = settings.getString("pf_usergender", ""); sys_uservisits = settings.getString("pf_uservisits", ""); sys_uservisits_Int = settings.getInt("pf_uservisits_Int", 0); + sys_appInDemoMode = settings.getBoolean("pf_appindemomode", false); sys_singlefilestreamdownload = settings.getBoolean("pf_singlefilestreamdownload", true); sys_multiplefilestreamdownload = settings.getBoolean("multiplefilestreamdownload", true); sys_servername = settings.getString("pf_server_name", " "); @@ -248,5 +259,4 @@ public void restorePref() { } - } \ No newline at end of file diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/FullscreenLogin.java b/app/src/main/java/pbell/offline/ole/org/pbell/FullscreenLogin.java index c73deb2..ff77ba9 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/FullscreenLogin.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/FullscreenLogin.java @@ -6,11 +6,14 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.net.wifi.WifiManager; import android.os.AsyncTask; import android.os.Build; import android.os.Environment; import android.support.annotation.RequiresApi; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.view.View; @@ -70,6 +73,7 @@ import android.os.Bundle; import android.util.Log; import android.widget.ImageButton; +import android.widget.Toast; /** * An example full-screen activity that shows and hides the system UI (i.e. @@ -90,6 +94,7 @@ public class FullscreenLogin extends AppCompatActivity { sys_password, sys_usercouchId, sys_userfirstname, sys_userlastname, sys_usergender, sys_uservisits, sys_servername, sys_serverversion, sys_NewDate = ""; Boolean sys_singlefilestreamdownload, sys_multiplefilestreamdownload; + Boolean sys_appInDemoMode = false; Object[] sys_membersWithResource; int sys_uservisits_Int; String Serverdate = null; @@ -98,7 +103,7 @@ public class FullscreenLogin extends AppCompatActivity { JSONObject jsonServerData; final Context context = this; String[] databaseList = {"members", "meetups", "usermeetups", "assignments", - "assignmentpaper","courseanswer","coursequestion","courses","courseschedule","coursestep","membercourseprogress", + "assignmentpaper", "courseanswer", "coursequestion", "courses", "courseschedule", "coursestep", "membercourseprogress", "calendar", "groups", "invitations", "configurations", "requests", "shelf", "languages"}; Replication[] push = new Replication[databaseList.length]; Replication[] pull = new Replication[databaseList.length]; @@ -109,10 +114,12 @@ public class FullscreenLogin extends AppCompatActivity { AndroidContext androidContext; Database database; Replication pullReplication; - Button dialogSyncButton,btnFeedback; - Boolean wipeClean =false; + Button dialogSyncButton, btnFeedback; + Boolean wipeClean = false; Intent serviceIntent; private static final String TAG = "LoginActivity"; + Button SignInButton; + private static final int REQUEST_WRITE_STORAGE = 112; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override @@ -127,17 +134,52 @@ protected void onCreate(Bundle savedInstanceState) { // Todo - : Decide on either to clear resource database and file storage anytime user syncs or rather keep old resources only if user doesn't change server url mUsername = (EditText) mContentView.findViewById(R.id.txtUsername); mPasswordView = (EditText) findViewById(R.id.txtPassword); + + SignInButton = (Button) findViewById(R.id.btnSignIn); + SignInButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + /*mDialog = new ProgressDialog(context); + mDialog.setMessage("Please wait. checking your credentials"); + mDialog.setCancelable(false); + mDialog.show();*/ + /* final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() {*/ + if (getSystemInfo()) { + if (authenticateUser()) { + if (updateActivityLog()) { + /* mDialog.dismiss();*/ + Intent intent = new Intent(context, User_Dashboard.class); + startActivity(intent); + } else { + alertDialogOkay("System Error. Please contact system manager"); + } + } else { + /*mDialog.dismiss();*/ + alertDialogOkay("Login incorrect / Not found. Check and try again."); + } + } else { + alertDialogOkay("Device not linked to a cummunity/nation. Use the setting button to sync with community/nation."); + } + /* } + }, 1000);*/ + } + }); // New UI - Button BecomeMemberButton = (Button) findViewById(R.id.btnBecomeMember); - BecomeMemberButton.setOnClickListener(new View.OnClickListener() { + Button DemoModeButton = (Button) findViewById(R.id.btnBecomeMember); + DemoModeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - /// alertDialogOkay("This feature has not been activated on this version."); + /// alertDialogOkay("This feature has not been activated on this version."); /// Demo Mode Code + sys_appInDemoMode = true; mUsername.setText("learner"); mPasswordView.setText("learner"); - DemoDataLoader demoDataLoader = new DemoDataLoader(context); - alertDialogOkay("Device configured for Demo. Click Sign-in"); + DemoDataLoader demoDataLoader = new DemoDataLoader(context, SignInButton); + + //alertDialogOkay("Device configured for Demo. Click Sign-in"); ///Intent intent = new Intent(context, Home.class); //startActivity(intent); @@ -154,38 +196,7 @@ public void onClick(View view) { } }); // - Button SignInButton = (Button) findViewById(R.id.btnSignIn); - SignInButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - /*mDialog = new ProgressDialog(context); - mDialog.setMessage("Please wait. checking your credentials"); - mDialog.setCancelable(false); - mDialog.show();*/ - /* final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() {*/ - if (getSystemInfo()){ - if (authenticateUser()) { - if (updateActivityLog()) { - /* mDialog.dismiss();*/ - Intent intent = new Intent(context, User_Dashboard.class); - startActivity(intent); - } else { - alertDialogOkay("System Error. Please contact system manager"); - } - } else { - /*mDialog.dismiss();*/ - alertDialogOkay("Login incorrect / Not found. Check and try again."); - } - }else{ - alertDialogOkay("Device not linked to a cummunity/nation. Use the setting button to sync with community/nation."); - } - /* } - }, 1000);*/ - } - }); + // New UI ImageButton SetupButton = (ImageButton) findViewById(R.id.btnSetup); @@ -198,8 +209,6 @@ public void onClick(View view) { // restorePref(); - //copyAPK(R.raw.adobe_reader, "adobe_reader.apk"); - //copyAPK(R.raw.firefox_49_0_multi_android, "firefox_49_0_multi_android.apk"); startServiceCommand(); btnFeedback = (Button) findViewById(R.id.btnFeedback); btnFeedback.setOnClickListener(new View.OnClickListener() { @@ -241,198 +250,221 @@ public void failure(Request request, Response response, FuelError fuelError) { }); } }); + + boolean hasPermission = (ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); + if (!hasPermission) { + ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_STORAGE); + } } + @Override public void onResume() { super.onResume(); updateUI(); } - public void sendfeedbackToServer(ProgressDialog feedbackDialog){ - Database resourceRating, activitylog, visits; - try { - // Get server date for activitylog update - GetServerDate gtSvDt = new GetServerDate(); - gtSvDt.setdbName("activitylog"); - gtSvDt.setView("date_now"); - gtSvDt.execute(""); - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "Getting date from server" + err); - } - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - resourceRating = manager.getDatabase("resourcerating"); - Query orderedQuery = chViews.ReadResourceRatingByIdView(resourceRating).createQuery(); - orderedQuery.setDescending(true); - QueryEnumerator results = orderedQuery.run(); - for (Iterator it = results; it.hasNext(); ) { - QueryRow row = it.next(); - String docId = (String) row.getValue(); - Document doc = resourceRating.getExistingDocument(docId); - Map properties = doc.getProperties(); - int sum = ((int) properties.get("sum")); - int timesRated = ((Integer) properties.get("timesRated")); - // Update server resources with new ratings - UpdateResourceDocument nwUpdateResDoc = new UpdateResourceDocument(); - nwUpdateResDoc.setResourceId(docId); - nwUpdateResDoc.setSum(sum); - nwUpdateResDoc.setTimesRated(timesRated); - nwUpdateResDoc.execute(""); - } - Database dbResources = manager.getDatabase("resourcerating"); - dbResources.delete(); - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading resource rating error " + err); - } - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - visits = manager.getDatabase("visits"); - Query orderedQuery = chViews.ReadMemberVisitsId(visits).createQuery(); - orderedQuery.setDescending(true); - QueryEnumerator results = orderedQuery.run(); - for (Iterator it = results; it.hasNext(); ) { - QueryRow row = it.next(); - String docId = (String) row.getValue(); - Document doc = visits.getExistingDocument(docId); - Map properties = doc.getProperties(); - int numOfVisits = ((Integer) properties.get("noOfVisits")); - Log.e("MyCouch", "Number Of visits for " + docId + " is " + numOfVisits); - // Update server members with visits - UpdateMemberVisitsDocument nwUpdateMemberVisits = new UpdateMemberVisitsDocument(); - nwUpdateMemberVisits.setMemberId(docId); - nwUpdateMemberVisits.setSumVisits(numOfVisits); - nwUpdateMemberVisits.execute(""); - } - Database visitsdb = manager.getDatabase("visits"); - visitsdb.delete(); - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading visits error " + err); - } - //// Read activitylog database details - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - activitylog = manager.getDatabase("activitylog"); - @SuppressLint("WifiManagerLeak") WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); - String m_WLANMAC = wm.getConnectionInfo().getMacAddress(); - Document doc = activitylog.getExistingDocument(m_WLANMAC); - Map properties = doc.getProperties(); - // Update server resources with new ratings - UpdateActivityLogDatabase nwActivityLog = new UpdateActivityLogDatabase(); - if (properties.get("female_visits") != null) { - nwActivityLog.set_female_visits(((Integer) properties.get("female_visits"))); - } else { - nwActivityLog.set_female_visits(0); - } - if (properties.get("male_visits") != null) { - nwActivityLog.set_male_visits(((Integer) properties.get("male_visits"))); - } else { - nwActivityLog.set_male_visits(0); - } - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading activity log " + err); - } - - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - resourceRating = manager.getDatabase("resourcerating"); - Query orderedQuery = chViews.ReadResourceRatingByIdView(resourceRating).createQuery(); - orderedQuery.setDescending(true); - QueryEnumerator results = orderedQuery.run(); - for (Iterator it = results; it.hasNext(); ) { - QueryRow row = it.next(); - String docId = (String) row.getValue(); - Document doc = resourceRating.getExistingDocument(docId); - Map properties = doc.getProperties(); - int sum = ((int) properties.get("sum")); - int timesRated = ((Integer) properties.get("timesRated")); - // Update server resources with new ratings - UpdateResourceDocument nwUpdateResDoc = new UpdateResourceDocument(); - nwUpdateResDoc.setResourceId(docId); - nwUpdateResDoc.setSum(sum); - nwUpdateResDoc.setTimesRated(timesRated); - nwUpdateResDoc.execute(""); - } - Database dbResources = manager.getDatabase("resourcerating"); - dbResources.delete(); - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading resource rating error " + err); - } - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - visits = manager.getDatabase("visits"); - Query orderedQuery = chViews.ReadMemberVisitsId(visits).createQuery(); - orderedQuery.setDescending(true); - QueryEnumerator results = orderedQuery.run(); - for (Iterator it = results; it.hasNext(); ) { - QueryRow row = it.next(); - String docId = (String) row.getValue(); - Document doc = visits.getExistingDocument(docId); - Map properties = doc.getProperties(); - int numOfVisits = ((Integer) properties.get("noOfVisits")); - Log.e("MyCouch", "Number Of visits for " + docId + " is " + numOfVisits); - // Update server members with visits - UpdateMemberVisitsDocument nwUpdateMemberVisits = new UpdateMemberVisitsDocument(); - nwUpdateMemberVisits.setMemberId(docId); - nwUpdateMemberVisits.setSumVisits(numOfVisits); - nwUpdateMemberVisits.execute(""); - } - Database dbResources = manager.getDatabase("visits"); - dbResources.delete(); - } catch (Exception err) { - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading visits error " + err); - } - //// Read activitylog database details - try { - Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); - activitylog = manager.getDatabase("activitylog"); - @SuppressLint("WifiManagerLeak") WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); - String m_WLANMAC = wm.getConnectionInfo().getMacAddress(); - Document doc = activitylog.getExistingDocument(m_WLANMAC); - Map properties = doc.getProperties(); - // Update server resources with new ratings - UpdateActivityLogDatabase nwActivityLog = new UpdateActivityLogDatabase(); - if (properties.get("female_visits") != null) { - nwActivityLog.set_female_visits(((Integer) properties.get("female_visits"))); - } else { - nwActivityLog.set_female_visits(0); - } - if (properties.get("male_visits") != null) { - nwActivityLog.set_male_visits(((Integer) properties.get("male_visits"))); - } else { - nwActivityLog.set_male_visits(0); - } - nwActivityLog.set_female_opened((ArrayList) properties.get("female_opened")); - nwActivityLog.set_female_rating(((ArrayList) properties.get("female_rating"))); - nwActivityLog.set_female_timesRated(((ArrayList) properties.get("female_timesRated"))); - nwActivityLog.set_male_opened(((ArrayList) properties.get("male_opened"))); - nwActivityLog.set_male_rating(((ArrayList) properties.get("male_rating"))); - nwActivityLog.set_male_timesRated(((ArrayList) properties.get("male_timesRated"))); - nwActivityLog.set_resources_names(((ArrayList) properties.get("resources_names"))); - nwActivityLog.set_resources_opened(((ArrayList) properties.get("resources_opened"))); - nwActivityLog.set_resourcesIds(((ArrayList) properties.get("resourcesIds"))); - nwActivityLog.execute(""); - feedbackDialog.dismiss(); - updateUI(); - } catch (Exception err) { - updateUI(); - feedbackDialog.dismiss(); - alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); - Log.e("MyCouch", "reading activity log error " + err); - } - - - } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + switch (requestCode) { + case REQUEST_WRITE_STORAGE: { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + //reload my activity with permission granted or use the features what required the permission + } else { + Toast.makeText(this, "The app was not allowed to write to your storage. Hence, it cannot function properly. Please consider granting it this permission", Toast.LENGTH_LONG).show(); + } + } + } + + } + + public void sendfeedbackToServer(ProgressDialog feedbackDialog) { + Database resourceRating, activitylog, visits; + try { + // Get server date for activitylog update + GetServerDate gtSvDt = new GetServerDate(); + gtSvDt.setdbName("activitylog"); + gtSvDt.setView("date_now"); + gtSvDt.execute(""); + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "Getting date from server" + err); + } + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + resourceRating = manager.getDatabase("resourcerating"); + Query orderedQuery = chViews.ReadResourceRatingByIdView(resourceRating).createQuery(); + orderedQuery.setDescending(true); + QueryEnumerator results = orderedQuery.run(); + for (Iterator it = results; it.hasNext(); ) { + QueryRow row = it.next(); + String docId = (String) row.getValue(); + Document doc = resourceRating.getExistingDocument(docId); + Map properties = doc.getProperties(); + int sum = ((int) properties.get("sum")); + int timesRated = ((Integer) properties.get("timesRated")); + // Update server resources with new ratings + UpdateResourceDocument nwUpdateResDoc = new UpdateResourceDocument(); + nwUpdateResDoc.setResourceId(docId); + nwUpdateResDoc.setSum(sum); + nwUpdateResDoc.setTimesRated(timesRated); + nwUpdateResDoc.execute(""); + } + Database dbResources = manager.getDatabase("resourcerating"); + dbResources.delete(); + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading resource rating error " + err); + } + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + visits = manager.getDatabase("visits"); + Query orderedQuery = chViews.ReadMemberVisitsId(visits).createQuery(); + orderedQuery.setDescending(true); + QueryEnumerator results = orderedQuery.run(); + for (Iterator it = results; it.hasNext(); ) { + QueryRow row = it.next(); + String docId = (String) row.getValue(); + Document doc = visits.getExistingDocument(docId); + Map properties = doc.getProperties(); + int numOfVisits = ((Integer) properties.get("noOfVisits")); + Log.e("MyCouch", "Number Of visits for " + docId + " is " + numOfVisits); + // Update server members with visits + UpdateMemberVisitsDocument nwUpdateMemberVisits = new UpdateMemberVisitsDocument(); + nwUpdateMemberVisits.setMemberId(docId); + nwUpdateMemberVisits.setSumVisits(numOfVisits); + nwUpdateMemberVisits.execute(""); + } + Database visitsdb = manager.getDatabase("visits"); + visitsdb.delete(); + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading visits error " + err); + } + //// Read activitylog database details + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + activitylog = manager.getDatabase("activitylog"); + @SuppressLint("WifiManagerLeak") WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); + String m_WLANMAC = wm.getConnectionInfo().getMacAddress(); + Document doc = activitylog.getExistingDocument(m_WLANMAC); + Map properties = doc.getProperties(); + // Update server resources with new ratings + UpdateActivityLogDatabase nwActivityLog = new UpdateActivityLogDatabase(); + if (properties.get("female_visits") != null) { + nwActivityLog.set_female_visits(((Integer) properties.get("female_visits"))); + } else { + nwActivityLog.set_female_visits(0); + } + if (properties.get("male_visits") != null) { + nwActivityLog.set_male_visits(((Integer) properties.get("male_visits"))); + } else { + nwActivityLog.set_male_visits(0); + } + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading activity log " + err); + } + + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + resourceRating = manager.getDatabase("resourcerating"); + Query orderedQuery = chViews.ReadResourceRatingByIdView(resourceRating).createQuery(); + orderedQuery.setDescending(true); + QueryEnumerator results = orderedQuery.run(); + for (Iterator it = results; it.hasNext(); ) { + QueryRow row = it.next(); + String docId = (String) row.getValue(); + Document doc = resourceRating.getExistingDocument(docId); + Map properties = doc.getProperties(); + int sum = ((int) properties.get("sum")); + int timesRated = ((Integer) properties.get("timesRated")); + // Update server resources with new ratings + UpdateResourceDocument nwUpdateResDoc = new UpdateResourceDocument(); + nwUpdateResDoc.setResourceId(docId); + nwUpdateResDoc.setSum(sum); + nwUpdateResDoc.setTimesRated(timesRated); + nwUpdateResDoc.execute(""); + } + Database dbResources = manager.getDatabase("resourcerating"); + dbResources.delete(); + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading resource rating error " + err); + } + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + visits = manager.getDatabase("visits"); + Query orderedQuery = chViews.ReadMemberVisitsId(visits).createQuery(); + orderedQuery.setDescending(true); + QueryEnumerator results = orderedQuery.run(); + for (Iterator it = results; it.hasNext(); ) { + QueryRow row = it.next(); + String docId = (String) row.getValue(); + Document doc = visits.getExistingDocument(docId); + Map properties = doc.getProperties(); + int numOfVisits = ((Integer) properties.get("noOfVisits")); + Log.e("MyCouch", "Number Of visits for " + docId + " is " + numOfVisits); + // Update server members with visits + UpdateMemberVisitsDocument nwUpdateMemberVisits = new UpdateMemberVisitsDocument(); + nwUpdateMemberVisits.setMemberId(docId); + nwUpdateMemberVisits.setSumVisits(numOfVisits); + nwUpdateMemberVisits.execute(""); + } + Database dbResources = manager.getDatabase("visits"); + dbResources.delete(); + } catch (Exception err) { + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading visits error " + err); + } + //// Read activitylog database details + try { + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + activitylog = manager.getDatabase("activitylog"); + @SuppressLint("WifiManagerLeak") WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); + String m_WLANMAC = wm.getConnectionInfo().getMacAddress(); + Document doc = activitylog.getExistingDocument(m_WLANMAC); + Map properties = doc.getProperties(); + // Update server resources with new ratings + UpdateActivityLogDatabase nwActivityLog = new UpdateActivityLogDatabase(); + if (properties.get("female_visits") != null) { + nwActivityLog.set_female_visits(((Integer) properties.get("female_visits"))); + } else { + nwActivityLog.set_female_visits(0); + } + if (properties.get("male_visits") != null) { + nwActivityLog.set_male_visits(((Integer) properties.get("male_visits"))); + } else { + nwActivityLog.set_male_visits(0); + } + nwActivityLog.set_female_opened((ArrayList) properties.get("female_opened")); + nwActivityLog.set_female_rating(((ArrayList) properties.get("female_rating"))); + nwActivityLog.set_female_timesRated(((ArrayList) properties.get("female_timesRated"))); + nwActivityLog.set_male_opened(((ArrayList) properties.get("male_opened"))); + nwActivityLog.set_male_rating(((ArrayList) properties.get("male_rating"))); + nwActivityLog.set_male_timesRated(((ArrayList) properties.get("male_timesRated"))); + nwActivityLog.set_resources_names(((ArrayList) properties.get("resources_names"))); + nwActivityLog.set_resources_opened(((ArrayList) properties.get("resources_opened"))); + nwActivityLog.set_resourcesIds(((ArrayList) properties.get("resourcesIds"))); + nwActivityLog.execute(""); + feedbackDialog.dismiss(); + updateUI(); + } catch (Exception err) { + updateUI(); + feedbackDialog.dismiss(); + alertDialogOkay("Device can not send feedback data. Check connection to server and try again"); + Log.e("MyCouch", "reading activity log error " + err); + } + + + } + //////// private void TestConnectionToServer(String textURL) { mDialog = new ProgressDialog(context); @@ -462,6 +494,7 @@ public void success(Request request, Response response, String s) { e.printStackTrace(); } } + @Override public void failure(Request request, Response response, FuelError fuelError) { mDialog.dismiss(); @@ -480,7 +513,7 @@ protected void onPostCreate(Bundle savedInstanceState) { public boolean authenticateUser() { AndroidContext androidContext = new AndroidContext(this); Manager manager = null; - /// getSystemInfo(); + /// getSystemInfo(); try { manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database db = manager.getExistingDatabase("members"); @@ -494,62 +527,63 @@ public boolean authenticateUser() { Map properties = doc.getProperties(); String doc_loginId = (String) properties.get("login"); String doc_password = (String) properties.get("password"); - if (doc_password == "" && !mPasswordView.getText().toString().equals("")) { - if (mUsername.getText().toString().equals(doc_loginId)) { - try { - Map doc_credentials = (Map) properties.get("credentials"); - AndroidDecrypter adc = new AndroidDecrypter(); - SharedPreferences.Editor editor = settings.edit(); - String ServerName = settings.getString("pf_server_code", ""); - - Log.e(TAG, " User Login " + (String) properties.get("login")); - Log.e(TAG, " User id " + (String) properties.get("_id")); - Log.e(TAG, " User ServerName " + ServerName); - Log.e(TAG, " User Value " + doc_credentials.get("value").toString()); - Log.e(TAG, " User Community " + (String) properties.get("community")); - - if (adc.AndroidDecrypter(doc_loginId, mPasswordView.getText().toString(), doc_credentials.get("value").toString())) { - Log.e(TAG, " Got Here 1"); - if (ServerName.equalsIgnoreCase((String) properties.get("community"))) { - Log.e(TAG, " Got Here 2"); - editor.putString("pf_username", (String) properties.get("login")); - editor.putString("pf_password", (String) properties.get("password")); - editor.putString("pf_usercouchId", (String) properties.get("_id")); - editor.putString("pf_userfirstname", (String) properties.get("firstName")); - editor.putString("pf_userlastname", (String) properties.get("lastName")); - editor.putString("pf_usergender", (String) properties.get("Gender")); - sys_usergender = (String) properties.get("Gender"); - try { - String noOfVisits = properties.get("visits").toString(); - int currentTotalVisits = Integer.parseInt(noOfVisits) + totalVisits((String) properties.get("_id")); - editor.putInt("pf_uservisits_Int", currentTotalVisits); - editor.putString("pf_uservisits", currentTotalVisits + ""); - editor.putString("pf_lastVisitDate", doc_lastVisit); - } catch (Exception err) { - alertDialogOkay(err.getMessage()); - err.printStackTrace(); - } - Set stgSet = settings.getStringSet("pf_userroles", new HashSet()); - ArrayList roleList = (ArrayList) properties.get("roles"); - for (int cnt = 0; cnt < roleList.size(); cnt++) { - stgSet.add(String.valueOf(roleList.get(cnt))); - } - editor.putStringSet("pf_userroles", stgSet); - editor.commit(); - Log.e("MYAPP", " RowChipsView Login Id: " + doc_loginId + " Password: " + doc_password); - restorePref(); - return true; - } - } - - } catch (Exception err) { - Log.e("MYAPP", " Encryption Err " + err.getMessage()); - err.printStackTrace(); - return false; - } - } + if (doc_password == "" && !mPasswordView.getText().toString().equals("")) { + if (mUsername.getText().toString().equals(doc_loginId)) { + try { + Map doc_credentials = (Map) properties.get("credentials"); + AndroidDecrypter adc = new AndroidDecrypter(); + SharedPreferences.Editor editor = settings.edit(); + String ServerName = settings.getString("pf_server_code", ""); + + Log.e(TAG, " User Login " + (String) properties.get("login")); + Log.e(TAG, " User id " + (String) properties.get("_id")); + Log.e(TAG, " User ServerName " + ServerName); + Log.e(TAG, " User Value " + doc_credentials.get("value").toString()); + Log.e(TAG, " User Community " + (String) properties.get("community")); + + if (adc.AndroidDecrypter(doc_loginId, mPasswordView.getText().toString(), doc_credentials.get("value").toString())) { + Log.e(TAG, " Got Here 1"); + if (ServerName.equalsIgnoreCase((String) properties.get("community"))) { + Log.e(TAG, " Got Here 2"); + editor.putString("pf_username", (String) properties.get("login")); + editor.putString("pf_password", (String) properties.get("password")); + editor.putString("pf_usercouchId", (String) properties.get("_id")); + editor.putString("pf_userfirstname", (String) properties.get("firstName")); + editor.putString("pf_userlastname", (String) properties.get("lastName")); + editor.putString("pf_usergender", (String) properties.get("Gender")); + editor.putBoolean("pf_appindemomode", sys_appInDemoMode); + sys_usergender = (String) properties.get("Gender"); + try { + String noOfVisits = properties.get("visits").toString(); + int currentTotalVisits = Integer.parseInt(noOfVisits) + totalVisits((String) properties.get("_id")); + editor.putInt("pf_uservisits_Int", currentTotalVisits); + editor.putString("pf_uservisits", currentTotalVisits + ""); + editor.putString("pf_lastVisitDate", doc_lastVisit); + } catch (Exception err) { + alertDialogOkay(err.getMessage()); + err.printStackTrace(); + } + Set stgSet = settings.getStringSet("pf_userroles", new HashSet()); + ArrayList roleList = (ArrayList) properties.get("roles"); + for (int cnt = 0; cnt < roleList.size(); cnt++) { + stgSet.add(String.valueOf(roleList.get(cnt))); + } + editor.putStringSet("pf_userroles", stgSet); + editor.commit(); + Log.e("MYAPP", " RowChipsView Login Id: " + doc_loginId + " Password: " + doc_password); + restorePref(); + return true; + } + } + + } catch (Exception err) { + Log.e("MYAPP", " Encryption Err " + err.getMessage()); + err.printStackTrace(); + return false; + } + } } else if (mUsername.getText().toString().equals(doc_loginId)) { - Log.e(TAG, " Got Here 3"); + Log.e(TAG, " Got Here 3"); if (mPasswordView.getText().toString().equals(doc_password) && !properties.containsKey("credentials")) { Log.e(TAG, " Got Here 4"); SharedPreferences.Editor editor = settings.edit(); @@ -559,6 +593,7 @@ public boolean authenticateUser() { editor.putString("pf_userfirstname", (String) properties.get("firstName")); editor.putString("pf_userlastname", (String) properties.get("lastName")); editor.putString("pf_usergender", (String) properties.get("Gender")); + editor.putBoolean("pf_appindemomode", sys_appInDemoMode); sys_usergender = (String) properties.get("Gender"); try { String noOfVisits = properties.get("visits").toString(); @@ -678,7 +713,7 @@ public boolean updateActivityLog() { //This is for setting the MAC address if it is being run in a android emulator. String m_WLANMAC; m_WLANMAC = wm.getConnectionInfo().getMacAddress(); - if(m_WLANMAC == null) { + if (m_WLANMAC == null) { m_WLANMAC = "mymac"; } @@ -715,14 +750,15 @@ public boolean updateActivityLog() { } } - public String todaysDate(){ + public String todaysDate() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); Log.e("MyCouch", "System Date : " + dateFormat.format(cal.getTime())); return dateFormat.format(cal.getTime()); } - public void getSyncURLDialog(){ + + public void getSyncURLDialog() { @SuppressLint("WifiManagerLeak") final WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); AlertDialog.Builder dialogB = new AlertDialog.Builder(this); dialogB.setView(R.layout.dialog_setup); @@ -743,18 +779,18 @@ public void onClick(View view) { chBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if(isChecked){ - wipeClean =true; - }else{ - wipeClean=false; + if (isChecked) { + wipeClean = true; + } else { + wipeClean = false; } Log.e("MYAPP", " Wipe clean is now " + isChecked); } }); //// - sys_singlefilestreamdownload =settings.getBoolean("pf_singlefilestreamdownload",true); - sys_multiplefilestreamdownload = settings.getBoolean("multiplefilestreamdownload",true); + sys_singlefilestreamdownload = settings.getBoolean("pf_singlefilestreamdownload", true); + sys_multiplefilestreamdownload = settings.getBoolean("multiplefilestreamdownload", true); dialogSyncButton = (Button) dialog.findViewById(R.id.btnNewSaveSyncURL); dialogSyncButton.setOnClickListener(new View.OnClickListener() { @@ -777,14 +813,14 @@ public void onClick(View v) { } }); dialogSyncButton.setVisibility(View.INVISIBLE); - if(wifiManager.isWifiEnabled()) { + if (wifiManager.isWifiEnabled()) { dialog.show(); //// - }else{ + } else { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface int_dialog, int which) { - switch (which){ + switch (which) { case DialogInterface.BUTTON_POSITIVE: //Yes button clicked wifiManager.setWifiEnabled(true); @@ -804,7 +840,8 @@ public void onClick(DialogInterface int_dialog, int which) { .setNegativeButton("No", dialogClickListener).show(); } } - public void setDateDialog(){ + + public void setDateDialog() { @SuppressLint("WifiManagerLeak") final WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); AlertDialog.Builder dialogB = new AlertDialog.Builder(this); dialogB.setView(R.layout.dialog_date); @@ -813,7 +850,7 @@ public void setDateDialog(){ dialog.show(); Button saveDate = (Button) dialog.findViewById(R.id.btnSaveDate); final DatePicker dp = (DatePicker) dialog.findViewById(R.id.datePicker); - String day = String.valueOf(dp.getDayOfMonth())+"-"+String.valueOf(dp.getMonth() + 1) +"-"+String.valueOf(dp.getYear()); + String day = String.valueOf(dp.getDayOfMonth()) + "-" + String.valueOf(dp.getMonth() + 1) + "-" + String.valueOf(dp.getYear()); Log.e("MyCouch", " date " + day); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); try { @@ -832,60 +869,63 @@ public void onClick(View view) { } }); } - public void restorePref(){ + + public void restorePref() { // Restore preferences settings = getSharedPreferences(PREFS_NAME, 0); - sys_username = settings.getString("pf_username",""); - sys_oldSyncServerURL = settings.getString("pf_sysncUrl","http://"); - sys_lastSyncDate = settings.getString("pf_lastSyncDate",""); - sys_password = settings.getString("pf_password",""); - sys_usercouchId = settings.getString("pf_usercouchId",""); - sys_userfirstname = settings.getString("pf_userfirstname",""); - sys_userlastname = settings.getString("pf_userlastname",""); - sys_usergender = settings.getString("pf_usergender",""); - sys_uservisits = settings.getString("pf_uservisits","");; - sys_uservisits_Int = settings.getInt("pf_uservisits_Int",0); - sys_singlefilestreamdownload =settings.getBoolean("pf_singlefilestreamdownload",true); - sys_multiplefilestreamdownload = settings.getBoolean("multiplefilestreamdownload",true); - sys_servername = settings.getString("pf_server_name"," "); - sys_serverversion = settings.getString("pf_server_version"," "); - - if(sys_username!=""){ + sys_username = settings.getString("pf_username", ""); + sys_oldSyncServerURL = settings.getString("pf_sysncUrl", "http://"); + sys_lastSyncDate = settings.getString("pf_lastSyncDate", ""); + sys_password = settings.getString("pf_password", ""); + sys_usercouchId = settings.getString("pf_usercouchId", ""); + sys_userfirstname = settings.getString("pf_userfirstname", ""); + sys_userlastname = settings.getString("pf_userlastname", ""); + sys_usergender = settings.getString("pf_usergender", ""); + sys_uservisits = settings.getString("pf_uservisits", ""); + ; + sys_uservisits_Int = settings.getInt("pf_uservisits_Int", 0); + sys_singlefilestreamdownload = settings.getBoolean("pf_singlefilestreamdownload", true); + sys_multiplefilestreamdownload = settings.getBoolean("multiplefilestreamdownload", true); + sys_servername = settings.getString("pf_server_name", " "); + sys_serverversion = settings.getString("pf_server_version", " "); + + if (sys_username != "") { mUsername.setText(sys_username); - }else{ + } else { mUsername.setText(""); } - Set mwr = settings.getStringSet("membersWithResource",null); - try{ + Set mwr = settings.getStringSet("membersWithResource", null); + try { sys_membersWithResource = mwr.toArray(); - Log.e("MYAPP", " membersWithResource = "+sys_membersWithResource.length); + Log.e("MYAPP", " membersWithResource = " + sys_membersWithResource.length); - }catch(Exception err){ + } catch (Exception err) { Log.e("MYAPP", " Error creating sys_membersWithResource"); } - try{ - serviceIntent = new Intent(context,ServerSearchService.class); + try { + serviceIntent = new Intent(context, ServerSearchService.class); context.stopService(serviceIntent); - }catch(Exception error) { - Log.e("MYAPP", " Creating Service error "+error.getMessage()); + } catch (Exception error) { + Log.e("MYAPP", " Creating Service error " + error.getMessage()); } } - public void startServiceCommand(){ - try{ - serviceIntent = new Intent(context,ServerSearchService.class); + public void startServiceCommand() { + try { + serviceIntent = new Intent(context, ServerSearchService.class); serviceIntent.putExtra("serverUrl", sys_oldSyncServerURL); context.startService(serviceIntent); - }catch(Exception err){ - Log.e("MYAPP", " Creating Service error "+err.getMessage()); + } catch (Exception err) { + Log.e("MYAPP", " Creating Service error " + err.getMessage()); } } - public void syncNotifier(){ + + public void syncNotifier() { emptyAllDbs(); - try{ + try { /// Todo Decide either use design document in apps or not JsonObject filterContent = new JsonObject(); - filterContent.addProperty("by_resource","function(doc, req){return doc._id === req.query._id;}"); + filterContent.addProperty("by_resource", "function(doc, req){return doc._id === req.query._id;}"); RunCreateDocTask newRunCreateFilterTask = new RunCreateDocTask(); newRunCreateFilterTask.setDbName("resources"); newRunCreateFilterTask.setDocNameId("_design/apps"); @@ -894,16 +934,16 @@ public void syncNotifier(){ newRunCreateFilterTask.setViewContent(filterContent); newRunCreateFilterTask.execute(""); - }catch(Exception err){ + } catch (Exception err) { Log.e("MYAPP", err.getMessage()); } - try{ + try { JsonObject viewContent = new JsonObject(); - viewContent.addProperty("map","function() { var now = new Date().toLocaleDateString(); " + + viewContent.addProperty("map", "function() { var now = new Date().toLocaleDateString(); " + "var output = JSON.parse(JSON.stringify(now)); emit(output, output); }"); JsonObject dateViewContent = new JsonObject(); - dateViewContent.add("date_now",viewContent); + dateViewContent.add("date_now", viewContent); RunCreateDocTask newRunCreateViewTask = new RunCreateDocTask(); newRunCreateViewTask.setDbName("activitylog"); newRunCreateViewTask.setDocNameId("_design/apps"); @@ -912,22 +952,23 @@ public void syncNotifier(){ newRunCreateViewTask.setViewContent(dateViewContent); newRunCreateViewTask.execute(""); - }catch(Exception err){ + } catch (Exception err) { Log.e("MYAPP", err.getMessage()); } ResourcesJson rsj = new ResourcesJson(); - if(rsj.ResourcesJson(sys_oldSyncServerURL,"resources",androidContext)){ + if (rsj.ResourcesJson(sys_oldSyncServerURL, "resources", androidContext)) { startSyncProcess(); } ///// End creating design Document } + public void emptyAllDbs() { - if(wipeClean) { + if (wipeClean) { for (int cnt = 0; cnt < databaseList.length; cnt++) { try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database db = manager.getDatabase(databaseList[cnt]); - Log.e("MYAPP","Deleting "+databaseList[cnt]); + Log.e("MYAPP", "Deleting " + databaseList[cnt]); db.delete(); } catch (Exception e) { e.printStackTrace(); @@ -938,25 +979,25 @@ public void emptyAllDbs() { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database dbResources = manager.getDatabase("resources"); dbResources.delete(); - }catch(Exception err){ + } catch (Exception err) { err.printStackTrace(); } try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database dbResources = manager.getDatabase("shadowresources"); dbResources.delete(); - }catch(Exception err){ + } catch (Exception err) { err.printStackTrace(); } try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database dbOffline_courses = manager.getDatabase("offline_courses"); dbOffline_courses.delete(); - }catch(Exception err){ + } catch (Exception err) { err.printStackTrace(); } - try{ + try { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/ole_temp"); String[] flist = myDir.list(); @@ -970,31 +1011,33 @@ public void emptyAllDbs() { temp.delete(); } } - }catch (Exception err){ + } catch (Exception err) { Log.e("MYAPP", " Deleting materials from ole_tem directory "); } } } - public void startSyncProcess(){ + + public void startSyncProcess() { /// Start Syncing databases from server final AsyncTask execute = new FullscreenLogin.TestAsyncPull().execute(); Log.e("MyCouch", "syncNotifier Running"); final Thread th = new Thread(new Runnable() { private long startTime = System.currentTimeMillis(); + public void run() { while (syncmembers) { runOnUiThread(new Runnable() { @Override public void run() { - if(openMemberList) { + if (openMemberList) { mDialog.dismiss(); - openMemberList=false; + openMemberList = false; alertDialogOkay("Completed. Thank you for waiting, you can now \" Sign In \" ."); - syncmembers=false; + syncmembers = false; return; } Log.d("runOnUiThread", "running pull members"); - mDialog.setMessage("Downloading, please wait ... " + databaseList[syncCnt] +" ["+ (syncCnt+1) +" / "+ databaseList.length+"]"); + mDialog.setMessage("Downloading, please wait ... " + databaseList[syncCnt] + " [" + (syncCnt + 1) + " / " + databaseList.length + "]"); } }); try { @@ -1007,7 +1050,8 @@ public void run() { }); th.start(); } - public void alertDialogOkay(String Message){ + + public void alertDialogOkay(String Message) { AlertDialog.Builder builder1 = new AlertDialog.Builder(context); builder1.setMessage(Message); builder1.setCancelable(true); @@ -1020,14 +1064,15 @@ public void onClick(DialogInterface dialog, int id) { AlertDialog alert11 = builder1.create(); alert11.show(); } + private void copyAPK(int resource, String apkUrl) { InputStream in = getResources().openRawResource(resource); String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/ole_temp2"); - if (!myDir.exists()){ + if (!myDir.exists()) { myDir.mkdirs(); } - File dst = new File(myDir,apkUrl); + File dst = new File(myDir, apkUrl); try { FileOutputStream out = new FileOutputStream(dst); byte[] buff = new byte[1024]; @@ -1037,11 +1082,12 @@ private void copyAPK(int resource, String apkUrl) { } in.close(); out.close(); - Log.e("tag", "Adobe Reader Copied "+ dst.toString()); - }catch(Exception err){ + Log.e("tag", "Adobe Reader Copied " + dst.toString()); + } catch (Exception err) { err.printStackTrace(); } } + class RunCreateDocTask extends AsyncTask { private Exception exception; private String cls_SyncServerURL; @@ -1049,51 +1095,62 @@ class RunCreateDocTask extends AsyncTask { private String cls_DocNameId; private String cls_Category; private JsonObject cls_ViewContent; - public String getSyncServerURL(){ + + public String getSyncServerURL() { return cls_SyncServerURL; } - public void setSyncServerURL(String oldSyncServerURL){ + + public void setSyncServerURL(String oldSyncServerURL) { cls_SyncServerURL = oldSyncServerURL; } - public String getDbName(){ + + public String getDbName() { return cls_DbName; } - public void setDbName(String dbName){ + + public void setDbName(String dbName) { cls_DbName = dbName; } - public String getDocNameId(){ + + public String getDocNameId() { return cls_DocNameId; } - public void setCategory(String category){ + + public void setCategory(String category) { cls_Category = category; } - public String getCategory(){ + + public String getCategory() { return cls_Category; } - public void setDocNameId(String docNameId){ + + public void setDocNameId(String docNameId) { cls_DocNameId = docNameId; } - public JsonObject getViewContent(){ + + public JsonObject getViewContent() { return cls_ViewContent; } + public void setViewContent(JsonObject viewContent) { cls_ViewContent = viewContent; } + protected Boolean doInBackground(String... urls) { try { - Log.e("MyCouch", "URL = "+getSyncServerURL()); + Log.e("MyCouch", "URL = " + getSyncServerURL()); URI uri = URI.create(getSyncServerURL()); String url_Scheme = uri.getScheme(); String url_Host = uri.getHost(); int url_Port = uri.getPort(); String url_user = null, url_pwd = null; - if(sys_oldSyncServerURL.contains("@")){ + if (sys_oldSyncServerURL.contains("@")) { String[] userinfo = uri.getUserInfo().split(":"); url_user = userinfo[0]; url_pwd = userinfo[1]; } CouchDbClientAndroid dbClient = new CouchDbClientAndroid(getDbName(), true, url_Scheme, url_Host, url_Port, url_user, url_pwd); - if(!dbClient.contains(URLEncoder.encode(getDocNameId(), "UTF-8"))){ + if (!dbClient.contains(URLEncoder.encode(getDocNameId(), "UTF-8"))) { JsonObject json = new JsonObject(); json.addProperty("_id", getDocNameId()); json.add(getCategory(), getViewContent()); @@ -1106,39 +1163,42 @@ protected Boolean doInBackground(String... urls) { return false; } } + protected void onPostExecute(Boolean docResult) { startSyncProcess(); } } + class TestAsyncPull extends AsyncTask { - protected void onPreExecute (){ - Log.d("PreExceute","On pre Exceute......"); + protected void onPreExecute() { + Log.d("PreExceute", "On pre Exceute......"); } - protected String doInBackground(Void...arg0) { - Log.d("DoINBackGround","On doInBackground..."); - syncmembers =true; - pull= new Replication[databaseList.length]; + + protected String doInBackground(Void... arg0) { + Log.d("DoINBackGround", "On doInBackground..."); + syncmembers = true; + pull = new Replication[databaseList.length]; db = new Database[databaseList.length]; manager = new Manager[databaseList.length]; try { manager[syncCnt] = new Manager(androidContext, Manager.DEFAULT_OPTIONS); db[syncCnt] = manager[syncCnt].getDatabase(databaseList[syncCnt]); - URL url = new URL(sys_oldSyncServerURL+"/"+databaseList[syncCnt]); - pull[syncCnt]= db[syncCnt].createPullReplication(url); + URL url = new URL(sys_oldSyncServerURL + "/" + databaseList[syncCnt]); + pull[syncCnt] = db[syncCnt].createPullReplication(url); pull[syncCnt].setContinuous(false); pull[syncCnt].addChangeListener(new Replication.ChangeListener() { @Override public void changed(Replication.ChangeEvent event) { - if(pull[syncCnt] .isRunning()){ - Log.e("MyCouch", databaseList[syncCnt]+" "+event.getChangeCount()); - }else { - Log.e("Finished", databaseList[syncCnt]+" "+ db[syncCnt].getDocumentCount()); - if(syncCnt < (databaseList.length-2)){ + if (pull[syncCnt].isRunning()) { + Log.e("MyCouch", databaseList[syncCnt] + " " + event.getChangeCount()); + } else { + Log.e("Finished", databaseList[syncCnt] + " " + db[syncCnt].getDocumentCount()); + if (syncCnt < (databaseList.length - 2)) { syncCnt++; new FullscreenLogin.TestAsyncPull().execute(); - }else{ - Log.e("MyCouch","Sync Completed"); - if(!openMemberList) { + } else { + Log.e("MyCouch", "Sync Completed"); + if (!openMemberList) { openMemberList = true; } } @@ -1147,38 +1207,46 @@ public void changed(Replication.ChangeEvent event) { }); pull[syncCnt].start(); } catch (Exception e) { - Log.e("MyCouch", databaseList[syncCnt]+" "+" Cannot create database", e); + Log.e("MyCouch", databaseList[syncCnt] + " " + " Cannot create database", e); } publishProgress(syncCnt); return "You are at PostExecute"; } - protected void onProgressUpdate(Integer...a){ - Log.d("onProgress","You are in progress update ... " + a[0]); - if(syncCnt != (databaseList.length-2)){ - }else{ + + protected void onProgressUpdate(Integer... a) { + Log.d("onProgress", "You are in progress update ... " + a[0]); + if (syncCnt != (databaseList.length - 2)) { + } else { } } + protected void onPostExecute(String result) { - Log.d("OnPostExec",""+result); + Log.d("OnPostExec", "" + result); } } + class UpdateMemberVisitsDocument extends AsyncTask { private Exception exception; private String cls_memberId; private int cls_sumVisits; private int cls_serverNewTotalVisits; - public String getMemberId(){ + + public String getMemberId() { return cls_memberId; } - public void setMemberId(String memberId){ + + public void setMemberId(String memberId) { cls_memberId = memberId; } - public int getSumVisits(){ + + public int getSumVisits() { return cls_sumVisits; } - public void setSumVisits(int sumVisits){ + + public void setSumVisits(int sumVisits) { cls_sumVisits = sumVisits; } + protected String doInBackground(String... urls) { try { URI uri = URI.create(sys_oldSyncServerURL); @@ -1186,26 +1254,27 @@ protected String doInBackground(String... urls) { String url_Host = uri.getHost(); int url_Port = uri.getPort(); String url_user = null, url_pwd = null; - if(sys_oldSyncServerURL.contains("@")){ + if (sys_oldSyncServerURL.contains("@")) { String[] userinfo = uri.getUserInfo().split(":"); url_user = userinfo[0]; url_pwd = userinfo[1]; } CouchDbClientAndroid dbClient = new CouchDbClientAndroid("members", true, url_Scheme, url_Host, url_Port, url_user, url_pwd); - if(dbClient.contains(cls_memberId)){ + if (dbClient.contains(cls_memberId)) { /// Handle with Json JsonObject json = dbClient.find(JsonObject.class, getMemberId()); cls_serverNewTotalVisits = (getSumVisits() + Integer.parseInt(json.get("visits").getAsString())); - json.addProperty("visits",cls_serverNewTotalVisits); + json.addProperty("visits", cls_serverNewTotalVisits); dbClient.update(json); } return ""; } catch (Exception e) { this.exception = e; - Log.e("MyCouch","Updating member visits on server "+ e.getMessage()); + Log.e("MyCouch", "Updating member visits on server " + e.getMessage()); return null; } } + protected void onPostExecute(String message) { AndroidContext androidContext = new AndroidContext(context); Manager manager = null; @@ -1222,42 +1291,52 @@ protected void onPostExecute(String message) { retrievedDocument.putProperties(newProperties); } } - }catch(Exception err){ - Log.e("MyCouch","Updating local member visits on device "+ err.getMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Updating local member visits on device " + err.getMessage()); } } } + class UpdateResourceDocument extends AsyncTask { private Exception exception; private String cls_resouceId; private int cls_sum; private int cls_timesRated; private String cls_revision; - public String getResourceId(){ + + public String getResourceId() { return cls_resouceId; } - public void setResourceId(String resouceId){ + + public void setResourceId(String resouceId) { cls_resouceId = resouceId; } - public void getRevision(String revision){ + + public void getRevision(String revision) { cls_revision = revision; } - public String setRevision(){ + + public String setRevision() { return cls_revision; } - public int getSum(){ + + public int getSum() { return cls_sum; } - public void setSum(int sum){ + + public void setSum(int sum) { cls_sum = sum; } - public int getTimesRated(){ + + public int getTimesRated() { return cls_timesRated; } + public void setTimesRated(int timesRated) { cls_timesRated = timesRated; } + protected String doInBackground(String... urls) { try { URI uri = URI.create(sys_oldSyncServerURL); @@ -1265,7 +1344,7 @@ protected String doInBackground(String... urls) { String url_Host = uri.getHost(); int url_Port = uri.getPort(); String url_user = null, url_pwd = null; - if(sys_oldSyncServerURL.contains("@")){ + if (sys_oldSyncServerURL.contains("@")) { String[] userinfo = uri.getUserInfo().split(":"); url_user = userinfo[0]; url_pwd = userinfo[1]; @@ -1274,14 +1353,14 @@ protected String doInBackground(String... urls) { // //} CouchDbClientAndroid dbClient = new CouchDbClientAndroid("resources", true, url_Scheme, url_Host, url_Port, url_user, url_pwd); - if(dbClient.contains(cls_resouceId)){ + if (dbClient.contains(cls_resouceId)) { /// Handle with Json JsonObject json = dbClient.find(JsonObject.class, getResourceId()); int total_sum = (int) (getSum() + Integer.parseInt(json.get("sum").getAsString())); - int total_timesRated = getTimesRated() + Integer.parseInt(json.get("timesRated").toString()); - json.addProperty("sum",total_sum); - json.addProperty("timesRated",total_timesRated); - dbClient.update(json); + int total_timesRated = getTimesRated() + Integer.parseInt(json.get("timesRated").toString()); + json.addProperty("sum", total_sum); + json.addProperty("timesRated", total_timesRated); + dbClient.update(json); } return ""; } catch (Exception e) { @@ -1290,25 +1369,83 @@ protected String doInBackground(String... urls) { return null; } } + protected void onPostExecute(String message) { } } + class UpdateActivityLogDatabase extends AsyncTask { - private int cls_male_visits,cls_female_visits; - private ArrayList cls_male_rating,cls_male_timesRated,cls_female_timesRated,cls_female_rating,cls_resourcesIds; - private ArrayList cls_male_opened,cls_female_opened,cls_resources_names,cls_resources_opened; - public void set_resourcesIds(ArrayList resourcesIds){cls_resourcesIds=resourcesIds;}; - public void set_resources_names(ArrayList resources_names){cls_resources_names=resources_names;}; - public void set_resources_opened(ArrayList resources_opened){cls_resources_opened=resources_opened;}; - public void set_male_visits(int male_visits){cls_male_visits=male_visits;}; - public void set_female_visits(int female_visits){cls_female_visits=female_visits;}; - public void set_male_rating(ArrayList male_rating){cls_male_rating=male_rating;}; - public void set_female_rating(ArrayList female_rating){cls_female_rating=female_rating;}; - public void set_male_timesRated(ArrayList male_timesRated){cls_male_timesRated=male_timesRated;}; - public void set_female_timesRated(ArrayList female_timesRated){cls_female_timesRated=female_timesRated;}; - public void set_male_opened(ArrayList male_opened){cls_male_opened=male_opened;}; - public void set_female_opened(ArrayList female_opened){cls_female_opened=female_opened;}; + private int cls_male_visits, cls_female_visits; + private ArrayList cls_male_rating, cls_male_timesRated, cls_female_timesRated, cls_female_rating, cls_resourcesIds; + private ArrayList cls_male_opened, cls_female_opened, cls_resources_names, cls_resources_opened; + + public void set_resourcesIds(ArrayList resourcesIds) { + cls_resourcesIds = resourcesIds; + } + + ; + + public void set_resources_names(ArrayList resources_names) { + cls_resources_names = resources_names; + } + + ; + + public void set_resources_opened(ArrayList resources_opened) { + cls_resources_opened = resources_opened; + } + + ; + + public void set_male_visits(int male_visits) { + cls_male_visits = male_visits; + } + + ; + + public void set_female_visits(int female_visits) { + cls_female_visits = female_visits; + } + + ; + + public void set_male_rating(ArrayList male_rating) { + cls_male_rating = male_rating; + } + + ; + + public void set_female_rating(ArrayList female_rating) { + cls_female_rating = female_rating; + } + + ; + + public void set_male_timesRated(ArrayList male_timesRated) { + cls_male_timesRated = male_timesRated; + } + + ; + + public void set_female_timesRated(ArrayList female_timesRated) { + cls_female_timesRated = female_timesRated; + } + + ; + + public void set_male_opened(ArrayList male_opened) { + cls_male_opened = male_opened; + } + + ; + + public void set_female_opened(ArrayList female_opened) { + cls_female_opened = female_opened; + } + + ; + protected String doInBackground(String... urls) { try { URI uri = URI.create(sys_oldSyncServerURL); @@ -1316,7 +1453,7 @@ protected String doInBackground(String... urls) { String url_Host = uri.getHost(); int url_Port = uri.getPort(); String url_user = null, url_pwd = null; - if(sys_oldSyncServerURL.contains("@")){ + if (sys_oldSyncServerURL.contains("@")) { String[] userinfo = uri.getUserInfo().split(":"); url_user = userinfo[0]; url_pwd = userinfo[1]; @@ -1325,28 +1462,28 @@ protected String doInBackground(String... urls) { // //} CouchDbClientAndroid dbClient = new CouchDbClientAndroid("activitylog", true, url_Scheme, url_Host, url_Port, url_user, url_pwd); - org.lightcouch.View view= dbClient.view("bell/getdocBylogdate").includeDocs(false); + org.lightcouch.View view = dbClient.view("bell/getdocBylogdate").includeDocs(false); List results = view.reduce(false).includeDocs(false).query(Map.class); String todaysActivityDocId = null; String docDateStr = null; - int i= 0; + int i = 0; if (results.size() != 0) { - while (i < results.size()){ + while (i < results.size()) { LinkedTreeMap treemap = (LinkedTreeMap) results.get(i).get("value"); Gson gson = new Gson(); JsonObject jsonObject = gson.toJsonTree(treemap).getAsJsonObject(); docDateStr = jsonObject.get("logDate").getAsString(); - Log.e("MyCouch",i+" "+ docDateStr +" - "+ jsonObject.get("_id").toString()); + Log.e("MyCouch", i + " " + docDateStr + " - " + jsonObject.get("_id").toString()); // Todo convert to date Compare date, month, year - if(docDateStr.equalsIgnoreCase(Serverdate)){ + if (docDateStr.equalsIgnoreCase(Serverdate)) { todaysActivityDocId = jsonObject.get("_id").getAsString(); - Log.e("MyCouch","Found "+docDateStr+" with Id "+todaysActivityDocId); + Log.e("MyCouch", "Found " + docDateStr + " with Id " + todaysActivityDocId); break; } i++; } //// Check if activitylog document for today exist - if(docDateStr!=null && todaysActivityDocId !=null ){ + if (docDateStr != null && todaysActivityDocId != null) { try { Gson gson = new Gson(); JsonParser parser = new JsonParser(); @@ -1355,81 +1492,81 @@ protected String doInBackground(String... urls) { JsonArray female_opened_Array = jsonObject.get("female_opened").getAsJsonArray(); JsonElement female_opened_Element = parser.parse(gson.toJson(cls_female_opened)); Log.e("MyCouch", "Begun -- "); - try{ + try { female_opened_Array.addAll(female_opened_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_opened "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_opened " + err.getLocalizedMessage()); } //male_rating JsonArray male_rating_Array = jsonObject.get("male_rating").getAsJsonArray(); JsonElement male_rating_Element = parser.parse(gson.toJson(cls_male_rating)); - try{ + try { male_rating_Array.addAll(male_rating_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_rating "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_rating " + err.getLocalizedMessage()); } //male_timesRated JsonArray male_timesRated_Array = jsonObject.get("male_timesRated").getAsJsonArray(); JsonElement male_timesRated_Element = parser.parse(gson.toJson(cls_male_timesRated)); - try{ + try { male_timesRated_Array.addAll(male_timesRated_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_timesRated "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_timesRated " + err.getLocalizedMessage()); } //female_timesRated JsonArray female_timesRated_Array = jsonObject.get("female_timesRated").getAsJsonArray(); JsonElement female_timesRated_Element = parser.parse(gson.toJson(cls_female_timesRated)); - try{ + try { female_timesRated_Array.addAll(female_timesRated_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_timesRated "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_timesRated " + err.getLocalizedMessage()); } //female_rating JsonArray female_rating_Array = jsonObject.get("female_rating").getAsJsonArray(); JsonElement female_rating_Element = parser.parse(gson.toJson(cls_female_rating)); - try{ + try { female_rating_Array.addAll(female_rating_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_rating "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_rating " + err.getLocalizedMessage()); } //resourcesIds JsonArray resourcesIds_Array = jsonObject.get("resourcesIds").getAsJsonArray(); JsonElement resourcesIds_Element = parser.parse(gson.toJson(cls_resourcesIds)); - try{ + try { resourcesIds_Array.addAll(resourcesIds_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to resourcesIds "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to resourcesIds " + err.getLocalizedMessage()); } //male_opened JsonArray male_opened_Array = jsonObject.get("male_opened").getAsJsonArray(); JsonElement male_opened_Element = parser.parse(gson.toJson(cls_male_opened)); - try{ + try { male_opened_Array.addAll(male_opened_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_opened "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_opened " + err.getLocalizedMessage()); } //resources_names JsonArray resources_names_Array = jsonObject.get("resources_names").getAsJsonArray(); JsonElement resources_names_Element = parser.parse(gson.toJson(cls_resources_names)); - try{ + try { resources_names_Array.addAll(resources_names_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to resources_names "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to resources_names " + err.getLocalizedMessage()); } //resources_opened JsonArray resources_opened_Array = jsonObject.get("resources_opened").getAsJsonArray(); JsonElement resources_opened_Element = parser.parse(gson.toJson(cls_resources_opened)); - try{ + try { resources_opened_Array.addAll(resources_opened_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to resources_opened "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to resources_opened " + err.getLocalizedMessage()); } Log.e("MyCouch", "Ended -- "); int totalMaleVisits = (cls_male_visits + jsonObject.get("male_visits").getAsInt()); jsonObject.addProperty("male_visits", totalMaleVisits); - int totalFemaleVisits = (cls_female_visits+ jsonObject.get("female_visits").getAsInt()); - jsonObject.addProperty("female_visits",totalFemaleVisits); + int totalFemaleVisits = (cls_female_visits + jsonObject.get("female_visits").getAsInt()); + jsonObject.addProperty("female_visits", totalFemaleVisits); jsonObject.add("female_opened", female_opened_Array); jsonObject.add("male_rating", male_rating_Array); jsonObject.add("male_timesRated", male_timesRated_Array); @@ -1440,10 +1577,10 @@ protected String doInBackground(String... urls) { jsonObject.add("resources_names", resources_names_Array); jsonObject.add("resources_opened", resources_opened_Array); dbClient.update(jsonObject); - }catch(Exception err){ - Log.e("MyCouch", "Error updating existing activity log "+ err.getMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Error updating existing activity log " + err.getMessage()); } - }else{ + } else { try { Gson gson = new Gson(); JsonParser parser = new JsonParser(); @@ -1452,74 +1589,74 @@ protected String doInBackground(String... urls) { //female_opened JsonArray female_opened_Array = new JsonArray(); JsonElement female_opened_Element = parser.parse(gson.toJson(cls_female_opened)); - try{ + try { female_opened_Array.addAll(female_opened_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_opened "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_opened " + err.getLocalizedMessage()); } //male_rating JsonArray male_rating_Array = new JsonArray(); JsonElement male_rating_Element = parser.parse(gson.toJson(cls_male_rating)); - try{ - male_rating_Array.addAll(male_rating_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_rating "+err.getLocalizedMessage()); + try { + male_rating_Array.addAll(male_rating_Element.getAsJsonArray()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_rating " + err.getLocalizedMessage()); } //male_timesRated JsonArray male_timesRated_Array = new JsonArray(); JsonElement male_timesRated_Element = parser.parse(gson.toJson(cls_male_timesRated)); - try{ + try { male_timesRated_Array.addAll(male_timesRated_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_timesRated "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_timesRated " + err.getLocalizedMessage()); } //female_timesRated JsonArray female_timesRated_Array = new JsonArray(); JsonElement female_timesRated_Element = parser.parse(gson.toJson(cls_female_timesRated)); - try{ + try { female_timesRated_Array.addAll(female_timesRated_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_timesRated "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_timesRated " + err.getLocalizedMessage()); } //female_rating JsonArray female_rating_Array = new JsonArray(); JsonElement female_rating_Element = parser.parse(gson.toJson(cls_female_rating)); - try{ + try { female_rating_Array.addAll(female_rating_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to female_rating "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to female_rating " + err.getLocalizedMessage()); } //resourcesIds JsonArray resourcesIds_Array = new JsonArray(); JsonElement resourcesIds_Element = parser.parse(gson.toJson(cls_resourcesIds)); - try{ + try { resourcesIds_Array.addAll(resourcesIds_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to resourcesIds "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to resourcesIds " + err.getLocalizedMessage()); } //male_opened JsonArray male_opened_Array = new JsonArray(); JsonElement male_opened_Element = parser.parse(gson.toJson(cls_male_opened)); - try{ + try { male_opened_Array.addAll(male_opened_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to male_opened "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to male_opened " + err.getLocalizedMessage()); } //resources_names JsonArray resources_names_Array = new JsonArray(); JsonElement resources_names_Element = parser.parse(gson.toJson(cls_resources_names)); - try{ + try { resources_names_Array.addAll(resources_names_Element.getAsJsonArray()); - }catch(Exception err){ - Log.e("MyCouch", "Got to resources_names "+err.getLocalizedMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Got to resources_names " + err.getLocalizedMessage()); } //resources_opened Log.e("MyCouch", "Ended New Activity Resource -- "); JsonArray resources_opened_Array = new JsonArray(); JsonElement resources_opened_Element = parser.parse(gson.toJson(cls_resources_opened)); - try{ + try { resources_opened_Array.addAll(resources_opened_Element.getAsJsonArray()); - }catch (Exception err){ + } catch (Exception err) { Log.e("MyCouch", "Opened resources null " + err.getMessage()); err.printStackTrace(); } @@ -1537,8 +1674,8 @@ protected String doInBackground(String... urls) { jsonObject.add("resources_names", resources_names_Array); jsonObject.add("resources_opened", resources_opened_Array); dbClient.save(jsonObject); - }catch(Exception err){ - Log.e("MyCouch", "Error writing new activity log data "+ err.getMessage()); + } catch (Exception err) { + Log.e("MyCouch", "Error writing new activity log data " + err.getMessage()); err.printStackTrace(); } } @@ -1549,8 +1686,9 @@ protected String doInBackground(String... urls) { return null; } } + protected void onPostExecute(String message) { - try{ + try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); Database activitylog = manager.getDatabase("activitylog"); activitylog.delete(); @@ -1560,11 +1698,12 @@ protected void onPostExecute(String message) { //String m_WLANMAC = wm.getConnectionInfo().getMacAddress(); //Document doc = activitylog.getExistingDocument(m_WLANMAC); //doc.delete(); - }catch(Exception err){ + } catch (Exception err) { Log.e("MyCouch", "Error deleting document from activitylog " + err.getMessage()); } } } + private void updateUI() { try { Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); @@ -1580,7 +1719,7 @@ private void updateUI() { btnFeedback.setTextColor(getResources().getColor(R.color.ole_white)); btnFeedback.setEnabled(false); } - }catch(Exception err){ + } catch (Exception err) { } /*runOnUiThread(new Runnable() { @@ -1596,27 +1735,33 @@ public void run() { } });*/ } + class GetServerDate extends AsyncTask { private Exception exception; private String cls_dbName; private String cls_View; - public String getdbName(){ + + public String getdbName() { return cls_dbName; } - public void setdbName(String dbName){ + + public void setdbName(String dbName) { cls_dbName = dbName; } - public String getView(){ + + public String getView() { return cls_View; } - public void setView(String view){ + + public void setView(String view) { cls_View = view; } + protected String doInBackground(String... urls) { Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); Serverdate = df.format(c.getTime()); - Log.e("MyCouch", "Current Date: "+Serverdate.toString()); + Log.e("MyCouch", "Current Date: " + Serverdate.toString()); /*try { URI uri = URI.create(sys_oldSyncServerURL); @@ -1648,6 +1793,7 @@ protected String doInBackground(String... urls) { */ return ""; } + protected void onPostExecute(String message) { // TODO: check this.exception // TODO: do something with the message diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/ListViewAdapter_myLibrary.java b/app/src/main/java/pbell/offline/ole/org/pbell/ListViewAdapter_myLibrary.java index 981dd28..80ca2f6 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/ListViewAdapter_myLibrary.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/ListViewAdapter_myLibrary.java @@ -75,16 +75,18 @@ public class ListViewAdapter_myLibrary extends BaseAdapter { private ProgressDialog mDialog; private long resources_enqueue; boolean singleFileDownload = true; - int universalHtmlCnt=0; + int universalHtmlCnt = 0; public static final String PREFS_NAME = "MyPrefsFile"; /// String String sys_oldSyncServerURL, sys_username, sys_lastSyncDate, sys_password, sys_usercouchId, sys_userfirstname, sys_userlastname, sys_usergender, sys_uservisits, sys_servername, sys_serverversion = ""; + + Boolean sys_appInDemoMode; String OneByOneResID, OneByOneResTitle; - String openWith ,title ,author,language,resourceType,uploadDate ; - JsonArray subject ; + String openWith, title, author, language, resourceType, uploadDate; + JsonArray subject; SharedPreferences settings; List resIDArrayList = new ArrayList<>(); List htmlResFileList = new ArrayList<>(); @@ -92,15 +94,14 @@ public class ListViewAdapter_myLibrary extends BaseAdapter { LogHouse logHouse = new LogHouse(); protected int _splashTime = 5000; private Thread splashTread; - Context contextTry =null; + Context contextTry = null; String openedResourceId, openedResourceTitle = ""; boolean openedResource = false; - private String downloadCompleteIntentName = DownloadManager.ACTION_DOWNLOAD_COMPLETE; private IntentFilter downloadCompleteIntentFilter = new IntentFilter(downloadCompleteIntentName); - private OnResouceListListener mListener; + private OnResouceListListener mListener; public ListViewAdapter_myLibrary(final List resIDsList, Activity a, Context cont, ArrayList> d) { resIDArrayList.addAll(resIDsList); @@ -159,7 +160,6 @@ public void onReceive(Context context, Intent intent) { } - public int getCount() { return data.size(); } @@ -286,10 +286,11 @@ public void restorePreferences(Activity activity) { sys_usergender = settings.getString("pf_usergender", ""); sys_uservisits = settings.getString("pf_uservisits", ""); sys_servername = settings.getString("pf_server_name", " "); + sys_appInDemoMode = settings.getBoolean("pf_appindemomode", false); sys_serverversion = settings.getString("pf_server_version", " "); } - public void createResourceDoc(String manualResId, String manualResTitle, String manualResopenWith, String manualauthor,String manuallanguage,JsonArray manualsubject,String manualresourceType,String manualuploadDate) { + public void createResourceDoc(String manualResId, String manualResTitle, String manualResopenWith, String manualauthor, String manuallanguage, JsonArray manualsubject, String manualresourceType, String manualuploadDate) { Database database = null; try { AndroidContext androidContext = new AndroidContext(context); @@ -306,10 +307,10 @@ public void createResourceDoc(String manualResId, String manualResTitle, String properties.put("uploadDate", manualuploadDate); // properties.put("resourceType", manualResType); Document document = database.getDocument(manualResId); - Log.e(TAG, "Saving document called " + manualResTitle + "- "+ manualResId); + Log.e(TAG, "Saving document called " + manualResTitle + "- " + manualResId); try { document.putProperties(properties); - Log.e(TAG, "Saved document called " + manualResTitle + "- "+ manualResId); + Log.e(TAG, "Saved document called " + manualResTitle + "- " + manualResId); } catch (Exception e) { Log.e(TAG, "Cannot save document" + e.getLocalizedMessage()); e.printStackTrace(); @@ -321,6 +322,7 @@ public void createResourceDoc(String manualResId, String manualResTitle, String } public void buttonAction(String resourceId, String action) { + restorePreferences(activity); switch (action) { case "Delete": break; @@ -334,11 +336,19 @@ public void buttonAction(String resourceId, String action) { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mDialog.setMessage("Please wait..."); mDialog.setCancelable(true); - mDialog.show(); - if (openResources(resourceId)) { - Log.i(TAG, "Open Clicked ********** " + resourceId); +////// mDialog.show(); + if (sys_appInDemoMode) { + if (openDemoResources(resourceId)) { + Log.i(TAG, "Demo Mode Open Clicked ********** " + resourceId); + } else { + Log.i(TAG, "Demo Mode Open ********** " + resourceId); + } } else { - Log.i(TAG, "Open ********** " + resourceId); + if (openResources(resourceId)) { + Log.i(TAG, "Open Clicked ********** " + resourceId); + } else { + Log.i(TAG, "Open ********** " + resourceId); + } } break; case "Download": @@ -370,8 +380,8 @@ public void downloadWithDownloadManagerSingleFile(String fileURL, String FileNam request.setDestinationInExternalPublicDir("ole_temp", FileName); // get download service and enqueue file mDialog.setMessage("Downloading \" " + OneByOneResTitle + " \" . please wait..."); - // resources_downloadManager = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE); - // resources_enqueue = resources_downloadManager.enqueue(request); + // resources_downloadManager = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE); + // resources_enqueue = resources_downloadManager.enqueue(request); DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); resources_enqueue = downloadManager.enqueue(request); @@ -379,6 +389,7 @@ public void downloadWithDownloadManagerSingleFile(String fileURL, String FileNam public interface OnResouceListListener { void onResourceDownloadCompleted(String CourseId, Object data); + void onResourceOpened(String resourceId, String resourceTitle); } @@ -386,7 +397,7 @@ class downloadSpecificResourceToDisk extends AsyncTask { @Override protected Boolean doInBackground(String... params) { try { - Log.e(TAG,"URL " + sys_oldSyncServerURL); + Log.e(TAG, "URL " + sys_oldSyncServerURL); URI uri = URI.create(sys_oldSyncServerURL); String url_Scheme = uri.getScheme(); String url_Host = uri.getHost(); @@ -430,7 +441,7 @@ public void run() { }); } } else { - try{ + try { JSONObject _attachments = new JSONObject(jsonAttachments.toString()); Iterator iter = _attachments.keys(); while (iter.hasNext()) { @@ -442,7 +453,7 @@ public void run() { e.printStackTrace(); } } - }catch(Exception err){ + } catch (Exception err) { mDialog.dismiss(); alertDialogOkay("Download was not successful. Check the connection to the server, resource metadata or contact manager for assistance "); } @@ -459,7 +470,7 @@ public void run() { if (!fileDir.mkdirs()) { Log.i(TAG, "Problem creating folders" + fileDir.getAbsolutePath()); } - }else{ + } else { Log.i(TAG, "Folders exists" + fileDir.getAbsolutePath()); } } catch (Exception err) { @@ -470,7 +481,7 @@ public void run() { activity.runOnUiThread(new Runnable() { @Override public void run() { - new DownloadHTMLFileFromURL().execute(sys_oldSyncServerURL + "/resources/" + OneByOneResID + "/" + htmlResFileList.get(0)); + new DownloadHTMLFileFromURL().execute(sys_oldSyncServerURL + "/resources/" + OneByOneResID + "/" + htmlResFileList.get(0)); } }); } catch (Exception err) { @@ -494,6 +505,171 @@ public void run() { } } + public Boolean openDemoResources(String id) { + String resourceIdTobeOpened = id; + Log.d(TAG, "Trying to open resource " + id); + try { + AndroidContext androidContext = new AndroidContext(context); + Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Database res_Db = manager.getExistingDatabase("shadowresources_demo"); + Document res_doc = res_Db.getExistingDocument(resourceIdTobeOpened); + openWith = (String) res_doc.getProperty("openWith"); + String openResName = (String) res_doc.getProperty("title"); + openedResourceId = resourceIdTobeOpened; + openedResourceTitle = openResName; + ///openFromDiskDirectly = true; + logHouse.updateActivityOpenedResources(context, sys_usercouchId, resourceIdTobeOpened, openResName); + Log.e("MYAPP", " member opening resource = " + resourceIdTobeOpened + " and Open with " + openWith); + /// List attmentNames = res_doc.getCurrentRevision().getAttachmentNames(); + //// PDF and Bell-Reader + if (openWith.equalsIgnoreCase("PDF.js") || (openWith.equalsIgnoreCase("Bell-Reader"))) { + Log.e(TAG, " Command name -: " + resourceIdTobeOpened); + String filenameOnly = ""; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp"); + if (!myDir.exists()) { + myDir.mkdirs(); + } + for (File f : myDir.listFiles()) { + if (f.isFile()) { + if (f.getName().indexOf(".") > 0) { + filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); + } + Log.e(TAG, " File name -: " + f.getName() + " Filename only " + filenameOnly); + if (filenameOnly.equalsIgnoreCase(resourceIdTobeOpened)) { + try { + mDialog.dismiss(); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setPackage("com.adobe.reader"); + intent.setDataAndType(Uri.fromFile(f), "application/pdf"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } catch (Exception err) { + err.printStackTrace(); + myDir = new File(Environment.getExternalStorageDirectory().toString() + "/ole_temp2"); + File dst = new File(myDir, "adobe_reader.apk"); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(dst), "application/vnd.android.package-archive"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + } + } + } +////MP3 + } else if (openWith.equalsIgnoreCase("MP3")) { + Log.e("MyCouch", " Command Video name -: " + resourceIdTobeOpened); + String filenameOnly = ""; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp"); + for (File f : myDir.listFiles()) { + if (f.isFile()) { + if (f.getName().indexOf(".") > 0) { + filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); + } + Log.e("MyCouch", " File name -: " + f.getName() + " Filename only " + filenameOnly); + if (filenameOnly.equalsIgnoreCase(resourceIdTobeOpened)) { + mDialog.dismiss(); + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(f).toString()); + String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + intent.setDataAndType(Uri.fromFile(f), mimetype); + context.startActivity(intent); + } + } + } +///// VIDEO or Video Book Player + } else if (openWith.equalsIgnoreCase("Flow Video Player") || (openWith.equalsIgnoreCase("Native Video"))) { + Log.e("MyCouch", " Command Video name -: " + resourceIdTobeOpened); + String filenameOnly = ""; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp"); + for (File f : myDir.listFiles()) { + if (f.isFile()) { + if (f.getName().indexOf(".") > 0) { + filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); + } + Log.e("MyCouch", " File name -: " + f.getName() + " Filename only " + filenameOnly); + if (filenameOnly.equalsIgnoreCase(resourceIdTobeOpened)) { + mDialog.dismiss(); + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(f).toString()); + String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + intent.setDataAndType(Uri.fromFile(f), mimetype); + context.startActivity(intent); + } + } + } + } +///// HTML + else if (openWith.equalsIgnoreCase("HTML")) { + Log.e(TAG, " Command name -: " + resourceIdTobeOpened); + String filenameOnly = ""; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp/" + resourceIdTobeOpened); + for (File f : myDir.listFiles()) { + if (f.isFile()) { + if (f.getName().indexOf(".") > 0) { + filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); + } + Log.e(TAG, " File name -: " + f.getName() + " Filename only " + filenameOnly); + if (filenameOnly.equalsIgnoreCase("index")) { + try { + mDialog.dismiss(); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setPackage("org.mozilla.firefox"); + intent.setDataAndType(Uri.parse(f.getAbsolutePath()), "text/html"); + intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App")); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + break; + } catch (Exception err) { + Log.e("Error", err.getMessage()); + myDir = new File(Environment.getExternalStorageDirectory().toString() + "/ole_temp2"); + File dst = new File(myDir, "firefox_49_0_multi_android.apk"); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(dst), "application/vnd.android.package-archive"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + break; + } + } + } + } + + + + + + /* indexFilePath = null; + if (attmentNames.size() > 1) { + for (int cnt = 0; cnt < attmentNames.size(); cnt++) { + downloadHTMLContent(resourceIdTobeOpened, (String) attmentNames.get(cnt)); + } + if (indexFilePath != null) { + openHTML(indexFilePath); + } + } else { + openImage(resourceIdTobeOpened, (String) attmentNames.get(0), getExtension(attmentNames.get(0))); + }*/ +//// PDF + } else if (openWith.equalsIgnoreCase("Just download")) { + //// Todo work to get just download + } else if (openWith.equalsIgnoreCase("BeLL Video Book Player")) { + } + sendResourceRatingFeedback(openedResourceId); + } catch (Exception Er) { + Log.d("MyCouch", "Opening resource error " + Er.getMessage()); + Er.printStackTrace(); + } + return true; + } + + public Boolean openResources(String id) { String resourceIdTobeOpened = id; Log.d(TAG, "Trying to open resource " + id); @@ -510,8 +686,8 @@ public Boolean openResources(String id) { logHouse.updateActivityOpenedResources(context, sys_usercouchId, resourceIdTobeOpened, openResName); Log.e("MYAPP", " member opening resource = " + resourceIdTobeOpened + " and Open with " + openWith); List attmentNames = res_doc.getCurrentRevision().getAttachmentNames(); - //// PDF and Bell-Reader - if (openWith.equalsIgnoreCase("PDF.js") || (openWith.equalsIgnoreCase("Bell-Reader"))) { + //// PDF and Bell-Reader + if (openWith.equalsIgnoreCase("PDF.js") || (openWith.equalsIgnoreCase("Bell-Reader"))) { Log.e(TAG, " Command name -: " + resourceIdTobeOpened); String filenameOnly = ""; String root = Environment.getExternalStorageDirectory().toString(); @@ -593,39 +769,39 @@ public Boolean openResources(String id) { } ///// HTML else if (openWith.equalsIgnoreCase("HTML")) { - Log.e(TAG, " Command name -: " + resourceIdTobeOpened); - String filenameOnly = ""; - String root = Environment.getExternalStorageDirectory().toString(); - File myDir = new File(root + "/ole_temp/"+resourceIdTobeOpened); - for (File f : myDir.listFiles()) { - if (f.isFile()) { - if (f.getName().indexOf(".") > 0) { - filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); - } - Log.e(TAG, " File name -: " + f.getName() + " Filename only " + filenameOnly); - if (filenameOnly.equalsIgnoreCase("index")) { - try{ - mDialog.dismiss(); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setPackage("org.mozilla.firefox"); - intent.setDataAndType(Uri.parse(f.getAbsolutePath()),"text/html"); - intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App")); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - break ; - }catch(Exception err){ - Log.e("Error", err.getMessage()); - myDir = new File(Environment.getExternalStorageDirectory().toString() + "/ole_temp2"); - File dst = new File(myDir,"firefox_49_0_multi_android.apk"); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(dst), "application/vnd.android.package-archive"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - break ; - } - } - } - } + Log.e(TAG, " Command name -: " + resourceIdTobeOpened); + String filenameOnly = ""; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/ole_temp/" + resourceIdTobeOpened); + for (File f : myDir.listFiles()) { + if (f.isFile()) { + if (f.getName().indexOf(".") > 0) { + filenameOnly = f.getName().substring(0, f.getName().lastIndexOf(".")); + } + Log.e(TAG, " File name -: " + f.getName() + " Filename only " + filenameOnly); + if (filenameOnly.equalsIgnoreCase("index")) { + try { + mDialog.dismiss(); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setPackage("org.mozilla.firefox"); + intent.setDataAndType(Uri.parse(f.getAbsolutePath()), "text/html"); + intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App")); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + break; + } catch (Exception err) { + Log.e("Error", err.getMessage()); + myDir = new File(Environment.getExternalStorageDirectory().toString() + "/ole_temp2"); + File dst = new File(myDir, "firefox_49_0_multi_android.apk"); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(dst), "application/vnd.android.package-archive"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + break; + } + } + } + } @@ -645,9 +821,8 @@ else if (openWith.equalsIgnoreCase("HTML")) { //// PDF } else if (openWith.equalsIgnoreCase("Just download")) { //// Todo work to get just download + } else if (openWith.equalsIgnoreCase("BeLL Video Book Player")) { } - else if (openWith.equalsIgnoreCase("BeLL Video Book Player")) { - } sendResourceRatingFeedback(openedResourceId); } catch (Exception Er) { Log.d("MyCouch", "Opening resource error " + Er.getMessage()); @@ -656,7 +831,7 @@ else if (openWith.equalsIgnoreCase("BeLL Video Book Player")) { } ////////// Rating - public void sendResourceRatingFeedback(String id){ + public void sendResourceRatingFeedback(String id) { try { AndroidContext androidContext = new AndroidContext(context); Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); @@ -665,8 +840,8 @@ public void sendResourceRatingFeedback(String id){ String openResName = (String) res_doc.getProperty("title"); openedResourceId = id; openedResourceTitle = openResName; - mListener.onResourceOpened(openedResourceId,openedResourceTitle); - }catch(Exception err){ + mListener.onResourceOpened(openedResourceId, openedResourceTitle); + } catch (Exception err) { Log.d("MyCouch", "Sending feedback on resource error " + err.getMessage()); } } @@ -676,7 +851,7 @@ class DownloadHTMLFileFromURL extends AsyncTask { /** * Before starting background thread - * */ + */ @Override protected void onPreExecute() { super.onPreExecute(); @@ -685,7 +860,7 @@ protected void onPreExecute() { /** * Downloading file in background thread - * */ + */ @Override protected String doInBackground(String... f_url) { int count; @@ -696,7 +871,7 @@ protected String doInBackground(String... f_url) { conection.connect(); int lenghtOfFile = conection.getContentLength(); InputStream input = new BufferedInputStream(url.openStream(), 8192); - File myFileWithDir = new File(root + "/ole_temp/"+OneByOneResID+"/"+htmlResFileList.get(universalHtmlCnt)); + File myFileWithDir = new File(root + "/ole_temp/" + OneByOneResID + "/" + htmlResFileList.get(universalHtmlCnt)); OutputStream output = new FileOutputStream(myFileWithDir); byte data[] = new byte[1024]; long total = 0; @@ -715,16 +890,17 @@ protected String doInBackground(String... f_url) { } return null; } + /** * After completing background task - * **/ + **/ @Override protected void onPostExecute(String file_url) { System.out.println("Downloaded"); - if(universalHtmlCnt < htmlResFileList.size()-1){ - universalHtmlCnt ++; - new DownloadHTMLFileFromURL().execute(sys_oldSyncServerURL + "/resources/" + OneByOneResID + "/"+ htmlResFileList.get(universalHtmlCnt) ); - }else { + if (universalHtmlCnt < htmlResFileList.size() - 1) { + universalHtmlCnt++; + new DownloadHTMLFileFromURL().execute(sys_oldSyncServerURL + "/resources/" + OneByOneResID + "/" + htmlResFileList.get(universalHtmlCnt)); + } else { ///mDialog.dismiss(); createResourceDoc(OneByOneResID, title, openWith, author, language, subject, resourceType, uploadDate); mListener.onResourceDownloadCompleted(OneByOneResTitle, resIDArrayList); @@ -734,6 +910,4 @@ protected void onPostExecute(String file_url) { } - - } \ No newline at end of file diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/Loading_Screen.java b/app/src/main/java/pbell/offline/ole/org/pbell/Loading_Screen.java index 8b40fc7..b42d3e6 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/Loading_Screen.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/Loading_Screen.java @@ -1,10 +1,14 @@ package pbell.offline.ole.org.pbell; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Environment; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; +import android.widget.Toast; import java.io.File; import java.io.FileOutputStream; @@ -18,18 +22,21 @@ protected void onCreate(Bundle savedInstanceState) { copyAPK(R.raw.adobe_reader, "adobe_reader.apk"); copyAPK(R.raw.firefox_49_0_multi_android, "firefox_49_0_multi_android.apk"); + + Intent intent = new Intent(this, FullscreenLogin.class); startActivity(intent); finish(); } + private void copyAPK(int resource, String apkUrl) { InputStream in = getResources().openRawResource(resource); String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/ole_temp2"); - if (!myDir.exists()){ + if (!myDir.exists()) { myDir.mkdirs(); } - File dst = new File(myDir,apkUrl); + File dst = new File(myDir, apkUrl); try { FileOutputStream out = new FileOutputStream(dst); byte[] buff = new byte[1024]; @@ -39,8 +46,8 @@ private void copyAPK(int resource, String apkUrl) { } in.close(); out.close(); - Log.e("tag", "Adobe Reader Copied "+ dst.toString()); - }catch(Exception err){ + Log.e("tag", "Adobe Reader Copied " + dst.toString()); + } catch (Exception err) { err.printStackTrace(); } } diff --git a/app/src/main/java/pbell/offline/ole/org/pbell/ResourcesJson.java b/app/src/main/java/pbell/offline/ole/org/pbell/ResourcesJson.java index 5cc82d3..aa6226b 100644 --- a/app/src/main/java/pbell/offline/ole/org/pbell/ResourcesJson.java +++ b/app/src/main/java/pbell/offline/ole/org/pbell/ResourcesJson.java @@ -39,32 +39,33 @@ public class ResourcesJson { Context context; String query_serverURL; String query_databaseName; - String url_Scheme ,url_Host; + String url_Scheme, url_Host; int url_Port; String url_user, url_pwd; JsonObject json; CouchViews chViews = new CouchViews(); - public Boolean ResourcesJson(String serverURL, String databaseName, final AndroidContext android_context){ + + public Boolean ResourcesJson(String serverURL, String databaseName, final AndroidContext android_context) { query_context = android_context; - query_serverURL= serverURL; + query_serverURL = serverURL; query_databaseName = databaseName; try { - Log.e("MyCouch", "URL = "+serverURL); + Log.e("MyCouch", "URL = " + serverURL); URI uri = URI.create(serverURL); - url_Scheme = uri.getScheme(); - url_Host = uri.getHost(); - url_Port = uri.getPort(); - url_user = null; - url_pwd = null; - if(serverURL.contains("@")){ + url_Scheme = uri.getScheme(); + url_Host = uri.getHost(); + url_Port = uri.getPort(); + url_user = null; + url_pwd = null; + if (serverURL.contains("@")) { String[] userinfo = uri.getUserInfo().split(":"); url_user = userinfo[0]; url_pwd = userinfo[1]; } new Thread(new Runnable() { - public void run(){ + public void run() { try { CouchDbClientAndroid dbClient = new CouchDbClientAndroid(query_databaseName, false, url_Scheme, url_Host, url_Port, url_user, url_pwd); List allDocs = dbClient.view("_all_docs").includeDocs(true).query(JsonObject.class); @@ -75,7 +76,7 @@ public void run(){ Database shadowresources = manager.getDatabase("shadowresources"); Map newshadowdocProperties; String[] shdResIds = new String[allDocs.size()]; - for(x=0;x diff --git a/app/src/main/res/values-af-rZA/strings.xml b/app/src/main/res/values-af-rZA/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-af-rZA/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-ar-rSA/strings.xml b/app/src/main/res/values-ar-rSA/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-ar-rSA/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-el-rGR/strings.xml b/app/src/main/res/values-el-rGR/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-el-rGR/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml new file mode 100644 index 0000000..aa52e00 --- /dev/null +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -0,0 +1,85 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Agree and Proceed + + Achievements + myLibrary + My Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date/time + Synchronize data with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + Sync Device + First-time configuration + Synchronize data with server + Close + Download resource + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Passord + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-es-rES/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml new file mode 100644 index 0000000..52d725a --- /dev/null +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -0,0 +1,85 @@ + + + + PLANET + Url du serveur de synchronisation + Dispositif de synchronisation + Réglages + Profil + Aide + A propos + Bonjour tout le monde de la section : %1$d + Faire à la maison + + Prendre la maison + Il semble que votre appareil n’a pas encore été reliée au réseau de BeLL. Si vous connaissez l’url de votre serveur de BeLL, entrez-le ci-dessous ou communiquez avec votre coach / du groupe d’assistance + Url du serveur de BeLL + Accepter et continuer + + Réalisations + myLibrary + Progrès du cours + myMeetups + + Visites + Ressources ouvertes + + Url du serveur de synchronisation + Enregistrer les modifications + + Date de dernière synchronisation + Synchroniser avec le serveur + Envoyer les modifications + Tirez sur les changements + Nettoyez avec un chiffon + Matériaux de synchronisation + + Nom d\'utilisateur + Mot de passe (facultatif) + Connexion + Connectez vous + Ce mot de passe est incorrect + Ce champ est obligatoire + « Contacts autorisations sont nécessaires pour fournir les achèvements courriel. » + Dispositif de synchronisation + Configuration au moment du premier + Synchroniser avec le serveur + Fermer + Télécharger des ressources + Cours ouverts + Cours + Mes tuteurs + Ma maison + Bibliothèque + Cours + Meetups + Déconnexion + Paramètres + Retour d\'information + Membre Login + Bienvenue + Mode démo + S\'identifier + Mot de passe + test + Paramètres + Ce matériau n’est pas sur cet appareil (hors ligne). Voulez vous ouvrir en ligne ou à télécharger dans cet appareil. + Téléchargez ce + Ouvrez en ligne + Télécharger l’ensemble + Téléchargement de matériels multiples + Seul matériau Télécharger + Désactivé la réplication JSON + PERSONNES HANDICAPÉES EN STREAMING DE FICHIER + Mise à jour + Devenez membre + Langue + Accueil + Bouton factice + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Bonjour fragment vide + diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-iw-rIL/strings.xml b/app/src/main/res/values-iw-rIL/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-iw-rIL/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-vi-rVN/strings.xml b/app/src/main/res/values-vi-rVN/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-vi-rVN/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 0000000..a9c3e6d --- /dev/null +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,87 @@ + + + + PLANET + Sync Server Url + Sync Device + Settings + Profile + Help + About + Hello World from section: %1$d + Take-Home + + Take Home + It appears your device hasn\'t yet been linked to the BeLL network. + If you know your BeLL server\'s url, please enter it bellow or contact your coach / group leader for assistance + BeLL Server Url + Save and Proceed + + Achievements + myLibrary + Courses Progress + myMeetups + + Visits + Opened Resources + + Sync server url + Save changes + + Last sync date + Synchronize device with server + Push Changes + Pull Changes + Wipe Clean + Sync Materials + + Username + Password (optional) + Sign in + Sign-in + This password is incorrect + This field is required + \"Contacts permissions are needed for providing email completions.\" + + Sync Device + First Time Configuration + Synchronize With Server + Close + Download Resources + Open Course + Course + My Tutors + My Home + Library + Courses + Meetups + Logout + Settings + Feedback + Member Login + Welcome + Demo Mode + Login + Password + test + Setup + This material is not on this device (offline). Do you want to open it online or download into this device. + Download this + Open Online + Download All + Multiple material download + Single material download + JSON Replication Disabled + FILE STREAMING DISABLED + Update + Become a member + Language + Home + Dummy Button + DUMMY\nCONTENT + User_Dashboard + myCourses + myTeams + + Hello blank fragment + diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000..e27bf98 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,6 @@ +files: + - source: /app/src/main/res/values/strings.xml + translation: /app/src/main/res/values-%android_code%/%original_file_name% + translate_content: '0' + translate_attributes: '0' + content_segmentation: '0'