diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle b/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle index 7f76950..b597ccf 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle +++ b/UI/AndroidApp/flavoursWithoutBorders/app/build.gradle @@ -34,7 +34,6 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.gms:play-services-maps:16.0.0' } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml index 4745b2a..a36e51b 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml @@ -45,6 +45,8 @@ + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/LoginActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/LoginActivity.java index b487f60..a8d08c0 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/LoginActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/LoginActivity.java @@ -18,7 +18,7 @@ public class LoginActivity extends BaseActivity { findViewById(R.id.login_btn_sign_up).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(getBaseContext(), SignUpActivity.class); + Intent intent = new Intent(view.getContext(), SignUpActivity.class); startActivity(intent); finish(); } @@ -27,7 +27,7 @@ public class LoginActivity extends BaseActivity { findViewById(R.id.login_btn_login).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(getBaseContext(), MainActivity.class); + Intent intent = new Intent(view.getContext(), MainActivity.class); startActivity(intent); finish(); } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java index 775fdcf..7145b75 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java @@ -29,7 +29,7 @@ public class SignUpActivity extends BaseActivity { findViewById(R.id.sign_up_btn_login).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(getBaseContext(), LoginActivity.class); + Intent intent = new Intent(view.getContext(), LoginActivity.class); startActivity(intent); finish(); } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java index de09f4f..51317d3 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java @@ -1,8 +1,10 @@ package gr.auth.databases.flavours.activities.main; +import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; @@ -13,12 +15,14 @@ import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.activities.restaurant.AddRestaurantActivity; import gr.auth.databases.flavours.activities.main.fragments.MainListFragment; import gr.auth.databases.flavours.activities.main.fragments.MainMapFragment; import gr.auth.databases.flavours.base.BaseActivity; public class MainActivity extends BaseActivity { private static final int NUM_PAGES = 2; + private ViewPager viewPager; private MenuItem menuMapItem; @@ -34,7 +38,6 @@ public class MainActivity extends BaseActivity { actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); - createDrawer(); viewPager = findViewById(R.id.main_pager); @@ -58,16 +61,26 @@ public class MainActivity extends BaseActivity { } }); + findViewById(R.id.main_fab).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class); + startActivity(intent); + } + }); + PagerAdapter pagerAdapter = new MainPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); } @Override public void onBackPressed() { - if (viewPager.getCurrentItem() == 0) { - super.onBackPressed(); - } else { + if (drawer.isDrawerOpen()) { + drawer.closeDrawer(); + } else if (viewPager.getCurrentItem() == 1) { viewPager.setCurrentItem(0); + } else { + super.onBackPressed(); } } diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java new file mode 100644 index 0000000..f032154 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java @@ -0,0 +1,49 @@ +package gr.auth.databases.flavours.activities.restaurant; + +import android.os.Bundle; +import android.view.MenuItem; + +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.Toolbar; +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.base.BaseActivity; + +public class AddRestaurantActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Toolbar toolbar = findViewById(R.id.main_toolbar); + toolbar.setTitle("Add Restaurant"); + setSupportActionBar(toolbar); + ActionBar actionbar = getSupportActionBar(); + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); + + createDrawer(); + } + + @Override + public void onBackPressed() { + if (drawer.isDrawerOpen()) { + drawer.closeDrawer(); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == android.R.id.home) { + drawer.openDrawer(); + return true; + } + + return super.onOptionsItemSelected(item); + } + +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java new file mode 100644 index 0000000..929ff5a --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java @@ -0,0 +1,15 @@ +package gr.auth.databases.flavours.activities.restaurant; + +import gr.auth.databases.flavours.R; +import gr.auth.databases.flavours.base.BaseActivity; + +import android.os.Bundle; + +public class RestaurantActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_restaurant); + } +} diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ScrollAwareFABBehavior.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ScrollAwareFABBehavior.java new file mode 100644 index 0000000..559db83 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ScrollAwareFABBehavior.java @@ -0,0 +1,63 @@ +package gr.auth.databases.flavours.utils; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; + +import com.google.android.material.floatingactionbutton.FloatingActionButton; +import com.google.android.material.snackbar.Snackbar; + +import androidx.annotation.NonNull; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.view.ViewCompat; + +@SuppressWarnings("unused") +public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior { + + public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { + super(); + } + + @Override + public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, + @NonNull final FloatingActionButton child, + @NonNull final View directTargetChild, @NonNull final View target, + final int nestedScrollAxes, int type) { + return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; + } + + @Override + public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, + @NonNull final FloatingActionButton child, + @NonNull final View target, final int dxConsumed, final int dyConsumed, + final int dxUnconsumed, final int dyUnconsumed, int type) { + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, + dyUnconsumed, type); + if (dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 && dyUnconsumed > 50)) { + child.hide(new FloatingActionButton.OnVisibilityChangedListener() { + @Override + public void onHidden(FloatingActionButton fab) { + super.onHidden(fab); + fab.setVisibility(View.INVISIBLE); + } + }); + } else if (dyConsumed < 0 || !target.canScrollVertically(-1) && dyUnconsumed < -50) { + child.show(); + child.setVisibility(View.VISIBLE); + } + } + + @Override + public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, + @NonNull FloatingActionButton child, @NonNull View dependency) { + return dependency instanceof Snackbar.SnackbarLayout; + } + + @Override + public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, + @NonNull FloatingActionButton child, @NonNull View dependency) { + float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); + child.setTranslationY(translationY); + return true; + } +} \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png new file mode 100644 index 0000000..9999b98 Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png differ diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png new file mode 100644 index 0000000..9d8a94e Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png differ diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png new file mode 100644 index 0000000..6d8e55d Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png differ diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png new file mode 100644 index 0000000..3a15191 Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png differ diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png new file mode 100644 index 0000000..078af52 Binary files /dev/null and b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png differ diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml new file mode 100644 index 0000000..e4a64de --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml @@ -0,0 +1,23 @@ + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml index 419ab8b..4e6e36e 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml @@ -29,8 +29,12 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + android:layout_gravity="bottom|end" + android:layout_margin="16dp" + android:src="@drawable/ic_add_white_24dp" + app:fabSize="mini" + app:layout_behavior="gr.auth.databases.flavours.utils.ScrollAwareFABBehavior" /> \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml new file mode 100644 index 0000000..29e5499 --- /dev/null +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml index 2b9e532..a880c57 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml @@ -1,8 +1,10 @@ \ No newline at end of file + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> \ No newline at end of file