Add original project.
49
.gitignore
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
|
||||
## Old ^^
|
||||
|
||||
## New vv
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Log/OS Files
|
||||
*.log
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
.externalNativeBuild/
|
||||
.cxx/
|
||||
*.apk
|
||||
output.json
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
misc.xml
|
||||
deploymentTargetDropDown.xml
|
||||
render.experimental.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
/app/debug/output-metadata.json
|
||||
|
||||
# Ha!
|
||||
keystore/*
|
||||
release
|
1
app/_gitignore
Executable file
@ -0,0 +1 @@
|
||||
/build
|
26
app/build.gradle
Executable file
@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.hyperling.carbupbeta"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 23
|
||||
versionCode 6
|
||||
versionName "0.11"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'com.google.android.gms:play-services-ads:8.3.0'
|
||||
}
|
81
app/manifest-merger-release-report.txt
Executable file
@ -0,0 +1,81 @@
|
||||
-- Merging decision tree log ---
|
||||
manifest
|
||||
ADDED from AndroidManifest.xml:2:1
|
||||
xmlns:android
|
||||
ADDED from AndroidManifest.xml:2:11
|
||||
package
|
||||
ADDED from AndroidManifest.xml:3:5
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
android:versionName
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
android:versionCode
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
application
|
||||
ADDED from AndroidManifest.xml:5:5
|
||||
MERGED from com.android.support:appcompat-v7:21.0.3:16:5
|
||||
MERGED from com.android.support:support-v4:21.0.3:16:5
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:8:9
|
||||
android:allowBackup
|
||||
ADDED from AndroidManifest.xml:6:9
|
||||
android:icon
|
||||
ADDED from AndroidManifest.xml:7:9
|
||||
android:theme
|
||||
ADDED from AndroidManifest.xml:9:9
|
||||
activity#carbupbeta.Splash
|
||||
ADDED from AndroidManifest.xml:10:9
|
||||
android:screenOrientation
|
||||
ADDED from AndroidManifest.xml:13:13
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:12:13
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:11:13
|
||||
intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
|
||||
ADDED from AndroidManifest.xml:14:13
|
||||
action#android.intent.action.MAIN
|
||||
ADDED from AndroidManifest.xml:15:17
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:15:25
|
||||
category#android.intent.category.LAUNCHER
|
||||
ADDED from AndroidManifest.xml:17:17
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:17:27
|
||||
activity#carbupbeta.Main
|
||||
ADDED from AndroidManifest.xml:20:9
|
||||
android:screenOrientation
|
||||
ADDED from AndroidManifest.xml:23:13
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:22:13
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:21:13
|
||||
activity#carbupbeta.Tab1
|
||||
ADDED from AndroidManifest.xml:25:9
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:27:13
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:26:13
|
||||
activity#carbupbeta.Tab2
|
||||
ADDED from AndroidManifest.xml:29:9
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:31:13
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:30:13
|
||||
activity#carbupbeta.Tab3
|
||||
ADDED from AndroidManifest.xml:33:9
|
||||
android:label
|
||||
ADDED from AndroidManifest.xml:35:13
|
||||
android:name
|
||||
ADDED from AndroidManifest.xml:34:13
|
||||
uses-sdk
|
||||
INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
|
||||
MERGED from com.android.support:appcompat-v7:21.0.3:15:5
|
||||
MERGED from com.android.support:support-v4:21.0.3:15:5
|
||||
android:targetSdkVersion
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
android:minSdkVersion
|
||||
INJECTED from AndroidManifest.xml:0:0
|
||||
INJECTED from AndroidManifest.xml:0:0
|
17
app/proguard-rules.pro
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/usb/android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
13
app/src/androidTest/java/com/hyperling/carbupbeta/ApplicationTest.java
Executable file
@ -0,0 +1,13 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
51
app/src/main/AndroidManifest.xml
Executable file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.hyperling.carbupbeta">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="com.google.android.gms,com.google.android.gms.ads" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/dr_face_straight2_circle"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".Splash"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Main"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
<activity
|
||||
android:name=".Tab1"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
<activity
|
||||
android:name=".Tab2"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
<activity
|
||||
android:name=".MySettings"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
<activity
|
||||
android:name=".Home"
|
||||
android:label="@string/title_activity_home"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
573
app/src/main/java/com/hyperling/carbupbeta/DALIH.java
Executable file
@ -0,0 +1,573 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by usb on 12/24/14.
|
||||
*/
|
||||
|
||||
// Database And ListItem Helper
|
||||
public class DALIH extends SQLiteOpenHelper{
|
||||
public final boolean DEBUG = false;
|
||||
|
||||
// SQL objects
|
||||
private static final String DB_NAME = "CARBUP.db";
|
||||
|
||||
private static final String list_table = "list"; // Saved List Table name (EX: 01, Schnuck's beans)
|
||||
private static final String item_table = "item"; // Saved Item Table name (EG: 01, red beans, 70 carbs, 200 calories, etc)
|
||||
private static final String setting_table = "settings";
|
||||
|
||||
private static final String list_id_col = "list_id";
|
||||
private static final String list_name_col = "list_name";
|
||||
|
||||
private static final String item_id_col = "item_id";
|
||||
private static final String item_name_col = "item_name";
|
||||
private static final String item_cost_col = "cost";
|
||||
private static final String item_servings_col = "servings";
|
||||
private static final String item_calories_col = "calories";
|
||||
private static final String item_carbs_col = "carbs";
|
||||
private static final String item_fiber_col = "fiber";
|
||||
private static final String item_list_id_col = list_id_col;
|
||||
|
||||
private static final String setting_last_list_col = "last_list";
|
||||
private static final String setting_last_item_col = "last_item";
|
||||
private static final String setting_ads_enabled_col = "ads_enabled";
|
||||
private static final String setting_quick_load_col = "quick_load";
|
||||
private static final String setting_open_tab_col = "open_tab";
|
||||
private static final int settings_total = 5;
|
||||
private static final int setting_last_list_index = 0;
|
||||
private static final int setting_last_item_index = 1;
|
||||
private static final int setting_ads_enabled_index = 2;
|
||||
private static final int setting_quick_load_index = 3;
|
||||
private static final int setting_open_tab_index = 4;
|
||||
private static final int setting_last_list_default = -1;
|
||||
private static final int setting_last_item_default = -1;
|
||||
private static final int setting_ads_enabled_default = 1;
|
||||
private static final int setting_quick_load_default = 0;
|
||||
private static final int setting_open_tab_default = 1;
|
||||
|
||||
private static final String CREATESLTABLE = "CREATE TABLE " + list_table + "(" +
|
||||
list_id_col + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
list_name_col + " TEXT NOT NULL" +
|
||||
"); ";
|
||||
|
||||
private static final String CREATESITABLE = "" +
|
||||
"CREATE TABLE " + item_table + "( " +
|
||||
item_id_col + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
item_name_col + " TEXT NOT NULL, " +
|
||||
item_cost_col + " REAL NOT NULL, " +
|
||||
item_servings_col + " REAL NOT NULL, " +
|
||||
item_calories_col + " REAL NOT NULL, " +
|
||||
item_carbs_col + " REAL NOT NULL, " +
|
||||
item_fiber_col + " REAL DEFAULT 0, " +
|
||||
item_list_id_col + " INTEGER NOT NULL, " +
|
||||
"FOREIGN KEY (" + item_list_id_col + ") REFERENCES " + list_table + "(" + list_id_col + ") ON DELETE CASCADE" +
|
||||
"); ";
|
||||
|
||||
private static final String CREATESETTINGTABLE = "" +
|
||||
"CREATE TABLE " + setting_table + "( " +
|
||||
" " + setting_last_list_col + " INTEGER NOT NULL, " +
|
||||
" " + setting_last_item_col + " INTEGER NOT NULL, " +
|
||||
" " + setting_ads_enabled_col + " INTEGER NOT NULL, " +
|
||||
" " + setting_quick_load_col + " INTEGER NOT NULL, " +
|
||||
" " + setting_open_tab_col + " INTEGER NOT NULL " +
|
||||
"); ";
|
||||
|
||||
|
||||
SQLiteDatabase db;
|
||||
|
||||
public DALIH(Context context){
|
||||
//4, add fiber column to list_item
|
||||
super(context, DB_NAME, null, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the database
|
||||
public void open() throws SQLException{
|
||||
if (DEBUG) System.out.println("Opening DB");
|
||||
|
||||
db = getWritableDatabase();
|
||||
return;
|
||||
}
|
||||
|
||||
// Close the database
|
||||
public void close(){
|
||||
if (DEBUG) System.out.println("Closing DB");
|
||||
|
||||
super.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert a ListItem into the DB
|
||||
public void insertItem(ListItemInfo listItem){
|
||||
if (DEBUG) System.out.println("Inserting item: " + listItem.getID() + " " + listItem.getName());
|
||||
|
||||
String query = "" +
|
||||
"INSERT INTO "+item_table+"("+item_name_col+", "+item_cost_col+", "+item_calories_col+", " +
|
||||
" "+item_carbs_col+", "+item_servings_col+", "+item_list_id_col+", " +
|
||||
" "+item_fiber_col+") " +
|
||||
"VALUES(\""+listItem.getName()+"\", "+listItem.getCost()+", "+listItem.getCalories()+", " +
|
||||
" "+listItem.getCarbs()+", "+listItem.getServings()+", "+listItem.getListID() + ", " +
|
||||
" "+listItem.getFiber()+"); ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
public void updateItem(ListItemInfo listItem){
|
||||
if (DEBUG) System.out.println("Updating item: " + listItem.getID() + " " + listItem.getName());
|
||||
|
||||
String query = "" +
|
||||
"UPDATE "+item_table+" " +
|
||||
" SET "+item_name_col+" = \""+listItem.getName()+"\", " +
|
||||
" "+item_cost_col+" = "+listItem.getCost()+", " +
|
||||
" "+item_calories_col+" = "+listItem.getCalories()+", " +
|
||||
" "+item_carbs_col+" = "+listItem.getCarbs()+", " +
|
||||
" "+item_servings_col+" = "+listItem.getServings()+", " +
|
||||
" "+item_fiber_col+" = "+listItem.getFiber()+", " +
|
||||
" "+item_list_id_col+" = "+listItem.getListID()+" " +
|
||||
" WHERE "+item_id_col+" = "+listItem.getID() + "; ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove a ListItem from the DB
|
||||
public void deleteItem(ListItemInfo listItem){
|
||||
if (DEBUG) System.out.println("Deleting item: " + listItem.getID() + " " + listItem.getName());
|
||||
|
||||
String query = "" +
|
||||
"DELETE FROM "+item_table+" " +
|
||||
" WHERE "+item_id_col+" = "+listItem.getID() + "; ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
// This method will give tab2 current List's items to sort through
|
||||
public ArrayList<ListItemInfo> getItems(int list_id){
|
||||
ArrayList<ListItemInfo> items = new ArrayList<ListItemInfo>();
|
||||
|
||||
String query = "" +
|
||||
"SELECT "+item_id_col+", " +
|
||||
" "+item_name_col+", " +
|
||||
" "+item_cost_col+", " +
|
||||
" "+item_servings_col+", " +
|
||||
" "+item_calories_col+", " +
|
||||
" "+item_carbs_col+", " +
|
||||
" "+item_fiber_col+", " +
|
||||
" "+item_list_id_col+" " +
|
||||
" FROM "+item_table+" " +
|
||||
" WHERE "+item_list_id_col+" = "+list_id+"; ";
|
||||
|
||||
if (DEBUG) System.out.println("Getting all items\n" + query);
|
||||
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
|
||||
if (DEBUG) System.out.println("Cursor size: " + c.getCount());
|
||||
|
||||
c.moveToFirst();
|
||||
while(!c.isAfterLast()){
|
||||
ListItemInfo temp = new ListItemInfo();
|
||||
|
||||
temp.setID(c.getInt(0));
|
||||
temp.setName(c.getString(1));
|
||||
temp.setCost(c.getDouble(2));
|
||||
temp.setServings(c.getDouble(3));
|
||||
temp.setCalories(c.getDouble(4));
|
||||
temp.setCarbs(c.getDouble(5));
|
||||
temp.setFiber(c.getDouble(6));
|
||||
temp.setListID(c.getInt(7));
|
||||
|
||||
items.add(temp);
|
||||
c.moveToNext();
|
||||
}
|
||||
c.close();
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public void insertList(ListInfo list){
|
||||
if (DEBUG) System.out.println("Inserting list: " + list.getID() + " " + list.getName());
|
||||
|
||||
String query = "" +
|
||||
"INSERT INTO "+list_table+"("+list_name_col+") " +
|
||||
"VALUES(\""+list.getName()+"\"); ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
public void updateList(ListInfo list){
|
||||
if (DEBUG) System.out.println("Updating list: " + list.getID() + " " + list.getName());
|
||||
|
||||
String query = "" +
|
||||
"UPDATE "+list_table+" " +
|
||||
" SET "+list_name_col+" = \""+list.getName()+"\" " +
|
||||
" WHERE "+list_id_col+" = "+list.getID()+"; ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
public void deleteList(ListInfo list){
|
||||
if (DEBUG) System.out.println("Deleting list: " + list.getID() + " " + list.getName());
|
||||
|
||||
String query = "" +
|
||||
"DELETE FROM "+list_table+" " +
|
||||
" WHERE "+list_id_col+" = "+list.getID()+"; ";
|
||||
|
||||
doQuery(query);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public ArrayList<ListInfo> getLists(){
|
||||
// Return ALL lists in an ArrayList
|
||||
ArrayList<ListInfo> lists = new ArrayList<ListInfo>();
|
||||
|
||||
String query = "" +
|
||||
"SELECT "+list_id_col+", " +
|
||||
" "+list_name_col+" " +
|
||||
" FROM "+list_table+"; ";
|
||||
|
||||
if (DEBUG) System.out.println("Getting all lists\n" + query);
|
||||
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
|
||||
if (DEBUG) System.out.println("Cursor size: " + c.getCount());
|
||||
|
||||
c.moveToFirst();
|
||||
while(!c.isAfterLast()){
|
||||
ListInfo temp = new ListInfo();
|
||||
|
||||
temp.setID(c.getInt(0));
|
||||
temp.setName(c.getString(1));
|
||||
|
||||
lists.add(temp);
|
||||
|
||||
c.moveToNext();
|
||||
}
|
||||
c.close();
|
||||
|
||||
return lists;
|
||||
}
|
||||
|
||||
private void setSettings(int[] settings){
|
||||
if (DEBUG) System.out.println("Setting settings");
|
||||
|
||||
int last_list = settings[getLastListIndex()];
|
||||
int last_item = settings[getLastItemIndex()];
|
||||
int ads_enabled = settings[getAdsEnabledIndex()];
|
||||
int quick_load = settings[getQuickLoadIndex()];
|
||||
int open_tab = settings[getOpenTabIndex()];
|
||||
String query = "" +
|
||||
"UPDATE "+setting_table+"" +
|
||||
" SET "+setting_last_list_col+" = "+last_list+", " +
|
||||
" "+setting_last_item_col+" = "+last_item+", " +
|
||||
" "+setting_ads_enabled_col+" = "+ads_enabled+", " +
|
||||
" "+setting_quick_load_col+" = "+quick_load+", " +
|
||||
" "+setting_open_tab_col+" = "+open_tab+"; ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
private int[] getSettings(){
|
||||
if (DEBUG) System.out.println("Getting settings");
|
||||
|
||||
String query = "" +
|
||||
"SELECT "+setting_last_list_col+", " +
|
||||
" "+setting_last_item_col+", " +
|
||||
" "+setting_ads_enabled_col+", " +
|
||||
" "+setting_quick_load_col+", " +
|
||||
" "+setting_open_tab_col+" " +
|
||||
" FROM "+setting_table+"; ";
|
||||
|
||||
int[] settings = null;
|
||||
Cursor c = db.rawQuery(query, null);
|
||||
|
||||
if (DEBUG) System.out.println("Cursor size: " + c.getCount());
|
||||
|
||||
if (c.getCount() == 0){
|
||||
setDefaults();
|
||||
|
||||
settings = new int[settings_total];
|
||||
settings[getLastListIndex()] = setting_last_list_default;
|
||||
settings[getLastItemIndex()] = setting_last_item_default;
|
||||
settings[getAdsEnabledIndex()] = setting_ads_enabled_default;
|
||||
settings[getQuickLoadIndex()] = setting_quick_load_default;
|
||||
settings[getOpenTabIndex()] = setting_open_tab_default;
|
||||
}
|
||||
else {
|
||||
if (DEBUG) System.out.println("Reading settings\n" + query);
|
||||
|
||||
c.moveToFirst();
|
||||
while (!c.isAfterLast()) {
|
||||
settings = new int[settings_total];
|
||||
settings[getLastListIndex()] = c.getInt(0);
|
||||
settings[getLastItemIndex()] = c.getInt(1);
|
||||
settings[getAdsEnabledIndex()] = c.getInt(2);
|
||||
settings[getQuickLoadIndex()] = c.getInt(3);
|
||||
settings[getOpenTabIndex()] = c.getInt(4);
|
||||
c.moveToNext();
|
||||
}
|
||||
}
|
||||
c.close();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
private void setDefaults(){
|
||||
if (DEBUG) System.out.println("Setting default settings");
|
||||
|
||||
String query = "" +
|
||||
"INSERT INTO " + setting_table + "("+setting_last_list_col+", "+setting_last_item_col+", " +
|
||||
" "+setting_ads_enabled_col+", "+setting_quick_load_col+", " +
|
||||
" "+setting_open_tab_col+") " +
|
||||
"VALUES("+setting_last_list_default+", "+setting_last_item_default+", " +
|
||||
" "+setting_ads_enabled_default+", "+setting_quick_load_default+", " +
|
||||
" "+setting_open_tab_default+"); ";
|
||||
|
||||
doQuery(query);
|
||||
return;
|
||||
}
|
||||
|
||||
private int getLastListIndex(){
|
||||
if (DEBUG) System.out.println("Getting last list index");
|
||||
|
||||
return setting_last_list_index;
|
||||
}
|
||||
|
||||
private int getLastItemIndex(){
|
||||
if (DEBUG) System.out.println("Getting last item index");
|
||||
|
||||
return setting_last_item_index;
|
||||
}
|
||||
|
||||
private int getAdsEnabledIndex(){
|
||||
if (DEBUG) System.out.println("Getting ads enabled index");
|
||||
|
||||
return setting_ads_enabled_index;
|
||||
}
|
||||
|
||||
private int getQuickLoadIndex(){
|
||||
if (DEBUG) System.out.println("Getting quick load index");
|
||||
|
||||
return setting_quick_load_index;
|
||||
}
|
||||
|
||||
private int getOpenTabIndex(){
|
||||
if (DEBUG) System.out.println("Getting open tab index");
|
||||
|
||||
return setting_open_tab_index;
|
||||
}
|
||||
|
||||
public int getLastList(){
|
||||
if (DEBUG) System.out.println("Getting last list");
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
return settings[getLastListIndex()];
|
||||
}
|
||||
|
||||
public void setLastList(int lastList){
|
||||
if (DEBUG) System.out.println("Setting last list to " + lastList);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
settings[getLastListIndex()] = lastList;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setLastList(){
|
||||
if (DEBUG) System.out.println("Setting last list to default, " + setting_last_list_default);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
settings[getLastListIndex()] = setting_last_list_default;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public int getLastItem(){
|
||||
if (DEBUG) System.out.println("Getting last item");
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
return settings[getLastItemIndex()];
|
||||
}
|
||||
|
||||
public void setLastItem(int lastItem){
|
||||
if (DEBUG) System.out.println("Setting last item to " + lastItem);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
settings[getLastItemIndex()] = lastItem;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setLastItem(){
|
||||
if (DEBUG) System.out.println("Setting last item to default, " + setting_last_item_default);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
settings[getLastItemIndex()] = setting_last_item_default;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean getAdsEnabled(){
|
||||
if (DEBUG) System.out.println("Getting ads enabled");
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
return (settings[getAdsEnabledIndex()] > 0);
|
||||
}
|
||||
|
||||
public void setAdsEnabled(boolean adsEnabled){
|
||||
if (DEBUG) System.out.println("Setting ads enabled to " + adsEnabled);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
int setting;
|
||||
if (adsEnabled){
|
||||
setting = 1;
|
||||
}
|
||||
else{
|
||||
setting = 0;
|
||||
}
|
||||
|
||||
settings[getAdsEnabledIndex()] = setting;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean getQuickLoad(){
|
||||
if (DEBUG) System.out.println("Getting quick load");
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
return (settings[getQuickLoadIndex()] > 0);
|
||||
}
|
||||
|
||||
public void setQuickLoad(boolean quickLoad){
|
||||
if (DEBUG) System.out.println("Setting quick load to " + quickLoad);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
int setting;
|
||||
if (quickLoad){
|
||||
setting = 1;
|
||||
}
|
||||
else{
|
||||
setting = 0;
|
||||
}
|
||||
|
||||
settings[getQuickLoadIndex()] = setting;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
public int getOpenTab(){
|
||||
if (DEBUG) System.out.println("Getting quick load");
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
return settings[getOpenTabIndex()];
|
||||
}
|
||||
|
||||
public void setOpenTab(int tab){
|
||||
if (DEBUG) System.out.println("Setting open tab to " + tab);
|
||||
|
||||
int[] settings = getSettings();
|
||||
|
||||
settings[getOpenTabIndex()] = tab;
|
||||
|
||||
setSettings(settings);
|
||||
return;
|
||||
}
|
||||
|
||||
private void doQuery(String query){
|
||||
if (DEBUG) System.out.println("Executing SQL:\n" + query);
|
||||
|
||||
db.execSQL(query);
|
||||
return;
|
||||
}
|
||||
|
||||
public String filterString(String input){
|
||||
if (DEBUG) System.out.println("Filtering string: " + input);
|
||||
String output = input.trim().replace("\"","").replace("\n", "").replace("\b", "").replace("\t", "");
|
||||
while(output.contains(" ")){
|
||||
if (DEBUG) System.out.println("In the space killer loop: " + output);
|
||||
output = output.replace(" ", " ");
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private void printDML(){
|
||||
System.out.println();
|
||||
System.out.println(CREATESLTABLE);
|
||||
System.out.println();
|
||||
System.out.println(CREATESITABLE);
|
||||
System.out.println();
|
||||
System.out.println(CREATESETTINGTABLE);
|
||||
System.out.println();
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase database) {
|
||||
if (DEBUG){
|
||||
System.out.println("Creating the DB");
|
||||
printDML();
|
||||
}
|
||||
|
||||
database.execSQL(CREATESLTABLE);
|
||||
database.execSQL(CREATESITABLE);
|
||||
database.execSQL(CREATESETTINGTABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
|
||||
if (DEBUG) System.out.println("Upgrading the DB");
|
||||
|
||||
switch(oldVersion){
|
||||
case 2:
|
||||
if (DEBUG) System.out.println("UPGRADING TO DBv3");
|
||||
String DBv3 = "" +
|
||||
" ALTER TABLE "+setting_table+" " +
|
||||
" ADD "+setting_open_tab_col+" INTEGER; " +
|
||||
"" +
|
||||
"UPDATE TABLE "+setting_table+" " +
|
||||
" SET "+setting_open_tab_col+" = "+setting_open_tab_default+"; " +
|
||||
"" +
|
||||
" ALTER TABLE "+setting_table+" " +
|
||||
" ALTER COLUMN "+setting_open_tab_col+" INTEGER NOT NULL; ";
|
||||
database.execSQL(DBv3);
|
||||
case 3:
|
||||
if (DEBUG) System.out.println("UPGRADING TO DBv4");
|
||||
String DBv4 = "" +
|
||||
" ALTER TABLE "+item_table+" " +
|
||||
" ADD "+item_fiber_col+" REAL DEFAULT 0; ";
|
||||
database.execSQL(DBv4);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
100
app/src/main/java/com/hyperling/carbupbeta/Home.java
Executable file
@ -0,0 +1,100 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
public class Home extends AppCompatActivity {
|
||||
|
||||
Resources recs;
|
||||
|
||||
Button btnCarbCalc, btnCalcHelp, btnWhyHCLF, btnWhyVegan;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up variables
|
||||
recs = getResources();
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up views
|
||||
btnCarbCalc = (Button) findViewById(R.id.btnCarbCalc);
|
||||
btnCalcHelp = (Button) findViewById(R.id.btnCalcHelp);
|
||||
btnWhyHCLF = (Button) findViewById(R.id.btnWhyHCLF);
|
||||
btnWhyVegan = (Button) findViewById(R.id.btnWhyVegan);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up button click listeners
|
||||
btnCarbCalc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Home.this, Main.class));
|
||||
}
|
||||
});
|
||||
|
||||
btnCalcHelp = (Button) findViewById(R.id.btnCalcHelp);
|
||||
|
||||
btnWhyHCLF = (Button) findViewById(R.id.btnWhyHCLF);
|
||||
|
||||
btnWhyVegan = (Button) findViewById(R.id.btnWhyVegan);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Finally, load ads >:)
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
// Load an ad into the AdMob banner view.
|
||||
AdView adView = (AdView) findViewById(R.id.adViewHome);
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // nexus 7
|
||||
.addTestDevice("B8B7561B850A9AB24E0D5B560FC50628") // Moto G
|
||||
.addTestDevice("") // Cappy, even though it doesn't support ads
|
||||
.setRequestAgent("android_studio:ad_template")
|
||||
.build();
|
||||
adView.loadAd(adRequest);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_home, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_exit) {
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
125
app/src/main/java/com/hyperling/carbupbeta/List.java
Executable file
@ -0,0 +1,125 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/31/15.
|
||||
*/
|
||||
public class List extends ListInfo{
|
||||
|
||||
LinearLayout linearLayout;
|
||||
Button btnDelete, btnEdit, btnItem;
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
private int textSize;
|
||||
|
||||
public List(Context context, ListInfo listInfo){
|
||||
// Set attributes
|
||||
setID(listInfo.getID());
|
||||
|
||||
dalih = new DALIH(context);
|
||||
|
||||
// Instantiate the Views
|
||||
linearLayout = new LinearLayout(context);
|
||||
btnDelete = new Button(context);
|
||||
btnEdit = new Button(context);
|
||||
btnItem = new Button(context);
|
||||
|
||||
// Give the views their required attributes (Wrap Content)
|
||||
LinearLayout.LayoutParams lay_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams delete_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
LinearLayout.LayoutParams edit_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
LinearLayout.LayoutParams item_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
|
||||
lay_lp.setMargins(1, 1, 1, 1);
|
||||
linearLayout.setLayoutParams(lay_lp);
|
||||
linearLayout.setPadding(1, 1, 1, 1);
|
||||
|
||||
delete_lp.setMargins(1, 1, 1, 1);
|
||||
btnDelete.setLayoutParams(delete_lp);
|
||||
|
||||
edit_lp.setMargins(1, 1, 1, 1);
|
||||
btnEdit.setLayoutParams(edit_lp);
|
||||
|
||||
item_lp.setMargins(1, 1, 1, 1);
|
||||
btnItem.setLayoutParams(item_lp);
|
||||
|
||||
// Add the values to the buttons
|
||||
btnDelete.setText(R.string.delete_button); // TODO: Make this an image
|
||||
btnEdit.setText(R.string.edit_button); // TODO: Make this a pencil image
|
||||
setName(listInfo.getName());
|
||||
|
||||
// ========== Style the buttons ==========
|
||||
// Color!
|
||||
linearLayout.setBackgroundColor(Color.BLACK);
|
||||
btnDelete.setBackgroundColor(Color.LTGRAY);
|
||||
btnDelete.setTextColor(Color.BLACK);
|
||||
btnEdit.setBackgroundColor(Color.LTGRAY);
|
||||
btnEdit.setTextColor(Color.BLACK);
|
||||
btnItem.setBackgroundColor(Color.WHITE);
|
||||
btnItem.setTextColor(getRandomColor());
|
||||
// Size!
|
||||
//textSize = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth()/30;
|
||||
btnDelete.setTextSize(16); //textSize-10);
|
||||
btnEdit.setTextSize(16); //textSize-10);
|
||||
btnItem.setTextSize(18); //textSize-6);
|
||||
|
||||
// Add the buttons to the layout!
|
||||
linearLayout.addView(btnDelete);
|
||||
linearLayout.addView(btnEdit);
|
||||
linearLayout.addView(btnItem);
|
||||
}
|
||||
|
||||
public LinearLayout getView(){
|
||||
return linearLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name){
|
||||
super.setName(name);
|
||||
btnItem.setText(getName());
|
||||
}
|
||||
|
||||
public int getRandomColor(){
|
||||
// Make negative to turn feature off
|
||||
int choice = (int) (Math.random()*12); // Highest case + 2 includes default
|
||||
|
||||
//if (dalih.DEBUG) System.out.println(getName() + " is color " + choice);
|
||||
|
||||
switch(choice){
|
||||
// Random assortment of colors
|
||||
case 0: return Color.rgb(250, 0, 0); // red
|
||||
case 1: return Color.rgb(250, 150, 0); // orange
|
||||
case 2: return Color.rgb(200, 200, 0); // yellow
|
||||
case 3: return Color.rgb(0, 250, 0); // green
|
||||
case 4: return Color.rgb(0, 150, 250); // aqua
|
||||
case 5: return Color.rgb(0, 0, 250); // blue
|
||||
case 6: return Color.rgb(150, 0, 250); // soft purple
|
||||
case 7: return Color.rgb(200, 0, 200); // purple
|
||||
|
||||
// Unused colors
|
||||
//case 8: return Color.rgb(0, 250, 250); // cyan
|
||||
case 9: return Color.rgb(125, 250, 0); // lime
|
||||
case 10: return Color.rgb(0, 250, 125); // turqoise?
|
||||
case 11: return Color.rgb(250, 0, 125); // magenta
|
||||
|
||||
// Shades of grey
|
||||
//case 12: return Color.rgb(200, 200, 200); // light grey
|
||||
case 8: return Color.rgb(100, 100, 100); // dark grey
|
||||
|
||||
// Possible theme?
|
||||
case 69: return Color.rgb(250, 250, 0); // yellow
|
||||
case 70: return Color.rgb(125, 0, 250); // purple
|
||||
|
||||
// Catch
|
||||
default: return Color.BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
26
app/src/main/java/com/hyperling/carbupbeta/ListInfo.java
Executable file
@ -0,0 +1,26 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
/**
|
||||
* Created by ling on 12/31/15.
|
||||
*/
|
||||
public class ListInfo {
|
||||
|
||||
private String name;
|
||||
private int ID;
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(int ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
}
|
151
app/src/main/java/com/hyperling/carbupbeta/ListItem.java
Executable file
@ -0,0 +1,151 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.widget.LinearLayout;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* Created by usb on 9/28/14.
|
||||
*/
|
||||
public class ListItem extends ListItemInfo {
|
||||
|
||||
private double calPerDol, carbPerCal;
|
||||
|
||||
LinearLayout linearLayout;
|
||||
Button btnDelete, btnEdit, btnItem;
|
||||
|
||||
private int textSize;
|
||||
|
||||
public ListItem(Context context, ListItemInfo listItemInfo){
|
||||
|
||||
// Instantiate the Views
|
||||
linearLayout = new LinearLayout(context);
|
||||
btnDelete = new Button(context);
|
||||
btnEdit = new Button(context);
|
||||
btnItem = new Button(context);
|
||||
|
||||
setID(listItemInfo.getID());
|
||||
setName(listItemInfo.getName());
|
||||
setCost(listItemInfo.getCost());
|
||||
setServings(listItemInfo.getServings());
|
||||
setCalories(listItemInfo.getCalories());
|
||||
setCarbs(listItemInfo.getCarbs());
|
||||
setFiber(listItemInfo.getFiber());
|
||||
calPerDol = getCalPerDol();
|
||||
carbPerCal = getCarbPerCal();
|
||||
|
||||
// Give the views their required attributes (Wrap Content)
|
||||
LinearLayout.LayoutParams lay_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams delete_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
LinearLayout.LayoutParams edit_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
LinearLayout.LayoutParams item_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
|
||||
lay_lp.setMargins(1, 1, 1, 1);
|
||||
linearLayout.setLayoutParams(lay_lp);
|
||||
linearLayout.setPadding(1, 1, 1, 1);
|
||||
|
||||
delete_lp.setMargins(1, 1, 1, 1);
|
||||
btnDelete.setLayoutParams(delete_lp);
|
||||
|
||||
edit_lp.setMargins(1, 1, 1, 1);
|
||||
btnEdit.setLayoutParams(edit_lp);
|
||||
|
||||
item_lp.setMargins(1, 1, 1, 1);
|
||||
btnItem.setLayoutParams(item_lp);
|
||||
|
||||
// Load values
|
||||
btnDelete.setText(R.string.delete_button); // TODO: Make this an image?
|
||||
btnEdit.setText(R.string.edit_button); // TODO: Make this a pencil?
|
||||
setName(listItemInfo.getName ());
|
||||
|
||||
// ========== Style the buttons ==========
|
||||
// Color!
|
||||
linearLayout.setBackgroundColor(Color.BLACK);
|
||||
btnDelete.setBackgroundColor(Color.LTGRAY);
|
||||
btnDelete.setTextColor(Color.BLACK);
|
||||
btnEdit.setBackgroundColor(Color.LTGRAY);
|
||||
btnEdit.setTextColor(Color.BLACK);
|
||||
btnItem.setBackgroundColor(Color.WHITE);
|
||||
int[] colors = getColors(carbPerCal);
|
||||
btnItem.setTextColor(Color.rgb(colors[0], colors[1], colors[2]));
|
||||
// Size!
|
||||
//textSize = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth()/30;
|
||||
btnDelete.setTextSize(16); //textSize-10);
|
||||
btnEdit.setTextSize(16); //textSize-10);
|
||||
btnItem.setTextSize(16); //textSize-8);
|
||||
|
||||
// Add the buttons to the layout!
|
||||
linearLayout.addView(btnDelete);
|
||||
linearLayout.addView(btnEdit);
|
||||
linearLayout.addView(btnItem);
|
||||
}
|
||||
|
||||
public LinearLayout getView(){
|
||||
return linearLayout;
|
||||
}
|
||||
|
||||
public int[] getColors(double carbPerCal){
|
||||
int r, g, b;
|
||||
b = 0;
|
||||
|
||||
// Find the ratio
|
||||
double dRed = 1-carbPerCal;
|
||||
double dGreen = carbPerCal;
|
||||
|
||||
// Find which is larger
|
||||
double max;
|
||||
if (dGreen > dRed){
|
||||
max = dGreen;
|
||||
} else {
|
||||
max = dRed;
|
||||
}
|
||||
|
||||
// Find the secret number (diff)
|
||||
double diff = 1 - max;
|
||||
|
||||
// Brighten the colors with diff!
|
||||
dRed += diff;
|
||||
dGreen += diff;
|
||||
|
||||
// Bring the colors into spectrum!
|
||||
dRed *= 255;
|
||||
dGreen *= 255;
|
||||
|
||||
// Make the numbers integers, increase to color spectrum
|
||||
r = (int) dRed;
|
||||
g = (int) dGreen;
|
||||
|
||||
// Put them in an array to pack and ship away
|
||||
int[] colors = {r, g, b};
|
||||
|
||||
if(carbPerCal >= 1){
|
||||
colors = new int[] {0, 255, 0};
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
public double getCalPerDol(){
|
||||
// Total calories divided by $$$
|
||||
return (getCalories()*getServings())/getCost();
|
||||
}
|
||||
|
||||
public double getCarbPerCal(){
|
||||
// Calories from carbs divided by calories from all sources
|
||||
return ((getCarbs()-getFiber())*4)/getCalories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name){
|
||||
super.setName(name);
|
||||
DecimalFormat format = new DecimalFormat("#.##");
|
||||
String strCalPerDol = format.format(calPerDol);
|
||||
strCalPerDol = getName() + "\n" + strCalPerDol + "Cal/$ " + format.format(carbPerCal * 100) + "%Carbs";
|
||||
btnItem.setText(strCalPerDol);
|
||||
}
|
||||
}
|
78
app/src/main/java/com/hyperling/carbupbeta/ListItemInfo.java
Executable file
@ -0,0 +1,78 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
/**
|
||||
* Created by usb on 1/4/15.
|
||||
*/
|
||||
public class ListItemInfo {
|
||||
private String name;
|
||||
private int ID, ListID;
|
||||
private double cost;
|
||||
private double servings;
|
||||
private double calories;
|
||||
private double carbs;
|
||||
private double fiber;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(int ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
|
||||
public int getListID() {
|
||||
return ListID;
|
||||
}
|
||||
|
||||
public void setListID(int listID) {
|
||||
ListID = listID;
|
||||
}
|
||||
|
||||
public double getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void setCost(double cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public double getServings() {
|
||||
return servings;
|
||||
}
|
||||
|
||||
public void setServings(double servings) {
|
||||
this.servings = servings;
|
||||
}
|
||||
|
||||
public double getCalories() {
|
||||
return calories;
|
||||
}
|
||||
|
||||
public void setCalories(double calories) {
|
||||
this.calories = calories;
|
||||
}
|
||||
|
||||
public double getCarbs() {
|
||||
return carbs;
|
||||
}
|
||||
|
||||
public void setCarbs(double carbs) {
|
||||
this.carbs = carbs;
|
||||
}
|
||||
|
||||
public double getFiber() {
|
||||
return fiber;
|
||||
}
|
||||
|
||||
public void setFiber(double fiber) {
|
||||
this.fiber = fiber;
|
||||
}
|
||||
}
|
109
app/src/main/java/com/hyperling/carbupbeta/Main.java
Executable file
@ -0,0 +1,109 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TabHost;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by usb on 9/29/14.
|
||||
*/
|
||||
public class Main extends TabActivity {
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
ArrayList<ListInfo> lists;
|
||||
|
||||
boolean createTab2 = false;
|
||||
int lastList, openTab, textSize;
|
||||
String tab2Name;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
// Instantiate DALIH
|
||||
dalih = new DALIH(this);
|
||||
|
||||
dalih.open();
|
||||
// THIS IS AN ASSIGNMENT STATEMENT. PLEASE READ IT CORRECTLY. #savecycles
|
||||
if ((lastList = dalih.getLastList()) >= 0) {
|
||||
openTab = dalih.getOpenTab();
|
||||
lists = dalih.getLists();
|
||||
}
|
||||
dalih.close();
|
||||
|
||||
if (lastList >= 0){
|
||||
createTab2 = true;
|
||||
|
||||
for (ListInfo list : lists){
|
||||
if (list.getID() == lastList){
|
||||
tab2Name = list.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init the TabHost
|
||||
TabHost tabHost = getTabHost();
|
||||
|
||||
// Create the tabs
|
||||
// Tab1
|
||||
TabHost.TabSpec createListSpec = tabHost.newTabSpec("Create List");
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
createListSpec.setIndicator("Choose List", getDrawable(R.drawable.dr_face_straight2_circle));
|
||||
}
|
||||
else{
|
||||
createListSpec.setIndicator("Choose List");
|
||||
}
|
||||
Intent createList = new Intent(this, Tab1.class);
|
||||
createListSpec.setContent(createList);
|
||||
// Add tab to TabHost
|
||||
tabHost.addTab(createListSpec);
|
||||
|
||||
// Tab2
|
||||
if (createTab2) {
|
||||
if (dalih.DEBUG) System.out.println("Creating tab2");
|
||||
|
||||
TabHost.TabSpec createItemsSpec = tabHost.newTabSpec("Create Items");
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
createItemsSpec.setIndicator(tab2Name);
|
||||
}
|
||||
else{
|
||||
createItemsSpec.setIndicator(tab2Name);
|
||||
}
|
||||
Intent createItems = new Intent(this, Tab2.class);
|
||||
createItemsSpec.setContent(createItems);
|
||||
|
||||
// Add tab to TabHost
|
||||
tabHost.addTab(createItemsSpec);
|
||||
}
|
||||
|
||||
// Settings/About Tab
|
||||
TabHost.TabSpec mySettingsSpec = tabHost.newTabSpec("Settings");
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mySettingsSpec.setIndicator("Settings", getDrawable(R.drawable.figsy_grass_circle_small));
|
||||
}
|
||||
else{
|
||||
mySettingsSpec.setIndicator("Settings");
|
||||
}
|
||||
Intent mySettingsList = new Intent(this, MySettings.class);
|
||||
mySettingsSpec.setContent(mySettingsList);
|
||||
// Add tab to TabHost
|
||||
tabHost.addTab(mySettingsSpec);
|
||||
|
||||
|
||||
// BEFORE FINAL, APP SHOULD OPEN ON TAB2
|
||||
//tabHost.setCurrentTab(1);
|
||||
// After app is final, app should open to tab1 if no previous lists exist
|
||||
// Otherwise, the app will open on tab 2 with the last selected list in place
|
||||
if (dalih.DEBUG) System.out.println("Opening tab " + openTab + ", index " + (openTab-1));
|
||||
tabHost.setCurrentTab(openTab-1);
|
||||
return;
|
||||
}
|
||||
}
|
25
app/src/main/java/com/hyperling/carbupbeta/MySettingInfo.java
Executable file
@ -0,0 +1,25 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
/**
|
||||
* Created by ling on 1/1/16.
|
||||
*/
|
||||
public class MySettingInfo {
|
||||
private String name;
|
||||
private boolean enabled;
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getEnabled(){
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled){
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
108
app/src/main/java/com/hyperling/carbupbeta/MySettingItem.java
Executable file
@ -0,0 +1,108 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
/**
|
||||
* Created by ling on 1/1/16.
|
||||
*/
|
||||
public class MySettingItem extends MySettingInfo{
|
||||
|
||||
private LinearLayout linearLayout;
|
||||
private RelativeLayout relativeLayout;
|
||||
Button btnItem;
|
||||
CheckBox checkBox;
|
||||
|
||||
private int textSize;
|
||||
|
||||
public MySettingItem(Context context, MySettingInfo info){
|
||||
// Instantiate the Views
|
||||
linearLayout = new LinearLayout(context);
|
||||
relativeLayout = new RelativeLayout(context);
|
||||
btnItem = new Button(context);
|
||||
checkBox = new CheckBox(context);
|
||||
|
||||
// Give the views their required attributes (Wrap Content)
|
||||
LayoutParams lay_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
LayoutParams rel_lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
LayoutParams item_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
RelativeLayout.LayoutParams check_lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
|
||||
lay_lp.setMargins(1, 1, 1, 1);
|
||||
linearLayout.setLayoutParams(lay_lp);
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
relativeLayout.setLayoutParams(rel_lp);
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
relativeLayout.setHorizontalGravity(RelativeLayout.ALIGN_PARENT_END);
|
||||
}
|
||||
else {
|
||||
relativeLayout.setHorizontalGravity(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
}
|
||||
|
||||
btnItem.setLayoutParams(item_lp);
|
||||
checkBox.setLayoutParams(check_lp);
|
||||
|
||||
// Add the values to the buttons
|
||||
setName(info.getName());
|
||||
setEnabled(info.getEnabled());
|
||||
|
||||
// ========== Style the buttons ==========
|
||||
// Color!
|
||||
linearLayout.setBackgroundColor(Color.LTGRAY);
|
||||
relativeLayout.setBackgroundColor(Color.LTGRAY);
|
||||
btnItem.setBackgroundColor(Color.LTGRAY);
|
||||
btnItem.setTextColor(Color.BLACK);
|
||||
// Size!
|
||||
//textSize = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth()/30;
|
||||
btnItem.setTextSize(24); // textSize);
|
||||
|
||||
// Add the items to the layout!
|
||||
relativeLayout.addView(checkBox);
|
||||
|
||||
linearLayout.addView(btnItem);
|
||||
linearLayout.addView(relativeLayout);
|
||||
|
||||
linearLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Build.VERSION.SDK_INT >= 15) {
|
||||
btnItem.callOnClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Build.VERSION.SDK_INT >= 15) {
|
||||
btnItem.callOnClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public LinearLayout getView(){
|
||||
return linearLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name){
|
||||
super.setName(name);
|
||||
btnItem.setText(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled){
|
||||
super.setEnabled(enabled);
|
||||
checkBox.setChecked(getEnabled());
|
||||
}
|
||||
}
|
98
app/src/main/java/com/hyperling/carbupbeta/MySettings.java
Executable file
@ -0,0 +1,98 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* Created by ling on 1/1/16.
|
||||
*/
|
||||
public class MySettings extends Activity {
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
Context context;
|
||||
|
||||
LinearLayout settingsArea;
|
||||
MySettingItem quickLoad, adsEnabled, rainbowLists, whiteOnBlack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.my_settings);
|
||||
|
||||
// Set default context
|
||||
context = this;
|
||||
|
||||
// Get DALIH ready to go!
|
||||
dalih = new DALIH(context);
|
||||
|
||||
// Find the layout
|
||||
settingsArea = (LinearLayout) findViewById(R.id.settingsArea);
|
||||
|
||||
// Instantiate settings
|
||||
quickLoad = new MySettingItem(context, new MySettingInfo());
|
||||
adsEnabled = new MySettingItem(context, new MySettingInfo());
|
||||
|
||||
// Name them
|
||||
quickLoad.setName("Quick Load:");
|
||||
adsEnabled.setName("Ads Enabled:");
|
||||
|
||||
// Set the checkboxes
|
||||
dalih.open();
|
||||
quickLoad.setEnabled(dalih.getQuickLoad());
|
||||
adsEnabled.setEnabled(dalih.getAdsEnabled());
|
||||
dalih.close();
|
||||
|
||||
// Set the checkbox actions
|
||||
quickLoad.btnItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dalih.setQuickLoad(!dalih.getQuickLoad());
|
||||
quickLoad.checkBox.setChecked(dalih.getQuickLoad());
|
||||
}
|
||||
});
|
||||
quickLoad.checkBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dalih.setQuickLoad(quickLoad.checkBox.isChecked());
|
||||
}
|
||||
});
|
||||
|
||||
adsEnabled.btnItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dalih.setAdsEnabled(!dalih.getAdsEnabled());
|
||||
adsEnabled.checkBox.setChecked(dalih.getAdsEnabled());
|
||||
}
|
||||
});
|
||||
adsEnabled.checkBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dalih.setAdsEnabled(adsEnabled.checkBox.isChecked());
|
||||
}
|
||||
});
|
||||
|
||||
// Throw them onto the screen
|
||||
settingsArea.addView(quickLoad.getView());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
settingsArea.addView(adsEnabled.getView());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
dalih.open();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
dalih.close();
|
||||
super.onPause();
|
||||
}
|
||||
}
|
66
app/src/main/java/com/hyperling/carbupbeta/Splash.java
Executable file
@ -0,0 +1,66 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
//This class is simply the load screen to start Tabs.class
|
||||
|
||||
|
||||
public class Splash extends Activity {
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
TextView txtStatus;
|
||||
|
||||
int loadTime = 3000;
|
||||
int quickTime = 500;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splash);
|
||||
|
||||
dalih = new DALIH(this);
|
||||
|
||||
// Find the TextViews
|
||||
txtStatus = (TextView) findViewById(R.id.txtLoadStatus);
|
||||
|
||||
// Create the TimerTask to launch main
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(Splash.this, Main.class));
|
||||
//startActivity(new Intent(Splash.this, Home.class));
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
dalih.open();
|
||||
if (dalih.getQuickLoad()){
|
||||
loadTime = quickTime;
|
||||
}
|
||||
dalih.close();
|
||||
|
||||
//Create and start the timer
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(timerTask, loadTime);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
dalih.open();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
dalih.close();
|
||||
super.onPause();
|
||||
}
|
||||
}
|
320
app/src/main/java/com/hyperling/carbupbeta/Tab1.java
Executable file
@ -0,0 +1,320 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
/**
|
||||
* Created by usb on 9/28/14.
|
||||
*
|
||||
* This class will:
|
||||
* Create a new list then open tab2
|
||||
*/
|
||||
|
||||
public class Tab1 extends Activity{
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
// Layout related
|
||||
Context context;
|
||||
EditText txtList;
|
||||
Button btnCreate;
|
||||
LinearLayout layListArea;
|
||||
TextView tvLeft, tvRight, selectHeader;
|
||||
AdView mAdView;
|
||||
|
||||
// The lists!
|
||||
ArrayList<List> lists = new ArrayList<List>();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tab1);
|
||||
|
||||
// Set default context
|
||||
context = this;
|
||||
|
||||
// Initiate DALIH
|
||||
dalih = new DALIH(context);
|
||||
|
||||
// Connect to the layout
|
||||
txtList = (EditText) findViewById(R.id.etListName);
|
||||
btnCreate = (Button) findViewById(R.id.btnAddToList);
|
||||
layListArea = (LinearLayout) findViewById(R.id.tab1ListArea);
|
||||
tvLeft = (TextView) findViewById(R.id.leftEditView);
|
||||
tvRight = (TextView) findViewById(R.id.rightEditView);
|
||||
selectHeader = (TextView) findViewById(R.id.selectListHeader);
|
||||
mAdView = (AdView) findViewById(R.id.adView);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void setButtonInsert(){
|
||||
btnCreate.setText(R.string.list_create_button_insert);
|
||||
tvLeft.setText("");
|
||||
tvRight.setText("");
|
||||
|
||||
dalih.setLastItem();
|
||||
|
||||
createLists();
|
||||
|
||||
btnCreate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ListInfo newList = new ListInfo();
|
||||
newList.setName(dalih.filterString(txtList.getText().toString()));
|
||||
|
||||
if (!testDuplicate(newList)) {
|
||||
if (dalih.DEBUG) System.out.println("List not duplicate, inserting");
|
||||
|
||||
hideKeyboard();
|
||||
|
||||
dalih.insertList(newList);
|
||||
|
||||
createLists();
|
||||
|
||||
dalih.setOpenTab(2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void setButtonUpdate(final List list){
|
||||
btnCreate.setText(R.string.list_create_button_update);
|
||||
String editing = getString(R.string.list_editing) + " "; // strings.xml must get trimmed, space is not appearing
|
||||
tvLeft.setText(editing);
|
||||
tvRight.setText(list.getName());
|
||||
|
||||
// Store the ID
|
||||
dalih.setLastItem(list.getID());
|
||||
|
||||
// Recreate the lists
|
||||
createLists();
|
||||
|
||||
// Pull the text
|
||||
txtList.setText(list.getName());
|
||||
|
||||
showKeyboard();
|
||||
|
||||
btnCreate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
list.setName(dalih.filterString(txtList.getText().toString()));
|
||||
|
||||
if (!testDuplicate(list)) {
|
||||
if (dalih.DEBUG) System.out.println("List not duplicate, updating");
|
||||
|
||||
hideKeyboard();
|
||||
|
||||
dalih.updateList(list);
|
||||
|
||||
if (dalih.getLastList() == list.getID()) {
|
||||
if (dalih.DEBUG) System.out.println("Last list renamed, resetting");
|
||||
|
||||
restart();
|
||||
}
|
||||
|
||||
setButtonInsert();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate all lists and place in alphabetical order
|
||||
private void createLists(){
|
||||
if (dalih.DEBUG) System.out.println("Creating lists for Tab1");
|
||||
|
||||
txtList.setText("");
|
||||
|
||||
lists = new ArrayList<List>();
|
||||
|
||||
for (ListInfo info : dalih.getLists()){
|
||||
if (dalih.DEBUG) System.out.println("Found list: " + info.getID() + " " +info.getName());
|
||||
|
||||
if (info.getID() != dalih.getLastItem()) {
|
||||
lists.add(new List(context, info));
|
||||
}
|
||||
}
|
||||
|
||||
if (lists.size() > 0){
|
||||
selectHeader.setText(R.string.list_select_header);
|
||||
}
|
||||
else{
|
||||
selectHeader.setText("");
|
||||
}
|
||||
|
||||
lists = orderLists(lists);
|
||||
|
||||
layListArea.removeAllViews();
|
||||
for (final List list : lists){
|
||||
list.btnDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dalih.DEBUG) System.out.println("Clicked delete button: " + list.getID() + " " + list.getName());
|
||||
|
||||
dalih.deleteList(list);
|
||||
|
||||
if (dalih.getLastList() == list.getID()){
|
||||
if (dalih.DEBUG) System.out.println("Last list deleted, resetting");
|
||||
|
||||
dalih.setLastList();
|
||||
|
||||
restart();
|
||||
}
|
||||
|
||||
createLists();
|
||||
}
|
||||
});
|
||||
|
||||
list.btnEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dalih.DEBUG) System.out.println("Clicked edit button: " + list.getID() + " " + list.getName());
|
||||
|
||||
// Change to update mode
|
||||
setButtonUpdate(list);
|
||||
}
|
||||
});
|
||||
|
||||
list.btnItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dalih.DEBUG) System.out.println("Clicked main button: " + list.getID() + " " + list.getName());
|
||||
|
||||
dalih.setLastList(list.getID());
|
||||
|
||||
dalih.setOpenTab(2);
|
||||
|
||||
//restart();
|
||||
startActivity(new Intent(Tab1.this, Main.class));
|
||||
}
|
||||
});
|
||||
|
||||
if (dalih.DEBUG) System.out.println("Creating list: " + list.getID() + " " + list.getName());
|
||||
|
||||
layListArea.addView(list.getView());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private ArrayList<List> orderLists(ArrayList<List> unorderedLists){
|
||||
if (dalih.DEBUG) System.out.println("Sorting lists");
|
||||
|
||||
ArrayList<List> orderedLists = new ArrayList<>();
|
||||
|
||||
while (!unorderedLists.isEmpty()) {
|
||||
String bestName = "z";
|
||||
int index = 0;
|
||||
|
||||
for (List list : unorderedLists) {
|
||||
if (list.getName().toUpperCase().compareTo(bestName.toUpperCase()) < 0) {
|
||||
//if (dalih.DEBUG) System.out.println(list.getName() + " is better than " + bestName);
|
||||
|
||||
bestName = list.getName();
|
||||
index = unorderedLists.indexOf(list);
|
||||
}
|
||||
}
|
||||
if (dalih.DEBUG) System.out.println(bestName + " was the best");
|
||||
|
||||
orderedLists.add(unorderedLists.get(index));
|
||||
unorderedLists.remove(index);
|
||||
}
|
||||
|
||||
return orderedLists;
|
||||
}
|
||||
|
||||
private boolean testDuplicate(ListInfo listInfo) {
|
||||
for (List list : lists) {
|
||||
if (listInfo.getName().equals(list.getName()) || listInfo.getName().equals("")) {
|
||||
Toast.makeText(context, "Name must be unique!", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restart(){
|
||||
finish();
|
||||
startActivity(new Intent(Tab1.this, Main.class));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
if (dalih.DEBUG) System.out.println("***** Resuming Tab1 *****");
|
||||
|
||||
dalih.open();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
if (dalih.getAdsEnabled()) {
|
||||
if (mAdView.getVisibility() != View.VISIBLE) {
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // nexus 7
|
||||
.addTestDevice("B8B7561B850A9AB24E0D5B560FC50628") // Moto G
|
||||
.addTestDevice("") // Cappy, even though it can't get ads
|
||||
.build();
|
||||
mAdView.setVisibility(View.VISIBLE);
|
||||
mAdView.loadAd(adRequest);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (mAdView.getVisibility() == View.VISIBLE) {
|
||||
mAdView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setButtonInsert();
|
||||
|
||||
super.onResume();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (dalih.DEBUG) System.out.println("***** Pausing Tab1 *****");
|
||||
|
||||
dalih.close();
|
||||
|
||||
hideKeyboard();
|
||||
|
||||
super.onPause();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void hideKeyboard(){
|
||||
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(btnCreate.getWindowToken(), 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void showKeyboard(){
|
||||
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(txtList, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
369
app/src/main/java/com/hyperling/carbupbeta/Tab2.java
Executable file
@ -0,0 +1,369 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by usb on 9/28/14.
|
||||
*
|
||||
* This class will:
|
||||
* Add items to the current selected list
|
||||
*
|
||||
* DEEMED "GOOD ENOUGH" 13:45 2014-09-30 :D
|
||||
* ListItems are created perfectly, ordered by Cal/$, and colored by Carb/Cal
|
||||
*/
|
||||
|
||||
public class Tab2 extends Activity{
|
||||
|
||||
private DALIH dalih;
|
||||
|
||||
// Define the Views
|
||||
Context context;
|
||||
LinearLayout layListArea;
|
||||
EditText txtName, txtCost, txtServings, txtCalories, txtCarbs, txtFiber;
|
||||
Button btnClear, btnAdd;
|
||||
AdView mAdView;
|
||||
|
||||
// List
|
||||
ArrayList<ListItem> items = new ArrayList<ListItem>();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tab2);
|
||||
|
||||
// Set default context
|
||||
context = this;
|
||||
|
||||
// Initiate DALIH
|
||||
dalih = new DALIH(context);
|
||||
|
||||
// Load/Find the Views!
|
||||
layListArea = (LinearLayout) findViewById(R.id.layTab2ListArea);
|
||||
txtName = (EditText) findViewById(R.id.etItemName);
|
||||
txtCost = (EditText) findViewById(R.id.etItemCost);
|
||||
txtServings = (EditText) findViewById(R.id.etItemServs);
|
||||
txtCalories = (EditText) findViewById(R.id.etItemCals);
|
||||
txtCarbs = (EditText) findViewById(R.id.etItemCarbs);
|
||||
txtFiber = (EditText) findViewById(R.id.etItemFiber);
|
||||
btnClear = (Button) findViewById(R.id.btnClear);
|
||||
btnAdd = (Button) findViewById(R.id.btnAddToList);
|
||||
mAdView = (AdView) findViewById(R.id.adView);
|
||||
|
||||
// Give the Buttons their power
|
||||
btnClear.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
removeItem();
|
||||
|
||||
// Clear all fields!
|
||||
txtName.setText("");
|
||||
txtCost.setText("");
|
||||
txtServings.setText("");
|
||||
txtCalories.setText("");
|
||||
txtCarbs.setText("");
|
||||
txtFiber.setText("");
|
||||
|
||||
setButtonInsert();
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}// end onCreate
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
if (dalih.DEBUG) System.out.println("***** Resuming Tab2 *****");
|
||||
|
||||
dalih.open();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
if (dalih.getAdsEnabled()) {
|
||||
if (mAdView.getVisibility() != View.VISIBLE) {
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // nexus 7
|
||||
.addTestDevice("B8B7561B850A9AB24E0D5B560FC50628") // Moto G
|
||||
.addTestDevice("") // Cappy, even though it can't get ads
|
||||
.build();
|
||||
mAdView.setVisibility(View.VISIBLE);
|
||||
mAdView.loadAd(adRequest);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (mAdView.getVisibility() == View.VISIBLE) {
|
||||
mAdView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setButtonInsert();
|
||||
|
||||
super.onResume();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause(){
|
||||
if (dalih.DEBUG) System.out.println("***** Pausing Tab2 *****");
|
||||
|
||||
dalih.close();
|
||||
|
||||
hideKeyboard();
|
||||
|
||||
super.onPause();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean validateItem(ListItemInfo newItem){
|
||||
// FIELDS MUST HAVE VALUES BEFORE CONVERTING!!!
|
||||
if (txtName.getText().toString().equals("")){
|
||||
Toast.makeText(context, "Item must have a name!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (txtCost.getText().toString().equals("") || txtCost.getText().toString().equals(".")){
|
||||
Toast.makeText(context, "Item must have a cost!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (txtServings.getText().toString().equals("") || txtServings.getText().toString().equals(".")){
|
||||
Toast.makeText(context, "Item must have servings!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (txtCalories.getText().toString().equals("") || txtCalories.getText().toString().equals(".")){
|
||||
Toast.makeText(context, "Item must have calories!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (txtCarbs.getText().toString().equals("") || txtCarbs.getText().toString().equals(".")){
|
||||
Toast.makeText(context, "Item must have carbohydrates!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
|
||||
newItem.setName(txtName.getText().toString());
|
||||
newItem.setCost(Double.parseDouble(txtCost.getText().toString()));
|
||||
newItem.setServings(Double.parseDouble(txtServings.getText().toString()));
|
||||
newItem.setCalories(Double.parseDouble(txtCalories.getText().toString()));
|
||||
newItem.setCarbs(Double.parseDouble(txtCarbs.getText().toString()));
|
||||
newItem.setFiber(Double.parseDouble(txtFiber.getText().toString()));
|
||||
newItem.setListID(dalih.getLastList());
|
||||
|
||||
// NAME MUST BE UNIQUE, VALUES MUST BE GREATER THAN 0
|
||||
boolean nameDuplicated = false;
|
||||
for(ListItem li : items){
|
||||
if(newItem.getName().equals(li.getName()) || newItem.getName().equals("")){
|
||||
nameDuplicated = true;
|
||||
}
|
||||
}
|
||||
if (nameDuplicated){
|
||||
Toast.makeText(context, "Name must be unique!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (newItem.getCost() <= 0){
|
||||
Toast.makeText(context, "Cost must be greater than 0!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (newItem.getServings() <= 0){
|
||||
Toast.makeText(context, "Servings must be greater than 0!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (newItem.getCalories() <= 0){
|
||||
Toast.makeText(context, "Calories must be greater than 0!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (newItem.getFiber() > newItem.getCarbs()){
|
||||
Toast.makeText(context, "Cannot have more fiber than carbs!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if ((newItem.getCarbs()-newItem.getFiber()) * 3.5 > newItem.getCalories()){
|
||||
Toast.makeText(context, "Too many carbs, not enough calories!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}// end else
|
||||
}// end else
|
||||
|
||||
return false;
|
||||
}// end validateItem()
|
||||
|
||||
public void setButtonInsert(){
|
||||
btnAdd.setText(R.string.item_create_button_insert);
|
||||
|
||||
// Reset to default
|
||||
dalih.setLastItem();
|
||||
|
||||
createItems();
|
||||
|
||||
if (dalih.DEBUG) System.out.println("Setting add button to insert");
|
||||
btnAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
ListItemInfo newItem = new ListItemInfo();
|
||||
|
||||
if (validateItem(newItem)) {
|
||||
hideKeyboard();
|
||||
|
||||
dalih.insertItem(newItem);
|
||||
|
||||
createItems();
|
||||
|
||||
dalih.setOpenTab(1);
|
||||
}
|
||||
}
|
||||
});// end btnAdd.setOnClickListener
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void setButtonUpdate(final ListItem listItem){
|
||||
btnAdd.setText(R.string.item_create_button_update);
|
||||
|
||||
// Pull Item info into top boxes then remove the ListItem
|
||||
// Save which item we are on
|
||||
dalih.setLastItem(listItem.getID());
|
||||
|
||||
// Remove the item
|
||||
createItems();
|
||||
|
||||
// Set all fields to the values
|
||||
txtName.setText(listItem.getName());
|
||||
txtCost.setText(Double.toString(listItem.getCost()));
|
||||
txtServings.setText(Double.toString(listItem.getServings()));
|
||||
txtCalories.setText(Double.toString(listItem.getCalories()));
|
||||
txtCarbs.setText(Double.toString(listItem.getCarbs()));
|
||||
txtFiber.setText(Double.toString(listItem.getFiber()));
|
||||
|
||||
showKeyboard();
|
||||
|
||||
if (dalih.DEBUG) System.out.println("");
|
||||
btnAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
if (validateItem(listItem)) {
|
||||
hideKeyboard();
|
||||
|
||||
dalih.updateItem(listItem);
|
||||
|
||||
setButtonInsert();
|
||||
}
|
||||
}
|
||||
});// end btnAdd.setOnClickListener
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void createItems(){
|
||||
if (dalih.DEBUG) System.out.println("Creating items");
|
||||
|
||||
txtName.setText("");
|
||||
txtCost.setText("");
|
||||
txtServings.setText("");
|
||||
txtCalories.setText("");
|
||||
txtCarbs.setText("");
|
||||
txtFiber.setText("");
|
||||
|
||||
items = new ArrayList<ListItem>();
|
||||
|
||||
for (ListItemInfo info : dalih.getItems(dalih.getLastList())){
|
||||
if (dalih.DEBUG) System.out.println("Found item: " + info.getID() + " " + info.getName());
|
||||
|
||||
// Prevent item being edited from being displayed
|
||||
if (info.getID() != dalih.getLastItem()) {
|
||||
items.add(new ListItem(context, info));
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Display the ListItems ==========
|
||||
// Order the list
|
||||
items = orderList(items);
|
||||
|
||||
// Give the Item Buttons functionality
|
||||
for (final ListItem li : items){
|
||||
li.btnEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Change the create button to update instead of insert
|
||||
setButtonUpdate(li);
|
||||
}
|
||||
});
|
||||
|
||||
li.btnDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dalih.deleteItem(li);
|
||||
|
||||
createItems();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Replace old List with new ordered list
|
||||
// Clear list
|
||||
layListArea.removeAllViews();
|
||||
// Add Views
|
||||
for (ListItem li : items) {
|
||||
layListArea.addView(li.getView());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public ArrayList<ListItem> orderList(ArrayList<ListItem> unorderedList){
|
||||
if (dalih.DEBUG) System.out.println("Sorting the items");
|
||||
|
||||
ArrayList<ListItem> orderedList = new ArrayList<ListItem>();
|
||||
|
||||
while (!unorderedList.isEmpty()) {
|
||||
double max = 0;
|
||||
int index = 0;
|
||||
|
||||
for (ListItem j : unorderedList) {
|
||||
if (j.getCalPerDol() > max) {
|
||||
//if (dalih.DEBUG) System.out.println(j.getCalPerDol()*100 + " is better than " + max*100);
|
||||
|
||||
max = j.getCalPerDol();
|
||||
index = unorderedList.indexOf(j);
|
||||
}
|
||||
}
|
||||
if (dalih.DEBUG) System.out.println(max*100 + " was the best");
|
||||
orderedList.add(unorderedList.get(index));
|
||||
unorderedList.remove(index);
|
||||
}
|
||||
|
||||
return orderedList;
|
||||
}
|
||||
|
||||
public void removeItem(){
|
||||
int deleteID = dalih.getLastItem();
|
||||
|
||||
for (ListItemInfo item : dalih.getItems(dalih.getLastList())){
|
||||
if (item.getID() == deleteID){
|
||||
if (dalih.DEBUG) System.out.println("Deleting item " + item.getID() + " " + item.getName());
|
||||
dalih.deleteItem(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void hideKeyboard(){
|
||||
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(btnAdd.getWindowToken(),0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void showKeyboard(){
|
||||
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(txtName, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}// end Tab2
|
64
app/src/main/java/com/hyperling/carbupbeta/changelog.txt
Executable file
@ -0,0 +1,64 @@
|
||||
|
||||
**********
|
||||
**********
|
||||
**********
|
||||
TODO:
|
||||
- Implement a database (Moves project to Beta v1.00)
|
||||
- Create 2 tables
|
||||
- 1st is List, one attribute is ListID(PK)
|
||||
- 2nd is Item, 2 primary keys per entry (ItemID, ListID(FK)), and attributes as Price, Servings, Calories, and Carbs
|
||||
- Have Tab1 create a List entity
|
||||
- Have Tab2 create Item entities with the correct ListID
|
||||
- Have Tab3 display all Lists, with the current selected List at the top
|
||||
- Finalize the app (Moves project to Final/Release/Something meaning it isn't beta/v1.00)
|
||||
- All functionality is functional
|
||||
- App is easy to understand for new users
|
||||
- Visuals and audio are high quality
|
||||
**********
|
||||
**********
|
||||
**********
|
||||
$VERSION_NAME v$VERSION_NUMBER $DATE_STARTED - $DATE_FINISHED
|
||||
**********
|
||||
**********
|
||||
**********
|
||||
Beta v0.08 2016/01/06 - 2016/01/06
|
||||
- Make the keyboard lower after adding a list or item
|
||||
Beta v0.07 2015/12/31 - 2016/01/03
|
||||
- Changed names of tables and columns on DB
|
||||
- Deleted tab 3, moved list of Lists to tab1 and selected list to tab2
|
||||
- Always open on tab1
|
||||
- Created List and ListInfo
|
||||
- Finished DALIH, added methods for List
|
||||
- Basically re-did the entire thing
|
||||
Aplha v0.06 2014/12/29 - Unfinished
|
||||
- Created Data to hold dalih for all tabs
|
||||
- Added Data to application in manifest
|
||||
- Brought DALIH to life (with insert, delete, and get methods)
|
||||
- Started preparing a toggle button on tab2 in case I add measuring by weight
|
||||
- Got tab2 to work with DALIH
|
||||
Alpha v0.05 2014/12/24 - 2014/12/29 Uploaded as Version 1(0.05)
|
||||
- Transfer project to Android Studio 1.0
|
||||
- Add @string version_name
|
||||
- Change @string my_version_number to version_number in all files
|
||||
- Created DALIH
|
||||
- Changed to circle icon
|
||||
Alpha v0.04 2014/10/16 - 2014/10/16
|
||||
- Change carbs to return to double in edit text
|
||||
Alpha v0.03 2014/10/13 - 2014/10/13
|
||||
- EditTexts adjust height if one grows
|
||||
Alpha v0.02 2014/10/07 - 2014/10/13
|
||||
- ListItem entries editable
|
||||
- Tab2 text edits need not be able to enter only a "."
|
||||
- Add percentages
|
||||
- Fix button text being displaced
|
||||
- All Tab2 ListItem information is on its own line
|
||||
- Renamed BETA TEST LIST to Unsaved Test LIst
|
||||
Alpha v0.01
|
||||
- Added ScrollView around tab2's ListITemLayout
|
||||
Alpha v0.00
|
||||
Designed entire app, got tab 2 "working"
|
||||
- Now working on bringing to the app store
|
||||
- Tab2 needs to be able to scroll
|
||||
- v0.01
|
||||
- Tab2 needs ListItems to be editable
|
||||
- Tab2 needs to have color codes, or to display a % of carb/calorie (in addition to color)
|
BIN
app/src/main/res/drawable-hdpi/dr_face_straight2_circle.png
Executable file
After Width: | Height: | Size: 6.9 KiB |
BIN
app/src/main/res/drawable-hdpi/dr_face_straight2_square.png
Executable file
After Width: | Height: | Size: 9.1 KiB |
BIN
app/src/main/res/drawable-hdpi/figsy_grass_circle_full.png
Executable file
After Width: | Height: | Size: 72 KiB |
BIN
app/src/main/res/drawable-hdpi/figsy_grass_circle_medium.png
Executable file
After Width: | Height: | Size: 31 KiB |
BIN
app/src/main/res/drawable-hdpi/figsy_grass_circle_small.png
Executable file
After Width: | Height: | Size: 9.3 KiB |
BIN
app/src/main/res/drawable-hdpi/figsy_grass_full.jpg
Executable file
After Width: | Height: | Size: 32 KiB |
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 9.2 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Executable file
After Width: | Height: | Size: 19 KiB |
94
app/src/main/res/layout/activity_home.xml
Executable file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
tools:context="com.hyperling.carbupbeta.Home"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight=".45"
|
||||
android:weightSum="1">
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".5"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:background="@color/colorAccent"
|
||||
android:text="Carb Calculator"
|
||||
android:textColor="@color/textAccentInverse"
|
||||
android:textAllCaps="false"
|
||||
android:id="@+id/btnCarbCalc"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".5"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="Calculator Help"
|
||||
android:textColor="@color/textPrimaryInverse"
|
||||
android:textAllCaps="false"
|
||||
android:id="@+id/btnCalcHelp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight=".45"
|
||||
android:weightSum="1">
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".5"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="Why High Carb?"
|
||||
android:textColor="@color/textPrimaryInverse"
|
||||
android:textAllCaps="false"
|
||||
android:id="@+id/btnWhyHCLF"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".5"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:background="@color/colorAccent"
|
||||
android:text="Why Vegan?"
|
||||
android:textColor="@color/textAccentInverse"
|
||||
android:textAllCaps="false"
|
||||
android:id="@+id/btnWhyVegan"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adViewHome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".1"
|
||||
ads:adSize="BANNER"
|
||||
ads:adUnitId="@string/banner_ad_home">
|
||||
</com.google.android.gms.ads.AdView>
|
||||
|
||||
</LinearLayout>
|
55
app/src/main/res/layout/activity_splash.xml
Executable file
@ -0,0 +1,55 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".Splash">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/txtSpace"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/txtAppVersion"
|
||||
android:text="@string/version_number"
|
||||
android:textSize="32sp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_above="@id/txtSpace"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name_short"
|
||||
android:textSize="60sp"
|
||||
android:id="@+id/txtAppName"
|
||||
android:layout_above="@+id/txtAppVersion"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/pbCircle"
|
||||
android:layout_below="@+id/txtSpace"/>
|
||||
|
||||
<!-- If the splash screen ever does anything, this will change with @strings -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Loading..."
|
||||
android:textSize="24sp"
|
||||
android:id="@+id/txtLoadStatus"
|
||||
android:layout_below="@+id/pbCircle"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
</RelativeLayout>
|
41
app/src/main/res/layout/list.xml
Executable file
@ -0,0 +1,41 @@
|
||||
<?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:layout_margin="5dp">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/delete_button"
|
||||
android:id="@+id/delete_btn"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/edit_button"
|
||||
android:id="@+id/edit_btn"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:id="@+id/radio_btn"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/radio_btn"
|
||||
android:layout_toStartOf="@+id/radio_btn"
|
||||
android:id="@+id/item_btn"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
23
app/src/main/res/layout/list_item.xml
Executable file
@ -0,0 +1,23 @@
|
||||
<?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">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/delete_button"
|
||||
android:id="@+id/delete_btn"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/edit_button"
|
||||
android:id="@+id/edit_btn"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/item_btn"/>
|
||||
|
||||
</LinearLayout>
|
33
app/src/main/res/layout/main.xml
Executable file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TabHost
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/title"
|
||||
android:id="@android:id/tabhost">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TabWidget
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@android:id/tabs"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_below="@android:id/tabs"
|
||||
android:padding="7dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</TabHost>
|
||||
|
||||
</RelativeLayout>
|
53
app/src/main/res/layout/my_settings.xml
Executable file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/version"
|
||||
android:text="@string/version_number"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="false"
|
||||
android:layout_above="@+id/version"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/app"
|
||||
android:text="@string/app_name_long"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="false"
|
||||
android:layout_above="@+id/app"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/author"
|
||||
android:text="@string/author"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="false"
|
||||
android:layout_above="@id/author">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/settingsArea" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
99
app/src/main/res/layout/tab1.xml
Executable file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/list_header"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/etListName"
|
||||
android:hint="@string/list_name_hint"
|
||||
android:capitalize="words"
|
||||
android:inputType="textCapWords"/>
|
||||
|
||||
<!-- The following items are assigned @strings in Tab1.java -->
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="start"
|
||||
android:text="Testing "
|
||||
android:textSize="20sp"
|
||||
android:id="@+id/leftEditView"/>
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="start"
|
||||
android:text="Test List"
|
||||
android:textSize="20sp"
|
||||
android:id="@+id/rightEditView"/>
|
||||
<TextView
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
<Button
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/btnAddToList"
|
||||
android:text="Test"
|
||||
android:textSize="18sp"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="Test:"
|
||||
android:textSize="24sp"
|
||||
android:id="@+id/selectListHeader"/>
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
ads:adSize="BANNER"
|
||||
android:visibility="gone"
|
||||
ads:adUnitId="@string/banner_ad_tab1">
|
||||
</com.google.android.gms.ads.AdView>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@+id/adView">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/tab1ListArea"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
128
app/src/main/res/layout/tab2.xml
Executable file
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/item_header"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TableRow>
|
||||
<!-- First row data entry -->
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="5"
|
||||
android:capitalize="words"
|
||||
android:inputType="textCapWords"
|
||||
android:id="@+id/etItemName"
|
||||
android:hint="@string/item_name_hint"/>
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="numberDecimal"
|
||||
android:id="@+id/etItemCost"
|
||||
android:hint="@string/item_cost_hint" />
|
||||
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="numberDecimal"
|
||||
android:id="@+id/etItemServs"
|
||||
android:hint="@string/item_servings_hint"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="numberDecimal"
|
||||
android:id="@+id/etItemCals"
|
||||
android:hint="@string/item_calories_hint"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="numberDecimal"
|
||||
android:id="@+id/etItemCarbs"
|
||||
android:hint="@string/item_carbs_hint" />
|
||||
|
||||
<EditText
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:inputType="numberDecimal"
|
||||
android:id="@+id/etItemFiber"
|
||||
android:hint="@string/item_fiber_hint" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<Button
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/btnClear"
|
||||
android:text="@string/item_clear_button"
|
||||
android:textSize="18sp"/>
|
||||
<TextView
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
<!-- Text is set with @string in Tab2.java -->
|
||||
<Button
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/btnAddToList"
|
||||
android:text="Test"
|
||||
android:textSize="18sp"/>
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
ads:adSize="BANNER"
|
||||
android:visibility="gone"
|
||||
ads:adUnitId="@string/banner_ad_tab2">
|
||||
</com.google.android.gms.ads.AdView>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@+id/adView">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/layTab2ListArea"
|
||||
android:isScrollContainer="true"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
50
app/src/main/res/layout/testing.xml
Executable file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:id="@+id/settingName"
|
||||
android:text="Quick Boot:"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/settingName"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:id="@+id/settingDescription"
|
||||
android:text="Skip the splash screen"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/checkBox"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
13
app/src/main/res/menu/menu_home.xml
Executable file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu 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"
|
||||
tools:context="com.hyperling.carbupbeta.Home">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_exit"
|
||||
android:orderInCategory="999"
|
||||
android:title="Exit"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
11
app/src/main/res/values-v21/styles.xml
Executable file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:navigationBarColor">?android:attr/colorPrimaryDark</item>
|
||||
</style>
|
||||
</resources>
|
6
app/src/main/res/values-w820dp/dimens.xml
Executable file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
8
app/src/main/res/values/colors.xml
Executable file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#CCCC00</color>
|
||||
<color name="colorPrimaryDark">#333333</color>
|
||||
<color name="colorAccent">#330066</color>
|
||||
<color name="textPrimaryInverse">#FFFFFF</color>
|
||||
<color name="textAccentInverse">#FFFFFF</color>
|
||||
</resources>
|
5
app/src/main/res/values/dimens.xml
Executable file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
65
app/src/main/res/values/strings.xml
Executable file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Carb Up! BETA</string>
|
||||
<string name="app_name_long">Carb Up! CTFU Helper</string>
|
||||
<string name="app_name_short">Carb Up!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_main">Main</string>
|
||||
<string name="version_name">-=Version Banana=-</string>
|
||||
<string name="version_number">-=Beta v0.10=-</string>
|
||||
|
||||
<string name="author">Hyperling</string>
|
||||
|
||||
<!-- Tab1 Views -->
|
||||
|
||||
<string name="list_header">Create a New List:</string>
|
||||
<string name="list_name_hint">List Name</string>
|
||||
|
||||
<string name="list_editing">Editing </string>
|
||||
|
||||
<string name="list_create_button_insert">Create</string>
|
||||
<string name="list_create_button_update">Rename</string>
|
||||
|
||||
<string name="list_select_header">Click on a List\'s Name:</string>
|
||||
|
||||
<!-- Tab2 Views -->
|
||||
|
||||
<string name="item_header">Create a New Item:</string>
|
||||
<string name="item_create_button_insert">Add</string>
|
||||
<string name="item_create_button_update">Update</string>
|
||||
|
||||
<string name="item_name_hint">Item Name</string>
|
||||
<string name="item_cost_hint">Cost ($)</string>
|
||||
<string name="item_servings_hint">Servings</string>
|
||||
<string name="item_calories_hint">Calories per Serving</string>
|
||||
<string name="item_carbs_hint">Carbs (g)</string>
|
||||
<string name="item_fiber_hint">Fiber (g)</string>
|
||||
|
||||
<string name="item_clear_button">Clear</string>
|
||||
|
||||
<!-- Settings -->
|
||||
|
||||
|
||||
<!-- Shared -->
|
||||
|
||||
<string name="delete_button">X</string>
|
||||
<string name="edit_button">Edit</string>
|
||||
|
||||
<string name="delete_dialog_title">Are you sure?</string>
|
||||
<string name="delete_dialog_list_message">This will delete the list permanently.</string>
|
||||
<string name="delete_dialog_item_message">This will delete the item permanently.</string>
|
||||
<string name="delete_dialog_ok">Delete</string>
|
||||
<string name="delete_dialog_cancel">Cancel</string>
|
||||
|
||||
<!-- Ads -->
|
||||
|
||||
<string name="banner_ad_unit_id">ca-app-pub-9712416021907617/1895014881</string>
|
||||
<string name="banner_ad_tab1">ca-app-pub-9712416021907617/1895014881</string>
|
||||
<string name="banner_ad_tab2">ca-app-pub-9712416021907617/6325214486</string>
|
||||
<string name="banner_ad_home">ca-app-pub-9712416021907617/4055112081</string>
|
||||
<string name="interstitial_ad_splash">ca-app-pub-9712416021907617/9278680882</string>
|
||||
<string name="title_activity_home">Home</string>
|
||||
|
||||
|
||||
</resources>
|
17
app/src/main/res/values/styles.xml
Executable file
@ -0,0 +1,17 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:colorForeground">@color/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
BIN
art/Screenshots/Phone/1_motoGSplash.png
Executable file
After Width: | Height: | Size: 40 KiB |
BIN
art/Screenshots/Phone/2_motoGTab1.png
Executable file
After Width: | Height: | Size: 96 KiB |
BIN
art/Screenshots/Phone/3_motoGTab1_rename.png
Executable file
After Width: | Height: | Size: 111 KiB |
BIN
art/Screenshots/Phone/4_motoGTab2_Starch.png
Executable file
After Width: | Height: | Size: 128 KiB |
BIN
art/Screenshots/Phone/5_motoGSettings.png
Executable file
After Width: | Height: | Size: 86 KiB |
BIN
art/Screenshots/Tablet/1_Nexus7_Splash.png
Executable file
After Width: | Height: | Size: 27 KiB |
BIN
art/Screenshots/Tablet/2_Nexus7_Tab1.png
Executable file
After Width: | Height: | Size: 59 KiB |
BIN
art/Screenshots/Tablet/3_Nexus7_Tab1_editing.png
Executable file
After Width: | Height: | Size: 86 KiB |
BIN
art/Screenshots/Tablet/4_Nexus7_Tab2.png
Executable file
After Width: | Height: | Size: 86 KiB |
BIN
art/Screenshots/Tablet/5_Nexus7_Settings.png
Executable file
After Width: | Height: | Size: 55 KiB |
BIN
art/ctfu.png
Executable file
After Width: | Height: | Size: 308 KiB |
BIN
art/figsy.xcf
Executable file
BIN
art/store_banner.xcf
Executable file
BIN
art/store_banner_blank.png
Executable file
After Width: | Height: | Size: 2.1 KiB |
19
build.gradle
Executable file
@ -0,0 +1,19 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
18
gradle.properties
Executable file
@ -0,0 +1,18 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Executable file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
1
settings.gradle
Executable file
@ -0,0 +1 @@
|
||||
include ':app'
|