@@ -0,0 +1,107 @@
package itp341.sposto.lorraine.a5;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import java.text.NumberFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Created by LorraineSposto on 2/26/16.
*/
public class MoneyFragment extends Fragment {
private String TAG = MainActivity.class.getName();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.money_fragment, container, false);

final EditText inputText = (EditText) v.findViewById(R.id.moneyInputEditText);
final TextView resultValueText = (TextView) v.findViewById(R.id.resultTextValue);

final Button convertButton = (Button) v.findViewById(R.id.convertButton);
final Spinner fromSpinner = (Spinner) v.findViewById(R.id.fromSpinner);
final Spinner toSpinner = (Spinner) v.findViewById(R.id.toSpinner);

final Map<Pair<Integer, Integer>, Double> conversionsMap = Collections.unmodifiableMap(
new HashMap<Pair<Integer, Integer>, Double>() {
{
String[] currencies = getResources().getStringArray(R.array.currencies);
Integer usd = -1, yuan = -1, euro = -1;

for (int i=0; i < currencies.length; ++i) {
if (currencies[i].equals(getString(R.string.usd))) {
usd = i;
}
if (currencies[i].equals(getString(R.string.yuan))) {
yuan = i;
}
if (currencies[i].equals(getString(R.string.euro))) {
euro = i;
}
}
this.put(Pair.create(usd, usd), 1.0);
this.put(Pair.create(usd, yuan), 6.51);
this.put(Pair.create(usd, euro), 0.90);

this.put(Pair.create(yuan, usd), 0.15);
this.put(Pair.create(yuan, yuan), 1.0);
this.put(Pair.create(yuan, euro), 0.14);

this.put(Pair.create(euro, usd), 1.12);
this.put(Pair.create(euro, yuan), 7.27);
this.put(Pair.create(euro, euro), 1.0);
}

}
);

convertButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int fromId = fromSpinner.getSelectedItemPosition();
int toId = toSpinner.getSelectedItemPosition();

Double input = -1.0;
try {
input = Double.parseDouble(inputText.getText().toString());
} catch (NumberFormatException e) {
Log.d(TAG, "Invalid input for unit conversion");
}

if (fromId < 0 || toId < 0 || input < 0) {
Log.d(TAG, "Something not chosen, returning");
return;
}

double conversionFactor = conversionsMap.get(Pair.create(fromId, toId));
Double result = conversionFactor * input;

resultValueText.setText(result.toString());
}
});
return v;
}
}
@@ -0,0 +1,192 @@
package itp341.sposto.lorraine.a5;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;

import java.text.NumberFormat;

