Dynamic Linking V2
Erstellt anstatt normalen invite links, dynamic links und speichert diese auch in die db
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								.idea/caches/gradle_models.ser
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.idea/caches/gradle_models.ser
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -42,5 +42,5 @@ dependencies {
 | 
				
			|||||||
    implementation 'com.android.support:recyclerview-v7:28.0.0'
 | 
					    implementation 'com.android.support:recyclerview-v7:28.0.0'
 | 
				
			||||||
    implementation 'com.android.support:support-v4:28.0.0'
 | 
					    implementation 'com.android.support:support-v4:28.0.0'
 | 
				
			||||||
    implementation 'cz.msebera.android:httpclient:4.4.1.2'
 | 
					    implementation 'cz.msebera.android:httpclient:4.4.1.2'
 | 
				
			||||||
    implementation 'com.google.firebase:firebase-dynamic-links:16.1.7'
 | 
					    implementation 'com.google.firebase:firebase-dynamic-links:16.1.8'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,12 +39,16 @@ import com.google.android.gms.tasks.OnCompleteListener;
 | 
				
			|||||||
import com.google.android.gms.tasks.Task;
 | 
					import com.google.android.gms.tasks.Task;
 | 
				
			||||||
import com.google.firebase.auth.FirebaseAuth;
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
import com.google.firebase.auth.FirebaseUser;
 | 
					import com.google.firebase.auth.FirebaseUser;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.DynamicLink;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.ShortDynamicLink;
 | 
				
			||||||
import com.google.firebase.iid.FirebaseInstanceId;
 | 
					import com.google.firebase.iid.FirebaseInstanceId;
 | 
				
			||||||
import com.google.firebase.iid.InstanceIdResult;
 | 
					import com.google.firebase.iid.InstanceIdResult;
 | 
				
			||||||
import com.squareup.picasso.Picasso;
 | 
					import com.squareup.picasso.Picasso;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@@ -138,7 +142,35 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        setMsgId();
 | 
					        setMsgId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Intent getIntent = getIntent();
 | 
				
			||||||
 | 
					        String sl_idToGo = getIntent.getStringExtra("sl_idToGo");
 | 
				
			||||||
 | 
					        String inviteToAdd = getIntent.getStringExtra("inviteToAdd");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (sl_idToGo != null && inviteToAdd != null) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                db.addInviteLinkDynamicLink(inviteToAdd, FirebaseAuth.getInstance().getCurrentUser().getUid());
 | 
				
			||||||
 | 
					            } catch (SQLException e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            } catch (JSONException e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					//           Damit werden die Shared Shoppinglists angezeigt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//            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();
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					            //Damit wird die hinzugefügte shoppinglist angezeigt
 | 
				
			||||||
 | 
					            onShoppinglistClickContainer(sl_idToGo);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /*
 | 
					        /*
 | 
				
			||||||
@@ -793,7 +825,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void onShoppinglistClickContainer(String sl_id, View v) {
 | 
					    private void onShoppinglistClickContainer(String sl_id) {
 | 
				
			||||||
        finish();
 | 
					        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);
 | 
				
			||||||
@@ -827,32 +859,22 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
     * @param sl_id Die Shoppingliste von der der invitelink gewünscht ist
 | 
					     * @param sl_id Die Shoppingliste von der der invitelink gewünscht ist
 | 
				
			||||||
     * @return
 | 
					     * @return
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private String getInviteLink(String sl_id) {
 | 
					//    private String getInviteLink(String sl_id, String invitelink, String dynamiclink) {
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        return link;
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onShareClick(final String sl_id, final View v) {
 | 
				
			||||||
        String link = null;
 | 
					        String link = null;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            if (db.isShared(sl_id)) {
 | 
					            if (db.isShared(sl_id)) {
 | 
				
			||||||
                link = db.getInviteLink(sl_id);
 | 
					                link = db.getInviteLink(sl_id);
 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                link = db.createInviteLink(sl_id);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } catch (SQLException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        } catch (JSONException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return link;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void onShareClick(final String sl_id, View v) {
 | 
					 | 
				
			||||||
        final String link = getInviteLink(sl_id);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
 | 
					                final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
 | 
				
			||||||
                View popupContentView = inflater.inflate(R.layout.add_share, null);
 | 
					                View popupContentView = inflater.inflate(R.layout.add_share, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                final TextView linkausgabe = (TextView) popupContentView.findViewById(R.id.shareLink);
 | 
					                final TextView linkausgabe = (TextView) popupContentView.findViewById(R.id.shareLink);
 | 
				
			||||||
        linkausgabe.setText("www.smartshopper.cf/invite/" + link);
 | 
					                linkausgabe.setText("invite.dergeorg.at/invite/" + link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ImageButton exitButton = (ImageButton) popupContentView.findViewById(R.id.shareExit);
 | 
					                ImageButton exitButton = (ImageButton) popupContentView.findViewById(R.id.shareExit);
 | 
				
			||||||
                Picasso.get().load(R.drawable.close).into(exitButton);
 | 
					                Picasso.get().load(R.drawable.close).into(exitButton);
 | 
				
			||||||
@@ -930,6 +952,129 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                popupShare.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
					                popupShare.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
				
			||||||
                popupShare.update();
 | 
					                popupShare.update();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                final String invitelink = db.generateInviteLink();
 | 
				
			||||||
 | 
					                String url = "https://smartshopper.cf/androidinvite/" + sl_id;
 | 
				
			||||||
 | 
					                Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
 | 
				
			||||||
 | 
					                        .setLink(Uri.parse("https://smartshopper.cf/invite/" + invitelink + "?slid=" + sl_id))
 | 
				
			||||||
 | 
					                        .setDomainUriPrefix("https://invite.dergeorg.at/invite")
 | 
				
			||||||
 | 
					                        .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
 | 
				
			||||||
 | 
					                        .buildShortDynamicLink()
 | 
				
			||||||
 | 
					                        .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
 | 
				
			||||||
 | 
					                            @Override
 | 
				
			||||||
 | 
					                            public void onComplete(@NonNull Task<ShortDynamicLink> task) {
 | 
				
			||||||
 | 
					                                if (task.isSuccessful()) {
 | 
				
			||||||
 | 
					                                    // Short link created
 | 
				
			||||||
 | 
					                                    final Uri shortLink = task.getResult().getShortLink();
 | 
				
			||||||
 | 
					                                    try {
 | 
				
			||||||
 | 
					                                        db.createInviteLink(sl_id, invitelink, db.getinviteFromLink(shortLink.toString()));
 | 
				
			||||||
 | 
					                                    } catch (SQLException e) {
 | 
				
			||||||
 | 
					                                        e.printStackTrace();
 | 
				
			||||||
 | 
					                                    } catch (JSONException e) {
 | 
				
			||||||
 | 
					                                        e.printStackTrace();
 | 
				
			||||||
 | 
					                                    } catch (IOException 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);
 | 
				
			||||||
 | 
					                                    try {
 | 
				
			||||||
 | 
					                                        linkausgabe.setText("invite.dergeorg.at/invite/" + db.getInviteLink(sl_id));
 | 
				
			||||||
 | 
					                                    } catch (SQLException e) {
 | 
				
			||||||
 | 
					                                        e.printStackTrace();
 | 
				
			||||||
 | 
					                                    } catch (JSONException e) {
 | 
				
			||||||
 | 
					                                        e.printStackTrace();
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    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();
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    final Button copyButton = (Button) popupContentView.findViewById(R.id.shareCopy);
 | 
				
			||||||
 | 
					                                    copyButton.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					                                        @Override
 | 
				
			||||||
 | 
					                                        public void onClick(View v) {
 | 
				
			||||||
 | 
					                                            copyText(linkausgabe.getText().toString());
 | 
				
			||||||
 | 
					                                            popupShare.dismiss();
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    Button delShare = (Button) popupContentView.findViewById(R.id.delShare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    delShare.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					                                        @Override
 | 
				
			||||||
 | 
					                                        public void onClick(View v) {
 | 
				
			||||||
 | 
					                                            Shoppinglist spl = null;
 | 
				
			||||||
 | 
					                                            try {
 | 
				
			||||||
 | 
					                                                spl = db.getShoppinglist(sl_id);
 | 
				
			||||||
 | 
					                                            } catch (SQLException e) {
 | 
				
			||||||
 | 
					                                                e.printStackTrace();
 | 
				
			||||||
 | 
					                                            } catch (JSONException e) {
 | 
				
			||||||
 | 
					                                                e.printStackTrace();
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                            try {
 | 
				
			||||||
 | 
					                                                MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
 | 
				
			||||||
 | 
					                                                myFirebaseSender.addMember(db.getAdmin(sl_id));
 | 
				
			||||||
 | 
					                                                myFirebaseSender.sendMessage("Das Sharing von " + spl.getname() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " aufgehoben!", spl.getname() + " sharing wurde geändert!");
 | 
				
			||||||
 | 
					                                            } catch (SQLException e) {
 | 
				
			||||||
 | 
					                                                e.printStackTrace();
 | 
				
			||||||
 | 
					                                            } catch (JSONException e) {
 | 
				
			||||||
 | 
					                                                e.printStackTrace();
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                            try {
 | 
				
			||||||
 | 
					                                                db.deleteInvite(db.getInviteLink(shortLink.toString()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                                TabHost tabhost = (TabHost) findViewById(R.id.tabHost1);
 | 
				
			||||||
 | 
					                                                tabhost.setCurrentTab(0);
 | 
				
			||||||
 | 
					                                                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();
 | 
				
			||||||
 | 
					                                    Uri flowchartLink = task.getResult().getPreviewLink();
 | 
				
			||||||
 | 
					                                } else {
 | 
				
			||||||
 | 
					                                    // Error
 | 
				
			||||||
 | 
					                                    // ...
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } catch (JSONException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -945,7 +1090,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onShoppinglistClick(String sl_id, View v) {
 | 
					    public void onShoppinglistClick(String sl_id, View v) {
 | 
				
			||||||
        onShoppinglistClickContainer(sl_id, v);
 | 
					        onShoppinglistClickContainer(sl_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -959,7 +1104,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void sharedOnShareClick(String sl_id, View v) {
 | 
					    public void sharedOnShareClick(String sl_id, View v) throws SQLException, JSONException {
 | 
				
			||||||
        final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
 | 
					        final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
 | 
				
			||||||
        View popupContentView = inflater.inflate(R.layout.edit_share_member, null);
 | 
					        View popupContentView = inflater.inflate(R.layout.edit_share_member, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -970,7 +1115,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
        Button stopShareBtn = popupContentView.findViewById(R.id.delShare);
 | 
					        Button stopShareBtn = popupContentView.findViewById(R.id.delShare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        linkAusgabe.setText("www.smartshopper.cf/invite/" + getInviteLink(sl_id));
 | 
					        linkAusgabe.setText("invite.dergeorg.at/invite/" + db.getInviteLink(sl_id));
 | 
				
			||||||
        exitBtn.setOnClickListener(new View.OnClickListener() {
 | 
					        exitBtn.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
@@ -1019,6 +1164,6 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void sharedOnShoppinglistClick(String sl_id, View v) {
 | 
					    public void sharedOnShoppinglistClick(String sl_id, View v) {
 | 
				
			||||||
        onShoppinglistClickContainer(sl_id, v);
 | 
					        onShoppinglistClickContainer(sl_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,10 +60,19 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
 | 
					                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
 | 
				
			||||||
                        // Get deep link from result (may be null if no link is found)
 | 
					                        // Get deep link from result (may be null if no link is found)
 | 
				
			||||||
                        Uri deepLink = null;
 | 
					                        Uri deepLink = null;
 | 
				
			||||||
 | 
					                        String sl_idToGo = "";
 | 
				
			||||||
                        if (pendingDynamicLinkData != null) {
 | 
					                        if (pendingDynamicLinkData != null) {
 | 
				
			||||||
                            deepLink = pendingDynamicLinkData.getLink();
 | 
					                            deepLink = pendingDynamicLinkData.getLink();
 | 
				
			||||||
 | 
					                            String invite = deepLink.toString();
 | 
				
			||||||
 | 
					                            invite = invite.replaceAll("https://smartshopper.cf/invite/", "");
 | 
				
			||||||
 | 
					                            invite = invite.replaceAll(".slid=.*", "");
 | 
				
			||||||
 | 
					                            sl_idToGo = deepLink.getQueryParameter("slid");
 | 
				
			||||||
                            Log.d("SmartShopper", deepLink.toString());
 | 
					                            Log.d("SmartShopper", deepLink.toString());
 | 
				
			||||||
 | 
					                            if (null != mAuth.getCurrentUser()) {
 | 
				
			||||||
 | 
					                                goDash(sl_idToGo, invite);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        // Handle the deep link. For example, open the linked
 | 
					                        // Handle the deep link. For example, open the linked
 | 
				
			||||||
@@ -109,7 +118,7 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Wechselt zu der Dash Activity
 | 
					     * Wechselt zu der Dash Activity
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void goDash() {
 | 
					    private void goDash(String sl_idToGo, String inviteToAdd) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        FirebaseInstanceId.getInstance().getInstanceId()
 | 
					        FirebaseInstanceId.getInstance().getInstanceId()
 | 
				
			||||||
                .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
 | 
					                .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
 | 
				
			||||||
@@ -156,6 +165,10 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Intent intent = new Intent(this, Dash.class);
 | 
					        Intent intent = new Intent(this, Dash.class);
 | 
				
			||||||
 | 
					        if(sl_idToGo != null){
 | 
				
			||||||
 | 
					            intent.putExtra("sl_idToGo", sl_idToGo);
 | 
				
			||||||
 | 
					            intent.putExtra("inviteToAdd", inviteToAdd);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        finish();
 | 
					        finish();
 | 
				
			||||||
        startActivity(intent);
 | 
					        startActivity(intent);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -175,7 +188,7 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
                            // Sign in success, update UI with the signed-in user's information
 | 
					                            // Sign in success, update UI with the signed-in user's information
 | 
				
			||||||
                            Log.d(TAG, "signInWithEmail:success");
 | 
					                            Log.d(TAG, "signInWithEmail:success");
 | 
				
			||||||
                            FirebaseUser user = mAuth.getCurrentUser();
 | 
					                            FirebaseUser user = mAuth.getCurrentUser();
 | 
				
			||||||
                            goDash();
 | 
					                            goDash(null, null);
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            // If sign in fails, display a message to the user.
 | 
					                            // If sign in fails, display a message to the user.
 | 
				
			||||||
                            Log.w(TAG, "signInWithEmail:failure", task.getException());
 | 
					                            Log.w(TAG, "signInWithEmail:failure", task.getException());
 | 
				
			||||||
@@ -225,7 +238,7 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
        mAuth = FirebaseAuth.getInstance();
 | 
					        mAuth = FirebaseAuth.getInstance();
 | 
				
			||||||
        db = new Database();
 | 
					        db = new Database();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        getDynamicLink();
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Button loginEmailBtn = (Button) findViewById(R.id.loginEmailBtn);
 | 
					        Button loginEmailBtn = (Button) findViewById(R.id.loginEmailBtn);
 | 
				
			||||||
        final TextView email = (TextView) findViewById(R.id.email);
 | 
					        final TextView email = (TextView) findViewById(R.id.email);
 | 
				
			||||||
@@ -277,7 +290,7 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
                            // Sign in success, update UI with the signed-in user's information
 | 
					                            // Sign in success, update UI with the signed-in user's information
 | 
				
			||||||
                            Log.d(TAG, "signInWithCredential:success");
 | 
					                            Log.d(TAG, "signInWithCredential:success");
 | 
				
			||||||
                            FirebaseUser user = mAuth.getCurrentUser();
 | 
					                            FirebaseUser user = mAuth.getCurrentUser();
 | 
				
			||||||
                            goDash();
 | 
					                            goDash(null, null);
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            // If sign in fails, display a message to the user.
 | 
					                            // If sign in fails, display a message to the user.
 | 
				
			||||||
                            Log.w(TAG, "signInWithCredential:failure", task.getException());
 | 
					                            Log.w(TAG, "signInWithCredential:failure", task.getException());
 | 
				
			||||||
@@ -297,9 +310,10 @@ public class LoginActivity extends AppCompatActivity {
 | 
				
			|||||||
    public void onStart() {
 | 
					    public void onStart() {
 | 
				
			||||||
        super.onStart();
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        getDynamicLink();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (null != mAuth.getCurrentUser()) {
 | 
					        if (null != mAuth.getCurrentUser()) {
 | 
				
			||||||
            goDash();
 | 
					            goDash(null, null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,21 @@
 | 
				
			|||||||
package at.smartshopper.smartshopperapp.db;
 | 
					package at.smartshopper.smartshopperapp.db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.net.Uri;
 | 
				
			||||||
import android.os.StrictMode;
 | 
					import android.os.StrictMode;
 | 
				
			||||||
 | 
					import android.support.annotation.NonNull;
 | 
				
			||||||
 | 
					import android.support.v7.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.android.gms.tasks.OnCompleteListener;
 | 
				
			||||||
 | 
					import com.google.android.gms.tasks.Task;
 | 
				
			||||||
import com.google.firebase.auth.FirebaseAuth;
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.DynamicLink;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
 | 
				
			||||||
 | 
					import com.google.firebase.dynamiclinks.ShortDynamicLink;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
import org.json.JSONObject;
 | 
					import org.json.JSONObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.sql.Connection;
 | 
					import java.sql.Connection;
 | 
				
			||||||
import java.sql.DriverManager;
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
import java.sql.PreparedStatement;
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
@@ -21,7 +30,7 @@ import at.smartshopper.smartshopperapp.shoppinglist.details.Details;
 | 
				
			|||||||
import at.smartshopper.smartshopperapp.shoppinglist.details.group.Group;
 | 
					import at.smartshopper.smartshopperapp.shoppinglist.details.group.Group;
 | 
				
			||||||
import at.smartshopper.smartshopperapp.shoppinglist.details.item.Item;
 | 
					import at.smartshopper.smartshopperapp.shoppinglist.details.item.Item;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Database {
 | 
					public class Database extends AppCompatActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    final private String HOST = "188.166.124.80";
 | 
					    final private String HOST = "188.166.124.80";
 | 
				
			||||||
    final private String DB_NAME = "smartshopperdb";
 | 
					    final private String DB_NAME = "smartshopperdb";
 | 
				
			||||||
@@ -163,7 +172,7 @@ public class Database {
 | 
				
			|||||||
    public void deleteInvite(String invitelink) throws SQLException, JSONException {
 | 
					    public void deleteInvite(String invitelink) throws SQLException, JSONException {
 | 
				
			||||||
        String sl_id = getSlIdFromInvite(invitelink);
 | 
					        String sl_id = getSlIdFromInvite(invitelink);
 | 
				
			||||||
        sqlUpdate("DELETE FROM \"Shoppinglist_member\" WHERE sl_id = ?", sl_id);
 | 
					        sqlUpdate("DELETE FROM \"Shoppinglist_member\" WHERE sl_id = ?", sl_id);
 | 
				
			||||||
        sqlUpdate("Update \"Shoppinglist\" set invitelink=null where sl_id=?", sl_id);
 | 
					        sqlUpdate("Update \"Shoppinglist\" set invitelink=null, dynamiclink=null where sl_id=?", sl_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -179,15 +188,17 @@ public class Database {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String getinviteFromLink(String eingabeLink) {
 | 
					    public String getinviteFromLink(String eingabeLink) {
 | 
				
			||||||
        String delString = null;
 | 
					        String delString = null;
 | 
				
			||||||
        if (eingabeLink.contains("https://")) {
 | 
					        if (eingabeLink.contains("https://")) {
 | 
				
			||||||
            delString = "https://www.smartshopper.cf/invite/";
 | 
					            delString = "https://invite.dergeorg.at/invite/";
 | 
				
			||||||
        } else if (eingabeLink.contains("http://")) {
 | 
					        } else if (eingabeLink.contains("http://")) {
 | 
				
			||||||
            delString = "http://www.smartshopper.cf/invite/";
 | 
					            delString = "http://invite.dergeorg.at/invite/";
 | 
				
			||||||
        } else if (eingabeLink.contains("www.smartshopper.cf/invite/")) {
 | 
					        } else if (eingabeLink.contains("invite.dergeorg.at/invite/")) {
 | 
				
			||||||
            delString = "www.smartshopper.cf/invite/";
 | 
					            delString = "invite.dergeorg.at/invite/";
 | 
				
			||||||
        } else if (!eingabeLink.contains("www.smartshopper.cf/invite/")) {
 | 
					        } else if (eingabeLink.contains("www.invite.dergeorg.atf/invite/")) {
 | 
				
			||||||
 | 
					            delString = "www.invite.dergeorg.at/invite";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
            delString = "";
 | 
					            delString = "";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        String invite = eingabeLink.replace(delString, "");
 | 
					        String invite = eingabeLink.replace(delString, "");
 | 
				
			||||||
@@ -204,7 +215,7 @@ public class Database {
 | 
				
			|||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String getInviteLink(String sl_id) throws SQLException, JSONException {
 | 
					    public String getInviteLink(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "Select invitelink from \"Shoppinglist\" WHERE sl_id = ?";
 | 
					        String SQL = "Select dynamiclink from \"Shoppinglist\" WHERE sl_id = ?";
 | 
				
			||||||
        String returnLink = executeQuery(SQL, sl_id);
 | 
					        String returnLink = executeQuery(SQL, sl_id);
 | 
				
			||||||
        return returnLink;
 | 
					        return returnLink;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -218,6 +229,20 @@ public class Database {
 | 
				
			|||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String getSlIdFromInvite(String invitelink) throws SQLException, JSONException {
 | 
					    public String getSlIdFromInvite(String invitelink) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        String SQL = "Select sl_id from \"Shoppinglist\" WHERE dynamiclink = ?";
 | 
				
			||||||
 | 
					        String returnSl_id = executeQuery(SQL, getinviteFromLink(invitelink));
 | 
				
			||||||
 | 
					        return returnSl_id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 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
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public String getSlIdFromInviteDynamicLink(String invitelink) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "Select sl_id from \"Shoppinglist\" WHERE invitelink = ?";
 | 
					        String SQL = "Select sl_id from \"Shoppinglist\" WHERE invitelink = ?";
 | 
				
			||||||
        String returnSl_id = executeQuery(SQL, getinviteFromLink(invitelink));
 | 
					        String returnSl_id = executeQuery(SQL, getinviteFromLink(invitelink));
 | 
				
			||||||
        return returnSl_id;
 | 
					        return returnSl_id;
 | 
				
			||||||
@@ -239,6 +264,21 @@ public class Database {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 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 addInviteLinkDynamicLink(String invitelink, String uid) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        String sl_id = getSlIdFromInviteDynamicLink(invitelink);
 | 
				
			||||||
 | 
					        if (!sl_id.equals("null")) {
 | 
				
			||||||
 | 
					            sqlUpdate2Param("INSERT INTO \"Shoppinglist_member\" (username, sl_id) VALUES (?, ?)", uid, sl_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Erstellt einen neuen InviteLink
 | 
					     * Erstellt einen neuen InviteLink
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -246,10 +286,17 @@ public class Database {
 | 
				
			|||||||
     * @return Der neue InviteLink
 | 
					     * @return Der neue InviteLink
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String createInviteLink(String sl_id) throws SQLException {
 | 
					    public void createInviteLink(String sl_id, String invitelink, String dynamiclink) throws SQLException, IOException, JSONException {
 | 
				
			||||||
        String invitelink = generateInviteLink();
 | 
					        sqlUpdate3Param("UPDATE \"Shoppinglist\" SET invitelink = ?, dynamiclink = ? WHERE sl_id = ?", invitelink, dynamiclink, sl_id);
 | 
				
			||||||
        sqlUpdate2Param("UPDATE \"Shoppinglist\" SET invitelink = ? WHERE sl_id = ?", invitelink, sl_id);
 | 
					    }
 | 
				
			||||||
        return invitelink;
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Generiert einen neuen dynamic link bei google und gibt nur die id zurück
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return DynamicId von dem neuen link
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void generateDynamicLink(final String sl_id, final String invitelink) throws IOException, SQLException, JSONException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,7 +99,13 @@ public class ShoppinglistSharedAdapter extends RecyclerView.Adapter<Shoppinglist
 | 
				
			|||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
                String sl_id = shoppinglist.getSlId();
 | 
					                String sl_id = shoppinglist.getSlId();
 | 
				
			||||||
                Toast.makeText(v.getContext(), "LISTENER im ADAPTER geht: " + sl_id, Toast.LENGTH_LONG);
 | 
					                Toast.makeText(v.getContext(), "LISTENER im ADAPTER geht: " + sl_id, Toast.LENGTH_LONG);
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
                    sharedOnShareClick.sharedOnShareClick(sl_id, v);
 | 
					                    sharedOnShareClick.sharedOnShareClick(sl_id, v);
 | 
				
			||||||
 | 
					                } catch (SQLException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                } catch (JSONException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -211,7 +217,7 @@ public class ShoppinglistSharedAdapter extends RecyclerView.Adapter<Shoppinglist
 | 
				
			|||||||
     * Interface damit onoclick in der dash activity ausgeführt werden kann
 | 
					     * Interface damit onoclick in der dash activity ausgeführt werden kann
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public interface SharedOnShareClick {
 | 
					    public interface SharedOnShareClick {
 | 
				
			||||||
        void sharedOnShareClick(String sl_id, View v);
 | 
					        void sharedOnShareClick(String sl_id, View v) throws SQLException, JSONException;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user