Recipebook Documentation

This can be a documentation for recipebook app created by WebsiteMan. Recipebook is a local Android software. You will discover right here helpful information about configuring, customizing, constructing and publishing the app.


  • Help for Ice Cream Sandwich (Android and newer
  • Developed with Android Studio & Gradle
  • Materials design following Android Design Tips
  • Eight colour themes (blue, brown, carrot, grey, inexperienced, indigo, purple, yellow)
  • Animations and results
  • Animated motion bar
  • Animated floating motion button
  • Parallax scrolling impact
  • Fast return impact
  • Ripple impact
  • Navigation drawer menu with classes
  • Record of recipes
  • Seek for recipe with suggestion
  • Favourite recipes
  • Recipe element display (intro, components, instruction)
  • Components verify listing
  • Share recipe or buying listing
  • Open net hyperlink of the recipe
  • Kitchen timer
  • Recalculate amount of elements by servings
  • Convert energy to joules
  • About dialog
  • Fee app on Google Play
  • Knowledge (classes, recipes, elements) is saved in native SQLite database
  • Photographs might be loaded from the Web or regionally
  • Caching pictures
  • App works in offline mode
  • Google Analytics
  • AdMob
  • Responsive design and pill help (portrait, panorama, dealing with orientation change)
  • Help for top-decision shows (xxhdpi)
  • Multi-language help
  • Risk to construct the undertaking with out Android Studio / Eclipse (utilizing Gradle & Android SDK)
  • Straightforward configuration
  • Nicely documented
  • High-quality clear code created by skilled senior Android developer
  • Free help

Android SDK & Android Studio

This chapter describes tips on how to set up Android SDK and Android Studio. You don’t have to put in Android Studio, however it’s higher. The challenge might be constructed with out Android Studio, utilizing Gradle and Android SDK. Gradle is a construct system used for constructing ultimate APK file.

  1. Set up Java JDK
  2. Set up Android SDK
  3. Run Android SDK Supervisor and download necessary SDK packages, just remember to have put in Android SDK Instruments, Android SDK Platform-instruments, Android SDK Construct-instruments, Android Help Repository, Android Help Library and Google Play providers
  4. Set up Android Studio
  5. Now it is best to be capable of open/edit the Android venture and construct APK
  6. You can too set up Genymotion – quick Android emulator

Venture construction

Venture has the next construction (directories are marked by sq. braces):

  • [doc] – documentation
  • [extras] – accommodates extras
  • [extras]/[keystore]
  • [extras]/[keystore]/recipebook.keystore – keystore certificates for signing APK
  • [extras]/[keystore]/ – alias and password for keystore
  • [gradle]
  • [gradle]/[wrapper] – Gradle Wrapper
  • [mobile] – most important module
  • [mobile]/[libs] – accommodates third celebration libraries (not used)
  • [mobile]/[src] – incorporates supply code
  • [mobile]/[src]/[main]
  • [mobile]/[src]/[main]/[assets] – asset information (prepopulated database, photographs)
  • [mobile]/[src]/[main]/[java] – java sources
  • [mobile]/[src]/[main]/[res] – xml assets, drawables
  • [mobile]/[src]/[main]/AndroidManifest.xml – manifest file
  • [mobile]/construct.gradle – fundamental construct script
  • [mobile]/proguard-guidelines.professional – Proguard config (not used)
  • .gitignore – Gitignore file
  • construct.gradle – father or mother construct script
  • – construct script properties containing path to keystore
  • gradlew – Gradle Wrapper (Unix)
  • gradlew.bat – Gradle Wrapper (Home windows)
  • – readme file
  • settings.gradle – construct settings containing listing of modules

Java packages:

  • com.websiteman.recipebook – accommodates software class and most important config class
  • com.websiteman.recipebook.exercise – incorporates actions representing screens
  • com.websiteman.recipebook.adapter – incorporates all adapters
  • com.websiteman.recipebook.content material – incorporates content material supplier for search ideas
  • com.websiteman.recipebook.database – incorporates database helper and instruments for managing asynchronous database calls
  • com.websiteman.recipebook.database.dao – database entry objects
  • com.websiteman.recipebook.database.knowledge – knowledge mannequin wrapper
  • com.websiteman.recipebook.database.mannequin – database fashions representing SQL tables
  • com.websiteman.recipebook.database.question – database queries
  • com.websiteman.recipebook.dialog – accommodates dialogs
  • com.websiteman.recipebook.fragment – accommodates fragments with major software logic
  • com.websiteman.recipebook.listener – accommodates listeners
  • com.websiteman.recipebook.utility – incorporates utilities
  • com.websiteman.recipebook.view – accommodates customized views, layouts, decorations and different instruments for working with views


This chapter describes the right way to configure the undertaking to be prepared for publishing. All these steps are essential!

1. Import

Unzip the package deal and import/open the undertaking in Android Studio. Select “Import undertaking” on Fast Begin display and choose “recipebook-x.y.z” listing.

2. Rename package deal identify

  1. Create new package deal in java listing, e.g. “com.mycompany.myapp”. Proper click on on cellular/src/principal/java listing -> New -> Package deal.
  2. Choose all packages and courses in “com.websiteman.recipebook” and transfer (drag) them to the brand new package deal. Affirm by click on on “Do Refactor”.
  3. Delete the previous package deal “com.websiteman.recipebook”.
  4. Open cellular/src/most important/AndroidManifest.xml and rename the package deal identify. Choose package deal identify “com.websiteman.recipebook” -> Proper click on on chosen textual content -> Refactor -> Rename -> enter the brand new package deal identify, choose “Search in feedback and strings” choice -> Refactor -> Do Refactor.
  5. Clear the venture. Most important menu -> Construct -> Clear Undertaking.
  6. Substitute all occurrences of “com.websiteman.recipebook” for a brand new package deal identify, e.g. “com.mycompany.myapp”. Proper click on on cellular listing -> Substitute in Path -> set previous and new package deal names, Case delicate to true -> Discover -> Substitute.
  7. Clear the challenge once more. Essential menu -> Construct -> Clear Undertaking.
  8. Synchronize the venture. Essential menu -> Instruments -> Android -> Sync Undertaking with Gradle Information.
  9. In the event you see “Exercise class doesn’t exist” error, restart Android Studio.

three. Rename software identify

Open cellular/src/primary/res/values/strings.xml and alter “recipebook” to your personal identify. Change app_name and drawer_title strings.

four. Create launcher icon

Proper click on on cellular/src/fundamental/res listing -> New -> Picture Asset -> Asset sort Launcher Icons, Useful resource identify “ic_launcher”, create the icon -> Subsequent -> End.

You may as well change the icon changing ic_launcher.png file in mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi directories. See Android Cheatsheet for Graphic Designers for proper launcher icon dimensions.

One other risk is to create launcher icons utilizing Android Asset Studio.

5. Select shade theme

Open cellular/src/fundamental/AndroidManifest.xml and alter worth of attribute. There are eight themes you should use:

  • Theme.recipebook.Blue
  • Theme.recipebook.Brown
  • Theme.recipebook.Carrot
  • Theme.recipebook.Grey
  • Theme.recipebook.Inexperienced
  • Theme.recipebook.Indigo
  • Theme.recipebook.Purple
  • Theme.recipebook.Yellow

You even have to switch MainActivity’s theme. Important Exercise makes use of a particular theme with clear standing bar due to navigation drawer standing overlay impact. It’s an attribute. Select considered one of these themes:

  • Theme.recipebook.TransparentStatusBar.Blue
  • Theme.recipebook.TransparentStatusBar.Brown
  • Theme.recipebook.TransparentStatusBar.Carrot
  • Theme.recipebook.TransparentStatusBar.Grey
  • Theme.recipebook.TransparentStatusBar.Inexperienced
  • Theme.recipebook.TransparentStatusBar.Indigo
  • Theme.recipebook.TransparentStatusBar.Pink
  • Theme.recipebook.TransparentStatusBar.Yellow

6. Put together database and pictures

Knowledge (classes, recipes, components) is saved in native SQLite database. Prepopulated database with recipes is saved in cellular/src/major/belongings/recipebook.db. This prepopulated database is routinely copied on gadget storage on first run of the appliance and in addition if the database is up to date (see under for more information about database replace). Database is in SQLite format and has the next construction (SQL script):

<span class="hljs-operator"><span class="hljs-key phrase">CREATE</span> <span class="hljs-key phrase">TABLE</span> <span class="hljs-string">`classes`</span> (<span class="hljs-string">`id`</span> <span class="hljs-built_in">INTEGER</span> <span class="hljs-key phrase">PRIMARY</span> <span class="hljs-key phrase">KEY</span> AUTOINCREMENT , <span class="hljs-string">`identify`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`picture`</span> <span class="hljs-built_in">VARCHAR</span> );</span>
<span class="hljs-operator"><span class="hljs-key phrase">CREATE</span> <span class="hljs-key phrase">TABLE</span> <span class="hljs-string">`recipes`</span> (<span class="hljs-string">`id`</span> <span class="hljs-built_in">INTEGER</span> <span class="hljs-key phrase">PRIMARY</span> <span class="hljs-key phrase">KEY</span> AUTOINCREMENT , <span class="hljs-string">`category_id`</span> <span class="hljs-built_in">BIGINT</span> , <span class="hljs-string">`identify`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`intro`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`instruction`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`picture`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`hyperlink`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`time`</span> <span class="hljs-built_in">INTEGER</span> , <span class="hljs-string">`servings`</span> <span class="hljs-built_in">INTEGER</span> , <span class="hljs-string">`energy`</span> <span class="hljs-built_in">INTEGER</span> , <span class="hljs-string">`favourite`</span> <span class="hljs-built_in">SMALLINT</span> );</span>
<span class="hljs-operator"><span class="hljs-key phrase">CREATE</span> <span class="hljs-key phrase">INDEX</span> <span class="hljs-string">`recipes_category_idx`</span> <span class="hljs-key phrase">ON</span> <span class="hljs-string">`recipes`</span> ( <span class="hljs-string">`category_id`</span> );</span>
<span class="hljs-operator"><span class="hljs-key phrase">CREATE</span> <span class="hljs-key phrase">TABLE</span> <span class="hljs-string">`components`</span> (<span class="hljs-string">`id`</span> <span class="hljs-built_in">INTEGER</span> <span class="hljs-key phrase">PRIMARY</span> <span class="hljs-key phrase">KEY</span> AUTOINCREMENT , <span class="hljs-string">`recipe_id`</span> <span class="hljs-built_in">BIGINT</span> , <span class="hljs-string">`identify`</span> <span class="hljs-built_in">VARCHAR</span> , <span class="hljs-string">`amount`</span> <span class="hljs-built_in">FLOAT</span> , <span class="hljs-string">`unit`</span> <span class="hljs-built_in">VARCHAR</span> );</span>
<span class="hljs-operator"><span class="hljs-key phrase">CREATE</span> <span class="hljs-key phrase">INDEX</span> <span class="hljs-string">`ingredients_recipe_idx`</span> <span class="hljs-key phrase">ON</span> <span class="hljs-string">`components`</span> ( <span class="hljs-string">`recipe_id`</span> );</span>

As you’ll be able to see, there are three SQL tables (classes, recipes, components) and a couple of indexes (category_id, recipe_id) that are additionally overseas keys. This database schema corresponds to database fashions within the code. Yow will discover fashions in com.websiteman.recipebook.database.mannequin package deal.

This app accommodates a prepopulated database with demo knowledge. Open database file cellular/src/foremost/belongings/recipebook.db in any SQLite editor and modify knowledge within the database as you want. You possibly can add/take away/edit recipes, classes and components. There are numerous SQLite editors. We advocate SQLite Studio as a result of it’s free, open supply, cross-platform, moveable and intuitive. In case you are working with SQLite Studio, don’t overlook to commit modifications. Don’t modify construction of the database, modify solely knowledge! Database tables have following columns:


  • id (integer) – Distinctive main key
  • identify (string) – Class identify
  • picture (string) – URL of the class picture. This subject is elective and whether it is empty or null, no class picture is proven. URL ought to be on this format: belongings://classes/mycategory.png. It factors to cellular/src/most important/belongings/classes folder the place all class pictures must be saved.


  • id (integer) – Distinctive main key
  • category_id (integer) – Overseas key pointing to class id
  • identify (string) – Recipe identify
  • intro (string) – Introduction textual content on recipe element display. This subject is non-compulsory and whether it is empty or null, no textual content is proven.
  • instruction (string) – Foremost instruction textual content for the recipe
  • picture (string) – URL of the recipe picture. Picture might be loaded from the Web (URL with normal HTTP protocol) or regionally from belongings. Native URL ought to be on this format: belongings://recipes/myrecipe.jpg. It factors to cellular/src/fundamental/belongings/recipes folder the place all native recipe photographs ought to be saved.
  • hyperlink (string) – URL of the online web page. This subject is elective and whether it is empty or null, no net hyperlink is proven within the menu.
  • time (integer) – Cooking time in minutes. This area is optionally available and whether it is empty or null, no time is proven.
  • servings (integer) – Variety of servings. This area is optionally available and whether it is empty or null, no servings information is proven.
  • energy (integer) – Variety of energy in kcal for one hundred g of serving. This subject is elective and whether it is empty or null, no energy information is proven.
  • favourite (boolean) – True/false worth if the recipe is favourite. This area ought to keep zero by default. That is the one column modified by the app. All different columns are learn solely.


  • id (integer) – Distinctive main key
  • recipe_id (integer) – Overseas key pointing to recipe id
  • identify (string) – Ingredient identify
  • amount (float) – Amount of the ingredient. This subject is non-compulsory and whether it is empty or null, no amount is proven.
  • unit (string) – Bodily unit of the amount. This subject is non-compulsory and whether it is empty or null, no unit is proven.

There are two particular classes: “All recipes” and “Favorites”. Understand that these classes are mechanically added to the menu and doesn’t should be within the database. Classes are ordered by id, recipes are ordered alphabetically by identify and elements are ordered by id. Search question is on the lookout for a match in identify, intro and instruction fields. Looking is case insensitive.

In the event you modify prepopulated database in belongings folder, inner database on system storage won’t be up to date mechanically. In case you make any change within the prepopulated database, you need to increment database model. Open configuration file /mobile/src/main/java/com/robotemplates/recipebook/ and increment quantity in DATABASE_VERSION fixed. Database helper detects that database knowledge has been modified and replica the prepopulated database on system storage so knowledge within the app will probably be up to date. You must increment database model each time if you need to publish a brand new construct on Google Play and you’ve got modified the info in prepopulated database.

Identify of the prepopulated database is outlined in configuration file /mobile/src/main/java/com/robotemplates/recipebook/ in DATABASE_NAME fixed. Database file identify ought to correspond to the file in cellular/src/major/belongings listing. The database file must be saved on this listing and never in any sub-listing.

7. Setup Google Analytics

Open cellular/src/most important/res/xml/analytics_app_tracker.xml and alter UA code (ga_trackingId parameter) to your personal UA code. You possibly can allow/disable Google Analytics in configuration file /mobile/src/main/java/com/robotemplates/recipebook/

eight. Setup AdMob

Open cellular/src/primary/res/values/admob.xml and alter unit ids (admob_unit_id_recipe_list and admob_unit_id_recipe_detail parameters) to your personal unit ids (banner ids). You also needs to specify your check system id (admob_test_device_id parameter) and use check mode when debugging the app. Requesting check advertisements is beneficial when testing your software so you don’t request invalid impressions. Yow will discover your hashed gadget id within the logcat output by requesting an advert when debugging in your gadget. You’ll be able to allow/disable AdMob banners in configuration file /mobile/src/main/java/com/robotemplates/recipebook/

9. Create signing keystore

That you must create your personal keystore to signal an APK file earlier than publishing on Google Play. You possibly can create the keystore by way of keytool utility which is a part of Java JDK.

  1. Run following command: keytool -genkey -v -keystore recipebook.keystore -alias <your_alias> -keyalg RSA -keysize 2048 -validity 36500 the place <your_alias> is your alias identify. For instance your organization identify or app identify. If you will publish the app on Google Play, it’s a must to set the validity attribute.
  2. Copy new recipebook.keystore file into extras/keystore listing.
  3. Open extras/keystore/ and set keystore alias and passwords.
  4. Executed. Keep in mind that recipebook.keystore and are mechanically learn by Gradle script when making a launch APK by way of assembleRelease command. Paths to those information are outlined in


This chapter describes some elective customizations of the app.

Customized colours and icons

You’ll be able to customise colours in cellular/src/primary/res/values/colours.xml.

There are eleven class icons. If you might want to create the icon for the class, it is strongly recommended to make use of Android Asset Studio. See Android Cheatsheet for Graphic Designers for proper icon dimensions. Use the icons with highest DPI.

Customized banner emblem in drawer menu

There’s a inexperienced desk material texture proven within the drawer menu. You’ll be able to simply change this texture changing banner.png file in drawable-xxhdpi listing.

About dialog

If you wish to change the textual content in About dialog, simply open cellular/src/foremost/res/values/strings.xml and edit dialog_about_message string. Word that this textual content is in HTML format and also can incorporates hyperlinks.

Multi-language help

Create a brand new listing cellular/src/essential/res/values-xx the place xx is an ISO 639-1 code of the language you need to translate. For instance “values-es” for Spanish, “values-fr” for French, “values-de” for German and so on. Copy strings.xml from cellular/src/major/res/values into the brand new listing. Now you’ll be able to translate texts for particular languages. The language is mechanically decided by system gadget settings. If there isn’t a match with values-xx language, default language in cellular/src/major/res/values is chosen. See Localizing with Resources for more information.

Constructing & publishing

This chapter describes methods to construct APK with Gradle and put together app for publishing. Android Studio makes use of Gradle for constructing Android purposes.

You don’t want to put in Gradle in your system, as a result of there’s a Gradle Wrapper. The wrapper is a batch script on Home windows, and a shell script for different working methods. Once you begin a Gradle construct by way of the wrapper, Gradle will probably be routinely downloaded and used to run the construct.

  1. Open the undertaking in Android Studio
  2. Open configuration file /mobile/src/main/java/com/robotemplates/recipebook/ and set constants as required (see under for more information)
  3. Open principal construct script /mobile/build.gradle and set constants as required (see under for more information)
  4. Run gradlew assemble in console
  5. APK must be obtainable in /mobile/build/outputs/apk listing

Notice: Additionally, you will want a “” file to set the situation of the SDK in the identical approach that the prevailing SDK requires, utilizing the “sdk.dir” property. Instance of “” on Home windows: sdk.dir=C:adt-bundle-windowssdk. Alternatively, you possibly can set an surroundings variable referred to as “ANDROID_HOME”.

Tip: Command gradlew assemble builds each – debug and launch APK. You need to use gradlew assembleDebug to construct debug APK. You need to use gradlew assembleRelease to construct launch APK. Debug APK is signed by debug keystore. Launch APK is signed by personal keystore, saved in /extras/keystore listing.

Signing course of: Keystore passwords are mechanically loaded from property file throughout constructing the discharge APK. Path to this file is outlined in “” property in “” file. If this property or the file doesn’t exist, consumer is requested for passwords explicitly.

That is the primary configuration file. There are some true/false switches. It is rather necessary to appropriately set these switches earlier than constructing the APK.

  • LOGS – true for enabling debug logs
  • ANALYTICS – true for enabling Google Analytics
  • ADMOB_RECIPE_LIST_BANNER – true for enabling Google AdMob banner on recipe listing display
  • ADMOB_RECIPE_DETAIL_BANNER – true for enabling Google AdMob on recipe element display

Necessary: Following configuration must be used for launch APK, meant for publishing on Google Play:

<span class="hljs-key phrase">public</span> <span class="hljs-key phrase">static</span> <span class="hljs-key phrase">last</span> <span class="hljs-key phrase">boolean</span> LOGS = <span class="hljs-key phrase">false</span>;
<span class="hljs-key phrase">public</span> <span class="hljs-key phrase">static</span> <span class="hljs-key phrase">ultimate</span> <span class="hljs-key phrase">boolean</span> ANALYTICS = <span class="hljs-key phrase">true</span>;
<span class="hljs-key phrase">public</span> <span class="hljs-key phrase">static</span> <span class="hljs-key phrase">remaining</span> <span class="hljs-key phrase">boolean</span> ADMOB_RECIPE_LIST_BANNER = <span class="hljs-key phrase">true</span>;
<span class="hljs-key phrase">public</span> <span class="hljs-key phrase">static</span> <span class="hljs-key phrase">last</span> <span class="hljs-key phrase">boolean</span> ADMOB_RECIPE_DETAIL_BANNER = <span class="hljs-key phrase">true</span>;


That is the primary construct script and there are four necessary constants for outlining model code and model identify.