/**
* Created by LorraineSposto on 2/24/16.
*/
public class TipFragment extends Fragment {
private String TAG = MainActivity.class.getName();

private double billAmount, tipPercent, calculatedTip, calculatedTotal, splitWays, perPerson;

// UI Elements
private EditText mBillAmountEditText;
private SeekBar mTipPercentSeekBar;
private TextView mTipPercentText;
private TextView mCalculatedTipText;
private TextView mCalculatedTotalText;
private Spinner mSplitSpinner;
private TextView mPerPerson;
private LinearLayout mPerPersonLayout;

// Keys
private final String BILLKEY = "BILL";
private final String PERCENTKEY = "PERCENT";
private final String CALCTIPKEY = "CALCTIP";
private final String CALCTOTALKEY = "CALCTOTAL";
private final String SPLITWAYSKEY = "SPLITWAYS";
private final String PERPERSONKEY = "PERPERSON";


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (savedInstanceState != null) {
billAmount = savedInstanceState.getDouble(BILLKEY);
tipPercent = savedInstanceState.getDouble(PERCENTKEY);
calculatedTip = savedInstanceState.getDouble(CALCTIPKEY);
calculatedTotal = savedInstanceState.getDouble(CALCTOTALKEY);
splitWays = savedInstanceState.getDouble(SPLITWAYSKEY);
perPerson = savedInstanceState.getDouble(PERPERSONKEY);
} else {
billAmount = 0;
calculatedTotal = 0;
calculatedTip = 0;
splitWays = 0;
perPerson = 0;
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View v = inflater.inflate(R.layout.tip_fragment, container, false);
mBillAmountEditText = (EditText) v.findViewById(R.id.billAmountInput);
mTipPercentSeekBar = (SeekBar) v.findViewById(R.id.tipPercentSeekBar);
mTipPercentText = (TextView) v.findViewById(R.id.tipPercentText);
mCalculatedTipText = (TextView) v.findViewById(R.id.calculatedTipText);
mCalculatedTotalText = (TextView) v.findViewById(R.id.calculatedTotalText);
mSplitSpinner = (Spinner) v.findViewById(R.id.splitSpinner);
mPerPerson = (TextView) v.findViewById(R.id.perPersonText);
mPerPersonLayout = (LinearLayout) v.findViewById(R.id.perPersonLayout);

// and set Default Values
String tempBillAmt = NumberFormat.getCurrencyInstance().format(billAmount/100);
mBillAmountEditText.setText(tempBillAmt);
mBillAmountEditText.setSelection(tempBillAmt.length());
mCalculatedTipText.setText(NumberFormat.getCurrencyInstance().format(calculatedTip / 100));
mCalculatedTotalText.setText(NumberFormat.getCurrencyInstance().format(calculatedTotal / 100));
mPerPerson.setText(NumberFormat.getCurrencyInstance().format(perPerson/100));

tipPercent = mTipPercentSeekBar.getProgress();
mTipPercentText.setText(tipPercent + "%");

// Set spinner choices
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.split_array, R.layout.support_simple_spinner_dropdown_item);
mSplitSpinner.setAdapter(adapter);
splitWays = getResources().getIntArray(R.array.split_values_array)[mSplitSpinner.getSelectedItemPosition()];

// Set Bill Amount Listener
mBillAmountEditText.addTextChangedListener(new TextWatcher() {
private String current = "";

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { /* do nothing */ }

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!s.toString().equals(current)) {
mBillAmountEditText.removeTextChangedListener(this);
String cleanString = s.toString().replaceAll("[$,.]", "");
try {
double parsed = Double.parseDouble(cleanString);
billAmount = parsed;
String formatted = NumberFormat.getCurrencyInstance().format(parsed / 100);
current = formatted;
} catch (NumberFormatException n) {
Log.d(TAG, "Invalid characters entered into bill amount.");
}
mBillAmountEditText.setText(current);
mBillAmountEditText.setSelection(current.length());
mBillAmountEditText.addTextChangedListener(this);

// do tip calculation
calculateTipAndSetValues();
}
}

@Override
public void afterTextChanged(Editable s) { /* do nothing */ }
});

// Set Seek Bar listener
mTipPercentSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tipPercent = progress;
String text = progress + "%";
mTipPercentText.setText(text);

// do tip calculation
calculateTipAndSetValues();
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) { /* do nothing */ }

@Override
public void onStopTrackingTouch(SeekBar seekBar) { /* do nothing */ }
});

// Spinner listen
mSplitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
splitWays = getResources().getIntArray(R.array.split_values_array)[position];
Log.d(TAG, "Split ways: " + splitWays);
if (splitWays > 1) {
mPerPersonLayout.setVisibility(View.VISIBLE);
}
else {
mPerPersonLayout.setVisibility(View.GONE);
}
calculateTipAndSetValues();
}

@Override
public void onNothingSelected(AdapterView<?> parent) { /* do nothing */ }
});
return v;
}

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putDouble(BILLKEY, billAmount);
savedInstanceState.putDouble(PERCENTKEY, tipPercent);
savedInstanceState.putDouble(CALCTIPKEY, calculatedTip);
savedInstanceState.putDouble(CALCTOTALKEY, calculatedTotal);
savedInstanceState.putDouble(SPLITWAYSKEY, splitWays);
savedInstanceState.putDouble(PERPERSONKEY, perPerson);
super.onSaveInstanceState(savedInstanceState);
}

