Browse Source

Main fab fixes, Init AddRestaurantActivity, RestaurantActivity

master
Apostolos Fanakis 6 years ago
parent
commit
cef22b3a54
  1. 1
      UI/AndroidApp/flavoursWithoutBorders/app/build.gradle
  2. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
  3. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/LoginActivity.java
  4. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/SignUpActivity.java
  5. 21
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
  6. 49
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java
  7. 15
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  8. 63
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ScrollAwareFABBehavior.java
  9. BIN
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png
  10. BIN
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png
  11. BIN
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
  12. BIN
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png
  13. BIN
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png
  14. 23
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml
  15. 8
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml
  16. 37
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml
  17. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml

1
UI/AndroidApp/flavoursWithoutBorders/app/build.gradle

@ -34,7 +34,6 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' implementation 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@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.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0' implementation 'com.google.android.gms:play-services-maps:16.0.0'
} }

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml

@ -45,6 +45,8 @@
<activity <activity
android:name=".activities.main.MainActivity" android:name=".activities.main.MainActivity"
android:label="@string/main_activity_title" /> android:label="@string/main_activity_title" />
<activity android:name=".activities.restaurant.RestaurantActivity" />
<activity android:name=".activities.restaurant.AddRestaurantActivity" />
</application> </application>
</manifest> </manifest>

4
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() { findViewById(R.id.login_btn_sign_up).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent intent = new Intent(getBaseContext(), SignUpActivity.class); Intent intent = new Intent(view.getContext(), SignUpActivity.class);
startActivity(intent); startActivity(intent);
finish(); finish();
} }
@ -27,7 +27,7 @@ public class LoginActivity extends BaseActivity {
findViewById(R.id.login_btn_login).setOnClickListener(new View.OnClickListener() { findViewById(R.id.login_btn_login).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent intent = new Intent(getBaseContext(), MainActivity.class); Intent intent = new Intent(view.getContext(), MainActivity.class);
startActivity(intent); startActivity(intent);
finish(); finish();
} }

2
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() { findViewById(R.id.sign_up_btn_login).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent intent = new Intent(getBaseContext(), LoginActivity.class); Intent intent = new Intent(view.getContext(), LoginActivity.class);
startActivity(intent); startActivity(intent);
finish(); finish();
} }

21
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; package gr.auth.databases.flavours.activities.main;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
@ -13,12 +15,14 @@ import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import gr.auth.databases.flavours.R; 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.MainListFragment;
import gr.auth.databases.flavours.activities.main.fragments.MainMapFragment; import gr.auth.databases.flavours.activities.main.fragments.MainMapFragment;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity {
private static final int NUM_PAGES = 2; private static final int NUM_PAGES = 2;
private ViewPager viewPager; private ViewPager viewPager;
private MenuItem menuMapItem; private MenuItem menuMapItem;
@ -34,7 +38,6 @@ public class MainActivity extends BaseActivity {
actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp);
createDrawer(); createDrawer();
viewPager = findViewById(R.id.main_pager); 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()); PagerAdapter pagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (viewPager.getCurrentItem() == 0) { if (drawer.isDrawerOpen()) {
super.onBackPressed(); drawer.closeDrawer();
} else { } else if (viewPager.getCurrentItem() == 1) {
viewPager.setCurrentItem(0); viewPager.setCurrentItem(0);
} else {
super.onBackPressed();
} }
} }

49
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);
}
}

15
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);
}
}

63
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<FloatingActionButton> {
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;
}
}

BIN
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

BIN
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

BIN
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

BIN
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

23
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_add_restaurant.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/add_restaurant_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.AppCompat.Light">
<androidx.appcompat.widget.Toolbar
android:id="@+id/add_restaurant_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.AppCompat.Light" />
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

8
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_main.xml

@ -29,8 +29,12 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/main_fab"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_anchor="@id/main_appbar" android:layout_gravity="bottom|end"
app:layout_anchorGravity="bottom|right|end" /> android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
app:fabSize="mini"
app:layout_behavior="gr.auth.databases.flavours.utils.ScrollAwareFABBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

37
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/restaurant_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.AppCompat.Light">
<androidx.appcompat.widget.Toolbar
android:id="@+id/restaurant_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.AppCompat.Light" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_main_list.xml

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_recycler" android:id="@+id/main_recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:orientation="vertical" /> android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Loading…
Cancel
Save