Compare commits
2 Commits
master
...
feature/mo
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ef91d04b78 | ||
![]() |
71baf82164 |
@ -15,10 +15,11 @@
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".PhotoPreviewActivity"></activity>
|
||||
<activity android:name=".PhotoPreviewActivity" />
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
@ -30,8 +31,17 @@
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<activity android:name=".ArchiveActivity" android:label="@string/archive"></activity>
|
||||
<activity android:name=".TestNutritionixActivity" android:label="Nutritionix"></activity>
|
||||
<activity
|
||||
android:name=".ArchiveActivity"
|
||||
android:label="@string/archive" />
|
||||
<activity
|
||||
android:name=".TestNutritionixActivity"
|
||||
android:label="Nutritionix" />
|
||||
<activity android:name=".custom_list.CustomListActivity" />
|
||||
<activity android:name=".Activity_custom" />
|
||||
<activity android:name=".RecognizedObjectActivity" />
|
||||
<activity android:name=".CaloriesActivity" />
|
||||
<activity android:name=".NewArchiveActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,59 @@
|
||||
package com.krokogator.photoeat;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.adapter.FoodAdapter;
|
||||
import com.krokogator.photoeat.model.FoodItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Activity_custom extends AppCompatActivity {
|
||||
private List<FoodItem> food;
|
||||
private RecyclerView recyclerView;
|
||||
private Button summaryButton;
|
||||
|
||||
public Activity_custom(){
|
||||
food = new ArrayList<>();
|
||||
food.add(new FoodItem("Schnitzel"));
|
||||
food.add(new FoodItem("Potatoes"));
|
||||
food.add(new FoodItem("Tomato"));
|
||||
food.add(new FoodItem("Tea"));
|
||||
food.add(new FoodItem("Water"));
|
||||
food.add(new FoodItem("Spaghetti"));
|
||||
}
|
||||
|
||||
public Activity_custom(List<FoodItem> food){
|
||||
this();
|
||||
this.food = food;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_custom);
|
||||
FoodAdapter adapter = new FoodAdapter(this, food);
|
||||
recyclerView = findViewById(R.id.recycler1);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
summaryButton = findViewById(R.id.summary_button);
|
||||
|
||||
summaryButton.setOnClickListener((view -> {
|
||||
List<FoodItem> food = adapter.getCheckedItems();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (FoodItem item : food){
|
||||
stringBuilder.append(item.getName() + " " + item.getQuantity() + item.getQuantityType() + "\n");
|
||||
}
|
||||
Toast.makeText(this, stringBuilder.toString(), Toast.LENGTH_LONG).show();
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
package com.krokogator.photoeat;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.database.Result;
|
||||
import com.krokogator.photoeat.database.ResultDBHelper;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ArchiveActivity extends AppCompatActivity {
|
||||
|
||||
@ -9,5 +18,38 @@ public class ArchiveActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_archive);
|
||||
|
||||
getFromDB();
|
||||
}
|
||||
|
||||
private void getFromDB() {
|
||||
SQLiteDatabase db = new ResultDBHelper(this).getReadableDatabase();
|
||||
String[] projection = {
|
||||
Result._ID,
|
||||
Result.COLUMN_NAME_FOOD,
|
||||
Result.COLUMN_NAME_CALORIES
|
||||
};
|
||||
String sortOrder = Result.COLUMN_NAME_FOOD + " DESC";
|
||||
Cursor cursor = db.query(
|
||||
Result.TABLE_NAME, // The table to query
|
||||
projection, // The columns to return
|
||||
null, // The columns for the WHERE clause
|
||||
null, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
null // The sort order
|
||||
);
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
long itemID = cursor.getLong(cursor.getColumnIndexOrThrow(
|
||||
Result._ID));
|
||||
String food = cursor.getString(cursor.getColumnIndexOrThrow(
|
||||
Result.COLUMN_NAME_FOOD));
|
||||
Integer calories = cursor.getInt(cursor.getColumnIndexOrThrow(
|
||||
Result.COLUMN_NAME_CALORIES));
|
||||
|
||||
Toast.makeText(this, food +" "+ calories+ "kcal", Toast.LENGTH_SHORT).show();
|
||||
//do something
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,150 @@
|
||||
package com.krokogator.photoeat;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.adapter.CaloriesAdapter;
|
||||
import com.krokogator.photoeat.database.Result;
|
||||
import com.krokogator.photoeat.database.ResultDBHelper;
|
||||
import com.krokogator.photoeat.model.CaloriesItem;
|
||||
import com.krokogator.photoeat.model.Food;
|
||||
import com.krokogator.photoeat.service.CustomFoodClassification;
|
||||
import com.krokogator.photoeat.service.NutritionixService;
|
||||
import com.krokogator.photoeat.service.WatsonService;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.SimpleTimeZone;
|
||||
|
||||
public class CaloriesActivity extends AppCompatActivity {
|
||||
|
||||
CaloriesAdapter caloriesAdapter;
|
||||
List<CaloriesItem> items;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_calories);
|
||||
|
||||
items = new ArrayList<>();
|
||||
caloriesAdapter = new CaloriesAdapter(this, items);
|
||||
|
||||
RecyclerView recyclerView = findViewById(R.id.calories_recycler);
|
||||
recyclerView.setAdapter(caloriesAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
String foodString = getIntent().getExtras().getString("foodString");
|
||||
Toast.makeText(this, foodString, Toast.LENGTH_LONG).show();
|
||||
//Execute nutritionix API
|
||||
|
||||
new CaloriesCounterAsync().execute(foodString);
|
||||
|
||||
findViewById(R.id.calories_save).setOnClickListener(v -> saveMeal());
|
||||
|
||||
}
|
||||
|
||||
private void saveMeal() {
|
||||
SQLiteDatabase db = new ResultDBHelper(this).getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
float calories = 0f;
|
||||
EditText editText = findViewById(R.id.calories_meal_name);
|
||||
String name = editText.getText().toString();
|
||||
|
||||
for (CaloriesItem item : items){
|
||||
calories += item.getCalories();
|
||||
}
|
||||
|
||||
values.put(Result.COLUMN_NAME_FOOD, name);
|
||||
values.put(Result.COLUMN_NAME_CALORIES, calories);
|
||||
values.put(Result.COLUMN_NAME_DATE, new Date().toString());
|
||||
long newRowId = db.insert(Result.TABLE_NAME,
|
||||
null, values);
|
||||
|
||||
Intent i = new Intent(this, MainActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
private class CaloriesCounterAsync extends AsyncTask<String, Integer, List<CaloriesItem>> {
|
||||
protected List<CaloriesItem> doInBackground(String... items) {
|
||||
|
||||
List<CaloriesItem> result = getClassificationsArray(items[0]);
|
||||
|
||||
// Escape early if cancel() is called
|
||||
if (isCancelled()) return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void onPostExecute(List<CaloriesItem> res) {
|
||||
// for(String imageClass : result.getClassifications().keySet()){
|
||||
// Float classValue = result.getClassifications().get(imageClass);
|
||||
// classifications.add(imageClass + " : " + classValue);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
items.addAll(res);
|
||||
caloriesAdapter.notifyDataSetChanged();
|
||||
//LISTAWYNIKÓW.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private List<CaloriesItem> getClassificationsArray(String item){
|
||||
|
||||
|
||||
NutritionixService nutritionix = new NutritionixService();
|
||||
JSONObject json = null;
|
||||
try {
|
||||
json = nutritionix.getCalories(item);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return getCaloriesFromJson(json);
|
||||
}
|
||||
|
||||
private List<CaloriesItem> getCaloriesFromJson(JSONObject result){
|
||||
List<CaloriesItem> out = new ArrayList<>();
|
||||
|
||||
try {
|
||||
int length = 0;
|
||||
length = result.getJSONArray("foods").length();
|
||||
|
||||
Log.d("CALORIES_ACTIVITY", result.toString());
|
||||
for (int i = 0; i < length; i++) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String name = (result.getJSONArray("foods").getJSONObject(i).getString("food_name"));
|
||||
|
||||
String calories = (result.getJSONArray("foods").getJSONObject(i).getString("nf_calories"));
|
||||
|
||||
out.add(new CaloriesItem(name, Float.parseFloat(calories), null, false));
|
||||
}
|
||||
} catch (Exception e){
|
||||
Log.d("CALORIES_ACTIVITY", e.getMessage());
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,8 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.krokogator.photoeat.custom_list.CustomListActivity;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -42,6 +44,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Button btnCamera = (Button) findViewById(R.id.button_take_photo);
|
||||
Button btnArchive = (Button) findViewById(R.id.button_archive);
|
||||
Button btnNutritionix = (Button) findViewById(R.id.button_nutritionix);
|
||||
Button btnTest = (Button) findViewById(R.id.button_test);
|
||||
|
||||
btnCamera.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -53,7 +56,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
btnArchive.setOnClickListener((view) -> {
|
||||
Intent intent = new Intent(this, ArchiveActivity.class);
|
||||
Intent intent = new Intent(this, NewArchiveActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
@ -62,6 +65,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
btnTest.setOnClickListener((view -> {
|
||||
Intent intent = new Intent(this, Activity_custom.class);
|
||||
startActivity(intent);
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -184,7 +192,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
|
||||
Intent previewPhotoIntent = new Intent(this, PhotoPreviewActivity.class);
|
||||
Intent previewPhotoIntent = new Intent(this, RecognizedObjectActivity.class);
|
||||
resize(mCurrentPhotoPath);
|
||||
previewPhotoIntent.putExtra("imagePath", mCurrentPhotoPath);
|
||||
startActivity(previewPhotoIntent);
|
||||
|
@ -0,0 +1,123 @@
|
||||
package com.krokogator.photoeat;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.adapter.CaloriesAdapter;
|
||||
import com.krokogator.photoeat.database.Result;
|
||||
import com.krokogator.photoeat.database.ResultDBHelper;
|
||||
import com.krokogator.photoeat.model.CaloriesItem;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class NewArchiveActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_new_archive);
|
||||
|
||||
List<CaloriesItem> items = getFromDB();
|
||||
|
||||
CaloriesAdapter archiveAdapter = new CaloriesAdapter(this, items);
|
||||
RecyclerView recyclerView = findViewById(R.id.archive_recycler);
|
||||
recyclerView.setAdapter(archiveAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<CaloriesItem> getFromDB() {
|
||||
SQLiteDatabase db = new ResultDBHelper(this).getReadableDatabase();
|
||||
String[] projection = {
|
||||
Result._ID,
|
||||
Result.COLUMN_NAME_FOOD,
|
||||
Result.COLUMN_NAME_CALORIES,
|
||||
Result.COLUMN_NAME_DATE
|
||||
};
|
||||
String sortOrder = Result.COLUMN_NAME_FOOD + " DESC";
|
||||
Cursor cursor = db.query(
|
||||
Result.TABLE_NAME, // The table to query
|
||||
projection, // The columns to return
|
||||
null, // The columns for the WHERE clause
|
||||
null, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
null // The sort order
|
||||
);
|
||||
|
||||
List<CaloriesItem> items = new ArrayList<>();
|
||||
CaloriesItem prev = null;
|
||||
|
||||
Calendar dailyDate = Calendar.getInstance();
|
||||
Float dailyCalories = 0f;
|
||||
|
||||
CaloriesItem current = null;
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
long itemID = cursor.getLong(cursor.getColumnIndexOrThrow(
|
||||
Result._ID));
|
||||
String food = cursor.getString(cursor.getColumnIndexOrThrow(
|
||||
Result.COLUMN_NAME_FOOD));
|
||||
Float calories = cursor.getFloat(cursor.getColumnIndexOrThrow(
|
||||
Result.COLUMN_NAME_CALORIES));
|
||||
Date date = new Date(cursor.getString(cursor.getColumnIndexOrThrow(
|
||||
Result.COLUMN_NAME_DATE))) {
|
||||
};
|
||||
|
||||
|
||||
//Toast.makeText(this, food +" "+ calories+ "kcal" + date + "date", Toast.LENGTH_SHORT).show();
|
||||
current = new CaloriesItem(food, calories, date, false);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
|
||||
|
||||
if (prev != null){
|
||||
if (checkIfSameDay(prev.getDate(), current.getDate())){
|
||||
dailyCalories += current.getCalories();
|
||||
} else {
|
||||
items.add(new CaloriesItem(sdf.format(dailyDate.getTime())+" Daily calories", dailyCalories, dailyDate.getTime(), true));
|
||||
dailyCalories = current.getCalories();
|
||||
dailyDate.setTime(current.getDate());
|
||||
|
||||
}
|
||||
} else {
|
||||
dailyCalories = current.getCalories();
|
||||
dailyDate.setTime(current.getDate());
|
||||
}
|
||||
|
||||
prev = current;
|
||||
items.add(current);
|
||||
|
||||
if(cursor.isLast() && dailyCalories != 0f){
|
||||
items.add(new CaloriesItem(sdf.format(dailyDate.getTime())+" Daily calories", dailyCalories, dailyDate.getTime(), true));
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private Boolean checkIfSameDay(Date prev, Date current) {
|
||||
Calendar calendarPrev = Calendar.getInstance();
|
||||
calendarPrev.setTime(prev);
|
||||
Calendar calendarCurrent = Calendar.getInstance();
|
||||
calendarCurrent.setTime(current);
|
||||
|
||||
if(calendarCurrent.get(Calendar.YEAR) == calendarPrev.get(Calendar.YEAR)){
|
||||
if(calendarCurrent.get(Calendar.DAY_OF_YEAR) == calendarPrev.get(Calendar.DAY_OF_YEAR)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.krokogator.photoeat;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Pair;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.adapter.FoodAdapter;
|
||||
import com.krokogator.photoeat.model.FoodItem;
|
||||
import com.krokogator.photoeat.model.FoodQuantityTypeEnum;
|
||||
import com.krokogator.photoeat.service.CustomFoodClassification;
|
||||
import com.krokogator.photoeat.service.NutritionixService;
|
||||
import com.krokogator.photoeat.service.WatsonService;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RecognizedObjectActivity extends AppCompatActivity {
|
||||
private List<FoodItem> food;
|
||||
private RecyclerView recyclerView;
|
||||
private Button summaryButton;
|
||||
|
||||
private FoodAdapter foodAdapter;
|
||||
|
||||
public RecognizedObjectActivity(){
|
||||
food = new ArrayList<>();
|
||||
// food.add(new FoodItem("Schnitzel"));
|
||||
// food.add(new FoodItem("Potatoes"));
|
||||
// food.add(new FoodItem("Tomato"));
|
||||
// food.add(new FoodItem("Tea"));
|
||||
// food.add(new FoodItem("Water"));
|
||||
// food.add(new FoodItem("Spaghetti"));
|
||||
}
|
||||
|
||||
public RecognizedObjectActivity(List<FoodItem> food){
|
||||
this();
|
||||
this.food = food;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_recognized_object);
|
||||
food = new ArrayList<>();
|
||||
foodAdapter = new FoodAdapter(this, food);
|
||||
recyclerView = findViewById(R.id.recognized_recycler);
|
||||
recyclerView.setAdapter(foodAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
summaryButton = findViewById(R.id.recognized_summary);
|
||||
|
||||
summaryButton.setOnClickListener((view -> {
|
||||
List<FoodItem> food = foodAdapter.getCheckedItems();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (FoodItem item : food){
|
||||
stringBuilder.append(item.getQuantity() + " " + getNutritionixValidCountRepresentation(item.getQuantityType()) + item.getName() + ", ");
|
||||
}
|
||||
|
||||
Intent caloriesIntent = new Intent(this, CaloriesActivity.class);
|
||||
caloriesIntent.putExtra("foodString", stringBuilder.toString());
|
||||
startActivity(caloriesIntent);
|
||||
|
||||
}));
|
||||
|
||||
findViewById(R.id.new_food_button).setOnClickListener(v -> addNewItem());
|
||||
|
||||
String imagePath = (String) getIntent().getExtras().get("imagePath");
|
||||
File file = new File(imagePath);
|
||||
new ClassifyImage().execute(file);
|
||||
}
|
||||
|
||||
private void addNewItem() {
|
||||
EditText text = findViewById(R.id.new_food_name);
|
||||
food.add(new FoodItem(text.getText().toString()));
|
||||
foodAdapter.notifyDataSetChanged();
|
||||
text.setText("");
|
||||
recyclerView.smoothScrollToPosition(food.size() - 1);
|
||||
}
|
||||
|
||||
private String getNutritionixValidCountRepresentation(FoodQuantityTypeEnum type){
|
||||
switch (type){
|
||||
case QUANTITY:
|
||||
return "";
|
||||
default:
|
||||
return type.toString() + " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class ClassifyImage extends AsyncTask<File, Integer, List<FoodItem>> {
|
||||
protected List<FoodItem> doInBackground(File... files) {
|
||||
WatsonService service = null;
|
||||
|
||||
try {
|
||||
service = new WatsonService(0.1f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CustomFoodClassification customFoodClassification = null;
|
||||
try {
|
||||
customFoodClassification = service.getCustomFoodClassification(files[0]);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
List<FoodItem> food = new ArrayList<>();
|
||||
|
||||
for (String foodName : customFoodClassification.getClassifications().keySet()){
|
||||
food.add(new FoodItem(foodName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Escape early if cancel() is called
|
||||
if (isCancelled()) return null;
|
||||
|
||||
return food;
|
||||
}
|
||||
|
||||
protected void onPostExecute(List<FoodItem> res) {
|
||||
// for(String imageClass : result.getClassifications().keySet()){
|
||||
// Float classValue = result.getClassifications().get(imageClass);
|
||||
// classifications.add(imageClass + " : " + classValue);
|
||||
//
|
||||
// }
|
||||
|
||||
food.addAll(res);
|
||||
|
||||
foodAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.krokogator.photoeat.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.krokogator.photoeat.R;
|
||||
import com.krokogator.photoeat.model.CaloriesItem;
|
||||
import com.krokogator.photoeat.model.FoodItem;
|
||||
import com.krokogator.photoeat.model.FoodQuantityTypeEnum;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CaloriesAdapter extends RecyclerView.Adapter<CaloriesAdapter.ViewHolder> {
|
||||
|
||||
private List<CaloriesItem> items;
|
||||
private Context context;
|
||||
|
||||
public CaloriesAdapter(Context context, List<CaloriesItem> caloriesItemList){
|
||||
this.context = context;
|
||||
this.items = caloriesItemList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_calorie_item, parent, false);
|
||||
ViewHolder holder = new ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
//PERFORM ACTION ON BINDING x ELEMENT OF RECYCLER VIEW
|
||||
CaloriesItem item = items.get(position);
|
||||
holder.foodName.setText(item.getName());
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMaximumFractionDigits(2);
|
||||
String calories = df.format(item.getCalories()) + " kcal";
|
||||
holder.calories.setText(calories);
|
||||
|
||||
if(item.isDailySummary()){
|
||||
holder.foodName.setTypeface(null, Typeface.BOLD);
|
||||
holder.calories.setTypeface(null, Typeface.BOLD);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
TextView foodName;
|
||||
TextView calories;
|
||||
|
||||
public ViewHolder(View itemView){
|
||||
super(itemView);
|
||||
|
||||
foodName = itemView.findViewById(R.id.calories_name);
|
||||
calories = itemView.findViewById(R.id.calories_count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package com.krokogator.photoeat.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.krokogator.photoeat.R;
|
||||
import com.krokogator.photoeat.model.FoodItem;
|
||||
import com.krokogator.photoeat.model.FoodQuantityTypeEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.ViewHolder> {
|
||||
|
||||
private List<FoodItem> items;
|
||||
private ArrayAdapter quantityTypeAdapter;
|
||||
private Context context;
|
||||
private Set<Integer> checked;
|
||||
|
||||
public FoodAdapter(Context context, List<FoodItem> foodList){
|
||||
this.context = context;
|
||||
this.items = foodList;
|
||||
ArrayAdapter spinnerAdapter = new ArrayAdapter(context, android.R.layout.simple_spinner_item, FoodQuantityTypeEnum.values());
|
||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
this.quantityTypeAdapter = spinnerAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_food_item, parent, false);
|
||||
ViewHolder holder = new ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
//PERFORM ACTION ON BINDING x ELEMENT OF RECYCLER VIEW
|
||||
holder.foodName.setText(items.get(position).getName());
|
||||
holder.foodQuantity.setAdapter(quantityTypeAdapter);
|
||||
holder.foodQuantity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
{
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int inner, long id)
|
||||
{
|
||||
String selectedItem = parent.getItemAtPosition(inner).toString();
|
||||
Log.d("FOOD_ADAPTER", FoodQuantityTypeEnum.valueOf(selectedItem).toString());
|
||||
items.get(position).setQuantityType(FoodQuantityTypeEnum.valueOf(selectedItem));
|
||||
} // to close the onItemSelected
|
||||
public void onNothingSelected(AdapterView<?> parent)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.checkBox.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
Log.d("FOOD_ADAPTER", "Changed checkbos to "+b);
|
||||
items.get(position).setChecked(b);
|
||||
});
|
||||
|
||||
holder.quantity.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
try{
|
||||
items.get(position).setQuantity(Integer.valueOf(editable.toString()));
|
||||
} catch (Exception e){}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public List<FoodItem> getCheckedItems(){
|
||||
List<FoodItem> resultList = new ArrayList<>();
|
||||
for (FoodItem food : items){
|
||||
if (food.getChecked()) resultList.add(food);
|
||||
}
|
||||
|
||||
Log.d("FOOD_ADAPTER", String.valueOf(resultList.size()));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
TextView foodName;
|
||||
Spinner foodQuantity;
|
||||
CheckBox checkBox;
|
||||
EditText quantity;
|
||||
|
||||
public ViewHolder(View itemView){
|
||||
super(itemView);
|
||||
|
||||
foodName = itemView.findViewById(R.id.item_name);
|
||||
foodQuantity = itemView.findViewById(R.id.spinner_quantity_type);
|
||||
checkBox = itemView.findViewById(R.id.item_checkbox);
|
||||
quantity = itemView.findViewById(R.id.item_quantity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.krokogator.photoeat.custom_list;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* This class is useful for using inside of a ListView that needs to have checkable items.
|
||||
* Adapted from [tokudu](https://gist.github.com/tokudu/410479#file-checkablelinearlayout-java)
|
||||
*/
|
||||
public class CheckableLinearLayout extends LinearLayout implements Checkable {
|
||||
private CheckBox checkbox;
|
||||
|
||||
public CheckableLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
int childCount = getChildCount();
|
||||
|
||||
// find checked text view
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
View view = getChildAt(i);
|
||||
|
||||
if (view instanceof CheckBox) {
|
||||
checkbox = (CheckBox) view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
|
||||
return checkbox != null ? checkbox.isChecked() : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
if (checkbox != null) {
|
||||
checkbox.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
if (checkbox != null) {
|
||||
checkbox.toggle();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.krokogator.photoeat.custom_list;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.krokogator.photoeat.R;
|
||||
|
||||
public class CustomAdapter extends BaseAdapter {
|
||||
private String[] data;
|
||||
private String[] resourceTypes;
|
||||
|
||||
private LayoutInflater inflater;
|
||||
private Context context;
|
||||
private ViewHolder viewHolder;
|
||||
|
||||
|
||||
public CustomAdapter(Context context, String[] fruit, String[] resourceTypes) {
|
||||
this.context = context;
|
||||
data = fruit;
|
||||
this.resourceTypes = resourceTypes;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return data[i]+" "+getSelectedResourceType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
final String current = data[i];
|
||||
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.recycler_food_item, viewGroup, false);
|
||||
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.name = (TextView) view.findViewById(R.id.item_name);
|
||||
viewHolder.spinner_quantity_type = (Spinner) view.findViewById(R.id.spinner_quantity_type);
|
||||
|
||||
view.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) view.getTag();
|
||||
}
|
||||
|
||||
viewHolder.name.setText(current);
|
||||
ArrayAdapter adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, resourceTypes);
|
||||
viewHolder.spinner_quantity_type.setAdapter(adapter);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
TextView name;
|
||||
Spinner spinner_quantity_type;
|
||||
}
|
||||
|
||||
private String getSelectedResourceType(){
|
||||
return (String) viewHolder.spinner_quantity_type.getSelectedItem();
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.krokogator.photoeat.custom_list;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.krokogator.photoeat.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomListActivity extends AppCompatActivity implements Button.OnClickListener {
|
||||
private ListView listView;
|
||||
private Button button;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_custom_list);
|
||||
|
||||
findViewsById();
|
||||
|
||||
String[] fruit = getResources().getStringArray(R.array.fruit_array);
|
||||
String[] resourceType = getResources().getStringArray(R.array.resource_type_array);
|
||||
CustomAdapter adapter = new CustomAdapter(getApplicationContext(), fruit, resourceType);
|
||||
|
||||
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
button.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.button:
|
||||
List<String> selected = getSelectedItems();
|
||||
String logString = "Selected items: " + TextUtils.join(", ", selected);
|
||||
|
||||
Log.d("MainActivity", logString);
|
||||
Toast.makeText(this, logString, Toast.LENGTH_SHORT).show();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void findViewsById() {
|
||||
listView = (ListView) findViewById(R.id.list);
|
||||
button = (Button) findViewById(R.id.button);
|
||||
}
|
||||
|
||||
private List<String> getSelectedItems() {
|
||||
List<String> result = new ArrayList<>();
|
||||
SparseBooleanArray checkedItems = listView.getCheckedItemPositions();
|
||||
|
||||
for (int i = 0; i < listView.getCount(); ++i) {
|
||||
if (checkedItems.valueAt(i)) {
|
||||
result.add((String) listView.getItemAtPosition(checkedItems.keyAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.krokogator.photoeat.database;
|
||||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public class Result implements BaseColumns {
|
||||
public static final String TABLE_NAME = "result";
|
||||
public static final String COLUMN_NAME_FOOD =
|
||||
"food";
|
||||
public static final String COLUMN_NAME_CALORIES =
|
||||
"calories";
|
||||
public static final String COLUMN_NAME_DATE =
|
||||
"date";
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.krokogator.photoeat.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class ResultDBHelper extends SQLiteOpenHelper {
|
||||
private static final String SQL_CREATE_ENTRIES =
|
||||
"CREATE TABLE " + Result.TABLE_NAME + " (" +
|
||||
Result._ID + " INTEGER PRIMARY KEY," +
|
||||
Result.COLUMN_NAME_FOOD + " TEXT," +
|
||||
Result.COLUMN_NAME_CALORIES + " TEXT," +
|
||||
Result.COLUMN_NAME_DATE + " TEXT)";
|
||||
private static final String SQL_DELETE_ENTRIES =
|
||||
"DROP TABLE IF EXISTS " + Result.TABLE_NAME;
|
||||
public static final int DATABASE_VERSION=1;
|
||||
public static final String DATABASE_NAME = "Weights.db";
|
||||
|
||||
public ResultDBHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
}
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(SQL_CREATE_ENTRIES);
|
||||
}
|
||||
public void onUpgrade(SQLiteDatabase db, int oldver, int nver) {
|
||||
db.execSQL(SQL_DELETE_ENTRIES);
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.krokogator.photoeat.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class CaloriesItem {
|
||||
private String name;
|
||||
private Float calories;
|
||||
private Date date;
|
||||
private Boolean dailySummary;
|
||||
|
||||
public CaloriesItem(String name, Float calories, Date date, Boolean dailySummary){
|
||||
|
||||
this.name = name;
|
||||
this.calories = calories;
|
||||
this.date = date;
|
||||
this.dailySummary = dailySummary;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Float getCalories() {
|
||||
return calories;
|
||||
}
|
||||
|
||||
public void setCalories(Float calories) {
|
||||
this.calories = calories;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
public Boolean isDailySummary() {
|
||||
return dailySummary;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.krokogator.photoeat.model;
|
||||
|
||||
public class FoodItem {
|
||||
private String name;
|
||||
private FoodQuantityTypeEnum quantityType;
|
||||
private Integer quantity;
|
||||
private Boolean checked;
|
||||
|
||||
public FoodItem(String name){
|
||||
|
||||
this.name = name;
|
||||
this.quantityType = FoodQuantityTypeEnum.QUANTITY;
|
||||
this.quantity = 1;
|
||||
this.checked = false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FoodQuantityTypeEnum getQuantityType() {
|
||||
return quantityType;
|
||||
}
|
||||
|
||||
public void setQuantityType(FoodQuantityTypeEnum quantityType) {
|
||||
this.quantityType = quantityType;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.krokogator.photoeat.model;
|
||||
|
||||
public enum FoodQuantityTypeEnum {
|
||||
QUANTITY,
|
||||
GRAMS,
|
||||
CUPS,
|
||||
MILLILITERS
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.krokogator.photoeat.service;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.api.client.http.ByteArrayContent;
|
||||
import com.google.api.client.http.GenericUrl;
|
||||
import com.google.api.client.http.HttpHeaders;
|
||||
@ -21,6 +23,7 @@ public class NutritionixService {
|
||||
|
||||
String content = "{\"query\":\"" + input + "\"}";
|
||||
|
||||
Log.d("NUTRITIONIX_SERVICE", content);
|
||||
|
||||
HttpRequestFactory requestFactory
|
||||
= new NetHttpTransport().createRequestFactory();
|
||||
|
44
android/app/src/main/res/layout/activity_calories.xml
Normal file
44
android/app/src/main/res/layout/activity_calories.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".CaloriesActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/calories_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/calories_save"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="vertical"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/calories_meal_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/calories_save"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/calories_save"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:text="Save meal"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_weight="1" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
36
android/app/src/main/res/layout/activity_custom.xml
Normal file
36
android/app/src/main/res/layout/activity_custom.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Activity_custom">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/summary_button"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="vertical"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/summary_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Count calories"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||
|
||||
/>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
21
android/app/src/main/res/layout/activity_custom_list.xml
Normal file
21
android/app/src/main/res/layout/activity_custom_list.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:text="Select"/>
|
||||
|
||||
</LinearLayout>
|
@ -55,20 +55,20 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:text="Nutritionix"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button4"
|
||||
app:layout_constraintBottom_toTopOf="@+id/button_test"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:id="@+id/button_test"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="94dp"
|
||||
android:layout_marginStart="36dp"
|
||||
android:layout_marginEnd="36dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:text="@string/settings"
|
||||
android:text="TEST"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
14
android/app/src/main/res/layout/activity_new_archive.xml
Normal file
14
android/app/src/main/res/layout/activity_new_archive.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".NewArchiveActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/archive_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Activity_custom">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recognized_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/new_food_layout"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="vertical"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/new_food_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@id/recognized_summary">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/new_food_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
<Button
|
||||
android:id="@+id/new_food_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Add"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/recognized_summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Count calories"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:backgroundTint="@color/colorAccent"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Button"
|
||||
|
||||
/>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
24
android/app/src/main/res/layout/custom_row.xml
Normal file
24
android/app/src/main/res/layout/custom_row.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/food_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/food_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"/>
|
||||
</LinearLayout>
|
24
android/app/src/main/res/layout/recycler_calorie_item.xml
Normal file
24
android/app/src/main/res/layout/recycler_calorie_item.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.krokogator.photoeat.custom_list.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/calories_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
|
||||
<TextView
|
||||
android:id="@+id/calories_count"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
|
||||
</com.krokogator.photoeat.custom_list.CheckableLinearLayout>
|
36
android/app/src/main/res/layout/recycler_food_item.xml
Normal file
36
android/app/src/main/res/layout/recycler_food_item.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.krokogator.photoeat.custom_list.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Banana"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/item_quantity"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="1"
|
||||
android:inputType="numberDecimal" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_quantity_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:spinnerMode="dropdown"
|
||||
/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/item_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.krokogator.photoeat.custom_list.CheckableLinearLayout>
|
@ -4,4 +4,18 @@
|
||||
<string name="daily_survey">Ankieta codzienna</string>
|
||||
<string name="archive">Historia</string>
|
||||
<string name="settings">Ustawienia</string>
|
||||
<string-array name="fruit_array">
|
||||
<item>Apple</item>
|
||||
<item>Orange</item>
|
||||
<item>Banana</item>
|
||||
<item>Lime</item>
|
||||
<item>Pear</item>
|
||||
<item>Coconut</item>
|
||||
</string-array>
|
||||
<string-array name="resource_type_array">
|
||||
<item>kg</item>
|
||||
<item>ilość</item>
|
||||
<item>g</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user