From 883b2ef7db4dbb8775d275024f9afcc4259e9aed Mon Sep 17 00:00:00 2001 From: Domagalski Date: Fri, 28 Sep 2018 01:33:29 +0200 Subject: [PATCH 1/7] to be conitnued... --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 32 +++---- .../findmytutor/activity/BaseActivity.java | 84 +++++++++++++++++++ .../wmi/findmytutor/activity/MapActivity.java | 16 ++++ .../activity/NotificationsActivity.java | 12 +++ .../findmytutor/activity/ProfileActivity.java | 14 ++++ .../findmytutor/activity/StartupActivity.java | 4 +- app/src/main/res/layout/activity_map.xml | 17 ++++ .../res/layout/activity_notifications.xml | 17 ++++ app/src/main/res/layout/activity_profile.xml | 17 ++++ .../res/layout/element_bottom_navigation.xml | 10 +++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 31 +++---- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 15 files changed, 228 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java create mode 100644 app/src/main/res/layout/activity_map.xml create mode 100644 app/src/main/res/layout/activity_notifications.xml create mode 100644 app/src/main/res/layout/activity_profile.xml create mode 100644 app/src/main/res/layout/element_bottom_navigation.xml diff --git a/app/build.gradle b/app/build.gradle index 6f6f95d..680323a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { } } -repositories{ +repositories { maven { url 'http://dl.bintray.com/amulyakhare/maven' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5f227e5..8f3b8bc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,7 +11,6 @@ - - - - - - - - + + + + + - - + android:launchMode="singleTop" /> - + android:launchMode="singleTask" + android:noHistory="true" /> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java new file mode 100644 index 0000000..ae60de9 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -0,0 +1,84 @@ +package com.uam.wmi.findmytutor.activity; + +import android.content.Intent; +import android.support.annotation.NonNull; +import android.support.design.widget.BottomNavigationView; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.MenuItem; + +import com.uam.wmi.findmytutor.R; + +public abstract class BaseActivity + extends AppCompatActivity + implements BottomNavigationView.OnNavigationItemSelectedListener { + + protected BottomNavigationView navigationView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(getContentViewId()); + + navigationView = (BottomNavigationView) findViewById(R.id.navigation); + navigationView.setOnNavigationItemSelectedListener(this); + } + + @Override + protected void onStart() { + super.onStart(); + updateNavigationBarState(); + } + + @Override + public void onPause() { + super.onPause(); + overridePendingTransition(0,0); + } + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + + navigationView.postDelayed(() -> { + int itemId = item.getItemId(); + if (itemId == R.id.nav_map) { + startActivity(new Intent(this, MapActivity.class)); + } else if (itemId == R.id.nav_profile) { + startActivity(new Intent(this, ProfileActivity.class)); + } else if (itemId == R.id.nav_notif) { + startActivity(new Intent(this, NotificationsActivity.class)); + } + finish(); + }, 300); + return true; + +// navigationView.postDelayed(() -> { +// int itemId = item.getItemId(); +// switch (itemId) { +// case R.id.nav_profile: +// startActivity(new Intent(this, ProfileActivity.class)); +// case R.id.nav_map: +// startActivity(new Intent(this, MapActivity.class)); +// case R.id.nav_notif: +// startActivity(new Intent(this, NotificationsActivity.class)); +// } +// +// finish(); +// }, 300); +// return true; + } + + private void updateNavigationBarState() { + int actionId = getNavigationMenuItemId(); + selectBottomNavigationBarItem(actionId); + } + + private void selectBottomNavigationBarItem(int itemId) { + MenuItem item = navigationView.getMenu().findItem(itemId); + item.setChecked(true); + } + + abstract int getNavigationMenuItemId(); + + abstract int getContentViewId(); +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java new file mode 100644 index 0000000..b7ac239 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -0,0 +1,16 @@ +package com.uam.wmi.findmytutor.activity; + +import com.uam.wmi.findmytutor.R; + +public class MapActivity extends BaseActivity { + + @Override + protected int getContentViewId() { + return R.layout.activity_map; + } + + @Override + protected int getNavigationMenuItemId() { + return R.id.nav_map; + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java new file mode 100644 index 0000000..b7f5e3d --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java @@ -0,0 +1,12 @@ +package com.uam.wmi.findmytutor.activity; + +import com.uam.wmi.findmytutor.R; + +public class NotificationsActivity extends BaseActivity { + + @Override + protected int getContentViewId() { return R.layout.activity_notifications; } + + @Override + protected int getNavigationMenuItemId() { return R.id.nav_notif; } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java new file mode 100644 index 0000000..5a3d92d --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java @@ -0,0 +1,14 @@ +package com.uam.wmi.findmytutor.activity; + +import com.uam.wmi.findmytutor.R; + +public class ProfileActivity extends BaseActivity { + + @Override + protected int getContentViewId() { return R.layout.activity_profile; } + + @Override + protected int getNavigationMenuItemId() { + return R.id.nav_profile; + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 257b01f..811b696 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -14,7 +14,7 @@ public class StartupActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { if (isLoggedIn()){ - Intent startupIntent = new Intent(this, MainActivity.class); + Intent startupIntent = new Intent(this, MapActivity.class); startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(startupIntent); finish(); @@ -36,7 +36,7 @@ public class StartupActivity extends AppCompatActivity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) { - Intent startupIntent = new Intent(this, MainActivity.class); + Intent startupIntent = new Intent(this, MapActivity.class); startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startupIntent.putExtra("is_tutor",(boolean) data.getExtras().get("is_tutor")); startActivity(startupIntent); diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml new file mode 100644 index 0000000..a4f7163 --- /dev/null +++ b/app/src/main/res/layout/activity_map.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_notifications.xml b/app/src/main/res/layout/activity_notifications.xml new file mode 100644 index 0000000..7bfe5a9 --- /dev/null +++ b/app/src/main/res/layout/activity_notifications.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml new file mode 100644 index 0000000..f17c373 --- /dev/null +++ b/app/src/main/res/layout/activity_profile.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/element_bottom_navigation.xml b/app/src/main/res/layout/element_bottom_navigation.xml new file mode 100644 index 0000000..4624eb7 --- /dev/null +++ b/app/src/main/res/layout/element_bottom_navigation.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc72b2f..29a8ba2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,4 +37,5 @@ pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew Black List White List + Main2Activity diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 31ff20c..edb90df 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,21 +1,22 @@ - + - + - + -