Skip to content

An Android app of a fictional cafe. Just for practice

License

Notifications You must be signed in to change notification settings

vasyl-nadtochii/Cucina

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cucina Android App

Introduction

This application is created only for educational purposes. All coincidences are accidental.

Name Cucina comes from Italian and means "kitchen".

The essence of the project is to create native android application for the fictional pizza franchise.

Basic functionality: user registration and authorization, displaying news, creating and tracking orders, displaying cafes on the map.

The application is translated into 4 languages: English, Ukrainian, Russian, Polish.

Used Tools

Language: Java 1.8

Gradle version: 4.0.1

Libraries (non-Android):

Databases: MySQL 8.0, SQLite (for User menus)

Additional Information

Min. SDK version: 7.0 (Nougat)

App Components

Activities and Fragments

  • StartActivity
  • MainActivity
    • NewsFragment
    • MapFragment
    • OrderFragment (OrderPageFragment, UserMenusFragment)
    • UserOrdersFragment
  • SettingsActivity
    • PreferenceFragment
  • AuthorizationActivity
  • RegistrationActivity
    • GreetingFragment
    • InfoFragment
    • RegFragment
  • OrderActivity
    • OrderFragment/MapFragment (depends on where the Activity was called)
    • MapFragment
    • DescFragment
    • ResultFragment
  • AnnouncementActivity
  • CafeActivity
  • ComplaintActivity
  • DishDescActivity
  • UserMenuActivity

StartActivity

This is the start screen of application. StartActivity is used to apply the application theme depending on the user's choice, redirect user to the MainActivity or to the AuthorizationActivity (if user isn't logged in). Also, StartActivity updates user's FCM token in order's DB table.

StartActivity

MainActivity

MainActivity is the main screen of the application. It consists of ToolBar, FragmentContainer and NavigationView.

FragmentContainer NavigationView

There are 4 Fragments in MainActivity:

NewsFragment

By default, user is redirected to the NewsFragment. It is used to display news in ViewPager and ListView. If the news list length is less than 3, then full news list will be displayed both in VIewPager and ListView. Otherwise, the first half of list will be displayed in ViewPager and the second in ListView. When user clicks ViewPager or ListView item, AnnoncementActivity with the chosen Announcement starts.

Announcement class:

param_name param_type
type* int
image_url String
title String
desc String
end_date String

*type is an Integer, that takes values from 0 to 3: 0 - new opening, 1 - good news, 2 - warning, 3 - bad news.

Depending on a type of Announcement, ListView items may show different icons.

UserOrdersFragment

This Fragment is used to display User's orders. It contains ListView with the order list.

UserOrdersFragment

ListView Adapter uses Order class:

param_name param_type
name String
phone String
orderList ArrayList<OrderDish*>
clarifications String
cafeID int
state int
id int

*orderList ArrayList uses OrderDish class:

param_name param_type
amount int
price int
name String

When the user clicks on ListView item, an AlertDialog with order information pops up.

Order information

If the order state == 3 (declined), there will be button in AlertDialog to delete this order from ListView and database. FloatingActionButton (FAB) in the bottom-right corner does the same thing, but it removes all user's declined orders.

MapFragment

MapFragment contains Fragment container (SupportMapFragment), three FABs in the bottom-right corner: button to move to the current location, to refresh cafe markers, to move to DescFragment (hidden when MapFragment is launched from NavigationView), information layout with chosen cafe address (hidden when MapFragment is launched from NavigationView).

MapFragment is used not only in MainActivity, but also in OrderActivity.

First image is MapFragment launched from NavigationView and the second is MapFragment in OrderActivity:

1 2

Cafe markers have different colors, depending on a state:

  1. Opened - green
  2. Only for takeaway - yellow
  3. Soon closing - red

Closed cafes are not shown on the map. If cafe state == 3 (closes soon), it's not shown on the map, when MapFragment is launched from OrderActivity.

When the MapFragment is started, the application retrieves cafes' coordinates from DB and then creates Markers on the map.

When the user clicks one of that Markers (MapFragment should be started from OrderActivity*), selected Cafe address and id are added to the user's Order.

Otherwise, the application retrieves all the data about the chosen cafe and loads it into Cafe object.

Cafe class:

param_name param_type
latitude double
longitude double
state int
address String
imgUrls ArrayList<String>
cafeID int

Then, the CafeActivity starts.

OrderFragment

OrderFragment contains only TabLayout, ViewPager and 2 FABs: the first adds a new User menu, the second redirects user to the OrderActivity (the first is shown when user switches to the user menus tab, the second is shown when user orders at least 1 meal).

OrderFragment1 OrderFragment2

All main functional is realized in OrderPageFragment and UserMenusFragment.

OrderPageFragment contains ListView, which in turn contains ViewPager in its each item. All dishes are divided into grous (DishGroup), so each ListView item represents each category, and each ViewPager item represents each dish. There are 3 buttons in ViewPager item: to add 1 dish, to remove 1 dish, to see the information about the dish. Also, there are 2 TextViews with the amount of ordered dish and dishes' price.

DishGroup class:

param_name param_type
name String
dishes ArrayList<Dish>

OrderPageFragment also used in OrderFragment in OrderActivity, if it's launched from CafeActvity. Its functional is the same, excepting the moment, that it doesn't use OrderFragment ArrayList<OrderDish> and directy adds dishes to the OrderActivity Order order.

if(!usesActivityList) {   // boolean usesActivityList is used to show if we use the OrderFragment ArrayList or OrderActivity.order ArrayList
    if(OrderFragment.orderList.size() == 1) {
        OrderFragment.orderInterface.showHideFABNext(true);
    }
}
else {
    if(OrderActivity.order.getOrderList().size() == 1) {
        OrderFragment.orderInterface.showHideFABNext(true);
    }
}

