Merge branch 'fixedDrawerNavigation' of s416084/find-my-tutor-android into develop

This commit is contained in:
Marcin Jedyński 2018-11-02 01:42:26 +00:00 committed by Gogs
commit b1dfb6611d
11 changed files with 170 additions and 81 deletions

View File

@ -8,6 +8,7 @@ import android.content.res.Configuration;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
@ -37,6 +38,8 @@ public abstract class BaseActivity
implements BottomNavigationView.OnNavigationItemSelectedListener {
protected BottomNavigationView navigationView;
protected NavigationView drawerNavigationView;
protected DrawerLayout sideDrawer;
protected Toolbar toolbar;
@ -46,10 +49,9 @@ public abstract class BaseActivity
private ListView listView;
private ArrayList<String> stringArrayList;
private SharingFragment sharingFragment;
private static final int REQUEST_PERMISSIONS = 100;
protected static final int REQUEST_PERMISSIONS = 100;
boolean boolean_permission;
private boolean isTutor;
protected boolean isTutor;
@ -58,7 +60,44 @@ public abstract class BaseActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewId());
drawerNavigationView = findViewById(R.id.nav_view);
sideDrawer = findViewById(R.id.activity_container);
drawerNavigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
String itemName = (String)item.getTitle();
Intent launchIntent;
if(itemName.equals("Whitelist")){
/* launchIntent = new Intent(getApplicationContext(), WhitelistActivity.class);
startActivity(launchIntent);*/
}else if (itemName.equals("Blacklist")){
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
startActivity(launchIntent);*/
}else if (itemName.equals("Profile")){
/* launchIntent = new Intent(getApplicationContext(), ProfileActivity.class);
startActivity(launchIntent);*/
}else if (itemName.equals("Settings")){
launchIntent = new Intent(getApplicationContext(), SettingsActivity.class);
startActivity(launchIntent);
}else if (itemName.equals("Log out")){
PrefUtils.cleanUserLocalStorage(getApplicationContext());
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
if (i != null) {
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(i);
finish();
}
sideDrawer.closeDrawers();
return true;
}
}
);
navigationView = findViewById(R.id.navigation);
navigationView.setOnNavigationItemSelectedListener(this);
sharingFragment = new SharingFragment();

View File

@ -6,11 +6,14 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
@ -22,6 +25,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
@ -62,7 +66,6 @@ public class MapActivity extends BaseActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
configureLogoutButton();
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
final String authToken = sharedPref.getString("authToken",null);
@ -185,22 +188,7 @@ public class MapActivity extends BaseActivity
}
private void configureLogoutButton(){
// Logout button
final FloatingActionButton button = findViewById(R.id.logoutButton);
button.setOnClickListener(view -> {
PrefUtils.cleanUserLocalStorage(getApplicationContext());
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
if (i != null) {
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(i);
finish();
});
}
@ -249,6 +237,34 @@ public class MapActivity extends BaseActivity
mapView.onSaveInstanceState(outState);
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(MapActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
} else {
ActivityCompat.requestPermissions(MapActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
},
REQUEST_PERMISSIONS);
}
} else {
if (isTutor) {
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
} else {
startService(intent);
}
} else {
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
}
}
}
@Override
protected int getContentViewId() {
return R.layout.activity_map;

View File

@ -32,17 +32,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.pref_main);
//TODO add on change listeners for preferences
// feedback preference click listener
Preference myPref = findPreference(getString(R.string.key_send_feedback));
myPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
sendFeedback(getActivity());
return true;
}
});
}
}

View File

