<file_sep>-- Import foods with volumes in cups
INSERT INTO ingredient (NDB_No, name, gPerCup)
SELECT FOOD_DES.NDB_No, FOOD_DES.Long_Desc, WEIGHT.Gm_Wgt / WEIGHT.Amount
FROM FOOD_DES INNER JOIN WEIGHT ON FOOD_DES.NDB_No = WEIGHT.NDB_No
WHERE WEIGHT.Msre_Desc = "cup";

-- Import foods with volumes in tbsp (16 tbsp / cup)
INSERT INTO ingredient (NDB_No, name, gPerCup)
SELECT FOOD_DES.NDB_No, FOOD_DES.Long_Desc, WEIGHT.Gm_Wgt / WEIGHT.Amount * 16.0
FROM FOOD_DES INNER JOIN WEIGHT ON FOOD_DES.NDB_No = WEIGHT.NDB_No
WHERE WEIGHT.Msre_Desc = "tbsp";

-- Import foods with volumes in fl oz (8 fl oz / cup)
INSERT INTO ingredient (NDB_No, name, gPerCup)
SELECT FOOD_DES.NDB_No, FOOD_DES.Long_Desc, WEIGHT.Gm_Wgt / WEIGHT.Amount * 8.0
FROM FOOD_DES INNER JOIN WEIGHT ON FOOD_DES.NDB_No = WEIGHT.NDB_No
WHERE WEIGHT.Msre_Desc = "fl oz";

-- Import foods with volumes in tsp (48 tsp / cup)
INSERT INTO ingredient (NDB_No, name, gPerCup)
SELECT FOOD_DES.NDB_No, FOOD_DES.Long_Desc, WEIGHT.Gm_Wgt / WEIGHT.Amount * 48.0
FROM FOOD_DES INNER JOIN WEIGHT ON FOOD_DES.NDB_No = WEIGHT.NDB_No
WHERE WEIGHT.Msre_Desc = "tsp";

-- Delete ingredients containing (capitalized) brand names
DELETE FROM ingredient WHERE name REGEXP '.*[A-Z][A-Z].*';

-- Delete all but first of duplicates (by name)
DELETE FROM ingredient WHERE id NOT IN
(SELECT * FROM
	(SELECT MIN(id) FROM ingredient group by name)
)<file_sep># Cupful

![Cupful header](https://raw.githubusercontent.com/natalieperna/cupful-android/master/images/web_feature_graphic.png)

## Install

[Cupful - Google Play Store](https://play.google.com/store/apps/details?id=com.natalieperna.cupful)

## About

Cupful is an app that allows you to easily convert amounts of ingredients from volume (i.e. cups, ml, tsp, tbsp) to weight (i.e. g, oz, lb), and vice versa, with over 500 different ingredients supported!
It's an essential tool for every baker and chef who values precise measurements in their baking and cooking.

## Screenshots

| Conversion                 | Ingredients                |
|:--------------------------:|:--------------------------:|
| ![Screenshot][screenshot1] | ![Screenshot][screenshot4] |


[screenshot1]: https://github.com/natalieperna/cupful-android/blob/master/images/screenshots/screenshot_1.png
[screenshot4]: https://github.com/natalieperna/cupful-android/blob/master/images/screenshots/screenshot_4.png
<file_sep>package com.natalieperna.cupful.data;

import com.natalieperna.cupful.models.DisplayUnit;

import javax.measure.quantity.Volume;
import javax.measure.quantity.VolumetricDensity;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;

public class Units {
    // Custom volume units
    public static final Unit<Volume> TABLESPOON_UK = NonSI.OUNCE_LIQUID_UK.divide(1.6);
    public static final Unit<Volume> TEASPOON_UK = TABLESPOON_UK.divide(3);
    public static final Unit<Volume> TABLESPOON_US = NonSI.OUNCE_LIQUID_US.divide(2);
    public static final Unit<Volume> TEASPOON_US = TABLESPOON_US.divide(3);
    public static final Unit<Volume> CUP_UK = NonSI.OUNCE_LIQUID_UK.times(10);
    public static final Unit<Volume> CUP_US = NonSI.OUNCE_LIQUID_US.times(8);

    // Density unit
    public static final Unit<VolumetricDensity> G_PER_CUP = SI.GRAM.divide(CUP_US).asType(VolumetricDensity.class);

    private static final DisplayUnit[] UNITS = {
            new DisplayUnit<>(CUP_US, "cup (US)"),
            new DisplayUnit<>(TABLESPOON_US, "tbsp (US)"),
            new DisplayUnit<>(TEASPOON_US, "tsp (US)"),
            new DisplayUnit<>(SI.GRAM, "g"),
            new DisplayUnit<>(SI.KILOGRAM, "kg"),
            new DisplayUnit<>(NonSI.OUNCE, "oz"),
            new DisplayUnit<>(NonSI.POUND, "lb"),
            new DisplayUnit<>(SI.MILLI(NonSI.LITER), "mL"),
            new DisplayUnit<>(NonSI.LITER, "L"),
            new DisplayUnit<>(NonSI.OUNCE_LIQUID_US, "fl oz (US)"),
            new DisplayUnit<>(CUP_UK, "cup (UK)"),
            new DisplayUnit<>(TABLESPOON_UK, "tbsp (UK)"),
            new DisplayUnit<>(TEASPOON_UK, "tsp (UK)"),
            new DisplayUnit<>(NonSI.OUNCE_LIQUID_UK, "fl oz (UK)"),
    };

    public static DisplayUnit[] getAll() {
        return UNITS;
    }
}
