Browse Source

Add ProfileActivity, Minor fixes

master
Apostolos Fanakis 6 years ago
parent
commit
b144e3251a
  1. 1
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
  2. 6
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java
  3. 6
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java
  4. 136
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java
  5. 71
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java
  6. 71
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java
  7. 76
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java
  8. 71
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java
  9. 1
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  10. 6
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java
  11. 25
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java
  12. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java
  13. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java
  14. 8
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java
  15. 52
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml
  16. 12
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml
  17. 12
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml
  18. 54
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml
  19. 4
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/ingredient_row.xml
  20. 25
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_row.xml
  21. 53
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml

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

@ -52,6 +52,7 @@
<activity android:name=".activities.drink.DrinkActivity" />
<activity android:name=".activities.AddRestaurantActivity" />
<activity android:name=".activities.AddItemActivity" />
<activity android:name=".activities.profile.ProfileActivity" />
</application>
</manifest>

6
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java

@ -40,9 +40,11 @@ public class DrinkInfoFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.fragment_drink_info, container, false);
TextView restaurantServing = rootView.findViewById(R.id.drink_serving_restaurant);
restaurantServing.setText(getString(R.string.drink_serving_restaurant, "Restaurant's name"));
restaurantServing.setText(getString(R.string.drink_serving_restaurant_placeholder, "Restaurant's name"));
TextView hasAlcohol = rootView.findViewById(R.id.drink_contains_alcohol);
hasAlcohol.setText(getString(R.string.drink_has_alcohol, "YES"));
hasAlcohol.setText(getString(R.string.drink_has_alcohol_placeholder, "YES"));
TextView rating = rootView.findViewById(R.id.drink_rating);
rating.setText(getString(R.string.drink_rating_placeholder, 4.65));
TextView description = rootView.findViewById(R.id.drink_description);
description.setText("a description");
return rootView;

6
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java

@ -40,9 +40,11 @@ public class FoodInfoFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.fragment_food_info, container, false);
TextView restaurantServing = rootView.findViewById(R.id.food_serving_restaurant);
restaurantServing.setText(getString(R.string.food_serving_restaurant, "Restaurant's name"));
restaurantServing.setText(getString(R.string.food_serving_restaurant_placeholder, "Restaurant's name"));
TextView calories = rootView.findViewById(R.id.food_calories);
calories.setText(getString(R.string.food_calories, 500));
calories.setText(getString(R.string.food_calories_placeholder, 500));
TextView rating = rootView.findViewById(R.id.food_rating);
rating.setText(getString(R.string.food_rating_placeholder, 4.65));
TextView description = rootView.findViewById(R.id.food_description);
description.setText("some awesome description");
return rootView;

136
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/ProfileActivity.java

@ -0,0 +1,136 @@
package gr.auth.databases.flavours.activities.profile;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.profile.fragments.ProfileDrinkRatingsFragment;
import gr.auth.databases.flavours.activities.profile.fragments.ProfileFoodRatingsFragment;
import gr.auth.databases.flavours.activities.profile.fragments.ProfileInfoFragment;
import gr.auth.databases.flavours.activities.profile.fragments.ProfileRestaurantRatingsFragment;
import gr.auth.databases.flavours.base.BaseActivity;
public class ProfileActivity extends BaseActivity {
public static final String BUNDLE_USER_ID = "BUNDLE_USER_ID";
private ViewPager viewPager;
private FloatingActionButton FAB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
Toolbar toolbar = findViewById(R.id.profile_toolbar);
toolbar.setTitle("Username");
setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar();
if (actionbar != null) {
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp);
}
createDrawer();
FAB = findViewById(R.id.profile_fab);
FAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
viewPager = findViewById(R.id.profile_pager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageSelected(int position) {
if (position != 0) {
FAB.hide();
} else {
FAB.show();
}
}
});
setupViewPager(viewPager);
TabLayout tabLayout = findViewById(R.id.profile_tabs);
tabLayout.setupWithViewPager(viewPager);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
drawer.openDrawer();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen()) {
drawer.closeDrawer();
} else {
super.onBackPressed();
}
}
private void setupViewPager(ViewPager viewPager) {
RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager());
adapter.addFrag(ProfileInfoFragment.newInstance(64), "INFO");
adapter.addFrag(ProfileFoodRatingsFragment.newInstance(64), "FOODS");
adapter.addFrag(ProfileDrinkRatingsFragment.newInstance(64), "DRINKS");
adapter.addFrag(ProfileRestaurantRatingsFragment.newInstance(64), "PLACES");
viewPager.setAdapter(adapter);
}
private class RestaurantPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
RestaurantPagerAdapter(FragmentManager manager) {
super(manager);
}
@NonNull
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
}

71
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileDrinkRatingsFragment.java

@ -0,0 +1,71 @@
package gr.auth.databases.flavours.activities.profile.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.utils.ItemRatingsAdapter;
public class ProfileDrinkRatingsFragment extends Fragment {
public ProfileDrinkRatingsFragment() {
// Required empty public constructor
}
private static final String PROFILE_ID = "PROFILE_ID";
private int profileId;
public static ProfileDrinkRatingsFragment newInstance(int profileId) {
ProfileDrinkRatingsFragment fragment = new ProfileDrinkRatingsFragment();
Bundle args = new Bundle();
args.putInt(PROFILE_ID, profileId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
assert getArguments() != null;
profileId = getArguments().getInt(PROFILE_ID);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<ItemRating> ratings = new ArrayList<>();
ratings.add(new ItemRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Apostolof", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM));
Context context = getContext();
assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mainContent.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
layoutManager.getOrientation());
mainContent.addItemDecoration(dividerItemDecoration);
return rootView;
}
}

71
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileFoodRatingsFragment.java

@ -0,0 +1,71 @@
package gr.auth.databases.flavours.activities.profile.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.utils.ItemRatingsAdapter;
public class ProfileFoodRatingsFragment extends Fragment {
public ProfileFoodRatingsFragment() {
// Required empty public constructor
}
private static final String PROFILE_ID = "PROFILE_ID";
private int profileId;
public static ProfileFoodRatingsFragment newInstance(int profileId) {
ProfileFoodRatingsFragment fragment = new ProfileFoodRatingsFragment();
Bundle args = new Bundle();
args.putInt(PROFILE_ID, profileId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
assert getArguments() != null;
profileId = getArguments().getInt(PROFILE_ID);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<ItemRating> ratings = new ArrayList<>();
ratings.add(new ItemRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Apostolof", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new ItemRating(4, "Apostolof", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM));
Context context = getContext();
assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mainContent.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
layoutManager.getOrientation());
mainContent.addItemDecoration(dividerItemDecoration);
return rootView;
}
}

76
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileInfoFragment.java

@ -0,0 +1,76 @@
package gr.auth.databases.flavours.activities.profile.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.fragment.app.Fragment;
import gr.auth.databases.flavours.R;
public class ProfileInfoFragment extends Fragment {
public ProfileInfoFragment() {
// Required empty public constructor
}
private static final String PROFILE_ID = "PROFILE_ID";
private int profileId;
public static ProfileInfoFragment newInstance(int profileId) {
ProfileInfoFragment fragment = new ProfileInfoFragment();
Bundle args = new Bundle();
args.putInt(PROFILE_ID, profileId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
assert getArguments() != null;
profileId = getArguments().getInt(PROFILE_ID);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_profile_info, container, false);
TextView email = rootView.findViewById(R.id.profile_email);
email.setText(getString(R.string.profile_email_placeholder, "apotwohd@gmail.com"));
TextView age = rootView.findViewById(R.id.profile_age);
age.setText(getString(R.string.profile_age_placeholder, 23));
TextView numberOfRatings = rootView.findViewById(R.id.profile_number_of_reviews);
numberOfRatings.setText(getString(R.string.profile_number_of_reviews_placeholder, 52));
numberOfRatings.setVisibility(View.VISIBLE);
TextView ownsRestaurant = rootView.findViewById(R.id.profile_owns_restaurant);
ownsRestaurant.setText(getString(R.string.profile_owns_restaurant_placeholder, "Κανένα :("));
ownsRestaurant.setVisibility(View.VISIBLE);
(rootView.findViewById(R.id.profile_diets_list_title)).setVisibility(View.VISIBLE);
LinearLayout dietsList = rootView.findViewById(R.id.profile_diets_list);
dietsList.setVisibility(View.VISIBLE);
View userDietRow = getLayoutInflater().inflate(R.layout.profile_diet_row, dietsList, false);
TextView dietName = userDietRow.findViewById(R.id.profile_diet_name);
dietName.setText("Όγκος φυσικά");
AppCompatImageButton removeDiet = userDietRow.findViewById(R.id.profile_diet_remove);
removeDiet.setVisibility(View.VISIBLE);
removeDiet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO
}
});
dietsList.addView(userDietRow);
return rootView;
}
}

71
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/profile/fragments/ProfileRestaurantRatingsFragment.java

@ -0,0 +1,71 @@
package gr.auth.databases.flavours.activities.profile.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.RestaurantRating;
import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter;
public class ProfileRestaurantRatingsFragment extends Fragment {
public ProfileRestaurantRatingsFragment() {
// Required empty public constructor
}
private static final String PROFILE_ID = "PROFILE_ID";
private int profileId;
public static ProfileRestaurantRatingsFragment newInstance(int profileId) {
ProfileRestaurantRatingsFragment fragment = new ProfileRestaurantRatingsFragment();
Bundle args = new Bundle();
args.putInt(PROFILE_ID, profileId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
assert getArguments() != null;
profileId = getArguments().getInt(PROFILE_ID);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<RestaurantRating> ratings = new ArrayList<>();
ratings.add(new RestaurantRating(5, "Apostolof", "Πάρα πολύ καλό!", "2018-01-04", RestaurantRating.Accessibility.MODERATE));
ratings.add(new RestaurantRating(5, "Apostolof", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", RestaurantRating.Accessibility.EASY));
ratings.add(new RestaurantRating(4, "Apostolof", "-", "2018-06-08", RestaurantRating.Accessibility.EASY));
ratings.add(new RestaurantRating(4, "Apostolof", "Μου άρεσε.", "2018-06-08", RestaurantRating.Accessibility.MODERATE));
ratings.add(new RestaurantRating(5, "Apostolof", "Τέλειο.", "2018-06-08", RestaurantRating.Accessibility.EASY));
ratings.add(new RestaurantRating(2, "Apostolof", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new RestaurantRating(4, "Apostolof", "-", "2018-06-08", RestaurantRating.Accessibility.MODERATE));
Context context = getContext();
assert context != null;
RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mainContent.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
layoutManager.getOrientation());
mainContent.addItemDecoration(dividerItemDecoration);
return rootView;
}
}

1
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java

@ -34,7 +34,6 @@ import static gr.auth.databases.flavours.activities.AddItemActivity.ITEM_TYPE;
public class RestaurantActivity extends BaseActivity
implements RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener,
RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener {
private ViewPager viewPager;
private FloatingActionButton FAB;

6
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsFragment.java

@ -1,5 +1,6 @@
package gr.auth.databases.flavours.activities.restaurant.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -14,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.RestaurantRating;
import gr.auth.databases.flavours.utils.RestaurantRatingsAdapter;
public class RestaurantRatingsFragment extends Fragment {
@ -53,7 +55,9 @@ public class RestaurantRatingsFragment extends Fragment {
ratings.add(new RestaurantRating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new RestaurantRating(4, "eddie lives inside you", "-", "2018-06-08", RestaurantRating.Accessibility.MODERATE));
RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(getContext(), ratings);
Context context = getContext();
assert context != null;
RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(context, ratings);
RecyclerView mainContent = rootView.findViewById(R.id.recycler_list);
mainContent.setAdapter(itemAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());

25
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseActivity.java

@ -18,6 +18,7 @@ import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
@ -27,9 +28,13 @@ import androidx.preference.PreferenceManager;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.activities.LoginActivity;
import gr.auth.databases.flavours.activities.main.MainActivity;
import gr.auth.databases.flavours.activities.profile.ProfileActivity;
import gr.auth.databases.flavours.session.SessionManager;
import okhttp3.OkHttpClient;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static gr.auth.databases.flavours.activities.profile.ProfileActivity.BUNDLE_USER_ID;
public abstract class BaseActivity extends AppCompatActivity {
// Client & Cookies
protected static OkHttpClient client;
@ -158,21 +163,23 @@ public abstract class BaseActivity extends AppCompatActivity {
.withHeaderBackground(R.color.primary)
.withTextColor(getResources().getColor(R.color.iron))
.addProfiles(profileDrawerItem)
/*.withOnAccountHeaderListener((view, profile, currentProfile) -> {
if (sessionManager.isLoggedIn()) {
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean current) {
//if (sessionManager.isLoggedIn()) {
Intent intent = new Intent(BaseActivity.this, ProfileActivity.class);
Bundle extras = new Bundle();
extras.putString(BUNDLE_PROFILE_URL, "https://www.thmmy.gr/smf/index.php?action=profile");
extras.putString(BUNDLE_PROFILE_USERNAME, sessionManager.getUsername());
extras.putInt(BUNDLE_USER_ID, sessionManager.getUserId());
intent.putExtras(extras);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return false;
} else
startLoginActivity();
return true;
})*/
//TODO
/*} else
startLoginActivity();*/
//return true;
}
})
.build();
DrawerBuilder drawerBuilder = new DrawerBuilder()

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/IngredientItemAdapter.java

@ -36,7 +36,7 @@ public class IngredientItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
itemViewHolder.name.setText(ingredient.getName());
itemViewHolder.hasAlcohol.setText(context.getString(R.string.ingredient_has_alcohol,
itemViewHolder.hasAlcohol.setText(context.getString(R.string.ingredient_has_alcohol_placeholder,
ingredient.hasAlcohol() ? "YES" : "NO"));
}

4
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java

@ -36,12 +36,12 @@ public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.
holder.authorUsername.setText(ratings.get(position).getUsername());
holder.date.setText(ratings.get(position).getDate());
holder.grade.setText(context.getString(R.string.restaurant_row_grade_placeholder,
holder.grade.setText(context.getString(R.string.item_ratings_row_grade_placeholder,
ratings.get(position).getGrade()));
if (ratings.get(position).getPortionSize() != null) {
holder.portionSize.setVisibility(View.VISIBLE);
holder.portionSize.setText(context.getString(R.string.restaurant_row_accessibility_placeholder,
holder.portionSize.setText(context.getString(R.string.item_ratings_row_accessibility_placeholder,
ratings.get(position).getPortionSize().toString()));
} else {
holder.portionSize.setVisibility(View.GONE);

8
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsAdapter.java → UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/RestaurantRatingsAdapter.java

@ -1,4 +1,4 @@
package gr.auth.databases.flavours.activities.restaurant.fragments;
package gr.auth.databases.flavours.utils;
import android.content.Context;
import android.view.LayoutInflater;
@ -17,7 +17,7 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRat
private Context context;
private ArrayList<RestaurantRating> ratings;
RestaurantRatingsAdapter(@NonNull Context context, ArrayList<RestaurantRating> ratings) {
public RestaurantRatingsAdapter(@NonNull Context context, ArrayList<RestaurantRating> ratings) {
this.context = context;
this.ratings = ratings;
}
@ -36,12 +36,12 @@ public class RestaurantRatingsAdapter extends RecyclerView.Adapter<RestaurantRat
holder.username.setText(ratings.get(position).getUsername());
holder.date.setText(ratings.get(position).getDate());
holder.grade.setText(context.getString(R.string.restaurant_row_grade_placeholder,
holder.grade.setText(context.getString(R.string.restaurant_ratings_row_grade_placeholder,
ratings.get(position).getGrade()));
if (ratings.get(position).getAccessibility() != null) {
holder.accessibility.setVisibility(View.VISIBLE);
holder.accessibility.setText(context.getString(R.string.restaurant_row_accessibility_placeholder,
holder.accessibility.setText(context.getString(R.string.restaurant_ratings_row_accessibility_placeholder,
ratings.get(position).getAccessibility().toString()));
} else {
holder.accessibility.setVisibility(View.GONE);

52
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_profile.xml

@ -0,0 +1,52 @@
<?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/profile_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolbarTheme">
<androidx.appcompat.widget.Toolbar
android:id="@+id/profile_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:gravity="center"
app:popupTheme="@style/ToolbarTheme" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/profile_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/accent"
app:tabTextColor="@color/iron" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/profile_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/profile_appbar"
app:layout_anchorGravity="bottom|start"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/profile_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
app:fabSize="normal"
app:layout_behavior="gr.auth.databases.flavours.utils.ScrollAwareFABBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

12
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_drink_info.xml

@ -10,17 +10,23 @@
android:id="@+id/drink_serving_restaurant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/drink_serving_restaurant_placeholder" />
android:text="@string/drink_serving_restaurant" />
<TextView
android:id="@+id/drink_contains_alcohol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/drink_has_alcohol_placeholder" />
android:text="@string/drink_has_alcohol" />
<TextView
android:id="@+id/drink_rating"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/drink_rating" />
<TextView
android:id="@+id/drink_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/drink_description_placeholder" />
android:text="@string/drink_description" />
</LinearLayout>

12
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_food_info.xml

@ -10,17 +10,23 @@
android:id="@+id/food_serving_restaurant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/food_serving_restaurant_placeholder" />
android:text="@string/food_serving_restaurant" />
<TextView
android:id="@+id/food_calories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/food_calories_placeholder" />
android:text="@string/food_calories" />
<TextView
android:id="@+id/food_rating"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/food_rating" />
<TextView
android:id="@+id/food_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/food_description_placeholder" />
android:text="@string/food_description" />
</LinearLayout>

54
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_profile_info.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp">
<TextView
android:id="@+id/profile_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_email" />
<TextView
android:id="@+id/profile_age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_age" />
<TextView
android:id="@+id/profile_number_of_reviews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_number_of_reviews"
android:visibility="gone" />
<TextView
android:id="@+id/profile_owns_restaurant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_owns_restaurant"
android:visibility="gone" />
<TextView
android:id="@+id/profile_diets_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_diet_list_title"
android:textStyle="bold"
android:visibility="gone" />
<LinearLayout
android:id="@+id/profile_diets_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

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

@ -10,12 +10,12 @@
android:id="@+id/ingredient_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ingredient_name_placeholder"
android:text="@string/ingredient_name"
android:textStyle="bold" />
<TextView
android:id="@+id/ingredient_has_alcohol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ingredient_has_alcohol_placeholder" />
android:text="@string/ingredient_has_alcohol" />
</LinearLayout>

25
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/profile_diet_row.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profile_diet_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:orientation="horizontal">
<TextView
android:id="@+id/profile_diet_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:text="@string/ingredient_name" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/profile_diet_remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete_black_18dp"
android:visibility="gone" />
</LinearLayout>

53
UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml

@ -46,31 +46,50 @@
<string name="restaurant_toolbar_title">Restaurant Name</string>
<string name="restaurant_working_hours">Working hours: %1$s - %2$s</string>
<string name="restaurant_type">Restaurant type: %1$s</string>
<string name="restaurant_average_rating">Restaurant average rating: %1$f</string>
<string name="restaurant_diet_average_rating">Restaurant average rating for diet %1$s: %2$f</string>
<string name="restaurant_row_grade_placeholder">Grade = %1$d/5</string>
<string name="restaurant_row_accessibility_placeholder">Accessibility = %1$s</string>
<string name="restaurant_average_rating">Restaurant average rating: %1$.2f</string>
<string name="restaurant_diet_average_rating">Restaurant average rating for diet %1$s: %2$.2f</string>
<string name="restaurant_ratings_row_grade_placeholder">Grade = %1$d/5</string>
<string name="restaurant_ratings_row_accessibility_placeholder">Accessibility = %1$s</string>
<!-- Item -->
<string name="item_ratings_row_grade_placeholder">Grade = %1$d/5</string>
<string name="item_ratings_row_accessibility_placeholder">Portion size = %1$s</string>
<!-- Food -->
<string name="food_toolbar_title">Food</string>
<string name="food_serving_restaurant_placeholder">Restaurant</string>
<string name="food_serving_restaurant">Restaurant: %1$s</string>
<string name="food_calories_placeholder">Food calories</string>
<string name="food_calories">Food calories: %1$d</string>
<string name="food_description_placeholder">Food description</string>
<string name="food_serving_restaurant">Restaurant</string>
<string name="food_serving_restaurant_placeholder">Restaurant: %1$s</string>
<string name="food_calories">Food calories</string>
<string name="food_calories_placeholder">Food calories: %1$d</string>
<string name="food_rating">Food average rating</string>
<string name="food_rating_placeholder">Food average rating: %1$.2f/5</string>
<string name="food_description">Food description</string>
<!-- Drink -->
<string name="drink_toolbar_title">Drink</string>
<string name="drink_serving_restaurant_placeholder">Restaurant</string>
<string name="drink_serving_restaurant">Restaurant: %1$s</string>
<string name="drink_has_alcohol_placeholder">Drink has alcohol</string>
<string name="drink_has_alcohol">Drink has alcohol: %1$s</string>
<string name="drink_description_placeholder">Drink description</string>
<string name="drink_serving_restaurant">Restaurant</string>
<string name="drink_serving_restaurant_placeholder">Restaurant: %1$s</string>
<string name="drink_has_alcohol">Drink has alcohol</string>
<string name="drink_has_alcohol_placeholder">Drink has alcohol: %1$s</string>
<string name="drink_rating">Drink average rating</string>
<string name="drink_rating_placeholder">Drink average rating: %1$.2f/5</string>
<string name="drink_description">Drink description</string>
<!-- Profile -->
<string name="profile_email">Email</string>
<string name="profile_email_placeholder">Email: %1$s</string>
<string name="profile_age">Age</string>
<string name="profile_age_placeholder">Age: %1$d</string>
<string name="profile_number_of_reviews">Number of reviews submitted</string>
<string name="profile_number_of_reviews_placeholder">Number of reviews submitted: %1$d</string>
<string name="profile_owns_restaurant">Owns restaurant</string>
<string name="profile_owns_restaurant_placeholder">Owns the restaurant: %1$s</string>
<string name="profile_diet_list_title">Diets:</string>
<!-- Ingredient -->
<string name="ingredient_name_placeholder">Ingredient name</string>
<string name="ingredient_has_alcohol_placeholder">Ingredient contains alcohol</string>
<string name="ingredient_has_alcohol">Ingredient contains alcohol: %1$s</string>
<string name="ingredient_name">Ingredient name</string>
<string name="ingredient_has_alcohol">Ingredient contains alcohol</string>
<string name="ingredient_has_alcohol_placeholder">Ingredient contains alcohol: %1$s</string>
<!-- Add Restaurant -->
<string name="add_restaurant_toolbar_title">Add Restaurant</string>

Loading…
Cancel
Save