Shared Shoppingliste show, add, del, insert link

Alle funktionen von shared sind verfügbar
This commit is contained in:
Georg Reisinger 2019-02-18 00:38:37 +01:00
parent 6eb0e704d1
commit 24f55b60c8
18 changed files with 802 additions and 29 deletions

153
.idea/assetWizardSettings.xml generated Normal file
View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="imageAssetPanel">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="actionbar">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="image">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="assetType" value="IMAGE" />
<entry key="imageAsset" value="C:\Users\georg\Downloads\baseline-share-black-18\2x\baseline_share_black_18dp.png" />
<entry key="outputName" value="share" />
<entry key="themeColor" value="ffffff" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcher">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="foregroundImage">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcherLegacy">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="notification">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="image">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="assetType" value="IMAGE" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputIconType" value="ACTIONBAR" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

Binary file not shown.

View File

@ -40,4 +40,5 @@ dependencies {
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.danielnilsson9:color-picker-view:1.4.0@aar'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
}

View File

@ -1,5 +1,8 @@
package at.smartshopper.smartshopper.activitys;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
@ -7,10 +10,13 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
@ -44,12 +50,12 @@ import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnItemClicked, ShoppinglistAdapter.OnChangeItemClick {
public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnItemClicked, ShoppinglistAdapter.OnChangeItemClick, ShoppinglistAdapter.OnShareClick {
private Database db = new Database();
private SwipeRefreshLayout ownswiperefresh;
private SwipeRefreshLayout ownswiperefresh, sharedswiperefresh;
private FloatingActionButton addShoppinglistFab;
private PopupWindow popupWindowAdd;
private PopupWindow popupWindowAdd, popupShare, popupAddShare;
private String color;
private Button colorBtn;
@ -116,12 +122,30 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
try {
try {
showOwnShoppingList(uid);
showSharedShoppingList(uid);
} catch (SQLException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
sharedswiperefresh = (SwipeRefreshLayout) findViewById(R.id.sharedSwipe);
sharedswiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
try {
showSharedShoppingList(uid);
sharedswiperefresh.setRefreshing(false);
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
ownswiperefresh = (SwipeRefreshLayout) findViewById(R.id.ownSwipe);
ownswiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@ -187,9 +211,9 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
if (fromDB) {
Shoppinglist dbShoppinglist = db.getShoppinglist(sl_id);
String colorstring;
if(dbShoppinglist.getcolor().contains("#")){
if (dbShoppinglist.getcolor().contains("#")) {
colorstring = dbShoppinglist.getcolor();
}else{
} else {
colorstring = "#" + dbShoppinglist.getcolor();
}
this.color = colorstring;
@ -205,7 +229,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
@Override
public void onClick(View v) {
if(fromDB){
if (fromDB) {
try {
db.editShoppinglist(sl_idString, name.getText().toString(), description.getText().toString(), color);
color = "ffffff";
@ -216,7 +240,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
} catch (JSONException e) {
e.printStackTrace();
}
}else {
} else {
try {
db.addShoppinglist(name.getText().toString(), description.getText().toString(), username, color);
color = "ffffff";
@ -259,6 +283,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
popupWindowAdd.setOutsideTouchable(false);
popupWindowAdd.setFocusable(true);
popupWindowAdd.setAnimationStyle(R.style.popup_window_animation_phone);
popupWindowAdd.showAtLocation(v, Gravity.CENTER, 0, 0);
@ -301,6 +326,24 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
}
/**
* Macht eine Datenbankverbindung und holt alle Shoppinglists die mit dem User geteilt werden, diese werden auf dem recycled view angezeigt
*
* @param uid Die UserId damit von diesem user die shoppinglisten angezeigt werden
*/
private void showSharedShoppingList(String uid) throws JSONException, SQLException {
RecyclerView sharedRecycler = (RecyclerView) findViewById(R.id.sharedrecycler);
sharedRecycler.setHasFixedSize(true);
sharedRecycler.setLayoutManager(new LinearLayoutManager(this));
List<Shoppinglist> ownListsList = db.getSharedShoppinglists(uid);
ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList);
shpAdapter.setOnDelClick(Dash.this);
shpAdapter.setOnChangeClick(Dash.this);
shpAdapter.setOnShareClick(Dash.this);
sharedRecycler.setAdapter(shpAdapter);
}
/**
* Macht eine Datenbankverbindung und holt alle Shoppinglists die dem User gehören, diese werden auf dem recycled view angezeigt
*
@ -314,6 +357,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList);
shpAdapter.setOnDelClick(Dash.this);
shpAdapter.setOnChangeClick(Dash.this);
shpAdapter.setOnShareClick(Dash.this);
ownRecycleView.setAdapter(shpAdapter);
}
@ -371,6 +415,9 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
logout();
return true;
case R.id.addInvite:
popupaddInvite();
default:
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
@ -379,6 +426,82 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
}
}
/**
* Öffnet ein popup in dem ein invite link eingegeben werden kann. Diese Shoppingliste wird dann hinzugefügt
*/
private void popupaddInvite() {
final LayoutInflater inflater = (LayoutInflater) getApplicationContext().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();
}
});
Button finish = (Button) popupContentView.findViewById(R.id.shareAddFinish);
finish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String eingabeLink = linkEingabe.getText().toString();
String delString = null;
if (eingabeLink.contains("https://")) {
delString = "https://www.smartshopper.cf/invite/";
} else if (eingabeLink.contains("http://")) {
delString = "http://www.smartshopper.cf/invite/";
} else if (eingabeLink.contains("www.smartshopper.cf/invite/")) {
delString = "www.smartshopper.cf/invite/";
} else if (!eingabeLink.contains("www.smartshopper.cf/invite/")) {
delString = "";
}
String invite = eingabeLink.replace(delString, "");
try {
db.addInviteLink(invite, FirebaseAuth.getInstance().getCurrentUser().getUid());
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
popupAddShare.dismiss();
try {
TabHost tabhost = (TabHost) findViewById(R.id.tabHost1);
tabhost.setCurrentTab(1);
sharedswiperefresh.setRefreshing(true);
showSharedShoppingList(FirebaseAuth.getInstance().getCurrentUser().getUid());
sharedswiperefresh.setRefreshing(false);
} catch (JSONException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
});
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(getWindow().getDecorView().findViewById(android.R.id.content), Gravity.CENTER, 0, 0);
popupAddShare.update();
}
//Für Double Back press to exit
private boolean doubleBackToExitPressedOnce = false;
@ -437,4 +560,90 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
e.printStackTrace();
}
}
@Override
public void onShareClick(String sl_id, View v) {
Log.d("ShareClick test", "Workt sl_id: " + sl_id);
String link = null;
try {
if (db.isShared(sl_id)) {
link = db.getInviteLink(sl_id);
} else {
link = db.createInviteLink(sl_id);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupContentView = inflater.inflate(R.layout.add_share, null);
final TextView linkausgabe = (TextView) popupContentView.findViewById(R.id.shareLink);
linkausgabe.setText("www.smartshopper.cf/invite/" + link);
ImageButton exitButton = (ImageButton) popupContentView.findViewById(R.id.shareExit);
Picasso.get().load(R.drawable.close).into(exitButton);
exitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupShare.dismiss();
}
});
Button copyButton = (Button) popupContentView.findViewById(R.id.shareCopy);
copyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("SmartShopper", linkausgabe.getText().toString());
clipboard.setPrimaryClip(clip);
popupShare.dismiss();
}
});
Button delShare = (Button) popupContentView.findViewById(R.id.delShare);
final String finalLink = link;
delShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
db.deleteInvite(finalLink);
TabHost tabhost = (TabHost) findViewById(R.id.tabHost1);
tabhost.setCurrentTab(1);
sharedswiperefresh.setRefreshing(true);
showSharedShoppingList(FirebaseAuth.getInstance().getCurrentUser().getUid());
sharedswiperefresh.setRefreshing(false);
popupShare.dismiss();
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
popupShare = new PopupWindow(popupContentView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popupShare.setOutsideTouchable(false);
popupShare.setFocusable(true);
// Set an elevation value for popup window
// Call requires API level 21
if (Build.VERSION.SDK_INT >= 21) {
popupShare.setElevation(5.0f);
}
popupShare.setAnimationStyle(R.style.popup_window_animation_phone);
popupShare.showAtLocation(v, Gravity.CENTER, 0, 0);
popupShare.update();
}
}

View File

@ -35,7 +35,6 @@ public class Database {
public Database() {
}
/**
* Verbindet Sich mit der Datenbank. Auf der Konsole wird "Database connected!" angezeigt, bei erfolgreicher verbindung
*
@ -50,10 +49,125 @@ public class Database {
System.out.println("Database connected!");
}
/**
* Entfernt einen invitelink anhand des invitelinks
* @param invitelink Löscht den invitelink aus der ganzen db
* @throws SQLException
* @throws JSONException
*/
public void deleteInvite(String invitelink) throws SQLException, JSONException {
String sl_id = getSlIdFromInvite(invitelink);
sqlUpdate("DELETE FROM \"Shoppinglist_member\" WHERE sl_id = ?", sl_id);
sqlUpdate("Update \"Shoppinglist\" set invitelink=null where sl_id=?", sl_id);
}
/**
* Gibt den Invite link einer Shoppingliste zurück, wenn keiner vorhanden ist --> null
* @param sl_id Die shoppinglist von der der invitelimnk gefragt ist
* @return Der invite link
* @throws SQLException
* @throws JSONException
*/
public String getInviteLink(String sl_id) throws SQLException, JSONException{
connectDatabase();
String SQL = "Select invitelink from \"Shoppinglist\" WHERE sl_id = ?";
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, sl_id);
ResultSet rs = pstmt.executeQuery();
rs.next();
String returnLink = rs.getString(1);
return returnLink;
}
/**
* Sucht anhand des invitelinks eine Shoppingliste und gibt dessen sl_id zurück
* @param invitelink Der invitelink nach dem gesucht werden soll
* @return Die sl_id die dem invitelink zugeordnet ist
* @throws SQLException
* @throws JSONException
*/
private String getSlIdFromInvite(String invitelink) throws SQLException, JSONException{
connectDatabase();
String SQL = "Select sl_id from \"Shoppinglist\" WHERE invitelink = ?";
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, invitelink);
ResultSet rs = pstmt.executeQuery();
rs.next();
String returnSl_id = rs.getString(1);
return returnSl_id;
}
/**
* Fügt einen invite link zu den shoppinglisten hinzu
* @param invitelink Der invite link der hinzugefügt werden soll
* @param uid Der user zu dem der invitelink hinzugefügt werden soll
* @throws SQLException
* @throws JSONException
*/
public void addInviteLink(String invitelink, String uid) throws SQLException, JSONException {
String sl_id = getSlIdFromInvite(invitelink);
if(!sl_id.equals("null")){
sqlUpdate2Param("INSERT INTO \"Shoppinglist_member\" (username, sl_id) VALUES (?, ?)", uid, sl_id);
}
}
/**
* Erstellt einen neuen InviteLink
* @param sl_id
* @return Der neue InviteLink
* @throws SQLException
*/
public String createInviteLink(String sl_id) throws SQLException{
String invitelink = generateInviteLink();
sqlUpdate2Param("UPDATE \"Shoppinglist\" SET invitelink = ? WHERE sl_id = ?", invitelink, sl_id);
return invitelink;
}
/**
* Wenn die Shoppingliste bereits geshared ist wird true zurückgegeben
* @param sl_id Die Liste die geprüft werden soll
* @return True wenn die liste bereits geshared ist
* @throws SQLException
* @throws JSONException
*/
public boolean isShared(String sl_id) throws SQLException, JSONException {
connectDatabase();
String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" WHERE sl_id = ?";
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, sl_id);
ResultSet rs = pstmt.executeQuery();
boolean returnBoolean = false;
while(rs.next()){
JSONObject jsonObject = new JSONObject(rs.getString(1));
Log.d("isShared LOG ", jsonObject.getString("invitelink"));
if(jsonObject.getString("invitelink").equals("null")){
returnBoolean = false;
}else{
returnBoolean = true;
}
}
return returnBoolean;
}
/**
* Löscht eine Gruppe von der Tabelle Group und alle items dieser group, desswegen wird aucj die tabelle item geleert
*
* @param group_id Die group id welche gelöscht werden soll
* @param sl_id Die Shoppingliste auf der sich die group befindet
* @param sl_id Die Shoppingliste auf der sich die group befindet
* @throws SQLException
*/
public void deleteGroup(String group_id, String sl_id) throws SQLException {
@ -61,12 +175,31 @@ public class Database {
sqlUpdate2Param("DELETE FROM \"Group\" WHERE group_id = ? AND sl_id = ?", group_id, sl_id);
}
/**
* Gibt den Besitzer einer Shoppingliste zurück
* @param sl_id Shoppingliste von der der Besitzer gefunden werden soll
* @return Die uid des Besitzers
*/
public String getShoppinglistOwner(String sl_id) throws SQLException {
connectDatabase();
String SQL = "Select username from \"Shoppinglist_admin\" WHERE sl_id = ?";
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, sl_id);
ResultSet rs = pstmt.executeQuery();
String owner = rs.getString(1);
return owner;
}
/**
* Bearbeitet ein Item in der Datenbank
* @param item_id Daqs zu bearbeitende item
*
* @param item_id Daqs zu bearbeitende item
* @param group_id Die gruppe in dem da sitem ist
* @param sl_id die shoppinglist in dem das item ist
* @param newname der neue name
* @param sl_id die shoppinglist in dem das item ist
* @param newname der neue name
* @param newcount die neue anzahl
* @throws SQLException
* @throws JSONException
@ -91,9 +224,10 @@ public class Database {
/**
* Löscht ein item
* @param item_id Item id
*
* @param item_id Item id
* @param group_id group id
* @param sl_id shoppoinglist id
* @param sl_id shoppoinglist id
*/
public void deleteItem(String item_id, String group_id, String sl_id) throws SQLException {
sqlUpdate3Param("DELETE FROM \"Item\" WHERE item_id = ? AND group_id = ? AND sl_id = ?", item_id, group_id, sl_id);
@ -101,10 +235,11 @@ public class Database {
/**
* Fügt ein neues Item der Datenbank hinzu
*
* @param group_id Die group id in der das neue item angezeigt werden soll
* @param sl_id Die Shoppingliste in der das neue item nagezeigt werden soll
* @param name Der name des Items
* @param count Die anzahl des Items
* @param sl_id Die Shoppingliste in der das neue item nagezeigt werden soll
* @param name Der name des Items
* @param count Die anzahl des Items
* @throws SQLException
*/
public void addItem(String group_id, String sl_id, String name, int count) throws SQLException {
@ -154,6 +289,7 @@ public class Database {
/**
* Hollt ein bestimtes item
*
* @param item_id Die sl_id in der das item ist
* @return
* @throws SQLException
@ -349,6 +485,35 @@ public class Database {
}
/**
* Verbindet sich mit dem server
* Holt alle shared shoppinglists des users
* @param uid User von dem die Shared Shoppinglists geholt werden sollen
* @return Die Shared Shoppinglisten des Users
* @throws SQLException
* @throws JSONException
*/
public List<Shoppinglist> getSharedShoppinglists(String uid) throws SQLException, JSONException {
connectDatabase();
String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_member\" USING (sl_id) WHERE username = ?";
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, uid);
ResultSet rs = pstmt.executeQuery();
System.out.println(uid);
ArrayList<Shoppinglist> shoppinglistArrayList = new ArrayList<Shoppinglist>();
while(rs.next()){
String shoppinglist = rs.getString(1);
JSONObject jsonObject = new JSONObject(shoppinglist);
shoppinglistArrayList.add(new Shoppinglist(jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color")));
}
return (List<Shoppinglist>) shoppinglistArrayList;
}
/**
* Hoolt alle groups und items der list und erstelt ein Detail objekt von jeder group. Die detail objekte kommen in eine List
@ -382,8 +547,9 @@ public class Database {
/**
* Holt alle Items einer bestimmten gruppe
*
* @param group_id Gruppe welche geholt werden soll
* @param sl_id Die Shoppinglist in der sich die gruppe befindet
* @param sl_id Die Shoppinglist in der sich die gruppe befindet
* @return
* @throws SQLException
* @throws JSONException
@ -392,9 +558,9 @@ public class Database {
List<Details> details = getListDetails(sl_id);
ArrayList<Item> result = new ArrayList<Item>();
for(Details d : details){
for (Details d : details) {
String group_idtmp = d.getGroup().getGroup_id();
if(group_idtmp.equals(group_id)){
if (group_idtmp.equals(group_id)) {
result = d.getItems();
}
}
@ -428,6 +594,7 @@ public class Database {
private String generateGroupId() {
return generateSL_Id();
}
/**
* Generiert eine neue 8 stellige item_id
*
@ -437,6 +604,15 @@ public class Database {
return generateSL_Id();
}
/**
* Generiert eine neue 8 stellige inviteLink
*
* @return Neue intielink
*/
public String generateInviteLink() {
return generateSL_Id();
}
/**
* Holt alle Items einer bestimmten shoppingliste, angegeben durch die shoppinglist id

View File

@ -14,6 +14,7 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
@ -31,6 +32,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
private OnChangeItemClick onChangeClick;
private OnItemClicked onClick;
private OnShareClick onShareClick;
private at.smartshopper.smartshopper.db.Database db;
//this context we will use to inflate the layout
@ -70,6 +72,11 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
public void onBindViewHolder(ShoppinglistViewHolder holder, final int position) {
//getting the product of the specified position,
final Shoppinglist shoppinglist = this.shoppinglist.get(position);
ImageButton shareButton = holder.share;
Picasso.get().load(R.drawable.share).into(shareButton);
db = new Database();
@ -107,6 +114,15 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
}
});
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String sl_id = shoppinglist.getSlId();
Toast.makeText(v.getContext(), "LISTENER im ADAPTER geht: " + sl_id, Toast.LENGTH_LONG);
onShareClick.onShareClick(sl_id, v);
}
});
int cardcolor;
try {
cardcolor = Color.parseColor(shoppinglist.getcolor());
@ -176,6 +192,25 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
this.onClick=onClick;
}
/**
* Interface damit onoclick in der dash activity ausgeführt werden kann
*/
public interface OnShareClick{
void onShareClick(String sl_id, View v);
}
/**
* Setzt das OnChangeItemClick event
* @param onShareClick Der Click event Listener
*/
public void setOnShareClick(OnShareClick onShareClick){
this.onShareClick = onShareClick;
}
/**
* Haltet alle elemente. Durch ein Objekt von dem kann jedes Element welches hier drinnen angeführt ist verwendet werden
@ -185,7 +220,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
TextView textViewTitle, textViewBeschreibung, ownerName;
ImageView imageView;
CardView ownList;
ImageButton bearbeiten, del;
ImageButton bearbeiten, del, share;
View shoppinglistColor;
public ShoppinglistViewHolder(View itemView) {
@ -199,7 +234,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
bearbeiten = itemView.findViewById(R.id.bearbeiteShoppinglist);
del = itemView.findViewById(R.id.deleteShoppinglist);
shoppinglistColor = itemView.findViewById(R.id.shoppinglistColor);
share = itemView.findViewById(R.id.shareButton);
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="1500"
android:fromAlpha="0.1"
android:toAlpha="1" />
</set>

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -75,10 +75,19 @@
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/sharedrecycler"
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/sharedSwipe"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/sharedrecycler"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical">
<ImageButton
android:id="@+id/shareExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/fui_transparent"
app:srcCompat="@drawable/close"
tools:layout_editor_absoluteY="731dp" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shared Link"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<EditText
android:id="@+id/shareLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:editable="false"
android:ems="10"
android:inputType="textPersonName"
android:text="Shared Link"
tools:layout_editor_absoluteY="731dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<Button
android:id="@+id/shareCopy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="in die zwischenablage kopieren" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="@+id/delShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Share Aufheben" />
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:orientation="vertical">
<ImageButton
android:id="@+id/addShareExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/fui_transparent"
app:srcCompat="@drawable/close" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hier den Invite Link eingeben:"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<EditText
android:id="@+id/addShareLinkInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="@+id/shareAddFinish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fertig" />
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>

View File

@ -76,7 +76,7 @@
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:orientation="vertical"
card_view:layout_constraintBottom_toBottomOf="parent"
@ -118,7 +118,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:layout_constraintGuide_begin="343dp" />
card_view:layout_constraintGuide_begin="319dp" />
<LinearLayout
android:id="@+id/linearLayout3"
@ -133,6 +133,13 @@
card_view:layout_constraintStart_toStartOf="@+id/guideline2"
card_view:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/shareButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/fui_transparent"
card_view:srcCompat="@drawable/share" />
<ImageButton
android:id="@+id/bearbeiteShoppinglist"
android:layout_width="wrap_content"

View File

@ -2,8 +2,8 @@
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/ocrBtn"
android:title="Rechnung Scanen" />
android:id="@+id/addInvite"
android:title="Insert Invite" />
<item
android:id="@+id/logoutBtn"
android:title="Logout"

View File

@ -7,4 +7,8 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="popup_window_animation_phone">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
</resources>