Added Toolbar
Toolbar auf jeder Activity
This commit is contained in:
parent
470e6a6075
commit
a57ee5bcb0
@ -64,6 +64,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
private Button colorBtn;
|
private Button colorBtn;
|
||||||
//Für Double Back press to exit
|
//Für Double Back press to exit
|
||||||
private boolean doubleBackToExitPressedOnce = false;
|
private boolean doubleBackToExitPressedOnce = false;
|
||||||
|
private TabHost host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convertiert eine int farbe in eine hexa dezimale Farbe
|
* Convertiert eine int farbe in eine hexa dezimale Farbe
|
||||||
@ -159,6 +160,16 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
// Erstellt die Tabs
|
// Erstellt die Tabs
|
||||||
tabHoster(uid);
|
tabHoster(uid);
|
||||||
|
|
||||||
|
// Get the transferred data from source activity.
|
||||||
|
Intent intent = getIntent();
|
||||||
|
String message = intent.getStringExtra("tab2");
|
||||||
|
String wahr = "true";
|
||||||
|
if(message != null){
|
||||||
|
if(message.equals(wahr)) {
|
||||||
|
host.setCurrentTab(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
showOwnShoppingList(uid);
|
showOwnShoppingList(uid);
|
||||||
@ -337,6 +348,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
colorBtn.setOnClickListener(new View.OnClickListener() {
|
colorBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
Intent intent = new Intent(Dash.this, Colorpicker.class);
|
Intent intent = new Intent(Dash.this, Colorpicker.class);
|
||||||
startActivityForResult(intent, 1);
|
startActivityForResult(intent, 1);
|
||||||
|
|
||||||
@ -526,7 +538,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
* Hier wird auch der Name der Tabs gesetzt
|
* Hier wird auch der Name der Tabs gesetzt
|
||||||
*/
|
*/
|
||||||
private void tabHoster(final String uid) {
|
private void tabHoster(final String uid) {
|
||||||
final TabHost host = (TabHost) findViewById(R.id.tabHost1);
|
host = (TabHost) findViewById(R.id.tabHost1);
|
||||||
host.setup();
|
host.setup();
|
||||||
|
|
||||||
//Tab 1
|
//Tab 1
|
||||||
@ -574,6 +586,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
* Schickt an die Login Activity einen intend mit dem extra EXIT. Um die app zu schließen
|
* Schickt an die Login Activity einen intend mit dem extra EXIT. Um die app zu schließen
|
||||||
*/
|
*/
|
||||||
private void exit() {
|
private void exit() {
|
||||||
|
finish();
|
||||||
Intent intent = new Intent(Dash.this, LoginActivity.class);
|
Intent intent = new Intent(Dash.this, LoginActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
intent.putExtra("EXIT", true);
|
intent.putExtra("EXIT", true);
|
||||||
@ -604,10 +617,12 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
popupaddInvite();
|
popupaddInvite();
|
||||||
return true;
|
return true;
|
||||||
case R.id.doneEinkauf:
|
case R.id.doneEinkauf:
|
||||||
|
finish();
|
||||||
Intent intent = new Intent(Dash.this, DoneItemActivity.class);
|
Intent intent = new Intent(Dash.this, DoneItemActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.editUser:
|
case R.id.editUser:
|
||||||
|
finish();
|
||||||
Intent intent2 = new Intent(Dash.this, EditUser.class);
|
Intent intent2 = new Intent(Dash.this, EditUser.class);
|
||||||
startActivity(intent2);
|
startActivity(intent2);
|
||||||
return true;
|
return true;
|
||||||
@ -765,6 +780,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onShoppinglistClickContainer(String sl_id, View v) {
|
private void onShoppinglistClickContainer(String sl_id, View v) {
|
||||||
|
finish();
|
||||||
Intent intent = new Intent(this, ShoppinglistDetails.class);
|
Intent intent = new Intent(this, ShoppinglistDetails.class);
|
||||||
intent.putExtra("sl_id", sl_id);
|
intent.putExtra("sl_id", sl_id);
|
||||||
|
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package at.smartshopper.smartshopper.activitys;
|
package at.smartshopper.smartshopper.activitys;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
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.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
@ -13,6 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import at.smartshopper.smartshopper.R;
|
import at.smartshopper.smartshopper.R;
|
||||||
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
||||||
|
import at.smartshopper.smartshopper.customViews.ToolbarHelper;
|
||||||
import at.smartshopper.smartshopper.db.Database;
|
import at.smartshopper.smartshopper.db.Database;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDetailsAdapter;
|
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDetailsAdapter;
|
||||||
@ -20,12 +25,89 @@ import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDe
|
|||||||
public class DoneItemActivity extends AppCompatActivity {
|
public class DoneItemActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private Database db;
|
private Database db;
|
||||||
|
private String from, sl_id;
|
||||||
|
private String groupname;
|
||||||
|
private String group_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu item Action listener
|
||||||
|
*
|
||||||
|
* @param item Action Item
|
||||||
|
* @return True wenn erfolgreich
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
ToolbarHelper th = new ToolbarHelper(getApplicationContext(), getWindow().getDecorView());
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.logoutBtn:
|
||||||
|
th.logout();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.addInvite:
|
||||||
|
th.popupaddInvite();
|
||||||
|
return true;
|
||||||
|
case R.id.editUser:
|
||||||
|
finish();
|
||||||
|
Intent intent2 = new Intent(this, EditUser.class);
|
||||||
|
startActivity(intent2);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
// If we got here, the user's action was not recognized.
|
||||||
|
// Invoke the superclass to handle it.
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
|
||||||
|
inflater.inflate(R.menu.done_items_menu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
finish();
|
||||||
|
Intent intent = new Intent(this, ShoppinglistDetails.class);
|
||||||
|
if (from != null) {
|
||||||
|
switch (from) {
|
||||||
|
case "shpdetails":
|
||||||
|
intent = new Intent(this, ShoppinglistDetails.class);
|
||||||
|
intent.putExtra("sl_id", sl_id);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "itemlist":
|
||||||
|
intent = new Intent(this, ItemListActivity.class);
|
||||||
|
intent.putExtra("sl_id", sl_id);
|
||||||
|
intent.putExtra("groupNameString", groupname);
|
||||||
|
intent.putExtra("group_id", group_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
intent = new Intent(this, Dash.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_done_item);
|
setContentView(R.layout.activity_done_item);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
from = intent.getStringExtra("from");
|
||||||
|
sl_id = intent.getStringExtra("sl_id");
|
||||||
|
groupname = intent.getStringExtra("groupNameString");
|
||||||
|
group_id = intent.getStringExtra("group_id");
|
||||||
|
|
||||||
|
|
||||||
db = new Database();
|
db = new Database();
|
||||||
|
|
||||||
final SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.doneItemListRefresh);
|
final SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.doneItemListRefresh);
|
||||||
|
@ -7,12 +7,16 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
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.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -32,12 +36,13 @@ import java.util.List;
|
|||||||
|
|
||||||
import at.smartshopper.smartshopper.R;
|
import at.smartshopper.smartshopper.R;
|
||||||
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
||||||
|
import at.smartshopper.smartshopper.customViews.ToolbarHelper;
|
||||||
import at.smartshopper.smartshopper.db.Database;
|
import at.smartshopper.smartshopper.db.Database;
|
||||||
import at.smartshopper.smartshopper.messaging.MyFirebaseSender;
|
import at.smartshopper.smartshopper.messaging.MyFirebaseSender;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemAdapter;
|
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemAdapter;
|
||||||
|
|
||||||
public class ItemListActivity extends Activity implements ItemAdapter.OnItemEditClicked, ItemAdapter.OnItemDelClicked, ItemAdapter.OnItemCheckClicked {
|
public class ItemListActivity extends AppCompatActivity implements ItemAdapter.OnItemEditClicked, ItemAdapter.OnItemDelClicked, ItemAdapter.OnItemCheckClicked {
|
||||||
private String group_id, groupNameString;
|
private String group_id, groupNameString;
|
||||||
private String sl_id;
|
private String sl_id;
|
||||||
private PopupWindow popupWindowItem;
|
private PopupWindow popupWindowItem;
|
||||||
@ -116,6 +121,50 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu item Action listener
|
||||||
|
*
|
||||||
|
* @param item Action Item
|
||||||
|
* @return True wenn erfolgreich
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
ToolbarHelper th = new ToolbarHelper(getApplicationContext(),getWindow().getDecorView());
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.logoutBtn:
|
||||||
|
th.logout();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.addInvite:
|
||||||
|
th.popupaddInvite();
|
||||||
|
return true;
|
||||||
|
case R.id.doneEinkauf:
|
||||||
|
th.doneEinkauf("itemlist", sl_id, group_id, groupNameString);
|
||||||
|
return true;
|
||||||
|
case R.id.editUser:
|
||||||
|
finish();
|
||||||
|
Intent intent2 = new Intent(this, EditUser.class);
|
||||||
|
startActivity(intent2);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
// If we got here, the user's action was not recognized.
|
||||||
|
// Invoke the superclass to handle it.
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
|
||||||
|
inflater.inflate(R.menu.dash_menu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void showItems(String group_id, String sl_id) throws SQLException, JSONException {
|
private void showItems(String group_id, String sl_id) throws SQLException, JSONException {
|
||||||
RecyclerView itemsListRecycler = findViewById(R.id.itemsListRecycler);
|
RecyclerView itemsListRecycler = findViewById(R.id.itemsListRecycler);
|
||||||
int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.item_spacing);
|
int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.item_spacing);
|
||||||
|
@ -8,11 +8,16 @@ import android.os.Bundle;
|
|||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -32,6 +37,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import at.smartshopper.smartshopper.R;
|
import at.smartshopper.smartshopper.R;
|
||||||
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
|
||||||
|
import at.smartshopper.smartshopper.customViews.ToolbarHelper;
|
||||||
import at.smartshopper.smartshopper.db.Database;
|
import at.smartshopper.smartshopper.db.Database;
|
||||||
import at.smartshopper.smartshopper.messaging.MyFirebaseSender;
|
import at.smartshopper.smartshopper.messaging.MyFirebaseSender;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
|
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
|
||||||
@ -40,15 +46,67 @@ import at.smartshopper.smartshopper.shoppinglist.details.DetailsAdapter;
|
|||||||
import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
|
import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
|
||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
|
||||||
|
|
||||||
public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnCardClicked {
|
public class ShoppinglistDetails extends AppCompatActivity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnCardClicked {
|
||||||
|
|
||||||
private Database db;
|
private Database db;
|
||||||
private FloatingActionButton fab;
|
private FloatingActionButton fab;
|
||||||
private String colorString;
|
private String colorString, sl_id;
|
||||||
private PopupWindow popupWindow;
|
private PopupWindow popupWindow;
|
||||||
private Button colorBtn;
|
private Button colorBtn;
|
||||||
private SwipeRefreshLayout detailsSwiperefresh;
|
private SwipeRefreshLayout detailsSwiperefresh;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu item Action listener
|
||||||
|
*
|
||||||
|
* @param item Action Item
|
||||||
|
* @return True wenn erfolgreich
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
ToolbarHelper th = new ToolbarHelper(getApplicationContext(),getWindow().getDecorView());
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.logoutBtn:
|
||||||
|
th.logout();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case R.id.addInvite:
|
||||||
|
th.popupaddInvite();
|
||||||
|
return true;
|
||||||
|
case R.id.doneEinkauf:
|
||||||
|
th.doneEinkauf("shpdetails", sl_id, " ", " ");
|
||||||
|
return true;
|
||||||
|
case R.id.editUser:
|
||||||
|
finish();
|
||||||
|
Intent intent2 = new Intent(this, EditUser.class);
|
||||||
|
startActivity(intent2);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
// If we got here, the user's action was not recognized.
|
||||||
|
// Invoke the superclass to handle it.
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
|
||||||
|
inflater.inflate(R.menu.dash_menu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
finish();
|
||||||
|
Intent intent = new Intent(this, Dash.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convertiert eine int farbe in eine hexa dezimale Farbe
|
* Convertiert eine int farbe in eine hexa dezimale Farbe
|
||||||
*
|
*
|
||||||
@ -63,11 +121,12 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_shoppinglist_details);
|
setContentView(R.layout.activity_shoppinglist_details);
|
||||||
|
|
||||||
fab = findViewById(R.id.addGroupFab);
|
fab = findViewById(R.id.addGroupFab);
|
||||||
db = new Database();
|
db = new Database();
|
||||||
colorBtn = (Button) findViewById(R.id.groupColor);
|
colorBtn = (Button) findViewById(R.id.groupColor);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String sl_id = intent.getStringExtra("sl_id");
|
sl_id = intent.getStringExtra("sl_id");
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,151 @@
|
|||||||
|
package at.smartshopper.smartshopper.customViews;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import at.smartshopper.smartshopper.R;
|
||||||
|
import at.smartshopper.smartshopper.activitys.Dash;
|
||||||
|
import at.smartshopper.smartshopper.activitys.DoneItemActivity;
|
||||||
|
import at.smartshopper.smartshopper.activitys.LoginActivity;
|
||||||
|
import at.smartshopper.smartshopper.db.Database;
|
||||||
|
|
||||||
|
public class ToolbarHelper extends Activity {
|
||||||
|
|
||||||
|
private PopupWindow popupAddShare;
|
||||||
|
private Database db = new Database();
|
||||||
|
private Context context;
|
||||||
|
private View decor;
|
||||||
|
|
||||||
|
public ToolbarHelper(Context context, View decor) {
|
||||||
|
this.context = context;
|
||||||
|
this.decor = decor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logt den User aus und geht zur Login Activity
|
||||||
|
*/
|
||||||
|
public void logout() {
|
||||||
|
finish();
|
||||||
|
FirebaseAuth.getInstance().signOut();
|
||||||
|
Intent intent = new Intent(context, LoginActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doneEinkauf(String from, String sl_id,String group_id, String groupname) {
|
||||||
|
finish();
|
||||||
|
Intent intent = new Intent(context, DoneItemActivity.class);
|
||||||
|
intent.putExtra("from", from);
|
||||||
|
intent.putExtra("sl_id", sl_id);
|
||||||
|
intent.putExtra("groupNameString", groupname);
|
||||||
|
intent.putExtra("group_id", group_id);
|
||||||
|
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Öffnet ein popup in dem ein invite link eingegeben werden kann. Diese Shoppingliste wird dann hinzugefügt
|
||||||
|
*/
|
||||||
|
public void popupaddInvite() {
|
||||||
|
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||||
|
View popupContentView = inflater.inflate(R.layout.add_share_link, null);
|
||||||
|
|
||||||
|
final TextView linkEingabe = (TextView) popupContentView.findViewById(R.id.addShareLinkInput);
|
||||||
|
|
||||||
|
ImageButton exitButton = (ImageButton) popupContentView.findViewById(R.id.addShareExit);
|
||||||
|
Picasso.get().load(R.drawable.close).into(exitButton);
|
||||||
|
exitButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
popupAddShare.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final Button finish = (Button) popupContentView.findViewById(R.id.shareAddFinish);
|
||||||
|
|
||||||
|
if (!linkEingabe.getText().toString().isEmpty()) {
|
||||||
|
finish.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
finish.setEnabled(false);
|
||||||
|
}
|
||||||
|
linkEingabe.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
if (!linkEingabe.getText().toString().isEmpty()) {
|
||||||
|
finish.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
finish.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
finish.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String invite = linkEingabe.getText().toString();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
db.addInviteLink(invite, FirebaseAuth.getInstance().getCurrentUser().getUid());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
popupAddShare.dismiss();
|
||||||
|
|
||||||
|
|
||||||
|
finish();
|
||||||
|
Intent intent = new Intent(context, Dash.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.putExtra("tab2", "true");
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
popupAddShare = new PopupWindow(popupContentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
popupAddShare.setOutsideTouchable(false);
|
||||||
|
popupAddShare.setFocusable(true);
|
||||||
|
// Set an elevation value for popup window
|
||||||
|
// Call requires API level 21
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
popupAddShare.setElevation(5.0f);
|
||||||
|
}
|
||||||
|
popupAddShare.setAnimationStyle(R.style.popup_window_animation_phone);
|
||||||
|
|
||||||
|
|
||||||
|
popupAddShare.showAtLocation(decor.findViewById(android.R.id.content), Gravity.CENTER, 0, 0);
|
||||||
|
popupAddShare.update();
|
||||||
|
}
|
||||||
|
}
|
13
app/src/main/res/menu/done_items_menu.xml
Normal file
13
app/src/main/res/menu/done_items_menu.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/addInvite"
|
||||||
|
android:title="Insert Invite" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/editUser"
|
||||||
|
android:title="Benutzer bearbeiten" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/logoutBtn"
|
||||||
|
android:enabled="true"
|
||||||
|
android:title="Logout" />
|
||||||
|
</menu>
|
Loading…
x
Reference in New Issue
Block a user