@ -0,0 +1,49 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="68dp"
android:height="68dp"
android:viewportWidth="68"
android:viewportHeight="68">
<path
android:pathData="M56.3,44.2c-2.1,2.2 -4.6,3.9 -7.3,5.2c-1.5,0.7 -29,8.5 -40.7,11.8c-1,0.3 -1.9,0.5 -2.6,0.7c0.2,-0.7 0.4,-1.6 0.7,-2.6c2.9,-11.6 9.9,-38.9 10.5,-40.4c1.2,-2.7 2.9,-5.1 5,-7.3c9.1,-9.3 23.8,-10.2 33.7,-2.5c0.4,0.3 0.7,0.6 1.1,0.9c0.3,0.3 0.6,0.6 0.9,1C65.8,20.5 65.4,34.9 56.3,44.2z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:pathData="M46.7,48.1"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.8,29.7l1,1.8l3.5,-2l1.5,2.7l-3.5,2l2.2,3.9l-3.1,1.7l-6.2,-11l7,-4l1.6,2.7L24.8,29.7z"/>
<path
android:fillColor="#FF000000"
android:pathData="M28,22.9l1.4,2.5l2.9,-1.6l-1.4,-2.5L28,22.9zM30,26.5l4.8,8.5l1.2,-4.8l-3,-5.4L30,26.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M45,22.4l2.9,5.2L45,29.2l-2.7,-4.8c-0.6,-1 -1.2,-1.3 -1.9,-0.9c-0.9,0.5 -1.1,1.5 -0.5,2.5l2.6,4.5l-2.9,1.7l-4.8,-8.5l2.1,-1.2l0.9,0.6c0.2,-1.1 0.9,-2 2,-2.6C41.7,19.5 43.8,20.2 45,22.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M52.1,9.9l6.6,11.6l-2.2,1.2l-0.6,-0.5c-0.4,1 -1.1,1.8 -2,2.4c-2.6,1.5 -5.5,0.6 -7,-2c-1.5,-2.6 -0.7,-5.6 1.9,-7.1c0.8,-0.4 1.6,-0.6 2.4,-0.6l-1.9,-3.4L52.1,9.9zM53.6,18.8c-0.6,-1.1 -1.9,-1.5 -3,-0.9c-1.1,0.6 -1.4,1.9 -0.8,3c0.6,1.1 1.9,1.5 3,0.9S54.2,19.9 53.6,18.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.1,42.1l-3,1.7l4.7,8.3l-3,1.7L18,45.5l-3,1.7l-1.5,-2.7l9,-5.1L24.1,42.1z"/>
<path
android:fillColor="#FF000000"
android:pathData="M27.2,46.4l-2.7,-4.8l2.9,-1.7l2.7,4.7c0.5,0.9 1.3,1.2 2.1,0.7c0.8,-0.4 1,-1.2 0.4,-2.1l-2.7,-4.7l2.9,-1.7l2.7,4.8c1.3,2.4 0.6,4.9 -2,6.3C31.1,49.4 28.6,48.8 27.2,46.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.7,38.5l1.5,2.6l-2,1.1c-1.9,1.1 -3.7,0.6 -4.7,-1.3l-1.8,-3.2L35,38.6l-0.4,-0.7l1.5,-6.2l0.6,-0.3l1.4,2.5l2.1,-1.2l1.3,2.3l-2.1,1.2l1.5,2.7c0.3,0.6 0.9,0.8 1.5,0.4L43.7,38.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.6,36.4c-1.5,-2.6 -0.6,-5.7 2.2,-7.2c2.8,-1.6 5.8,-0.8 7.3,1.8c1.5,2.6 0.6,5.7 -2.2,7.2C48.1,39.8 45,39 43.6,36.4zM49.4,35.6c1.1,-0.6 1.4,-1.8 0.8,-2.9c-0.6,-1.1 -1.8,-1.5 -2.9,-0.9s-1.4,1.8 -0.8,2.9C47.1,35.8 48.3,36.2 49.4,35.6L49.4,35.6z"/>
<path
android:fillColor="#FF000000"
android:pathData="M57.5,22.8l1.5,2.7l-1.1,0.6c-1,0.6 -1.2,1.3 -0.6,2.4l2.4,4.3l-2.9,1.7L52,26l2,-1.1l1,0.7c0.2,-1 0.8,-1.7 1.8,-2.3L57.5,22.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M20.8,37.8l0.9,1.7L20.8,40L20,38.5c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.3,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-0.9,-1.6c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.2,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-1.5,-2.7l0.6,-0.4l0.3,0.2c0.1,-0.3 0.3,-0.6 0.6,-0.8c0.3,-0.2 0.7,-0.2 1,0c0.1,-0.3 0.3,-0.7 0.6,-0.9C19.8,37 20.5,37.2 20.8,37.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M22.3,35.7l0.3,1.8l-1.4,-1.1l-1,0.6l2.5,1.8c0,0.2 0,0.4 -0.1,0.5l0.5,0.8c0.5,-0.4 0.6,-0.8 0.5,-1.7l-0.3,-3.2L22.3,35.7z"/>
</vector>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
@ -13,6 +14,13 @@
<!-- Login progress -->
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:contentDescription="Logo find my tutor"
app:srcCompat="@drawable/logo_design_black2" />
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"

View File

@ -82,6 +82,7 @@
app:layout_anchorGravity="bottom|center"
app:menu="@menu/nav_items" />
</RelativeLayout>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"

View File

@ -18,14 +18,6 @@
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginTop="77dp"
app:backgroundTint="@android:color/holo_red_dark"
app:srcCompat="@android:drawable/ic_lock_power_off" />
</android.support.constraint.ConstraintLayout>

View File

@ -13,6 +13,7 @@
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/nav_header"
android:layout_width="match_parent"
android:layout_height="160dp"
@ -9,20 +11,15 @@
android:foreground="?attr/selectableItemBackgroundBorderless"
android:gravity="bottom"
android:orientation="vertical"
android:padding="16dp"
android:padding="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/nav_header_imageView"
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/nav_header_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="Chike Mgbemena"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
android:layout_height="match_parent"
android:visibility="visible"
app:srcCompat="@drawable/logo_design_black2" />
</LinearLayout>

View File

@ -1,34 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item android:id="@+id/nav_item_one"
android:icon="@drawable/ic_menu_camera"
android:title="Item 1" />
<item android:id="@+id/nav_item_two"
android:icon="@drawable/ic_menu_gallery"
android:title="Item 2" />
<item android:id="@+id/nav_item_three"
android:icon="@drawable/ic_menu_share"
android:title="Item 3" />
</group>
<group android:id="@+id/group_menu">
<item android:id="@+id/nav_item_four"
<item
android:id="@+id/nav_item_one"
android:icon="@drawable/ic_people_white"
android:title="@string/action_white_list" />
<item android:id="@+id/nav_item_five"
android:title="@string/navigation_item_whitelist" />
<item
android:id="@+id/nav_item_two"
android:icon="@drawable/ic_people_black"
android:title="@string/action_black_list" />
android:title="@string/navigation_item_blacklist" />
<item
android:id="@+id/nav_item_three"
android:icon="@drawable/outline_person_white_24dp"
android:title="@string/navigation_item_profile" />
</group>
<group android:id="@+id/group_menu">
<item
android:id="@+id/nav_item_four"
android:icon="@drawable/ic_menu_settings_key"
android:title="@string/navigation_item_settings" />
<item
android:id="@+id/nav_item_five"
android:icon="@android:drawable/ic_lock_power_off"
android:title="@string/navigation_item_logout" />
</group>
<item android:title="Title 1">
<menu>
<item android:id="@+id/nav_item_six"
android:icon="@drawable/ic_menu_settings_gear"
android:title="@string/action_settings" />
<item android:id="@+id/nav_item_sign_out"
android:icon="@drawable/ic_menu_sign_out2"
android:title="@string/action_sign_out" />
</menu>
</item>
</menu>

View File

@ -11,7 +11,11 @@
<!--Side Menu-->
<string name="navigation_drawer_open">Drawer Open</string>
<string name="navigation_drawer_close">Drawer Closed</string>
<string name="navigation_item_blacklist">Blacklist</string>
<string name="navigation_item_whitelist">Whitelist</string>
<string name="navigation_item_settings">Settings</string>
<string name="navigation_item_profile">Profile</string>
<string name="navigation_item_logout">Log out</string>
<!-- Tutors list -->
<string name="action_settings">Settings</string>
<string name="activity_title_home">Notes</string>