private void calculateTipAndSetValues() {
calculatedTip = billAmount * (tipPercent/100);
calculatedTotal = calculatedTip + billAmount;
perPerson = calculatedTotal/splitWays;
String formattedTipValue = NumberFormat.getCurrencyInstance().format(calculatedTip / 100);
String formattedTotalValue = NumberFormat.getCurrencyInstance().format(calculatedTotal / 100);
String formattedPerPersonValue = NumberFormat.getCurrencyInstance().format(perPerson / 100);
mCalculatedTipText.setText(formattedTipValue);
mCalculatedTotalText.setText(formattedTotalValue);
mPerPerson.setText(formattedPerPersonValue);
}
}
@@ -0,0 +1,135 @@
package itp341.sposto.lorraine.a5;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import java.text.NumberFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Created by LorraineSposto on 2/26/16.
*/
public class UnitFragment extends Fragment {
private String TAG = MainActivity.class.getName();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.unit_fragment, container, false);

final EditText inputText = (EditText) v.findViewById(R.id.unitInputEditText);
final TextView resultValueText = (TextView) v.findViewById(R.id.resultTextValue);

final Button convertButton = (Button) v.findViewById(R.id.convertButton);
final RadioGroup fromGroup = (RadioGroup) v.findViewById(R.id.fromRadioGroup);
final RadioGroup toGroup = (RadioGroup) v.findViewById(R.id.toRadioGroup);

final RadioButton fromCentimeterRadioButton = (RadioButton) v.findViewById(R.id.fromCentimeterRB);
final RadioButton fromMeterRadioButton = (RadioButton) v.findViewById(R.id.fromMetersRB);
final RadioButton fromFeetRadioButton = (RadioButton) v.findViewById(R.id.fromFeetRB);
final RadioButton fromMileRadioButton = (RadioButton) v.findViewById(R.id.fromMilesRB);
final RadioButton fromKmRadioButton = (RadioButton) v.findViewById(R.id.fromKilometersRB);

final RadioButton toCentimeterRadioButton = (RadioButton) v.findViewById(R.id.toCentimeterRB);
final RadioButton toMeterRadioButton = (RadioButton) v.findViewById(R.id.toMetersRB);
final RadioButton toFeetRadioButton = (RadioButton) v.findViewById(R.id.toFeetRB);
final RadioButton toMileRadioButton = (RadioButton) v.findViewById(R.id.toMilesRB);
final RadioButton toKmRadioButton = (RadioButton) v.findViewById(R.id.toKilometersRB);