UserMenusFragment is used to add dishes from User menus to the order, to change or delete User menus. When OrderFragment is called from OrderActivity, 'Add menu' FAB is disabled.

It contains only one RecyclerView. Each item represents each menu from User menus ArrayList.

UserMenu class:

param_name param_type
id String
name String
dishes ArrayList<OrderDish>

The principle of adding/removing dishes is the same as in the OrderPageFragment.

When a User menu dish list is retrieved from the SQLite database, it is checked for deleted dishes. If the User menu contains removed dishes, user will be notified by the clickable warning sign (which removes deleted dishes from User menu when user clicks it) and the RecyclerView item buttons of this User menu will be disabled.

SettingsActivity

SettingsActivity is only a container for PreferenceFragment. When the user changes the theme, after closing SettingsActivity, the whole application closes. This is done in order to avoid collateral problems when the application applies a new theme.

PreferenceFragment

PreferenceFragment

PreferenceFragment is the PreferenceScreen, which contains Preferences to:

  • Change the theme
  • Change the username
  • Change the phone number
  • Change the city
  • Send bug report
  • Go to the user agreement
  • Show the current application version

The first one changes the application theme. When user chooses new color theme, the application closes after user leaves SettingsActivity.

The next three are used to change user data, sending StringRequest with the changed data. Note: when user wants to change city, it can't be done, while user has active orders (when state < 3). The same thing for the phone number changing. Also, when user changes the phone number to the taken one, he/she gets notified, that the phone number is already taken.

'Bug report' Preference redirects user to the Gmail app or notifies user that the Gmail app is not installed.

Gmail Redirect

'User agreement' Preference opens user agreement sample in browser (I'm sorry, I don't have my own user agreement)

The last one needs no introduction.

AuthorizationActivity

AuthorizationActivity is the simple activity to login user. It has 2 EditText, Button and TextView. If the user entered login data correctly, StringRequest will return all user data, which will be placed in new User object and then user will be redirected to the MainActivity and his/her logged in state will be saved in SharedPreferences. Otherwise, StringRequest will return error and user will be notified that login data is incorrect.

Note: password restoration is not available at this moment. It will be implemented in future updates (maybe)

AuthActivity

User class:

param_name param_type
id int
name String
phone String
city String

The TextView below the login button redirects user to the RegistrationActivity

RegistrationActivity

GreetingFragment InfoFragment RegFragment

This activity contains only ViewPager with a custom FragmentPager adapter (it can be swiped only programatically) and FAB to swipe ViewPager to the next item. There are 3 Fragments in the FragmentPager.

GreetingFragment and InfoFragment

Nothing special. The first one is just the screen with the greeting (particles were used there). The second one is the screen with the enticing slogans. Just decorations.

RegFragment

This Fragment does the whole stuff. It is quite similar to the AuthorizationActivity, but there user also has to enter his name, choose city and confirm his password. If somewhere user enters wrong data, he/she will be notified about that. Then, app sends request, and if it's successful and user's phone is not taken by anyone, user data will be added to the users DB table and user will be logged in with this data as in the AuthorizationActivity.

OrderActivity

OrderActivity has already been mentioned before, this activity stores order information and sends it, when user goes to the last page of FragmentPager. This activity is similar to the RegistrationActivity, OrderActivity uses the same FragmentPager adapter. As in the RegistrationActivity there is only one FAB and ViewPager. When the user is at the first or last page of the FragmentPager, onBackPressed closes the activity. Otherwise, it will swipe one page back.

OrderActivity can be started not only from MainActivity, but also from CafeActivity (if user presses 'Order here' button). If it is started from MainActivity, then the Fragment at the first page will be MapFragment. Otherwise it will be OrderFragment at the first page.

MapFragment and OrderFragment have already been mentioned before, so they will not be described there. Excepting these two, activity has 3 fragments.

DescFragment

This Fragment is used to get order clarifications from EditText. Clarifications string cannot be null.

ConfFragment

ConfFragment displays all order information: address of cafe, clarifications and dishes list. It is used to check the order before sending.

ResFragment

The last one is ResFragment. It shows the result of sending the request.

DescFragment ConfFragment ResFragment

AnnouncementActivity

As it has been mentioned in NewsFragment part, AnnouncementActivity starts when the user clicks at the NewsFragment ListView or ViewPager item (chooses announcement). There is an ImageView at the top of activity and a CardView with announcement header and body TextViews. If the device language is not russian, there will be also translate FAB, which translates header and body text into device language. If it is clicked again, it translates text back into russian.

AnnouncementActivity1 AnnouncementActivity2

CafeActivity

CafeActivity

CafeActivity shows information about the selected cafe from the map. It has 3 TextViews: with cafe address, state and working schedule. Also, it has 3 buttons: to make an order in this cafe (opens OrderActivity), to make a route to the selected cafe (redirects user to the Google maps app), to complain about the selected cafe.

ComplaintActivity

ComplaintActivity has only EditText and FAB. When user presses FAB, app posts complaint to the DB. Complaint string cannot be null.

ComplaintActivity

DishDescActivity

This activity is similar to the AnnouncementActivity. It has the same layout but with the price TextView. 'Translate' FAB does the same stuff as in the AnnouncementActivity.

DishDescActivity

UserMenuActivity

UserMenuActivity is used to add (if it is called from the FAB of the OrderFragment) or to edit (if it is called by clicking 'edit' button in RecyclerView item) User menu. It loads dish list from DB, like the OrderPageFragment does, but there dishes are not divided into categories. When the user clicks FAB, if menu name EditText is not empty, new User menu will be saved.

UserMenuActivity

About

An Android app of a fictional cafe. Just for practice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages