logout button

This commit is contained in:
Domagalski 2018-10-18 09:03:48 +02:00
parent 9162c7fd34
commit 61e5faa81b
2 changed files with 31 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
@ -43,6 +44,8 @@ public class MapActivity extends BaseActivity {
}
});
// TODO remove logout button
configureLogoutButton();
}
@ -90,6 +93,23 @@ public class MapActivity extends BaseActivity {
mapView.onSaveInstanceState(outState);
}
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();
});
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {

View File

@ -19,6 +19,17 @@
</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" />
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"