final Map<Pair<Integer, Integer>, Double> conversionsMap = Collections.unmodifiableMap(
new HashMap<Pair<Integer, Integer>, Double> () {
{
Integer fromCentimeters = fromCentimeterRadioButton.getId();
Integer fromMeters = fromMeterRadioButton.getId();
Integer fromFeet = fromFeetRadioButton.getId();
Integer fromMiles = fromMileRadioButton.getId();
Integer fromKm = fromKmRadioButton.getId();

Integer toCentimeters = toCentimeterRadioButton.getId();
Integer toMeters = toMeterRadioButton.getId();
Integer toFeet = toFeetRadioButton.getId();
Integer toMiles = toMileRadioButton.getId();
Integer toKm = toKmRadioButton.getId();

this.put(Pair.create(fromCentimeters, toCentimeters), 1.0);
this.put(Pair.create(fromCentimeters, toMeters), .01);
this.put(Pair.create(fromCentimeters, toFeet), 0.0328);
this.put(Pair.create(fromCentimeters, toMiles), 0.00000621);
this.put(Pair.create(fromCentimeters, toKm), 0.00001);

this.put(Pair.create(fromMeters, toMeters), 1.0);
this.put(Pair.create(fromMeters, toCentimeters), 100.0);
this.put(Pair.create(fromMeters, toFeet), 3.2808);
this.put(Pair.create(fromMeters, toMiles), 0.000621);
this.put(Pair.create(fromMeters, toKm), .01);

this.put(Pair.create(fromFeet, toFeet), 1.0);
this.put(Pair.create(fromFeet, toCentimeters), 30.48);
this.put(Pair.create(fromFeet, toMeters), 0.3048);
this.put(Pair.create(fromFeet, toMiles), 0.000189);
this.put(Pair.create(fromFeet, toKm), 0.000304);

this.put(Pair.create(fromMiles, toMiles), 1.0);
this.put(Pair.create(fromMiles, toCentimeters), 160934.0);
this.put(Pair.create(fromMiles, toMeters), 1609.34);
this.put(Pair.create(fromMiles, toFeet), 5280.0);
this.put(Pair.create(fromMiles, toKm), 1.60934);

this.put(Pair.create(fromKm, toKm), 1.0);
this.put(Pair.create(fromKm, toCentimeters), 100000.0);
this.put(Pair.create(fromKm, toMeters), 1000.0);
this.put(Pair.create(fromKm, toFeet), 3280.84);
this.put(Pair.create(fromKm, toMiles), 0.62137);
}

}
);

convertButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Integer fromId = fromGroup.getCheckedRadioButtonId();
Integer toId = toGroup.getCheckedRadioButtonId();

Double input = -1.0;
try {
input = Double.parseDouble(inputText.getText().toString());
} catch (NumberFormatException e) {
Log.d(TAG, "Invalid input for unit conversion");
}

if (fromId < 0 || toId < 0 || input < 0) {
Log.d(TAG, "Something not chosen, returning");
return;
}

Double conversionFactor = conversionsMap.get(Pair.create(fromId, toId));

Double result = input * conversionFactor;
resultValueText.setText(result.toString());
}
});

return v;
}
}
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="ipt341.sposto.lorraine.a4.MainActivity">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/chooseTipButton"
android:text="@string/button_tip"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/chooseUnitButton"
android:text="@string/button_units"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/chooseMoneyButton"
android:text="@string/button_money"
android:layout_weight="1" />
</LinearLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fragment_container">

</FrameLayout>

</LinearLayout>
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/unitInputEditText"/>

<fragment
android:name="itp341.sposto.lorraine.a5.UnitFragment"
android:id="@+id/converterFragmentContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/convertButton"
android:text="@string/text_convert"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextLabel"
android:text="@string/text_result"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextValue"
android:text="Placeholder"/>

</LinearLayout>

</LinearLayout>
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- VAL INPUT -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:id="@+id/moneyInputEditText"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_from"
android:layout_margin="@dimen/element_horizontal_margin"/>
<!-- FROM Spinner -->
<Spinner
android:id="@+id/fromSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/currencies"
android:layout_margin="@dimen/element_horizontal_margin">
</Spinner>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_to"
android:layout_margin="@dimen/element_horizontal_margin"/>
<!-- TO Spinner -->
<Spinner
android:id="@+id/toSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/currencies"
android:layout_margin="@dimen/element_horizontal_margin">

</Spinner>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/convertButton"
android:text="@string/text_convert"
android:layout_margin="@dimen/element_horizontal_margin"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextLabel"
android:text="@string/text_result"
android:layout_marginRight="@dimen/element_horizontal_margin"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextValue"
android:text="0"/>

</LinearLayout>
</LinearLayout>
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- BILL INPUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/billAmountText"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/billAmountInput"/>
</LinearLayout>

<!-- TIP PERCENT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/percentText"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tipPercentText"
android:text="0"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="30"
android:id="@+id/tipPercentSeekBar"
android:progress="15"/>
</LinearLayout>

