to be conitnued...

This commit is contained in:
Domagalski 2018-09-28 01:33:29 +02:00
parent 02db1722a2
commit 883b2ef7db
15 changed files with 228 additions and 35 deletions

View File

@ -22,7 +22,7 @@ android {
}
}
repositories{
repositories {
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}

View File

@ -11,7 +11,6 @@
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@ -19,30 +18,35 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.StartupActivity"
<activity
android:name=".activity.StartupActivity"
android:label="@string/title_activity_startup"
android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
<activity
android:name=".activity.MainActivity"
android:label="@string/title_activity_main"
android:launchMode="singleTop">
</activity>
android:launchMode="singleTop" />
<activity
android:name=".activity.LoginActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:label="@string/title_activity_login"
android:noHistory="true">
</activity>
android:launchMode="singleTask"
android:noHistory="true" />
<!--<activity android:name=".activity.BaseActivity" />-->
<activity android:name=".activity.ProfileActivity" />
<activity android:name=".activity.MapActivity"> <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter></activity>
<activity android:name=".activity.NotificationsActivity" />
</application>
</manifest>

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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; }
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.MapActivity">
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.NotificationsActivity">
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ProfileActivity">
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.BottomNavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:menu="@menu/nav_items"
/>

View File

@ -37,4 +37,5 @@
<string name="access_token" translatable="false">pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew</string>
<string name="action_black_list">Black List</string>
<string name="action_white_list">White List</string>
<string name="title_activity_main2">Main2Activity</string>
</resources>

View File

@ -1,21 +1,22 @@
<resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
</resources>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong

View File

@ -1,6 +1,6 @@
#Sun Aug 12 23:17:46 CEST 2018
#Fri Sep 28 00:01:36 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip