diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index 5a6d845..acece03 100644 Binary files a/.idea/caches/gradle_models.ser and b/.idea/caches/gradle_models.ser differ diff --git a/app/build.gradle b/app/build.gradle index 576c023..f0f5603 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,10 +5,10 @@ android { compileSdkVersion 28 defaultConfig { applicationId "at.smartshopper.smartshopperapp" - minSdkVersion 26 + minSdkVersion 19 targetSdkVersion 28 - versionCode 5 - versionName "3.2" + versionCode 10 + versionName "4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -28,7 +28,7 @@ dependencies { androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.google.firebase:firebase-auth:16.2.0' - implementation 'com.google.firebase:firebase-messaging:17.4.0' + implementation 'com.google.firebase:firebase-messaging:17.5.0' implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-storage:16.1.0' implementation 'com.firebase:firebase-jobdispatcher:0.8.5' diff --git a/app/google-services.json b/app/google-services.json index a6d3bdb..164fd3b 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -30,6 +30,14 @@ "certificate_hash": "4f9180e4472117e0f2b5a891778d247c99b1ea16" } }, + { + "client_id": "221332577314-e0fidj0e30k4f7bffbpn263o6q41klah.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "at.smartshopper.smartshopperapp", + "certificate_hash": "3f5e1db662961243853557e59547222f4980eeb2" + } + }, { "client_id": "221332577314-oo8b4uqtlgj75e7u7o3qt1vc96prfv52.apps.googleusercontent.com", "client_type": 3 diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 52d6ae2..63a7718 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/app.aab b/app/release/app.aab index 72c8a0e..59158b4 100644 Binary files a/app/release/app.aab and b/app/release/app.aab differ diff --git a/app/release/output.json b/app/release/output.json index 59113a0..8fb3618 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5,"versionName":"3.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":10,"versionName":"4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/Dash.java b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/Dash.java index ef6cf37..a22ad30 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/Dash.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/Dash.java @@ -15,6 +15,7 @@ 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.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; @@ -138,6 +139,10 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dash); + + Toolbar myToolbar = (Toolbar) findViewById(R.id.dashToolbar); + setSupportActionBar(myToolbar); + color = "ffffff"; setMsgId(); @@ -289,7 +294,9 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte colorBtn = (Button) customView.findViewById(R.id.addColor); final Button addFertig = (Button) customView.findViewById(R.id.addFertig); final EditText name = (EditText) customView.findViewById(R.id.addName); + name.setTextIsSelectable(true); final EditText description = (EditText) customView.findViewById(R.id.addDescription); + description.setTextIsSelectable(true); Picasso.get().load(R.drawable.close).into(addClose); @@ -298,6 +305,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte } else { addFertig.setEnabled(false); } + name.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -478,7 +486,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte sharedListsListTmp = sharedListsArrayListTmp; } else { sharedListsListTmp = sharedListsList; - findViewById(R.id.pfeilnachunten3).setVisibility(View.GONE); +// findViewById(R.id.pfeilnachunten3).setVisibility(View.GONE); } ShoppinglistSharedAdapter shpAdapter = new ShoppinglistSharedAdapter(Dash.this, sharedListsListTmp, db); if (sharedListsList.isEmpty()) { @@ -599,23 +607,37 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte spec.setIndicator("Geteilte Einkaufslisten"); host.addTab(spec); + host.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { - int i = host.getCurrentTab(); + View pfeil = findViewById(R.id.pfeilnachunten3); + FloatingActionButton fab = findViewById(R.id.addShoppinglistFab); if (i == 0) { try { refreshOwnShoppinglist(uid); + fab.show(); + + if (db.getMyShoppinglists(uid).isEmpty()) { + pfeil.setVisibility(View.VISIBLE); + } else { + pfeil.setVisibility(View.GONE); + } + //TODO } catch (SQLException e) { e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); } } else if (i == 1) { try { showSharedShoppingList(uid); + pfeil.setVisibility(View.GONE); + fab.hide(); } catch (JSONException e) { e.printStackTrace(); } catch (SQLException e) { @@ -863,7 +885,6 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte // // return link; // } - @Override public void onShareClick(final String sl_id, final View v) { String link = null; @@ -874,6 +895,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte View popupContentView = inflater.inflate(R.layout.add_share, null); final TextView linkausgabe = (TextView) popupContentView.findViewById(R.id.shareLink); + linkausgabe.setTextIsSelectable(true); linkausgabe.setText("invite.dergeorg.at/invite/" + link); ImageButton exitButton = (ImageButton) popupContentView.findViewById(R.id.shareExit); @@ -885,15 +907,37 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte } }); - final Button copyButton = (Button) popupContentView.findViewById(R.id.shareCopy); - copyButton.setOnClickListener(new View.OnClickListener() { + ImageButton shareIntentBtn = (ImageButton) popupContentView.findViewById(R.id.shareIntentBtn); + Picasso.get().load(R.drawable.share).into(shareIntentBtn); + shareIntentBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - copyText(linkausgabe.getText().toString()); + String shoppinglistname = ""; + try { + shoppinglistname = db.getShoppinglist(sl_id).getname(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Einladung zum bearbeiten der Shoppingliste " + shoppinglistname + " von: " + FirebaseAuth.getInstance().getCurrentUser().getDisplayName()); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, linkausgabe.getText().toString()); popupShare.dismiss(); + startActivity(Intent.createChooser(sharingIntent, "Teile mit")); } }); +// 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); final String finalLink = link; @@ -979,6 +1023,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte View popupContentView = inflater.inflate(R.layout.add_share, null); final TextView linkausgabe = (TextView) popupContentView.findViewById(R.id.shareLink); + linkausgabe.setTextIsSelectable(true); try { linkausgabe.setText("invite.dergeorg.at/invite/" + db.getInviteLink(sl_id)); } catch (SQLException e) { @@ -996,15 +1041,37 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte } }); - final Button copyButton = (Button) popupContentView.findViewById(R.id.shareCopy); - copyButton.setOnClickListener(new View.OnClickListener() { + ImageButton shareIntentBtn = (ImageButton) popupContentView.findViewById(R.id.shareIntentBtn); + Picasso.get().load(R.drawable.share).into(shareIntentBtn); + shareIntentBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - copyText(linkausgabe.getText().toString()); + String shoppinglistname = ""; + try { + shoppinglistname = db.getShoppinglist(sl_id).getname(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Einladung zum bearbeiten der Shoppingliste " + shoppinglistname + " von: " + FirebaseAuth.getInstance().getCurrentUser().getDisplayName()); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, linkausgabe.getText().toString()); popupShare.dismiss(); + startActivity(Intent.createChooser(sharingIntent, "Teile mit")); } }); +// 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() { @@ -1104,17 +1171,17 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte } @Override - public void sharedOnShareClick(String sl_id, View v) throws SQLException, JSONException { + public void sharedOnShareClick(final String sl_id, View v) throws SQLException, JSONException { final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE); View popupContentView = inflater.inflate(R.layout.edit_share_member, null); ImageButton exitBtn = popupContentView.findViewById(R.id.exitButton); Picasso.get().load(R.drawable.close).into(exitBtn); final TextView linkAusgabe = popupContentView.findViewById(R.id.linkausgabe); - Button copyBtn = popupContentView.findViewById(R.id.copyButton); +// Button copyBtn = popupContentView.findViewById(R.id.copyButton); Button stopShareBtn = popupContentView.findViewById(R.id.delShare); - + linkAusgabe.setTextIsSelectable(true); linkAusgabe.setText("invite.dergeorg.at/invite/" + db.getInviteLink(sl_id)); exitBtn.setOnClickListener(new View.OnClickListener() { @Override @@ -1122,11 +1189,31 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte popupEditShare.dismiss(); } }); - copyBtn.setOnClickListener(new View.OnClickListener() { +// copyBtn.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// copyText(linkAusgabe.getText().toString()); +// popupEditShare.dismiss(); +// } +// }); + ImageButton shareIntentBtn = popupContentView.findViewById(R.id.shareIntentBtn); + Picasso.get().load(R.drawable.share).into(shareIntentBtn); + shareIntentBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - copyText(linkAusgabe.getText().toString()); - popupEditShare.dismiss(); + String shoppinglistname = ""; + try { + shoppinglistname = db.getShoppinglist(sl_id).getname(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Einladung zum bearbeiten der Shoppingliste " + shoppinglistname + " von: " + FirebaseAuth.getInstance().getCurrentUser().getDisplayName()); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, linkAusgabe.getText().toString()); + startActivity(Intent.createChooser(sharingIntent, "Teilen mit")); } }); stopShareBtn.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/DoneItemActivity.java b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/DoneItemActivity.java index c7a2d93..bc6e6b8 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/DoneItemActivity.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/DoneItemActivity.java @@ -6,6 +6,7 @@ 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.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ItemListActivity.java b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ItemListActivity.java index f9f8cdb..2b31c98 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ItemListActivity.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ItemListActivity.java @@ -9,6 +9,7 @@ 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.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.Gravity; @@ -59,24 +60,39 @@ public class ItemListActivity extends AppCompatActivity implements ItemAdapter.O super.onCreate(savedInstanceState); setContentView(R.layout.activity_item_list); + Intent myIntent = getIntent(); // gets the previously created intent this.group_id = myIntent.getStringExtra("group_id"); // will return "FirstKeyValue" this.sl_id = myIntent.getStringExtra("sl_id"); // will return "SecondKeyValue" this.groupNameString = myIntent.getStringExtra("groupNameString"); // will return "SecondKeyValue" this.db = new Database(); + String colorToolbar = null; + try { + colorToolbar = db.getGroup(group_id, sl_id).getColor(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + + Toolbar toolbar = findViewById(R.id.itemToolbar); + toolbar.setTitle("Gruppe: " + this.groupNameString); + String colorstring; + if (colorToolbar.contains("#")) { + colorstring = colorToolbar; + } else { + colorstring = "#" + colorToolbar; + } + toolbar.setBackgroundColor(Color.parseColor(colorstring)); + setSupportActionBar(toolbar); this.groupName = (TextView) findViewById(R.id.groupViewName); this.groupName.setText(groupNameString); this.colorView = (View) findViewById(R.id.itemListColorView); - try { - this.colorView.setBackgroundColor(Color.parseColor(db.getGroup(group_id, sl_id).getColor())); - } catch (SQLException e) { - e.printStackTrace(); - } catch (JSONException e) { - e.printStackTrace(); - } + this.colorView.setBackgroundColor(Color.parseColor(colorstring)); + this.swipeRefreshLayoutItem = (SwipeRefreshLayout) findViewById(R.id.itemListRefresh); this.swipeRefreshLayoutItem.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @@ -182,7 +198,7 @@ public class ItemListActivity extends AppCompatActivity implements ItemAdapter.O List itemListTmp; View pfeil = findViewById(R.id.pfeilnachunten2); if (itemList.isEmpty()) { - itemArrayListTmp.add(new Item("empty", "empty", "empty", "Bitte ein Item Hinzufügen!", "")); + itemArrayListTmp.add(new Item("empty", "empty", "empty", "Bitte ein Item Hinzufügen!", "1")); itemListTmp = itemArrayListTmp; pfeil.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/LoginActivity.java b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/LoginActivity.java index 555c7fc..d8a9e27 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/LoginActivity.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/LoginActivity.java @@ -129,21 +129,11 @@ public class LoginActivity extends AppCompatActivity { return; } - String uid = FirebaseAuth.getInstance().getUid(); + FirebaseUser userFirebase = FirebaseAuth.getInstance().getCurrentUser(); Member user; String name = null; String picture = null; String email = null; - try { - user = db.getUser(uid); - name = user.getName(); - picture = user.getPic(); - email = user.getEmail(); - } catch (SQLException e) { - e.printStackTrace(); - } catch (JSONException e) { - e.printStackTrace(); - } // Get new Instance ID token String token = task.getResult().getToken(); @@ -151,10 +141,23 @@ public class LoginActivity extends AppCompatActivity { try { if (!db.checkIfUserExists(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - db.createUser(uid, token, name, picture, email); + name = userFirebase.getDisplayName(); + picture = userFirebase.getPhotoUrl().toString(); + email = userFirebase.getEmail(); + db.createUser(userFirebase.getUid(), token, name, picture, email); } else { - db.updateUser(uid, token, name, picture, email); + try { + user = db.getUser(userFirebase.getUid()); + name = user.getName(); + picture = user.getPic(); + email = user.getEmail(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + db.updateUser(userFirebase.getUid(), token, name, picture, email); } } catch (SQLException e) { e.printStackTrace(); diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ShoppinglistDetails.java b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ShoppinglistDetails.java index 1b9f9cc..2ed83c3 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ShoppinglistDetails.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/activitys/ShoppinglistDetails.java @@ -9,6 +9,7 @@ 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.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.Gravity; @@ -125,14 +126,25 @@ public class ShoppinglistDetails extends AppCompatActivity implements DetailsAda Intent intent = getIntent(); sl_id = intent.getStringExtra("sl_id"); - + Shoppinglist shoppinglist = null; try { - Shoppinglist shoppinglist = db.getShoppinglist(sl_id); + shoppinglist = db.getShoppinglist(sl_id); } catch (SQLException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } + Toolbar toolbar = findViewById(R.id.shoppinglistDetailsToolbar); + toolbar.setTitle("Shoppingliste: " + shoppinglist.getname()); + String colorstring; + if (shoppinglist.getcolor().contains("#")) { + colorstring = shoppinglist.getcolor(); + } else { + colorstring = "#" + shoppinglist.getcolor(); + } + toolbar.setBackgroundColor(Color.parseColor(colorstring)); + setSupportActionBar(toolbar); + final String finalSl_id = sl_id; fab.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/customViews/AnimatedTabHostListener.java b/app/src/main/java/at/smartshopper/smartshopperapp/customViews/AnimatedTabHostListener.java new file mode 100644 index 0000000..2f28cc2 --- /dev/null +++ b/app/src/main/java/at/smartshopper/smartshopperapp/customViews/AnimatedTabHostListener.java @@ -0,0 +1,191 @@ +package at.smartshopper.smartshopperapp.customViews; + +import android.content.Context; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.Animation; +import android.view.animation.TranslateAnimation; +import android.widget.TabHost; + +public class AnimatedTabHostListener implements TabHost.OnTabChangeListener +{ + + private static final int ANIMATION_TIME = 240; + private TabHost tabHost; + private View previousView; + private View currentView; + private GestureDetector gestureDetector; + private int currentTab; + + /** + * Constructor that takes the TabHost as a parameter and sets previousView to the currentView at instantiation + * + * @param context + * @param tabHost + */ + public AnimatedTabHostListener(Context context, TabHost tabHost) + { + this.tabHost = tabHost; + this.previousView = tabHost.getCurrentView(); + gestureDetector = new GestureDetector(context, new MyGestureDetector()); + tabHost.setOnTouchListener(new View.OnTouchListener() + { + public boolean onTouch(View v, MotionEvent event) + { + if (gestureDetector.onTouchEvent(event)) + { + return false; + } + else + { + return true; + } + } + }); + } + + /** + * When tabs change we fetch the current view that we are animating to and animate it and the previous view in the + * appropriate directions. + */ + @Override + public void onTabChanged(String tabId) + { + + currentView = tabHost.getCurrentView(); + if (tabHost.getCurrentTab() > currentTab) + { + previousView.setAnimation(outToLeftAnimation()); + currentView.setAnimation(inFromRightAnimation()); + } + else + { + previousView.setAnimation(outToRightAnimation()); + currentView.setAnimation(inFromLeftAnimation()); + } + previousView = currentView; + currentTab = tabHost.getCurrentTab(); + + } + + /** + * Custom animation that animates in from right + * + * @return Animation the Animation object + */ + private Animation inFromRightAnimation() + { + Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 1.0f, + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, + 0.0f); + return setProperties(inFromRight); + } + + /** + * Custom animation that animates out to the right + * + * @return Animation the Animation object + */ + private Animation outToRightAnimation() + { + Animation outToRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, + 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); + return setProperties(outToRight); + } + + /** + * Custom animation that animates in from left + * + * @return Animation the Animation object + */ + private Animation inFromLeftAnimation() + { + Animation inFromLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f, + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, + 0.0f); + return setProperties(inFromLeft); + } + + /** + * Custom animation that animates out to the left + * + * @return Animation the Animation object + */ + private Animation outToLeftAnimation() + { + Animation outtoLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, + -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); + return setProperties(outtoLeft); + } + + /** + * Helper method that sets some common properties + * + * @param animation + * the animation to give common properties + * @return the animation with common properties + */ + private Animation setProperties(Animation animation) + { + animation.setDuration(ANIMATION_TIME); + animation.setInterpolator(new AccelerateInterpolator()); + return animation; + } + + /** + * A gesture listener that listens for a left or right swipe and uses the swip gesture to navigate a TabHost that + * uses an AnimatedTabHost listener. + * + * @author Daniel Kvist + * + */ + class MyGestureDetector extends GestureDetector.SimpleOnGestureListener + { + private static final int SWIPE_MIN_DISTANCE = 120; + private static final int SWIPE_MAX_OFF_PATH = 250; + private static final int SWIPE_THRESHOLD_VELOCITY = 200; + private int maxTabs; + + /** + * An empty constructor that uses the tabhosts content view to decide how many tabs there are. + */ + public MyGestureDetector() + { + maxTabs = tabHost.getTabContentView().getChildCount(); + } + + /** + * Listens for the onFling event and performs some calculations between the touch down point and the touch up + * point. It then uses that information to calculate if the swipe was long enough. It also uses the swiping + * velocity to decide if it was a "true" swipe or just some random touching. + */ + @Override + public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) + { + int newTab = 0; + if (Math.abs(event1.getY() - event2.getY()) > SWIPE_MAX_OFF_PATH) + { + return false; + } + if (event1.getX() - event2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) + { + // Swipe right to left + newTab = currentTab + 1; + } + else if (event2.getX() - event1.getX() > SWIPE_MIN_DISTANCE + && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) + { + // Swipe left to right + newTab = currentTab - 1; + } + if (newTab < 0 || newTab > (maxTabs - 1)) + { + return false; + } + tabHost.setCurrentTab(newTab); + return super.onFling(event1, event2, velocityX, velocityY); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/db/Database.java b/app/src/main/java/at/smartshopper/smartshopperapp/db/Database.java index 7df664d..32c5ae1 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/db/Database.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/db/Database.java @@ -132,7 +132,7 @@ public class Database extends AppCompatActivity { } else { newpicture = picture; } - if (email.isEmpty()) { + if (email == null) { newemail = "EMPTY"; } else { newemail = email; @@ -532,7 +532,7 @@ public class Database extends AppCompatActivity { */ public void createUser(String username, String message_id, String name, String picture, String email) throws SQLException { String SQL = "INSERT INTO \"User\" (username, message_id, name, picture, email) VALUES (?, ?, ?, ?, ?)"; - if (picture.isEmpty()) { + if (picture == null) { picture = "https://st2.depositphotos.com/1537427/5927/v/950/depositphotos_59279377-stock-illustration-user-icon.jpg"; } sqlUpdate5Param(SQL, username, message_id, name, picture, email); diff --git a/app/src/main/java/at/smartshopper/smartshopperapp/shoppinglist/ShoppinglistSharedAdapter.java b/app/src/main/java/at/smartshopper/smartshopperapp/shoppinglist/ShoppinglistSharedAdapter.java index 3f9ae2d..68d9ebb 100644 --- a/app/src/main/java/at/smartshopper/smartshopperapp/shoppinglist/ShoppinglistSharedAdapter.java +++ b/app/src/main/java/at/smartshopper/smartshopperapp/shoppinglist/ShoppinglistSharedAdapter.java @@ -118,22 +118,17 @@ public class ShoppinglistSharedAdapter extends RecyclerView.Adapter + + + + app:layout_constraintTop_toBottomOf="@+id/dashToolbar"> diff --git a/app/src/main/res/layout/activity_item_list.xml b/app/src/main/res/layout/activity_item_list.xml index a0e9ca0..e25307f 100644 --- a/app/src/main/res/layout/activity_item_list.xml +++ b/app/src/main/res/layout/activity_item_list.xml @@ -4,10 +4,24 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="8dp" tools:context=".activitys.ItemListActivity"> + + + app:layout_constraintTop_toBottomOf="@+id/itemToolbar"> diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 28847db..01c6371 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -71,6 +71,7 @@ android:id="@+id/loginEmailBtn" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/colorButton" android:text="Login Email" /> diff --git a/app/src/main/res/layout/activity_shoppinglist_details.xml b/app/src/main/res/layout/activity_shoppinglist_details.xml index 08132e6..7b39a69 100644 --- a/app/src/main/res/layout/activity_shoppinglist_details.xml +++ b/app/src/main/res/layout/activity_shoppinglist_details.xml @@ -6,10 +6,21 @@ android:layout_height="match_parent" tools:context=".activitys.ShoppinglistDetails"> + + + app:layout_constraintTop_toBottomOf="@+id/shoppinglistDetailsToolbar"> diff --git a/app/src/main/res/layout/add_group_dialog.xml b/app/src/main/res/layout/add_group_dialog.xml index 190d15d..a4076f3 100644 --- a/app/src/main/res/layout/add_group_dialog.xml +++ b/app/src/main/res/layout/add_group_dialog.xml @@ -94,6 +94,7 @@ android:id="@+id/groupColor" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/colorButton" android:text="Farbe Auswählen" /> @@ -113,6 +114,7 @@ android:id="@+id/groupFinish" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/colorButton" android:text="Fertig" /> diff --git a/app/src/main/res/layout/add_item_dialog.xml b/app/src/main/res/layout/add_item_dialog.xml index 6fb0b47..ab176bc 100644 --- a/app/src/main/res/layout/add_item_dialog.xml +++ b/app/src/main/res/layout/add_item_dialog.xml @@ -121,6 +121,7 @@ android:id="@+id/itemFinish" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/colorButton" android:text="Fertig" /> diff --git a/app/src/main/res/layout/add_share.xml b/app/src/main/res/layout/add_share.xml index 44f2c9e..b3048c2 100644 --- a/app/src/main/res/layout/add_share.xml +++ b/app/src/main/res/layout/add_share.xml @@ -62,6 +62,7 @@ android:ems="10" android:inputType="textPersonName" android:text="Shared Link" + android:textIsSelectable="true" tools:layout_editor_absoluteY="731dp" /> @@ -71,13 +72,26 @@ android:layout_height="match_parent" android:gravity="center"> -