ActionBar, Menu, Logout
ActionBar hinzugefügt Menu zu ActionBar hinzugefügt Logout jetzt in Actionbar
This commit is contained in:
parent
071f6b9be2
commit
36bc515c4b
@ -19,8 +19,8 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".Dash"
|
android:name=".Dash"
|
||||||
android:label="@string/title_activity_dash"
|
android:label="SmartShopper"
|
||||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
android:theme="@style/AppTheme"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,13 +1,20 @@
|
|||||||
package at.smartshopper.smartshopper;
|
package at.smartshopper.smartshopper;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
@ -29,10 +36,7 @@ public class Dash extends AppCompatActivity {
|
|||||||
private Database db = new Database();
|
private Database db = new Database();
|
||||||
private SwipeRefreshLayout ownswiperefresh;
|
private SwipeRefreshLayout ownswiperefresh;
|
||||||
|
|
||||||
private void goLogin() {
|
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,20 +45,12 @@ public class Dash extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_dash);
|
setContentView(R.layout.activity_dash);
|
||||||
|
|
||||||
|
|
||||||
|
// Erstellt die Tabs
|
||||||
tabHoster();
|
tabHoster();
|
||||||
|
|
||||||
Button logoutBtn = (Button) findViewById(R.id.logoutBtn);
|
|
||||||
logoutBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
FirebaseAuth.getInstance().signOut();
|
|
||||||
goLogin();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get userinformations
|
Get userinformations and show them
|
||||||
*/
|
*/
|
||||||
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
|
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@ -92,11 +88,21 @@ public class Dash extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logt den User aus und geht zur Login Activity
|
||||||
|
*/
|
||||||
|
private void logout(){
|
||||||
|
FirebaseAuth.getInstance().signOut();
|
||||||
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshed die eigene shoppinglist und veranlasst das das refreshen beendet wird
|
* Refreshed die eigene shoppinglist und veranlasst das das refreshen beendet wird
|
||||||
|
*
|
||||||
* @param uid Von dem benutzer von welchem die Shoppinglists angezeigt werden sollen
|
* @param uid Von dem benutzer von welchem die Shoppinglists angezeigt werden sollen
|
||||||
*/
|
*/
|
||||||
private void refreshOwnShoppinglist(String uid){
|
private void refreshOwnShoppinglist(String uid) {
|
||||||
try {
|
try {
|
||||||
showOwnShoppingList(uid);
|
showOwnShoppingList(uid);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -152,31 +158,30 @@ public class Dash extends AppCompatActivity {
|
|||||||
host.addTab(spec);
|
host.addTab(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
getMenuInflater().inflate(R.menu.dash_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
// Handle action bar item clicks here. The action bar will
|
switch (item.getItemId()) {
|
||||||
// automatically handle clicks on the Home/Up button, so long
|
case R.id.logoutBtn:
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
logout();
|
||||||
int id = item.getItemId();
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
// If we got here, the user's action was not recognized.
|
||||||
|
// Invoke the superclass to handle it.
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
|
||||||
if (id == R.id.action_settings) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
<TabHost
|
<TabHost
|
||||||
android:id="@+id/tabHost1"
|
android:id="@+id/tabHost1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content">
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_centerHorizontal="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -21,12 +19,14 @@
|
|||||||
<TabWidget
|
<TabWidget
|
||||||
android:id="@android:id/tabs"
|
android:id="@android:id/tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
</TabWidget>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@android:id/tabcontent"
|
android:id="@android:id/tabcontent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">x
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tab1"
|
android:id="@+id/tab1"
|
||||||
@ -40,14 +40,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/logoutBtn"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Logout" />
|
|
||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/ownSwipe"
|
android:id="@+id/ownSwipe"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -75,12 +68,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/logoutBtn2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Logout" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/sharedrecycler"
|
android:id="@+id/sharedrecycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -91,6 +78,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TabHost>
|
</TabHost>
|
||||||
|
|
||||||
|
7
app/src/main/res/menu/dash_menu.xml
Normal file
7
app/src/main/res/menu/dash_menu.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/logoutBtn"
|
||||||
|
android:title="Logout"
|
||||||
|
android:enabled="true" />
|
||||||
|
</menu>
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#008577</color>
|
<color name="colorPrimary">#FFFFFF</color>
|
||||||
<color name="colorPrimaryDark">#00574B</color>
|
<color name="colorPrimaryDark">#00574B</color>
|
||||||
<color name="colorAccent">#880e4f</color>
|
<color name="colorAccent">#880e4f</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,20 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
|
||||||
<!-- Base application theme. -->
|
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.NoActionBar">
|
</resources>
|
||||||
<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" />
|
|
||||||
|
|
||||||
</resources>
|
|
Loading…
x
Reference in New Issue
Block a user