<!-- CALCULATED TIP -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/tipText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/calculatedTipText"/>
</LinearLayout>

<!-- TOTAL -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/totalText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/calculatedTotalText"/>
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/grey"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"/>

<!-- SPLIT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/splitBillText"/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/split_array"
android:id="@+id/splitSpinner"/>
</LinearLayout>

<!-- IF SPLIT TRUE -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/perPersonLayout"
android:visibility="gone">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minEms="@integer/text_min_ems"
android:text="@string/perPersonText"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/perPersonText"/>
</LinearLayout>

</LinearLayout>
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- VAL INPUT -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:id="@+id/unitInputEditText"/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_from"
android:layout_marginRight="@dimen/element_horizontal_margin"/>
<!-- FROM RadioButton -->
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fromRadioGroup"
android:layout_marginRight="@dimen/element_horizontal_margin">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fromCentimeterRB"
android:text="@string/text_centimeters">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fromMetersRB"
android:text="@string/text_meters">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fromFeetRB"
android:text="@string/text_feet">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fromMilesRB"
android:text="@string/text_miles">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fromKilometersRB"
android:text="@string/text_kilometers">
</RadioButton>
</RadioGroup>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_to"
android:layout_marginLeft="@dimen/element_horizontal_margin"
android:layout_marginRight="@dimen/element_horizontal_margin"/>
<!-- TO RadioButton -->
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toRadioGroup"
android:layout_marginRight="@dimen/element_horizontal_margin">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toCentimeterRB"
android:text="@string/text_centimeters">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toMetersRB"
android:text="@string/text_meters">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toFeetRB"
android:text="@string/text_feet">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toMilesRB"
android:text="@string/text_miles">
</RadioButton>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toKilometersRB"
android:text="@string/text_kilometers">
</RadioButton>
</RadioGroup>

</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/convertButton"
android:text="@string/text_convert"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextLabel"
android:text="@string/text_result"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resultTextValue"
android:text="0"/>

</LinearLayout>

</LinearLayout>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="split_array">
<item>No</item>
<item>2 ways</item>
<item>3 ways</item>
<item>4 ways</item>
</string-array>
<integer-array name="split_values_array">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</integer-array>
<string-array name="currencies">
<item>@string/usd</item>
<item>@string/yuan</item>
<item>@string/euro</item>
</string-array>
</resources>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="grey">#d3d3d3</color>
</resources>
@@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="element_horizontal_margin">8dp</dimen>
<integer name="text_min_ems">8</integer>
</resources>
@@ -0,0 +1,28 @@
<resources>
<string name="app_name">A5</string>
<string name="billAmountText">Bill Amount</string>
<string name="percentText">Percent</string>
<string name="tipText">Tip</string>
<string name="totalText">Total</string>
<string name="splitBillText">Split Bill?</string>
<string name="perPersonText">Per Person</string>


<string name="text_centimeters">centimeters</string>
<string name="text_meters">meters</string>
<string name="text_feet">feet</string>
<string name="text_miles">miles</string>
<string name="text_kilometers">kilometers</string>
<string name="text_from">From:</string>
<string name="text_to">To:</string>
<string name="text_convert">CONVERT</string>
<string name="text_result">Result:</string>
<string name="button_tip">TIP CALC</string>
<string name="button_units">UNIT CONV</string>
<string name="button_money">MONEY EXCH</string>

<string name="usd">USD</string>
<string name="yuan">Yuan</string>
<string name="euro">Euro</string>

</resources>
@@ -0,0 +1,11 @@
<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>
</style>

</resources>
@@ -0,0 +1,15 @@
package itp341.sposto.lorraine.a5;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
@@ -0,0 +1,23 @@
// 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()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
@@ -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
Binary file not shown.
@@ -0,0 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
@@ -0,0 +1,160 @@
#!/usr/bin/env bash

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
echo "$*"
}

die ( ) {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@@ -0,0 +1 @@
include ':app'