Skip to content

Instantly share code, notes, and snippets.

@Jonty800
Last active August 29, 2015 13:57
Show Gist options
  • Save Jonty800/9918407 to your computer and use it in GitHub Desktop.
Save Jonty800/9918407 to your computer and use it in GitHub Desktop.
Weight management
/** NutritionCentral
* Copyright (C) <2013, 2014> Jonathan Baker, Max Tayler - University of Kent
* All rights reserved
*/
package com.ukc.nutritioncentral.adapter;
import java.util.List;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class WeightResultArrayAdapter extends ArrayAdapter<String> {
public class ViewHolder {
public TextView title;
}
protected List<String> data;
protected int layoutResourceId;
public ArrayAdapter<String> adapter = this;
public WeightResultArrayAdapter(Context context, int layoutResourceId,
List<String> data) {
super(context, layoutResourceId, data);
this.data = data;
this.layoutResourceId = layoutResourceId;
}
}
/** NutritionCentral
* Copyright (C) <2013, 2014> Jonathan Baker, Max Tayler - University of Kent
* All rights reserved
*/
package com.ukc.nutritioncentral.activity;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import android.app.ActionBar;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import com.ukc.nutritioncentral.ErrorPopup;
import com.ukc.nutritioncentral.LinearListView;
import com.ukc.nutritioncentral.R;
import com.ukc.nutritioncentral.UserCache;
import com.ukc.nutritioncentral.adapter.WeightResultArrayAdapter;
public class WeightManagementActivity extends BaseActivity implements
ActionBar.TabListener {
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
// Show 2 total pages.
return 2;
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment = new WeightSectionFragment();
return fragment;
}
@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_WeightSection1).toUpperCase(l);
case 1:
return getString(R.string.title_WeightSection2).toUpperCase(l);
}
return null;
}
}
/**
* A dummy fragment representing a section of the app, but that simply
* displays dummy text.
*/
public static class WeightSectionFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public WeightSectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View rootView = inflater.inflate(
R.layout.fragment_weight_management, container, false);
return rootView;
}
}
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link android.support.v4.app.FragmentPagerAdapter} derivative, which
* will keep every loaded fragment in memory. If this becomes too memory
* intensive, it may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
double kg;
double cm;
double age;
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weight_management);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
setTitle("Weight Management");
int position = 0;
Bundle b = getIntent().getExtras();
if (b != null) {
position = b.getInt("position");
// not sure yet
}
// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager
.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
actionBar.setSelectedNavigationItem(position);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.static_menu, menu);
return true;
}
@Override
public void onTabReselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabSelected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
int pos = tab.getPosition();
mViewPager.setCurrentItem(pos);
setContentView(R.layout.fragment_weight_management);
if (pos == 1) {
((ScrollView) findViewById(R.id.bmi_scrollable_layout))
.setVisibility(View.VISIBLE);
((Button) findViewById(R.id.bmi_more_info))
.setVisibility(View.VISIBLE);
((LinearLayout) findViewById(R.id.weightmanageview))
.setVisibility(View.GONE);
// Set EditText views
final EditText weightText = (EditText) findViewById(R.id.bmi_weight_edit_text);
final EditText heightText = (EditText) findViewById(R.id.bmi_height_edit_text);
final EditText ageText = (EditText) findViewById(R.id.bmi_age_edit_text);
weightText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View arg0, boolean arg1) {
if (arg1) {
weightText
.setBackgroundResource(R.drawable.rounded_edittext_active);
}
if (!arg1) {
weightText
.setBackgroundResource(R.drawable.rounded_edittext);
}
}
});
heightText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View arg0, boolean arg1) {
if (arg1) {
heightText
.setBackgroundResource(R.drawable.rounded_edittext_active);
}
if (!arg1) {
heightText
.setBackgroundResource(R.drawable.rounded_edittext);
}
}
});
ageText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View arg0, boolean arg1) {
if (arg1) {
ageText.setBackgroundResource(R.drawable.rounded_edittext_active);
}
if (!arg1) {
ageText.setBackgroundResource(R.drawable.rounded_edittext);
}
}
});
// Set spinner view
final Spinner weightSpinner = (Spinner) findViewById(R.id.bmi_weight_spinner);
final Spinner heightSpinner = (Spinner) findViewById(R.id.bmi_height_spinner);
final DecimalFormat fmt = new DecimalFormat("0.00");
// Create an ArrayAdapter using the string array and a default
// spinner
// layout
ArrayAdapter<CharSequence> heightAdapter = ArrayAdapter
.createFromResource(this, R.array.height_array,
R.layout.spinner_item);
ArrayAdapter<CharSequence> weightAdapter = ArrayAdapter
.createFromResource(this, R.array.weight_array,
R.layout.spinner_item);
// Specify the layout to use when the list of choices appears
heightAdapter
.setDropDownViewResource(R.layout.dropdown_spinner_item);
weightAdapter
.setDropDownViewResource(R.layout.dropdown_spinner_item);
// Apply the adapter to the spinner
heightSpinner.setAdapter(heightAdapter);
weightSpinner.setAdapter(weightAdapter);
// More info button
Button moreBtn = (Button) findViewById(R.id.bmi_more_info);
moreBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context,
BmiDetailsActivity.class);
startActivity(intent);
overridePendingTransition(android.R.anim.slide_in_left,
android.R.anim.slide_out_right);
}
});
final LinearLayout updateWeightLayout = (LinearLayout) findViewById(R.id.wm_update_weight_container);
LinearLayout updateWeightBtn = (LinearLayout) findViewById(R.id.wm_update_container);
updateWeightBtn.setClickable(true);
updateWeightBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
updateWeightLayout.setVisibility(View.VISIBLE);
}
});
ImageView hideUpdateWeight = (ImageView) findViewById(R.id.update_weight_hide);
hideUpdateWeight.setClickable(true);
hideUpdateWeight.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
updateWeightLayout.setVisibility(View.GONE);
}
});
// Make EditText change color when focused
final EditText updateWeight = (EditText) findViewById(R.id.update_weight_edit_text);
updateWeight.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean focused) {
if (focused) {
updateWeight
.setBackgroundResource(R.drawable.rounded_edittext_active);
}
if (!focused) {
updateWeight
.setBackgroundResource(R.drawable.rounded_edittext);
}
}
});
// Save users updated weight value
Button saveUpdate = (Button) findViewById(R.id.save_new_weight_button);
saveUpdate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO
}
});
// Set update weight spinner
Spinner updateWeightSpinner = (Spinner) findViewById(R.id.update_weight_spinner);
ArrayAdapter<CharSequence> updateWeightAdapter = ArrayAdapter
.createFromResource(this, R.array.weight_array,
R.layout.spinner_item);
updateWeightAdapter
.setDropDownViewResource(R.layout.dropdown_spinner_item);
updateWeightSpinner.setAdapter(updateWeightAdapter);
// Calculate button
Button calcBtn = (Button) findViewById(R.id.bmi_calculate_button);
calcBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Set result TextView's
TextView idealBMI = (TextView) findViewById(R.id.bmi_ideal_result);
TextView resultBMI = (TextView) findViewById(R.id.bmi_result);
TextView meaning = (TextView) findViewById(R.id.bmi_meaning);
// Parse age string as double
try {
age = Double.parseDouble(ageText.getText().toString());
}// Display error message if age is invalid
catch (NumberFormatException e) {
idealBMI.setText("error");
new ErrorPopup("Please enter your age", context).show();
return;
}
// Parse height string as double
// If kg is selected on spinner, parse normally
try {
if (weightSpinner.getSelectedItemPosition() == 0) {
kg = Double.parseDouble(weightText.getText()
.toString());
} else {
// If lbs is selected on spiner, convert to kg
kg = Double.parseDouble(weightText.getText()
.toString()) / 2.2046;
}
}// Display error message if weight is invalid
catch (NumberFormatException e) {
resultBMI.setText("error");
new ErrorPopup("Please enter your weight", context)
.show();
return;
}
// If cm is selected on spinner, parse normally
try {
if (heightSpinner.getSelectedItemPosition() == 0) {
cm = Double.parseDouble(heightText.getText()
.toString());
} else {
// If inches is selected on spiner, convert to cm
cm = Double.parseDouble(heightText.getText()
.toString()) * 2.54;
}
}// Display error message if height is invalid
catch (NumberFormatException e) {
resultBMI.setText("error");
new ErrorPopup("Please enter your height", context)
.show();
return;
}
// Calculate BMI using kg and cm
double bmiValue = (kg / Math.pow(cm / 100, 2));
// Format and print BMI
resultBMI.setText(fmt.format(bmiValue));
// Set ideal age depending on given value and interpret BMI
// value
if (age > 0 && age < 2) {
idealBMI.setText("14-17");
if (bmiValue >= 14 && bmiValue <= 17) {
meaning.setText("Healthy");
} else if (bmiValue <= 13) {
meaning.setText("Underweight");
} else if (bmiValue > 17 && bmiValue <= 19) {
meaning.setText("Overweight");
} else if (bmiValue > 19) {
meaning.setText("Obese");
}
} else if (age >= 2 && age < 4) {
idealBMI.setText("15 - 17");
if (bmiValue >= 15 && bmiValue <= 17) {
meaning.setText("Healthy");
} else if (bmiValue < 15) {
meaning.setText("Underweight");
} else if (bmiValue >= 17 && bmiValue <= 18) {
meaning.setText("Overweight");
} else if (bmiValue > 18) {
meaning.setText("Obese");
}
} else if (age >= 4 && age < 9) {
idealBMI.setText("14 - 18");
if (bmiValue >= 14 && bmiValue <= 18) {
meaning.setText("Healthy");
} else if (bmiValue < 14) {
meaning.setText("Underweight");
} else if (bmiValue > 18 && bmiValue <= 21) {
meaning.setText("Overweight");
} else if (bmiValue > 21) {
meaning.setText("Obese");
}
} else if (age >= 9 && age < 12) {
idealBMI.setText("15 - 21");
if (bmiValue >= 15 && bmiValue <= 21) {
meaning.setText("Healthy");
} else if (bmiValue < 15) {
meaning.setText("Underweight");
} else if (bmiValue > 21 && bmiValue <= 24) {
meaning.setText("Overweight");
} else if (bmiValue > 24) {
meaning.setText("Obese");
}
} else if (age >= 12 && age < 14) {
idealBMI.setText("15 - 22");
if (bmiValue >= 15 && bmiValue <= 22) {
meaning.setText("Healthy");
} else if (bmiValue < 15) {
meaning.setText("Underweight");
} else if (bmiValue > 22 && bmiValue <= 26) {
meaning.setText("Overweight");
} else if (bmiValue > 26) {
meaning.setText("Obese");
}
} else if (age >= 14 && age < 16) {
idealBMI.setText("16 - 23");
if (bmiValue >= 16 && bmiValue <= 23) {
meaning.setText("Healthy");
} else if (bmiValue < 16) {
meaning.setText("Underweight");
} else if (bmiValue > 23 && bmiValue <= 27) {
meaning.setText("Overweight");
} else if (bmiValue > 27) {
meaning.setText("Obese");
}
} else if (age >= 16 && age < 18) {
idealBMI.setText("17 - 25");
if (bmiValue >= 17 && bmiValue <= 25) {
meaning.setText("Healthy");
} else if (bmiValue < 17) {
meaning.setText("Underweight");
} else if (bmiValue > 25 && bmiValue <= 29) {
meaning.setText("Overweight");
} else if (bmiValue > 29) {
meaning.setText("Obese");
}
} else if (age >= 18 && age < 20) {
idealBMI.setText("18 - 26");
if (bmiValue >= 18 && bmiValue <= 26) {
meaning.setText("Healthy");
} else if (bmiValue < 18) {
meaning.setText("Underweight");
} else if (bmiValue > 26 && bmiValue <= 30) {
meaning.setText("Overweight");
} else if (bmiValue > 30) {
meaning.setText("Obese");
}
} else if (age >= 20 && age < 65) {
idealBMI.setText("20 - 25");
if (bmiValue >= 20 && bmiValue <= 25) {
meaning.setText("Healthy");
} else if (bmiValue < 20) {
meaning.setText("Underweight");
} else if (bmiValue > 25 && bmiValue <= 30) {
meaning.setText("Overweight");
} else if (bmiValue > 30) {
meaning.setText("Obese");
}
} else if (age >= 65) {
idealBMI.setText("25 - 27");
if (bmiValue >= 25 && bmiValue <= 27) {
meaning.setText("Healthy");
} else if (bmiValue < 25) {
meaning.setText("Underweight");
} else if (bmiValue > 27 && bmiValue <= 30) {
meaning.setText("Overweight");
} else if (bmiValue > 30) {
meaning.setText("Obese");
}
}
}
});
} else {
((ScrollView) findViewById(R.id.bmi_scrollable_layout))
.setVisibility(View.GONE);
((Button) findViewById(R.id.bmi_more_info))
.setVisibility(View.GONE);
((LinearLayout) findViewById(R.id.weightmanageview))
.setVisibility(View.VISIBLE);
WebView webView = (WebView) findViewById(R.id.webview_history);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.setVisibility(View.VISIBLE);
// TextView tv = (TextView) findViewById(R.id.loadingtv);
// tv.setVisibility(View.GONE);
//view.setInitialScale(100);
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
// webView.setInitialScale(1);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
refreshChart(webView);
}
}
float convertDpToPixel(float dp, Context context) {
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
float px = (dp * (metrics.densityDpi / 160f));
return px;
}
int maxEntries = 5;
public List<String> getWeights() {
return UserCache.previousWeights;
}
public String generateGraphWeightString() {
String s = "[\"Date\", \"Weight (KG)\", { role: \"style\" } ],";
List<String> entries;
if (getWeights().size() < 5)
entries = getWeights();
else {
entries = new ArrayList<String>();
for (int i = 4; i >= 0; i--) {
entries.add(getWeights().get(i));
}
}
for (String entry : entries) {
String[] split = entry.split("\\$");
String key = split[0];
String value = split[1];
Date date = new Date();
try {
date = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH)
.parse(key);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
s += "[\"" + format.format(date) + "\", " + value + ", \"red\"],";
}
s += "]);";
System.out.println(s);
return s;
}
public void setupListView() {
LinearListView lv = (LinearListView) findViewById(R.id.wm_entry_history);
WeightResultArrayAdapter adp = new WeightResultArrayAdapter(context,
R.layout.adapter_weight_items, UserCache.previousWeights) {
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
View cell = convertView;
ViewHolder holder = null;
if (cell == null) {
holder = new ViewHolder();
LayoutInflater inflater = ((Activity) context)
.getLayoutInflater();
cell = inflater.inflate(layoutResourceId, parent, false);
holder.title = (TextView) cell
.findViewById(R.id.weight_title);
cell.setTag(holder);
} else {
holder = (ViewHolder) cell.getTag();
}
final String item = data.get(position);
String[] split = item.split("\\$");
String date = split[0];
String weight = split[1];
holder.title.setText("Date: " + date + " - " + "Weight: "
+ weight + "KG");
LinearLayout layout = (LinearLayout) cell
.findViewById(R.id.delete_layout);
final List<String> copy = new ArrayList<String>(
UserCache.previousWeights);
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
for (String w : UserCache.previousWeights) {
if (w.equals(item)) {
copy.remove(w);
}
}
UserCache.previousWeights = copy;
adapter.clear();
adapter.addAll(UserCache.previousWeights);
adapter.notifyDataSetChanged();
refreshChart((WebView) findViewById(R.id.webview_history));
}
});
return cell;
}
};
lv.setAdapter(adp);
}
public String weightType = "KG";
public void refreshChart(WebView webView) {
if (getWeights().size() == 0) {
webView.setVisibility(View.GONE);
return;
}
setupListView();
String content = "<html>"
+ " <head>"
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
+ " <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>"
+ " <script type=\"text/javascript\">"
+ "google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});"
+ " google.setOnLoadCallback(drawChart);"
+ "function drawChart() {"
+ "var data = google.visualization.arrayToDataTable(["
+ generateGraphWeightString()
+ "var view = new google.visualization.DataView(data);"
+ "view.setColumns([0, 1,"
+ " { calc: \"stringify\","
+ " sourceColumn: 1,"
+ " type: \"string\","
+ " role: \"annotation\" },"
+ " 2]);"
+ " var options = {"
+ "width: '100%',"
+ "bar: {groupWidth: \"95%\"},"
+ "vAxis: { title: 'Weight ("
+ weightType
+ ")' },"
+ " legend: { position: \"none\" },"
+ " };"
+ " var chart = new google.visualization.ColumnChart(document.getElementById(\"columnchart_values\"));"
+ " chart.draw(view, options);"
+ "}"
+ "</script>"
+ "<div id=\"columnchart_values\" style=\"height: "
+ "px; margin: 0; padding: 0;\"></div></center>"
+ "</body>"
+ "</html>";
System.out.println(content);
webView.loadDataWithBaseURL("file:///android_asset/", content,
"text/html", "utf-8", null);
}
@Override
public void onTabUnselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e5e5e5"
android:orientation="vertical" >
<ScrollView
android:id="@+id/bmi_scrollable_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="vertical"
android:scrollbars="vertical"
android:visibility="gone" >
<LinearLayout
android:id="@+id/bmi_scroll_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp" >
<LinearLayout
android:id="@+id/bmi_details_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<TextView
android:id="@+id/bmi_your_details_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/yourDetails"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="@+id/bmi_seperator1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
android:background="#3f4843" />
<LinearLayout
android:id="@+id/bmi_age_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/bmi_age_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="7"
android:gravity="center_vertical|center_horizontal"
android:text="@string/yourAge"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:id="@+id/bmi_age_edit_text"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="5"
android:background="@drawable/rounded_edittext"
android:gravity="center_horizontal|center_vertical"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:textColor="#3f4843"
android:textSize="14sp" >
</EditText>
<TextView
android:id="@+id/bmi_empty_string2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="7"
android:gravity="center_horizontal|center_vertical"
android:text="@string/empty"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/bmi_weight_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal" >
<TextView
android:id="@+id/bmi_weight_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="7"
android:gravity="center_vertical|center_horizontal"
android:text="@string/yourWeight"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:id="@+id/bmi_weight_edit_text"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="5"
android:background="@drawable/rounded_edittext"
android:gravity="center_horizontal|center_vertical"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:textColor="#3f4843"
android:textSize="14sp" >
</EditText>
<LinearLayout
android:id="@+id/bmi_weight_spinner_container"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="7"
android:gravity="center" >
<Spinner
android:id="@+id/bmi_weight_spinner"
android:layout_width="100dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/bmi_height_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/bmi_height_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="7"
android:gravity="center_horizontal"
android:text="@string/yourHeight"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:id="@+id/bmi_height_edit_text"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:layout_weight="5"
android:background="@drawable/rounded_edittext"
android:ems="10"
android:gravity="center_horizontal|center_vertical"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:textColor="#3f4843"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/bmi_height_spinner_container"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="7"
android:gravity="center" >
<Spinner
android:id="@+id/bmi_height_spinner"
android:layout_width="100dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/bmi_calculate_button_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:paddingTop="16dp" >
<Button
android:id="@+id/bmi_calculate_button"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/button_bg"
android:gravity="center_horizontal|center_vertical"
android:padding="4dp"
android:text="@string/calcBtn"
android:textColor="#fff"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/bmi_result_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/bmi_your_result_container"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/bmi_results_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7.5"
android:padding="8dp"
android:text="@string/yourResult"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bmi_meaning"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_weight="3"
android:gravity="center"
android:text="@string/empty"
android:textColor="#0e7058"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/bmi_seperator2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:background="#3f4843" />
<LinearLayout
android:id="@+id/bmi_bmi_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp" >
<TextView
android:id="@+id/bmi_bmi_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="7"
android:gravity="left"
android:text="@string/yourBMI"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bmi_result"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="3"
android:gravity="center_horizontal"
android:textColor="#0e7058"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/bmi_ideal_bmi_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/bmi_ideal_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="16dp"
android:layout_weight="7"
android:text="@string/idealAge"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/bmi_ideal_result"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="8dp"
android:layout_weight="3"
android:gravity="center_horizontal"
android:textColor="#0e7058"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
android:background="#fff"
android:orientation="vertical" >
<Button
android:id="@+id/bmi_more_info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@null"
android:gravity="center"
android:text="@string/clickForInfo"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/weightmanageview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e5e5e5"
android:visibility="gone"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/weight_management_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/wm_your_weight_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/profile_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3.6"
android:padding="8dp"
android:text="@string/yourWeight"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/wm_update_container"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:paddingRight="4dp"
android:orientation="horizontal" >
<ImageView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:contentDescription="@string/profilePicture"
android:src="@drawable/profile_settings" />
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="7"
android:gravity="left|center_vertical"
android:paddingLeft="4dp"
android:text="Update Weight"
android:textColor="#c2c2c2"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/seperator1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:background="#3f4843" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="8dp" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/wm_current_weight_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="N/A"
android:textColor="#3f4843"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/wm_current_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="CURRENT"
android:textColor="#c2c2c2"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/wm_starting_weight_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="N/A"
android:textColor="#3f4843"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/wm_starting_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="STARTING"
android:textColor="#c2c2c2"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/wm_change_weight_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0.0lb"
android:textColor="#3f4843"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/wm_change_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="CHANGE"
android:textColor="#c2c2c2"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/wm_update_weight_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:visibility="gone"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/update_weight_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
android:padding="8dp"
android:text="Update Weight"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/update_weight_hide"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:paddingRight="8dp"
android:src="@drawable/minus" />
</LinearLayout>
<View
android:id="@+id/wm_seperator1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:background="#3f4843" />
<LinearLayout
android:id="@+id/update_weight_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal" >
<TextView
android:id="@+id/update_weight_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="7"
android:gravity="center_vertical|center_horizontal"
android:text="@string/weight"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:id="@+id/update_weight_edit_text"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:layout_weight="5"
android:background="@drawable/rounded_edittext"
android:gravity="center_horizontal|center_vertical"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:textColor="#3f4843"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/update_weight_spinner_container"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="7"
android:gravity="center" >
<Spinner
android:id="@+id/update_weight_spinner"
android:layout_width="100dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/save_new_weight_button_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp" >
<Button
android:id="@+id/save_new_weight_button"
android:layout_width="130dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:background="@drawable/button_bg"
android:gravity="center_horizontal|center_vertical"
android:text="@string/update"
android:textColor="#fff"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/wm_your_weight_history_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<TextView
android:id="@+id/wm_your_weight_history"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="History"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="@+id/wm_seperator2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:background="#3f4843" />
<WebView
android:id="@+id/webview_history"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/wm_your_entry_history_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/dropshadow"
android:orientation="vertical" >
<TextView
android:id="@+id/wm_your_entry_history"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Entries"
android:textColor="#3f4843"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:id="@+id/wm_seperator3"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_gravity="center_vertical"
android:background="#3f4843" />
<com.ukc.nutritioncentral.LinearListView
android:id="@+id/wm_entry_history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment