From f164e2f5416e33c2da81a2a88183b58351cb6ea0 Mon Sep 17 00:00:00 2001 From: Leonard Maximus Irenous Mensah Date: Thu, 25 Jan 2018 21:44:02 +0000 Subject: [PATCH] New Dashboard (#147) --- app/build.gradle | 17 +- app/src/main/AndroidManifest.xml | 24 +- .../planetlearning/FullscreenLogin.java | 12 + .../planet/planetlearning/Main_Dashboard.java | 247 +++++++++++++++++ .../planet/planetlearning/User_Dashboard.java | 18 +- .../main/res/drawable-v21/ic_menu_camera.xml | 12 + .../main/res/drawable-v21/ic_menu_gallery.xml | 9 + .../main/res/drawable-v21/ic_menu_manage.xml | 9 + .../main/res/drawable-v21/ic_menu_send.xml | 9 + .../main/res/drawable-v21/ic_menu_share.xml | 9 + .../res/drawable-v21/ic_menu_slideshow.xml | 9 + .../res/drawable/rounded_corners_visits.xml | 26 ++ app/src/main/res/drawable/side_nav_bar.xml | 9 + .../res/layout/app_bar_main__dashboard.xml | 67 +++++ .../res/layout/content_main__dashboard.xml | 259 ++++++++++++++++++ app/src/main/res/layout/main_dashboard.xml | 62 +++++ app/src/main/res/layout/nav_footer_main.xml | 28 ++ .../main/res/layout/nav_header_bass_main.xml | 38 +++ .../res/layout/nav_header_main__dashboard.xml | 15 + .../main/res/layout/new_activity_login.xml | 2 +- app/src/main/res/menu/main__dashboard.xml | 9 + .../main/res/menu/main_dashboard_drawer.xml | 34 +++ app/src/main/res/values-v21/styles.xml | 1 + app/src/main/res/values/dimens.xml | 4 + app/src/main/res/values/drawables.xml | 8 + app/src/main/res/values/strings.xml | 4 + app/src/main/res/values/styles.xml | 4 + build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 29 files changed, 932 insertions(+), 19 deletions(-) create mode 100644 app/src/main/java/org/ole/learning/planet/planetlearning/Main_Dashboard.java create mode 100644 app/src/main/res/drawable-v21/ic_menu_camera.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_gallery.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_manage.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_send.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_share.xml create mode 100644 app/src/main/res/drawable-v21/ic_menu_slideshow.xml create mode 100644 app/src/main/res/drawable/rounded_corners_visits.xml create mode 100644 app/src/main/res/drawable/side_nav_bar.xml create mode 100644 app/src/main/res/layout/app_bar_main__dashboard.xml create mode 100644 app/src/main/res/layout/content_main__dashboard.xml create mode 100644 app/src/main/res/layout/main_dashboard.xml create mode 100644 app/src/main/res/layout/nav_footer_main.xml create mode 100644 app/src/main/res/layout/nav_header_bass_main.xml create mode 100644 app/src/main/res/layout/nav_header_main__dashboard.xml create mode 100644 app/src/main/res/menu/main__dashboard.xml create mode 100644 app/src/main/res/menu/main_dashboard_drawer.xml create mode 100644 app/src/main/res/values-v21/styles.xml create mode 100644 app/src/main/res/values/drawables.xml diff --git a/app/build.gradle b/app/build.gradle index db8e5cc..56b4968 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 - buildToolsVersion "25.0.2" + buildToolsVersion '26.0.2' defaultConfig { applicationId "org.ole.learning.planet.planetlearning" minSdkVersion 17 targetSdkVersion 25 versionCode 2 - versionName "2.1.2" + versionName "2.1.3" multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -21,9 +21,14 @@ android { } packagingOptions { - exclude 'META-INF/ASL2.0' + exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/license.txt' exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/notice.txt' + exclude 'META-INF/ASL2.0' } lintOptions { abortOnError false @@ -45,13 +50,14 @@ android { compile 'com.github.kittinunf.fuel:fuel-android:1.3.1' compile 'com.couchbase.lite:couchbase-lite-android:1.+' compile 'org.lightcouch:lightcouch:0.1.8' - compile 'com.github.tonyofrancis:Fetch:+' + compile 'com.tonyodev.fetch:fetch:1.1.5' compile 'us.feras.mdv:markdownview:1.1.0' compile 'com.makeramen:roundedimageview:2.3.0' + compile 'com.github.tdscientist:ShelfView:v1.0' compile 'com.github.florent37:diagonallayout:1.0.4' compile 'org.webjars.npm:jsonparse:1.2.0' - compile 'org.apache.httpcomponents:httpclient-android:4.3.5' + //compile 'org.apache.httpcomponents:httpclient-android:4.3.5' compile 'com.roughike:bottom-bar:1.3.3' compile 'com.mcxiaoke.volley:library-aar:1.0.0' compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+' @@ -66,6 +72,7 @@ android { } } dependencies { + implementation 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:support-v4:26.+' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94ca08f..69ef810 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -31,39 +32,50 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" - android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:supportsRtl="false" + android:theme="@style/AppTheme" + tools:replace="allowBackup,supportsRtl" + tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"> + + + + android:theme="@style/AppTheme" /> + android:theme="@style/FullscreenTheme" /> + android:theme="@style/FullscreenTheme" /> + \ No newline at end of file diff --git a/app/src/main/java/org/ole/learning/planet/planetlearning/FullscreenLogin.java b/app/src/main/java/org/ole/learning/planet/planetlearning/FullscreenLogin.java index e7a8835..29fbc98 100644 --- a/app/src/main/java/org/ole/learning/planet/planetlearning/FullscreenLogin.java +++ b/app/src/main/java/org/ole/learning/planet/planetlearning/FullscreenLogin.java @@ -195,6 +195,18 @@ public void onClick(View view) { }); // + TextView Version = (TextView) findViewById(R.id.txtVersion); + Version.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //alertDialogOkay("This feature has not been activated on this version."); + //setLocale("fr"); + Intent intent = new Intent(context, Main_Dashboard.class); + startActivity(intent); + } + }); + // + // New UI ImageButton SetupButton = (ImageButton) findViewById(R.id.btnSetup); diff --git a/app/src/main/java/org/ole/learning/planet/planetlearning/Main_Dashboard.java b/app/src/main/java/org/ole/learning/planet/planetlearning/Main_Dashboard.java new file mode 100644 index 0000000..d616c2b --- /dev/null +++ b/app/src/main/java/org/ole/learning/planet/planetlearning/Main_Dashboard.java @@ -0,0 +1,247 @@ +package org.ole.learning.planet.planetlearning; + +import android.app.ProgressDialog; +import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.util.Log; +import android.view.View; +import android.support.design.widget.NavigationView; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Button; +import android.widget.LinearLayout; + +import com.couchbase.lite.Database; +import com.couchbase.lite.Document; +import com.couchbase.lite.Manager; +import com.couchbase.lite.Query; +import com.couchbase.lite.QueryEnumerator; +import com.couchbase.lite.QueryRow; +import com.tdscientist.shelfview.BookModel; +import com.tdscientist.shelfview.ShelfView; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Map; + +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; + + +public class Main_Dashboard extends AppCompatActivity + implements NavigationView.OnNavigationItemSelectedListener { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main_dashboard); + //Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + //setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + drawer.addDrawerListener(toggle); + toggle.syncState(); + + NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + + } +/* + public void LoadShelfResourceList() { + String memberId = sys_usercouchId; + try { + manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Database db = manager.getExistingDatabase("shelf"); + Database resource_Db = manager.getDatabase("resources"); + Query orderedQuery = chViews.ReadShelfByIdView(db).createQuery(); + orderedQuery.setDescending(true); + QueryEnumerator results = orderedQuery.run(); + resourceIdList = new String[results.getCount()]; + resourceTitleList= new String[results.getCount()]; + rsLstCnt = 0; + for (Iterator it = results; it.hasNext(); ) { + QueryRow row = it.next(); + String docId = (String) row.getValue(); + Document doc = db.getExistingDocument(docId); + Map properties = doc.getProperties(); + Map resource_properties = null; + if(memberId.equals((String) properties.get("memberId"))) { + String myresTitile = ((String) properties.get("resourceTitle")); + String myresId = ((String) properties.get("resourceId")); + String myresType,myresDec,myresExt = ""; + resourceTitleList[rsLstCnt]=myresTitile; + resourceIdList[rsLstCnt]=myresId; + resIDArrayList.add(myresId); + Log.e("tag", "MEMBER ID "+ (String) properties.get("resourceTitle")); + try { + Document resource_doc = resource_Db.getExistingDocument((String) properties.get("resourceId")); + Log.e("tag", "RES ID "+ (String) properties.get("resourceId")); + try { + resource_properties = resource_doc.getProperties(); + }catch(Exception errs){ + Log.e("tag", "OBJECT ERROR "+ errs.toString()); + } + //myresTitile = (String) resource_properties.get("title")+""; + //myresId = (String) properties.get("resourceId")+""; + myresDec = (String) resource_properties.get("author")+""; + myresType = (String) resource_properties.get("averageRating")+""; + myresExt = (String) resource_properties.get("openWith")+""; + rsLstCnt++; + }catch(Exception err){ + Log.e("tag", "ERROR "+ err.getMessage()); + //myresTitile = "Unknown resource .. "; + //myresId = ""; + myresDec = ""; + myresType = ""; + rsLstCnt++; + } + Resource resource = new Resource(); + resource.setTitle(myresTitile); + resource.setThumbnailUrl(getIconType(myresExt)); + resource.setDescription(myresDec); + resource.setRating(myresType); + + resource.setGenre(null); + // adding resource to resources array + resourceList.add(resource); + resourceNo++; + } + } + + LinearLayout row2 = (LinearLayout) findViewById(R.id.layholder_library); + libraryButtons = new Button[rsLstCnt]; + for( int ButtonCnt=0;ButtonCnt< rsLstCnt;ButtonCnt++) { + libraryButtons[ButtonCnt] = new Button(this); + libraryButtons[ButtonCnt].setText(resourceTitleList[ButtonCnt]); + libraryButtons[ButtonCnt].setId(ButtonCnt); + libraryButtons[ButtonCnt].setBackgroundResource(R.drawable.rounded_corners_black_blue); + libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.white)); + libraryButtons[ButtonCnt].setAllCaps(false); + libraryButtons[ButtonCnt].setPadding(10, 5, 10, 5); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + libraryButtons[ButtonCnt].setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + } + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(170,MATCH_PARENT); + layoutParams.setMargins(1, 0, 1, 0); // left, top, right, bottom + GradientDrawable drawable = new GradientDrawable(); + drawable.setShape(GradientDrawable.RECTANGLE); + drawable.setStroke(2, Color.WHITE); + drawable.setCornerRadius(2); + drawable.setColor(getResources().getColor(R.color.ole_black_blue)); + libraryButtons[ButtonCnt].setBackgroundDrawable(drawable); + libraryButtons[ButtonCnt].setLayoutParams(layoutParams); + row2.addView(libraryButtons[ButtonCnt]); + try { + manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); + Document resource_doc = resource_Db.getExistingDocument((String) resourceIdList[ButtonCnt]); + Map resource_properties = resource_doc.getProperties(); + Log.e("tag", "RES ID " + (String) resource_properties.get("resourceId")); + libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.ole_white)); + }catch(Exception errs){ + libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.ole_yellow)); + Log.e("tag", "OBJECT ERROR "+ errs.toString()); + } + + libraryButtons[ButtonCnt].setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(libraryButtons[view.getId()].getCurrentTextColor()==getResources().getColor(R.color.ole_yellow)){ + MaterialClickDialog(false,resourceTitleList[view.getId()],resourceIdList[view.getId()],view.getId()); + }else{ + mDialog = new ProgressDialog(context); + mDialog.setMessage("Opening please "+resourceTitleList[view.getId()]+" wait..."); + mDialog.setCancelable(true); + mDialog.show(); + openedResourceId=resourceIdList[view.getId()]; + openedResourceTitle = resourceTitleList[view.getId()]; + openedResource =true; + openDoc(resourceIdList[view.getId()]); + Log.e("MyCouch", "Clicked to open "+ resourceIdList[view.getId()]); + + } + + } + + }); + //////////// Save list in Preferences + } + db.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + */ + + @Override + public void onBackPressed() { + DrawerLayout drawer = findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main__dashboard, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @SuppressWarnings("StatementWithEmptyBody") + @Override + public boolean onNavigationItemSelected(MenuItem item) { + // Handle navigation view item clicks here. + int id = item.getItemId(); + + if (id == R.id.nav_camera) { + // Handle the camera action + } else if (id == R.id.nav_gallery) { + + } else if (id == R.id.nav_slideshow) { + + } else if (id == R.id.nav_manage) { + + } + + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; + } +} diff --git a/app/src/main/java/org/ole/learning/planet/planetlearning/User_Dashboard.java b/app/src/main/java/org/ole/learning/planet/planetlearning/User_Dashboard.java index e378889..00de456 100644 --- a/app/src/main/java/org/ole/learning/planet/planetlearning/User_Dashboard.java +++ b/app/src/main/java/org/ole/learning/planet/planetlearning/User_Dashboard.java @@ -50,6 +50,8 @@ import java.util.Set; /** + * org.ole.learning.planet + * * An example full-screen activity that shows and hides the system UI (i.e. * status bar and navigation/system bar) with user interaction. */ @@ -568,13 +570,21 @@ public void runBackgroundService() { public void resetActiveButton() { lt_myLibrary.setBackgroundColor(Color.TRANSPARENT); - lt_myLibrary.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); lt_myCourses.setBackgroundColor(Color.TRANSPARENT); - lt_myCourses.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); lt_myTeams.setBackgroundColor(Color.TRANSPARENT); - lt_myTeams.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); lt_myMembers.setBackgroundColor(Color.TRANSPARENT); - lt_myMembers.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); + int sdk = android.os.Build.VERSION.SDK_INT; + if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { + lt_myLibrary.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); + lt_myCourses.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); + lt_myTeams.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); + lt_myMembers.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); + } else { + lt_myLibrary.setBackground(getResources().getDrawable(R.drawable.border)); + lt_myCourses.setBackground(getResources().getDrawable(R.drawable.border)); + lt_myTeams.setBackground(getResources().getDrawable(R.drawable.border)); + lt_myMembers.setBackground(getResources().getDrawable(R.drawable.border)); + } lblHome.setTextColor(ContextCompat.getColor(context,R.color.ole_white)); lblLibrary.setTextColor(ContextCompat.getColor(context,R.color.ole_white)); lblCourses.setTextColor(ContextCompat.getColor(context,R.color.ole_white)); diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-v21/ic_menu_camera.xml new file mode 100644 index 0000000..0d9ea10 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-v21/ic_menu_gallery.xml new file mode 100644 index 0000000..f6872c4 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-v21/ic_menu_manage.xml new file mode 100644 index 0000000..c1be60b --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_manage.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-v21/ic_menu_send.xml new file mode 100644 index 0000000..00c668c --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_send.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-v21/ic_menu_share.xml new file mode 100644 index 0000000..a28fb9e --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_share.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml new file mode 100644 index 0000000..209aa64 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/rounded_corners_visits.xml b/app/src/main/res/drawable/rounded_corners_visits.xml new file mode 100644 index 0000000..f600002 --- /dev/null +++ b/app/src/main/res/drawable/rounded_corners_visits.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..6d81870 --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_main__dashboard.xml b/app/src/main/res/layout/app_bar_main__dashboard.xml new file mode 100644 index 0000000..8f619c7 --- /dev/null +++ b/app/src/main/res/layout/app_bar_main__dashboard.xml @@ -0,0 +1,67 @@ + + + + + + + +