From 7623c455ecf9415fcdcc8e55ee7990d677e93b58 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Tue, 8 Oct 2019 22:52:18 -0400 Subject: [PATCH] Commit of code from 2015 --- .gitignore | 112 +-- README.md | 132 +-- app/.gitignore | 2 +- app/build.gradle | 50 +- app/proguard-rules.pro | 34 +- .../cis298assignment2/ApplicationTest.java | 24 +- app/src/main/AndroidManifest.xml | 42 +- .../cis298/cis298assignment2/Conversion.java | 308 +++--- .../TemperatureConverter.java | 916 +++++++++--------- .../activity_temperature_converter.xml | 324 +++---- .../layout/activity_temperature_converter.xml | 310 +++--- .../res/menu/menu_temperature_converter.xml | 12 +- app/src/main/res/values-w820dp/dimens.xml | 12 +- app/src/main/res/values/dimens.xml | 10 +- app/src/main/res/values/strings.xml | 42 +- app/src/main/res/values/styles.xml | 16 +- build.gradle | 38 +- gradle.properties | 34 +- gradle/wrapper/gradle-wrapper.properties | 12 +- gradlew | 328 +++---- gradlew.bat | 180 ++-- settings.gradle | 2 +- 22 files changed, 1470 insertions(+), 1470 deletions(-) diff --git a/.gitignore b/.gitignore index b772014..8329c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,56 +1,56 @@ -#built application files -*.apk -*.ap_ - -#files for the dex VM -*.dex - -#Java class files -*.class - -#generated files -bin/ -gen/ -out/ -build/ -captures/ - -#Local configuration files (sdk path, etc) -local.properties - -#Window thumbnail db -Thumbs.db - -#OSX files -.DS_Store - -#Eclipse project files -.classpath -.project - -#Android Studio -*.iml -.idea - -#Android Studio Navigation editor temp files -.navigation/ - -#old-style IDEA project files -*.ipr -*.iws - -#Local IDEA workspace -.idea/workspace.xml - -#Local IDEA Libraries -.idea/libraries - -#Gradel cache -.gradle - -#Sandbox stuff -_sandbox - -#NDK -obj/ - +#built application files +*.apk +*.ap_ + +#files for the dex VM +*.dex + +#Java class files +*.class + +#generated files +bin/ +gen/ +out/ +build/ +captures/ + +#Local configuration files (sdk path, etc) +local.properties + +#Window thumbnail db +Thumbs.db + +#OSX files +.DS_Store + +#Eclipse project files +.classpath +.project + +#Android Studio +*.iml +.idea + +#Android Studio Navigation editor temp files +.navigation/ + +#old-style IDEA project files +*.ipr +*.iws + +#Local IDEA workspace +.idea/workspace.xml + +#Local IDEA Libraries +.idea/libraries + +#Gradel cache +.gradle + +#Sandbox stuff +_sandbox + +#NDK +obj/ + diff --git a/README.md b/README.md index 3d33aae..5aebbc9 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,66 @@ -# Assignment 2 - Temperature Converter - -## Author - -Brandon Rodriguez - -## Description - -A simple temperature conversion phone app. - -User can input a temperature, including decimals and negatives. This input is then converted to/from any of the following: Celsius, Fahrenheit, Kelvin, or Rankine. - -For each conversion, the user will see both the input temperature and the converted temperature, as well as the standard equation generally used for such a conversion. - -Data is saved on screen rotate and persistant until end of application. - -## Project Requirements - -Create a temperature converter application. -The application should look like the screen shots I have provided. -The application should do the calculation and display the formula that was used to do the calculation. -The calculation of the conversion should take place in a seperate class -The application should handle errors gracefully. -The application should have a different layout for landscape form that looks like the one pictured here. -The application must retain it's information on the screen when rotated to lanscape. - -Solution Requirements: - -* Seperate class for calculation -* Handle errors gracefully -* Seperate Layout for landscape -* Retain information across rotation - - - - -### Notes - -The book does not cover how to do work with Radio Buttons. I will talk about it as needed in class. If you are stuck or have questions about it, ask. - -## Outside Resources Used - -http://stackoverflow.com/questions/2344524/java-equivalent-to-region-in-c-sharp -* Learned how to use C#'s "#region" equivalent in java. - -http://stackoverflow.com/questions/6608673/i-want-to-create-documentation-in-c-something-similar-to-javadoc -http://www.oracle.com/technetwork/articles/java/index-137868.html -* Learned about the Java equivalent of /// from C#. -* Is called "JavaDoc." - -http://javatechig.com/android/android-radio-button-example -* Determined the equivalent of OnClickListener for radio buttons. - -http://stackoverflow.com/questions/7543835/configure-android-edittext-to-allow-decimals-and-negatives -* Accepting both negative numbers and decimals in user text input. - -https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature -* Found all the proper temperature convertions. - -http://floating-point-gui.de/languages/java/ -http://stackoverflow.com/questions/4885254/string-format-to-format-double-in-java -* Rounding numbers in java. - -## Known Problems, Issues, And/Or Errors in the Program - -None noted thus far. +# Assignment 2 - Temperature Converter + +## Author + +Brandon Rodriguez + +## Description + +A simple temperature conversion phone app. + +User can input a temperature, including decimals and negatives. This input is then converted to/from any of the following: Celsius, Fahrenheit, Kelvin, or Rankine. + +For each conversion, the user will see both the input temperature and the converted temperature, as well as the standard equation generally used for such a conversion. + +Data is saved on screen rotate and persistant until end of application. + +## Project Requirements + +Create a temperature converter application. +The application should look like the screen shots I have provided. +The application should do the calculation and display the formula that was used to do the calculation. +The calculation of the conversion should take place in a seperate class +The application should handle errors gracefully. +The application should have a different layout for landscape form that looks like the one pictured here. +The application must retain it's information on the screen when rotated to lanscape. + +Solution Requirements: + +* Seperate class for calculation +* Handle errors gracefully +* Seperate Layout for landscape +* Retain information across rotation + + + + +### Notes + +The book does not cover how to do work with Radio Buttons. I will talk about it as needed in class. If you are stuck or have questions about it, ask. + +## Outside Resources Used + +http://stackoverflow.com/questions/2344524/java-equivalent-to-region-in-c-sharp +* Learned how to use C#'s "#region" equivalent in java. + +http://stackoverflow.com/questions/6608673/i-want-to-create-documentation-in-c-something-similar-to-javadoc +http://www.oracle.com/technetwork/articles/java/index-137868.html +* Learned about the Java equivalent of /// from C#. +* Is called "JavaDoc." + +http://javatechig.com/android/android-radio-button-example +* Determined the equivalent of OnClickListener for radio buttons. + +http://stackoverflow.com/questions/7543835/configure-android-edittext-to-allow-decimals-and-negatives +* Accepting both negative numbers and decimals in user text input. + +https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature +* Found all the proper temperature convertions. + +http://floating-point-gui.de/languages/java/ +http://stackoverflow.com/questions/4885254/string-format-to-format-double-in-java +* Rounding numbers in java. + +## Known Problems, Issues, And/Or Errors in the Program + +None noted thus far. diff --git a/app/.gitignore b/app/.gitignore index 796b96d..3543521 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1 @@ -/build +/build diff --git a/app/build.gradle b/app/build.gradle index 3741b9a..1e1a6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,25 +1,25 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.0" - - defaultConfig { - applicationId "edu.kvcc.cis298.cis298assignment2" - minSdkVersion 16 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - 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.0.0' -} +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.0" + + defaultConfig { + applicationId "edu.kvcc.cis298.cis298assignment2" + minSdkVersion 16 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + 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.0.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 38fca8a..4d611f4 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,17 +1,17 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in C:\Users\David\AppData\Local\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 *; -#} +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\David\AppData\Local\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 *; +#} diff --git a/app/src/androidTest/java/edu/kvcc/cis298/cis298assignment2/ApplicationTest.java b/app/src/androidTest/java/edu/kvcc/cis298/cis298assignment2/ApplicationTest.java index f93687b..1e55b72 100644 --- a/app/src/androidTest/java/edu/kvcc/cis298/cis298assignment2/ApplicationTest.java +++ b/app/src/androidTest/java/edu/kvcc/cis298/cis298assignment2/ApplicationTest.java @@ -1,13 +1,13 @@ -package edu.kvcc.cis298.cis298assignment2; - -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); - } +package edu.kvcc.cis298.cis298assignment2; + +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); + } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a52cb92..2115fc4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,21 +1,21 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="edu.kvcc.cis298.cis298assignment2" > - - <application - android:allowBackup="true" - android:icon="@mipmap/ic_launcher" - android:label="@string/app_name" - android:theme="@style/AppTheme" > - <activity - android:name=".TemperatureConverter" - android:label="@string/app_name" > - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="edu.kvcc.cis298.cis298assignment2" > + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".TemperatureConverter" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/app/src/main/java/edu/kvcc/cis298/cis298assignment2/Conversion.java b/app/src/main/java/edu/kvcc/cis298/cis298assignment2/Conversion.java index 0ac71fd..8134877 100644 --- a/app/src/main/java/edu/kvcc/cis298/cis298assignment2/Conversion.java +++ b/app/src/main/java/edu/kvcc/cis298/cis298assignment2/Conversion.java @@ -1,154 +1,154 @@ -package edu.kvcc.cis298.cis298assignment2; - -import android.widget.RadioButton; -import android.widget.RadioGroup; - -/** - * Created by brodriguez8774 on 10/1/2015. - */ -public class Conversion { - - //region Variables - - private double initialValueDouble; // Temperature user wants to convert. - private double convertedValueDouble; // Temperature after conversion. - private double baseDouble; // Temperature at default value, arbitrarily specified as - // Celsius in this program. Used to help modularize program. - private int initialGroupInt; // Holds temperature type of initial value. - private int convertGroupInt; // Holds temperature type of converted value. - - //endregion - - - - //region Constructor - - public Conversion(double initialValue, int initialGroup, int convertGroup) - { - setInitialValueDouble(initialValue); - setInitialGroupInt(initialGroup); - setConvertGroupInt(convertGroup); - - CalculateTemperature(); - } - - //endregion - - - - //region Properties - - public double getInitialValueDouble() { - return initialValueDouble; - } - - public void setInitialValueDouble(double initialValueDouble) { - this.initialValueDouble = initialValueDouble; - } - - public double getConvertedValueDouble() { - return convertedValueDouble; - } - - public int getInitialGroupInt() { - return initialGroupInt; - } - - public void setInitialGroupInt(int initialGroupInt) { - this.initialGroupInt = initialGroupInt; - } - - public int getConvertGroupInt() { - return convertGroupInt; - } - - public void setConvertGroupInt(int convertGroupInt) { - this.convertGroupInt = convertGroupInt; - } - - //endregion - - - - //region Private Methods - - /** - * Converts user's input to a "base" which in this case is Celsius. - * Then converts the base to whatever the desired end-result is. - * <p> - * Doing it this way helps ensure that all conversions are correct. - * IE: if single equation involving celsius is correct, then all celsius equations should be correct. - * Same goes for the other three conversion types. - */ - private void CalculateTemperature() - { - CalculateBase(); - CalculateConvertTo(); - } - - /** - * Converts user's int to base int. - */ - private void CalculateBase() { - // If initial is Celsius, set base equal to user input. - if (initialGroupInt == 1) { - baseDouble = initialValueDouble; - } - else { - // If initial is Fahrenheit, convert to Celsius then set as base. - if (initialGroupInt == 2) { - baseDouble = ((initialValueDouble - 32) * 5 / 9); - } - else { - // If initial is Kelvin, convert to Celsius then set as base. - if (initialGroupInt == 3) { - baseDouble = (initialValueDouble - 273.15); - } - // If initial is Rankin, convert to Celsius then set as base. - else { - baseDouble = ((initialValueDouble - 491.67) * 5 / 9); - } - } - } - - } - - /** - * Converts base int to desired convert to int. - */ - private void CalculateConvertTo() - { - // If desired is Celsius, set convert equal to base. - if (convertGroupInt == 1) { - convertedValueDouble = baseDouble; - } - else { - // If desired is Fahrenheit, convert from base. - if (convertGroupInt == 2) { - convertedValueDouble = (baseDouble * 9 / 5 + 32); - } - else { - // If desired is Kelvin, convert from base. - if (convertGroupInt == 3) { - convertedValueDouble = (baseDouble + 273.15); - } - // If desired is Rankin, convert from base. - else { - convertedValueDouble = ((baseDouble + 273.15) * 9 / 5); - } - } - } - - } - - //endregion - - - - //region Public Methods - - - - //endregion - -} +package edu.kvcc.cis298.cis298assignment2; + +import android.widget.RadioButton; +import android.widget.RadioGroup; + +/** + * Created by brodriguez8774 on 10/1/2015. + */ +public class Conversion { + + //region Variables + + private double initialValueDouble; // Temperature user wants to convert. + private double convertedValueDouble; // Temperature after conversion. + private double baseDouble; // Temperature at default value, arbitrarily specified as + // Celsius in this program. Used to help modularize program. + private int initialGroupInt; // Holds temperature type of initial value. + private int convertGroupInt; // Holds temperature type of converted value. + + //endregion + + + + //region Constructor + + public Conversion(double initialValue, int initialGroup, int convertGroup) + { + setInitialValueDouble(initialValue); + setInitialGroupInt(initialGroup); + setConvertGroupInt(convertGroup); + + CalculateTemperature(); + } + + //endregion + + + + //region Properties + + public double getInitialValueDouble() { + return initialValueDouble; + } + + public void setInitialValueDouble(double initialValueDouble) { + this.initialValueDouble = initialValueDouble; + } + + public double getConvertedValueDouble() { + return convertedValueDouble; + } + + public int getInitialGroupInt() { + return initialGroupInt; + } + + public void setInitialGroupInt(int initialGroupInt) { + this.initialGroupInt = initialGroupInt; + } + + public int getConvertGroupInt() { + return convertGroupInt; + } + + public void setConvertGroupInt(int convertGroupInt) { + this.convertGroupInt = convertGroupInt; + } + + //endregion + + + + //region Private Methods + + /** + * Converts user's input to a "base" which in this case is Celsius. + * Then converts the base to whatever the desired end-result is. + * <p> + * Doing it this way helps ensure that all conversions are correct. + * IE: if single equation involving celsius is correct, then all celsius equations should be correct. + * Same goes for the other three conversion types. + */ + private void CalculateTemperature() + { + CalculateBase(); + CalculateConvertTo(); + } + + /** + * Converts user's int to base int. + */ + private void CalculateBase() { + // If initial is Celsius, set base equal to user input. + if (initialGroupInt == 1) { + baseDouble = initialValueDouble; + } + else { + // If initial is Fahrenheit, convert to Celsius then set as base. + if (initialGroupInt == 2) { + baseDouble = ((initialValueDouble - 32) * 5 / 9); + } + else { + // If initial is Kelvin, convert to Celsius then set as base. + if (initialGroupInt == 3) { + baseDouble = (initialValueDouble - 273.15); + } + // If initial is Rankin, convert to Celsius then set as base. + else { + baseDouble = ((initialValueDouble - 491.67) * 5 / 9); + } + } + } + + } + + /** + * Converts base int to desired convert to int. + */ + private void CalculateConvertTo() + { + // If desired is Celsius, set convert equal to base. + if (convertGroupInt == 1) { + convertedValueDouble = baseDouble; + } + else { + // If desired is Fahrenheit, convert from base. + if (convertGroupInt == 2) { + convertedValueDouble = (baseDouble * 9 / 5 + 32); + } + else { + // If desired is Kelvin, convert from base. + if (convertGroupInt == 3) { + convertedValueDouble = (baseDouble + 273.15); + } + // If desired is Rankin, convert from base. + else { + convertedValueDouble = ((baseDouble + 273.15) * 9 / 5); + } + } + } + + } + + //endregion + + + + //region Public Methods + + + + //endregion + +} diff --git a/app/src/main/java/edu/kvcc/cis298/cis298assignment2/TemperatureConverter.java b/app/src/main/java/edu/kvcc/cis298/cis298assignment2/TemperatureConverter.java index b4386cf..dc986a2 100644 --- a/app/src/main/java/edu/kvcc/cis298/cis298assignment2/TemperatureConverter.java +++ b/app/src/main/java/edu/kvcc/cis298/cis298assignment2/TemperatureConverter.java @@ -1,458 +1,458 @@ -package edu.kvcc.cis298.cis298assignment2; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.RadioButton; -import android.widget.RadioGroup; -import android.widget.TextView; -import android.widget.Toast; - -public class TemperatureConverter extends AppCompatActivity { - - //region Variables - - private RadioGroup mInitialGroup; - private RadioButton mInitial1Radio; - private RadioButton mInitial2Radio; - private RadioButton mInitial3Radio; - private RadioButton mInitial4Radio; - - private RadioGroup mConvertGroup; - private RadioButton mConvert1Radio; - private RadioButton mConvert2Radio; - private RadioButton mConvert3Radio; - private RadioButton mConvert4Radio; - - private Button mConvertButton; - - private TextView mConversionTextView; - private TextView mEquationTextView; - - private EditText mUserInputEditText; - - // Pointer for strings.xml. - private int messageResId; - private int mSelectedInitialId; - private int mSelectedConvertId; - - // Values to check if user input is present. - private boolean mInitialGroupChecked; - private boolean mConvertGroupChecked; - private boolean mConvertButtonIsClicked; - - // Java's version of static constants. - private static final String TAG = "TemperatureConverter"; - private static final String KEY_INDEX = "index"; - - private boolean[] mCurrentStatus = new boolean[3]; - - Conversion conversion; - - //endregion - - - - //region Standard Methods - - /** - * Gets the values of user's input and converts. - * <p> - * Only use if both groups have been checked and user has input a number to convert. - */ - private void Convert() - { - // Sets user's input to a variable. - String userInputString = mUserInputEditText.getText().toString().trim(); - Log.d(TAG, "Parsed: " + userInputString); - double userDouble = Double.parseDouble(userInputString); - Log.d(TAG, "Parsed: " + userDouble); - - // Query to determine which radio buttons have been selected. Stores value as int. - mSelectedInitialId = mInitialGroup.getCheckedRadioButtonId(); - mSelectedConvertId = mConvertGroup.getCheckedRadioButtonId(); - - int initialGroupSelection = 0; - int convertGroupSelection = 0; - - if (mSelectedInitialId == mInitial1Radio.getId()) { - initialGroupSelection = 1; - } - else { - if (mSelectedInitialId == mInitial2Radio.getId()) { - initialGroupSelection = 2; - } - else { - if (mSelectedInitialId == mInitial3Radio.getId()) { - initialGroupSelection = 3; - } - else { - if (mSelectedInitialId == mInitial4Radio.getId()) { - initialGroupSelection = 4; - } - } - } - } - - if (mSelectedConvertId == mConvert1Radio.getId()) { - convertGroupSelection = 1; - } - else { - if (mSelectedConvertId == mConvert2Radio.getId()) { - convertGroupSelection = 2; - } - else { - if (mSelectedConvertId == mConvert3Radio.getId()) { - convertGroupSelection = 3; - } - else { - if (mSelectedConvertId == mConvert4Radio.getId()) { - convertGroupSelection = 4; - } - } - } - } - - conversion = new Conversion(userDouble, initialGroupSelection, convertGroupSelection); - - DisplayConversion(); - } - - /** - * Creates strings for UI display and sends them over to appropriate xml properties. - */ - private void DisplayConversion() - { - String initialTemp = String.format("%.2f", conversion.getInitialValueDouble()); - String convertTemp = String.format("%.2f", conversion.getConvertedValueDouble()); - - - String conversion1String; - String conversion2String; - String equation1String; - String equation2String; - - // Determines what types of strings should display. - // Combinations for FromCelsius selected. - if (mSelectedInitialId == mInitial1Radio.getId()) { - if (mSelectedConvertId == mConvert1Radio.getId()) { - conversion1String = initialTemp + " °C"; - conversion2String = convertTemp + " °C"; - equation1String = "[°C]"; - equation2String = "[°C]"; - } - else { - if (mSelectedConvertId == mConvert2Radio.getId()) { - conversion1String = initialTemp + " °C"; - conversion2String = convertTemp + " °F"; - equation1String = "[°F]"; - equation2String = "([°C] x 9/5) + 32"; - } - else { - if (mSelectedConvertId == mConvert3Radio.getId()) { - conversion1String = initialTemp + " °C"; - conversion2String = convertTemp + " °K"; - equation1String = "[°K]"; - equation2String = "[°C] + 273.15"; - } - else { - conversion1String = initialTemp + " °C"; - conversion2String = convertTemp + " °R"; - equation1String = "[°R]"; - equation2String = "([°C] + 273.15) * 9 / 5"; - } - } - } - } - else { - // Combinations for FromFahrenheit selected. - if (mSelectedInitialId == mInitial2Radio.getId()) { - if (mSelectedConvertId == mConvert1Radio.getId()) { - conversion1String = initialTemp + " °F"; - conversion2String = convertTemp + " °C"; - equation1String = "[°C]"; - equation2String = "([°F] - 32) * 5 / 9"; - } - else { - if (mSelectedConvertId == mConvert2Radio.getId()) { - conversion1String = initialTemp + " °F"; - conversion2String = convertTemp + " °F"; - equation1String = "[°F]"; - equation2String = "[°F]"; - } - else { - if (mSelectedConvertId == mConvert3Radio.getId()) { - conversion1String = initialTemp + " °F"; - conversion2String = convertTemp + " °K"; - equation1String = "[°K]"; - equation2String = "([°F] + 459.67) * 5 / 9"; - } - else { - conversion1String = initialTemp + " °F"; - conversion2String = convertTemp + " °R"; - equation1String = "[°R]"; - equation2String = "[°F] + 459.67"; - } - } - } - } - else { - // Combinations for FromKelvin selected. - if (mSelectedInitialId == mInitial3Radio.getId()) { - if (mSelectedConvertId == mConvert1Radio.getId()) { - conversion1String = initialTemp + " °K"; - conversion2String = convertTemp + " °C"; - equation1String = "[°C]"; - equation2String = "[°K] - 273.15"; - } - else { - if (mSelectedConvertId == mConvert2Radio.getId()) { - conversion1String = initialTemp + " °K"; - conversion2String = convertTemp + " °F"; - equation1String = "[°F]"; - equation2String = "([°K] * 9 / 5) - 459.67"; - } - else { - if (mSelectedConvertId == mConvert3Radio.getId()) { - conversion1String = initialTemp + " °K"; - conversion2String = convertTemp + " °K"; - equation1String = "[°K]"; - equation2String = "[°K]"; - } - else { - conversion1String = initialTemp + " °K"; - conversion2String = convertTemp + " °R"; - equation1String = "[°R]"; - equation2String = "[°K] * 9 / 5"; - } - } - } - } - else { - // Combinations for FromRankine selected - if (mSelectedConvertId == mConvert1Radio.getId()) { - conversion1String = initialTemp + " °R"; - conversion2String = convertTemp + " °C"; - equation1String = "[°C]"; - equation2String = "([°R] - 491.67) * 5 / 9"; - } - else { - if (mSelectedConvertId == mConvert2Radio.getId()) { - conversion1String = initialTemp + " °R"; - conversion2String = convertTemp + " °F"; - equation1String = "[°F]"; - equation2String = "[°R] - 459.67"; - } - else { - if (mSelectedConvertId == mConvert3Radio.getId()) { - conversion1String = initialTemp + " °R"; - conversion2String = convertTemp + " °K"; - equation1String = "[°K]"; - equation2String = "[°R] * 5 / 9"; - } - else { - conversion1String = initialTemp + " °R"; - conversion2String = convertTemp + " °R"; - equation1String = "[°R]"; - equation2String = "[°R]"; - } - } - } - } - } - } - - // Combines above strings into one string, then sends to appropriate single string to textview. - String fullConversionString = conversion1String + " = " + conversion2String; - String fullEquationString = equation1String + " = " + equation2String; - - mConversionTextView.setText(fullConversionString); - mEquationTextView.setText(fullEquationString); - } - - //endregion - - - - //region Override Methods - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Log.d(TAG, "onCreate() called"); - setContentView(R.layout.activity_temperature_converter); - - // Section which assigns (casts) variables to equivalent entity in xml file. - - // Assigns (casts) variable mConvertButton to an actual button in the xml file. - mConvertButton = (Button) findViewById(R.id.convert_button); - - // Assigns (casts) 'initial' radio group to equivalent entities in the xml file. - mInitialGroup = (RadioGroup) findViewById(R.id.initial_value_group); - mInitial1Radio = (RadioButton) findViewById(R.id.initial_1_radio); - mInitial2Radio = (RadioButton) findViewById(R.id.initial_2_radio); - mInitial3Radio = (RadioButton) findViewById(R.id.initial_3_radio); - mInitial4Radio = (RadioButton) findViewById(R.id.initial_4_radio); - // Assigns (casts) 'convert to' radio group to equivalent entities in the xml file. - mConvertGroup = (RadioGroup) findViewById(R.id.convert_to_group); - mConvert1Radio = (RadioButton) findViewById(R.id.convert_1_radio); - mConvert2Radio = (RadioButton) findViewById(R.id.convert_2_radio); - mConvert3Radio = (RadioButton) findViewById(R.id.convert_3_radio); - mConvert4Radio = (RadioButton) findViewById(R.id.convert_4_radio); - - // Assigns (casts) text views to equivalent entities in the xml file. - mConversionTextView = (TextView) findViewById(R.id.converstion_text_view); - mEquationTextView = (TextView) findViewById(R.id.equation_text_view); - - // Assigns (casts) edit text to equivalent entities in the xml file. - mUserInputEditText = (EditText) findViewById(R.id.user_input_edit_text); - - // Gets saved state for booleans. - if (savedInstanceState != null) { - - // Loads saved value of initial variables. - boolean[] savedStateBool = savedInstanceState.getBooleanArray(KEY_INDEX); - - mConvertButtonIsClicked = savedStateBool[0]; - mInitialGroupChecked = savedStateBool[1]; - mConvertGroupChecked = savedStateBool[2]; - - // Checks to see if user has input a number. - if (mUserInputEditText.length() > 0) { - // Checks to see if both groups have been checked, and if convert button has been - // clicked at least once. - if (mInitialGroupChecked && mConvertGroupChecked && mConvertButtonIsClicked) { - Convert(); - } - } - } - else { - // Initial variables to store user inputs. - mConvertButtonIsClicked = false; - mInitialGroupChecked = false; - mConvertGroupChecked = false; - } - - // Section which sets onClickListeners (watches for user action). - // OnClickListener for Initial Radio Button Group. - mInitialGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(RadioGroup group, int checkedID) { - - // Debugging to figure out what values are actually given for checked buttons. - int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); - int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); - Log.d(TAG, "Initial Checked ID: " + selectedInitialId); - Log.d(TAG, "Convert Checked ID: " + selectedConvertId); - - // Checks to see if both groups have been checked, if convert button has been - // clicked at least once, and user has input a number. - if (mInitialGroupChecked && mConvertGroupChecked && mUserInputEditText.length() > 0) { - Convert(); - } else { - mInitialGroupChecked = true; - } - } - }); - - // OnCheckChangeListener for Convert To Radio Button Group. - mConvertGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(RadioGroup group, int checkedID) { - - // Debugging to figure out what values are actually given for checked buttons. - int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); - int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); - Log.d(TAG, "Initial Checked ID: " + selectedInitialId); - Log.d(TAG, "Convert Checked ID: " + selectedConvertId); - - - // Checks to see if both groups have been checked, if convert button has been - // clicked at least once, and user has input a number. - if (mInitialGroupChecked && mConvertGroupChecked && mConvertButtonIsClicked - && mUserInputEditText.length() > 0) { - Convert(); - } else { - mConvertGroupChecked = true; - } - } - }); - - // OnClickListener for Convert Button. - mConvertButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - // Debugging to figure out what values are actually given for checked buttons. - int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); - int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); - Log.d(TAG, "Initial Checked ID: " + selectedInitialId); - Log.d(TAG, "Convert Checked ID: " + selectedConvertId); - - // Checks to see if user has input a number. - if (mUserInputEditText.length() > 0) { - - // Checks to see if both groups have been checked. - if (mInitialGroupChecked && mConvertGroupChecked) { - mConvertButtonIsClicked = true; - Convert(); - } else { - messageResId = R.string.convert_error_2_toast; - Toast.makeText(TemperatureConverter.this, messageResId, Toast.LENGTH_SHORT).show(); - } - } else { - messageResId = R.string.convert_error_1_toast; - Toast.makeText(TemperatureConverter.this, messageResId, Toast.LENGTH_SHORT).show(); - } - } - }); - - } - - // Attempted saveInstanceState. Saving part works but can't figure out loading section. - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - Log.d(TAG, "onSaveInstanceState"); - - // Saves current state booleans since all user input stays on rotation. - // Keeping the booleans will ensure the conversions show even on rotation. - // Uses an array over multiple puts, since the booleans are all similarly related. - mCurrentStatus[0] = mConvertButtonIsClicked; - mCurrentStatus[1] = mInitialGroupChecked; - mCurrentStatus[2] = mConvertGroupChecked; - - outState.putBooleanArray(KEY_INDEX, mCurrentStatus); - } - - @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_temperature_converter, 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(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } - - return super.onOptionsItemSelected(item); - } - - //endregion - -} +package edu.kvcc.cis298.cis298assignment2; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.TextView; +import android.widget.Toast; + +public class TemperatureConverter extends AppCompatActivity { + + //region Variables + + private RadioGroup mInitialGroup; + private RadioButton mInitial1Radio; + private RadioButton mInitial2Radio; + private RadioButton mInitial3Radio; + private RadioButton mInitial4Radio; + + private RadioGroup mConvertGroup; + private RadioButton mConvert1Radio; + private RadioButton mConvert2Radio; + private RadioButton mConvert3Radio; + private RadioButton mConvert4Radio; + + private Button mConvertButton; + + private TextView mConversionTextView; + private TextView mEquationTextView; + + private EditText mUserInputEditText; + + // Pointer for strings.xml. + private int messageResId; + private int mSelectedInitialId; + private int mSelectedConvertId; + + // Values to check if user input is present. + private boolean mInitialGroupChecked; + private boolean mConvertGroupChecked; + private boolean mConvertButtonIsClicked; + + // Java's version of static constants. + private static final String TAG = "TemperatureConverter"; + private static final String KEY_INDEX = "index"; + + private boolean[] mCurrentStatus = new boolean[3]; + + Conversion conversion; + + //endregion + + + + //region Standard Methods + + /** + * Gets the values of user's input and converts. + * <p> + * Only use if both groups have been checked and user has input a number to convert. + */ + private void Convert() + { + // Sets user's input to a variable. + String userInputString = mUserInputEditText.getText().toString().trim(); + Log.d(TAG, "Parsed: " + userInputString); + double userDouble = Double.parseDouble(userInputString); + Log.d(TAG, "Parsed: " + userDouble); + + // Query to determine which radio buttons have been selected. Stores value as int. + mSelectedInitialId = mInitialGroup.getCheckedRadioButtonId(); + mSelectedConvertId = mConvertGroup.getCheckedRadioButtonId(); + + int initialGroupSelection = 0; + int convertGroupSelection = 0; + + if (mSelectedInitialId == mInitial1Radio.getId()) { + initialGroupSelection = 1; + } + else { + if (mSelectedInitialId == mInitial2Radio.getId()) { + initialGroupSelection = 2; + } + else { + if (mSelectedInitialId == mInitial3Radio.getId()) { + initialGroupSelection = 3; + } + else { + if (mSelectedInitialId == mInitial4Radio.getId()) { + initialGroupSelection = 4; + } + } + } + } + + if (mSelectedConvertId == mConvert1Radio.getId()) { + convertGroupSelection = 1; + } + else { + if (mSelectedConvertId == mConvert2Radio.getId()) { + convertGroupSelection = 2; + } + else { + if (mSelectedConvertId == mConvert3Radio.getId()) { + convertGroupSelection = 3; + } + else { + if (mSelectedConvertId == mConvert4Radio.getId()) { + convertGroupSelection = 4; + } + } + } + } + + conversion = new Conversion(userDouble, initialGroupSelection, convertGroupSelection); + + DisplayConversion(); + } + + /** + * Creates strings for UI display and sends them over to appropriate xml properties. + */ + private void DisplayConversion() + { + String initialTemp = String.format("%.2f", conversion.getInitialValueDouble()); + String convertTemp = String.format("%.2f", conversion.getConvertedValueDouble()); + + + String conversion1String; + String conversion2String; + String equation1String; + String equation2String; + + // Determines what types of strings should display. + // Combinations for FromCelsius selected. + if (mSelectedInitialId == mInitial1Radio.getId()) { + if (mSelectedConvertId == mConvert1Radio.getId()) { + conversion1String = initialTemp + " °C"; + conversion2String = convertTemp + " °C"; + equation1String = "[°C]"; + equation2String = "[°C]"; + } + else { + if (mSelectedConvertId == mConvert2Radio.getId()) { + conversion1String = initialTemp + " °C"; + conversion2String = convertTemp + " °F"; + equation1String = "[°F]"; + equation2String = "([°C] x 9/5) + 32"; + } + else { + if (mSelectedConvertId == mConvert3Radio.getId()) { + conversion1String = initialTemp + " °C"; + conversion2String = convertTemp + " °K"; + equation1String = "[°K]"; + equation2String = "[°C] + 273.15"; + } + else { + conversion1String = initialTemp + " °C"; + conversion2String = convertTemp + " °R"; + equation1String = "[°R]"; + equation2String = "([°C] + 273.15) * 9 / 5"; + } + } + } + } + else { + // Combinations for FromFahrenheit selected. + if (mSelectedInitialId == mInitial2Radio.getId()) { + if (mSelectedConvertId == mConvert1Radio.getId()) { + conversion1String = initialTemp + " °F"; + conversion2String = convertTemp + " °C"; + equation1String = "[°C]"; + equation2String = "([°F] - 32) * 5 / 9"; + } + else { + if (mSelectedConvertId == mConvert2Radio.getId()) { + conversion1String = initialTemp + " °F"; + conversion2String = convertTemp + " °F"; + equation1String = "[°F]"; + equation2String = "[°F]"; + } + else { + if (mSelectedConvertId == mConvert3Radio.getId()) { + conversion1String = initialTemp + " °F"; + conversion2String = convertTemp + " °K"; + equation1String = "[°K]"; + equation2String = "([°F] + 459.67) * 5 / 9"; + } + else { + conversion1String = initialTemp + " °F"; + conversion2String = convertTemp + " °R"; + equation1String = "[°R]"; + equation2String = "[°F] + 459.67"; + } + } + } + } + else { + // Combinations for FromKelvin selected. + if (mSelectedInitialId == mInitial3Radio.getId()) { + if (mSelectedConvertId == mConvert1Radio.getId()) { + conversion1String = initialTemp + " °K"; + conversion2String = convertTemp + " °C"; + equation1String = "[°C]"; + equation2String = "[°K] - 273.15"; + } + else { + if (mSelectedConvertId == mConvert2Radio.getId()) { + conversion1String = initialTemp + " °K"; + conversion2String = convertTemp + " °F"; + equation1String = "[°F]"; + equation2String = "([°K] * 9 / 5) - 459.67"; + } + else { + if (mSelectedConvertId == mConvert3Radio.getId()) { + conversion1String = initialTemp + " °K"; + conversion2String = convertTemp + " °K"; + equation1String = "[°K]"; + equation2String = "[°K]"; + } + else { + conversion1String = initialTemp + " °K"; + conversion2String = convertTemp + " °R"; + equation1String = "[°R]"; + equation2String = "[°K] * 9 / 5"; + } + } + } + } + else { + // Combinations for FromRankine selected + if (mSelectedConvertId == mConvert1Radio.getId()) { + conversion1String = initialTemp + " °R"; + conversion2String = convertTemp + " °C"; + equation1String = "[°C]"; + equation2String = "([°R] - 491.67) * 5 / 9"; + } + else { + if (mSelectedConvertId == mConvert2Radio.getId()) { + conversion1String = initialTemp + " °R"; + conversion2String = convertTemp + " °F"; + equation1String = "[°F]"; + equation2String = "[°R] - 459.67"; + } + else { + if (mSelectedConvertId == mConvert3Radio.getId()) { + conversion1String = initialTemp + " °R"; + conversion2String = convertTemp + " °K"; + equation1String = "[°K]"; + equation2String = "[°R] * 5 / 9"; + } + else { + conversion1String = initialTemp + " °R"; + conversion2String = convertTemp + " °R"; + equation1String = "[°R]"; + equation2String = "[°R]"; + } + } + } + } + } + } + + // Combines above strings into one string, then sends to appropriate single string to textview. + String fullConversionString = conversion1String + " = " + conversion2String; + String fullEquationString = equation1String + " = " + equation2String; + + mConversionTextView.setText(fullConversionString); + mEquationTextView.setText(fullEquationString); + } + + //endregion + + + + //region Override Methods + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.d(TAG, "onCreate() called"); + setContentView(R.layout.activity_temperature_converter); + + // Section which assigns (casts) variables to equivalent entity in xml file. + + // Assigns (casts) variable mConvertButton to an actual button in the xml file. + mConvertButton = (Button) findViewById(R.id.convert_button); + + // Assigns (casts) 'initial' radio group to equivalent entities in the xml file. + mInitialGroup = (RadioGroup) findViewById(R.id.initial_value_group); + mInitial1Radio = (RadioButton) findViewById(R.id.initial_1_radio); + mInitial2Radio = (RadioButton) findViewById(R.id.initial_2_radio); + mInitial3Radio = (RadioButton) findViewById(R.id.initial_3_radio); + mInitial4Radio = (RadioButton) findViewById(R.id.initial_4_radio); + // Assigns (casts) 'convert to' radio group to equivalent entities in the xml file. + mConvertGroup = (RadioGroup) findViewById(R.id.convert_to_group); + mConvert1Radio = (RadioButton) findViewById(R.id.convert_1_radio); + mConvert2Radio = (RadioButton) findViewById(R.id.convert_2_radio); + mConvert3Radio = (RadioButton) findViewById(R.id.convert_3_radio); + mConvert4Radio = (RadioButton) findViewById(R.id.convert_4_radio); + + // Assigns (casts) text views to equivalent entities in the xml file. + mConversionTextView = (TextView) findViewById(R.id.converstion_text_view); + mEquationTextView = (TextView) findViewById(R.id.equation_text_view); + + // Assigns (casts) edit text to equivalent entities in the xml file. + mUserInputEditText = (EditText) findViewById(R.id.user_input_edit_text); + + // Gets saved state for booleans. + if (savedInstanceState != null) { + + // Loads saved value of initial variables. + boolean[] savedStateBool = savedInstanceState.getBooleanArray(KEY_INDEX); + + mConvertButtonIsClicked = savedStateBool[0]; + mInitialGroupChecked = savedStateBool[1]; + mConvertGroupChecked = savedStateBool[2]; + + // Checks to see if user has input a number. + if (mUserInputEditText.length() > 0) { + // Checks to see if both groups have been checked, and if convert button has been + // clicked at least once. + if (mInitialGroupChecked && mConvertGroupChecked && mConvertButtonIsClicked) { + Convert(); + } + } + } + else { + // Initial variables to store user inputs. + mConvertButtonIsClicked = false; + mInitialGroupChecked = false; + mConvertGroupChecked = false; + } + + // Section which sets onClickListeners (watches for user action). + // OnClickListener for Initial Radio Button Group. + mInitialGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedID) { + + // Debugging to figure out what values are actually given for checked buttons. + int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); + int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); + Log.d(TAG, "Initial Checked ID: " + selectedInitialId); + Log.d(TAG, "Convert Checked ID: " + selectedConvertId); + + // Checks to see if both groups have been checked, if convert button has been + // clicked at least once, and user has input a number. + if (mInitialGroupChecked && mConvertGroupChecked && mUserInputEditText.length() > 0) { + Convert(); + } else { + mInitialGroupChecked = true; + } + } + }); + + // OnCheckChangeListener for Convert To Radio Button Group. + mConvertGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedID) { + + // Debugging to figure out what values are actually given for checked buttons. + int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); + int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); + Log.d(TAG, "Initial Checked ID: " + selectedInitialId); + Log.d(TAG, "Convert Checked ID: " + selectedConvertId); + + + // Checks to see if both groups have been checked, if convert button has been + // clicked at least once, and user has input a number. + if (mInitialGroupChecked && mConvertGroupChecked && mConvertButtonIsClicked + && mUserInputEditText.length() > 0) { + Convert(); + } else { + mConvertGroupChecked = true; + } + } + }); + + // OnClickListener for Convert Button. + mConvertButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + // Debugging to figure out what values are actually given for checked buttons. + int selectedInitialId = mInitialGroup.getCheckedRadioButtonId(); + int selectedConvertId = mConvertGroup.getCheckedRadioButtonId(); + Log.d(TAG, "Initial Checked ID: " + selectedInitialId); + Log.d(TAG, "Convert Checked ID: " + selectedConvertId); + + // Checks to see if user has input a number. + if (mUserInputEditText.length() > 0) { + + // Checks to see if both groups have been checked. + if (mInitialGroupChecked && mConvertGroupChecked) { + mConvertButtonIsClicked = true; + Convert(); + } else { + messageResId = R.string.convert_error_2_toast; + Toast.makeText(TemperatureConverter.this, messageResId, Toast.LENGTH_SHORT).show(); + } + } else { + messageResId = R.string.convert_error_1_toast; + Toast.makeText(TemperatureConverter.this, messageResId, Toast.LENGTH_SHORT).show(); + } + } + }); + + } + + // Attempted saveInstanceState. Saving part works but can't figure out loading section. + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + Log.d(TAG, "onSaveInstanceState"); + + // Saves current state booleans since all user input stays on rotation. + // Keeping the booleans will ensure the conversions show even on rotation. + // Uses an array over multiple puts, since the booleans are all similarly related. + mCurrentStatus[0] = mConvertButtonIsClicked; + mCurrentStatus[1] = mInitialGroupChecked; + mCurrentStatus[2] = mConvertGroupChecked; + + outState.putBooleanArray(KEY_INDEX, mCurrentStatus); + } + + @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_temperature_converter, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + //endregion + +} diff --git a/app/src/main/res/layout-land/activity_temperature_converter.xml b/app/src/main/res/layout-land/activity_temperature_converter.xml index 80b684d..a7b91dc 100644 --- a/app/src/main/res/layout-land/activity_temperature_converter.xml +++ b/app/src/main/res/layout-land/activity_temperature_converter.xml @@ -1,163 +1,163 @@ - -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="start" - android:padding="20dp" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_vertical" - android:padding="10dp" - android:orientation="vertical" > - - - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start" - android:paddingRight="10dp" - android:text="@string/convert_string" /> - - <EditText - android:id="@+id/user_input_edit_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:inputType="numberDecimal|numberSigned" /> - - </LinearLayout> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_horizontal" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center" - android:paddingTop="10dp" - android:orientation="vertical" > - - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center_horizontal" - android:orientation="horizontal" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/from_string"/> - - <RadioGroup - android:id="@+id/initial_value_group" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" > - - <RadioButton - android:id="@+id/initial_1_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/celsius_string" /> - - <RadioButton - android:id="@+id/initial_2_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/fahrenheit_string" /> - - <RadioButton - android:id="@+id/initial_3_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/kelvin_string" /> - - <RadioButton - android:id="@+id/initial_4_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/rankine_string" /> - - </RadioGroup> - - </LinearLayout> - - <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:paddingRight="16dp" - android:text="@string/to_string"/> - - <RadioGroup - android:id="@+id/convert_to_group" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <RadioButton - android:id="@+id/convert_1_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/celsius_string" /> - - <RadioButton - android:id="@+id/convert_2_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/fahrenheit_string" /> - - <RadioButton - android:id="@+id/convert_3_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/kelvin_string" /> - - <RadioButton - android:id="@+id/convert_4_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/rankine_string" /> - </RadioGroup> - - </LinearLayout> - - </LinearLayout> - - <Button - android:id="@+id/convert_button" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/convert_button_string"/> - - <TextView - android:id="@+id/converstion_text_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="18dp" /> - - <TextView - android:id="@+id/equation_text_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - </LinearLayout> - - </LinearLayout> - + +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="start" + android:padding="20dp" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:padding="10dp" + android:orientation="vertical" > + + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="start" + android:paddingRight="10dp" + android:text="@string/convert_string" /> + + <EditText + android:id="@+id/user_input_edit_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:inputType="numberDecimal|numberSigned" /> + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_horizontal" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:paddingTop="10dp" + android:orientation="vertical" > + + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/from_string"/> + + <RadioGroup + android:id="@+id/initial_value_group" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <RadioButton + android:id="@+id/initial_1_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/celsius_string" /> + + <RadioButton + android:id="@+id/initial_2_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/fahrenheit_string" /> + + <RadioButton + android:id="@+id/initial_3_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/kelvin_string" /> + + <RadioButton + android:id="@+id/initial_4_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/rankine_string" /> + + </RadioGroup> + + </LinearLayout> + + <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:paddingRight="16dp" + android:text="@string/to_string"/> + + <RadioGroup + android:id="@+id/convert_to_group" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <RadioButton + android:id="@+id/convert_1_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/celsius_string" /> + + <RadioButton + android:id="@+id/convert_2_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/fahrenheit_string" /> + + <RadioButton + android:id="@+id/convert_3_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/kelvin_string" /> + + <RadioButton + android:id="@+id/convert_4_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/rankine_string" /> + </RadioGroup> + + </LinearLayout> + + </LinearLayout> + + <Button + android:id="@+id/convert_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/convert_button_string"/> + + <TextView + android:id="@+id/converstion_text_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="18dp" /> + + <TextView + android:id="@+id/equation_text_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + </LinearLayout> + + </LinearLayout> + </FrameLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_temperature_converter.xml b/app/src/main/res/layout/activity_temperature_converter.xml index cc644c2..8db5ffe 100644 --- a/app/src/main/res/layout/activity_temperature_converter.xml +++ b/app/src/main/res/layout/activity_temperature_converter.xml @@ -1,156 +1,156 @@ - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="start" - android:padding="20dp" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_vertical" - android:padding="10dp" - android:orientation="vertical"> - - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="start" - android:text="@string/convert_string" /> - - <EditText - android:id="@+id/user_input_edit_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:inputType="numberDecimal|numberSigned" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:orientation="vertical" > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center" - android:paddingTop="10dp" - android:paddingBottom="10dp" - android:orientation="horizontal" > - - - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="start" - android:paddingRight="30dp" - android:orientation="vertical" > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/from_string"/> - - <RadioGroup - android:id="@+id/initial_value_group" - android:layout_width="wrap_content" - android:layout_height="wrap_content" > - - <RadioButton - android:id="@+id/initial_1_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/celsius_string" /> - - <RadioButton - android:id="@+id/initial_2_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/fahrenheit_string" /> - - <RadioButton - android:id="@+id/initial_3_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/kelvin_string" /> - - <RadioButton - android:id="@+id/initial_4_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/rankine_string" /> - - </RadioGroup> - - </LinearLayout> - - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="end" - android:paddingLeft="30dp" - android:orientation="vertical"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/to_string"/> - - <RadioGroup - android:id="@+id/convert_to_group" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - - <RadioButton - android:id="@+id/convert_1_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/celsius_string" /> - - <RadioButton - android:id="@+id/convert_2_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/fahrenheit_string" /> - - <RadioButton - android:id="@+id/convert_3_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/kelvin_string" /> - - <RadioButton - android:id="@+id/convert_4_radio" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/rankine_string" /> - </RadioGroup> - - </LinearLayout> - - </LinearLayout> - - <Button - android:id="@+id/convert_button" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/convert_button_string"/> - - <TextView - android:id="@+id/converstion_text_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="18dp" /> - - <TextView - android:id="@+id/equation_text_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - </LinearLayout> - - </LinearLayout> - + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="start" + android:padding="20dp" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:padding="10dp" + android:orientation="vertical"> + + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="start" + android:text="@string/convert_string" /> + + <EditText + android:id="@+id/user_input_edit_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:inputType="numberDecimal|numberSigned" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:paddingTop="10dp" + android:paddingBottom="10dp" + android:orientation="horizontal" > + + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="start" + android:paddingRight="30dp" + android:orientation="vertical" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/from_string"/> + + <RadioGroup + android:id="@+id/initial_value_group" + android:layout_width="wrap_content" + android:layout_height="wrap_content" > + + <RadioButton + android:id="@+id/initial_1_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/celsius_string" /> + + <RadioButton + android:id="@+id/initial_2_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/fahrenheit_string" /> + + <RadioButton + android:id="@+id/initial_3_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/kelvin_string" /> + + <RadioButton + android:id="@+id/initial_4_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/rankine_string" /> + + </RadioGroup> + + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:paddingLeft="30dp" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/to_string"/> + + <RadioGroup + android:id="@+id/convert_to_group" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <RadioButton + android:id="@+id/convert_1_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/celsius_string" /> + + <RadioButton + android:id="@+id/convert_2_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/fahrenheit_string" /> + + <RadioButton + android:id="@+id/convert_3_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/kelvin_string" /> + + <RadioButton + android:id="@+id/convert_4_radio" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/rankine_string" /> + </RadioGroup> + + </LinearLayout> + + </LinearLayout> + + <Button + android:id="@+id/convert_button" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/convert_button_string"/> + + <TextView + android:id="@+id/converstion_text_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="18dp" /> + + <TextView + android:id="@+id/equation_text_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + </LinearLayout> + + </LinearLayout> + </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/menu/menu_temperature_converter.xml b/app/src/main/res/menu/menu_temperature_converter.xml index e113229..4fbf67b 100644 --- a/app/src/main/res/menu/menu_temperature_converter.xml +++ b/app/src/main/res/menu/menu_temperature_converter.xml @@ -1,6 +1,6 @@ -<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=".TemperatureConverter"> - <item android:id="@+id/action_settings" android:title="@string/action_settings" - android:orderInCategory="100" app:showAsAction="never" /> -</menu> +<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=".TemperatureConverter"> + <item android:id="@+id/action_settings" android:title="@string/action_settings" + android:orderInCategory="100" app:showAsAction="never" /> +</menu> diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml index 63fc816..62df187 100644 --- a/app/src/main/res/values-w820dp/dimens.xml +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -1,6 +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> +<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> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 47c8224..295b5a9 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,5 +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> +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> +</resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9f78203..d159c90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,21 +1,21 @@ -<resources> - <string name="app_name">CIS298Assignment2</string> - - <string name="hello_world">Hello world!</string> - <string name="action_settings">Settings</string> - - <!--Static Text--> - <string name="convert_string">Convert:</string> - <string name="from_string">From:</string> - <string name="to_string">To: </string> - <string name="celsius_string">Celsius</string> - <string name="fahrenheit_string">Fahrenheit</string> - <string name="kelvin_string">Kelvin</string> - <string name="rankine_string">Rankine</string> - <string name="convert_button_string">Convert</string> - - <!--Toasts--> - <string name="convert_error_1_toast">Please input a number to convert!</string> - <string name="convert_error_2_toast">Please select a temperature type!</string> - -</resources> +<resources> + <string name="app_name">CIS298Assignment2</string> + + <string name="hello_world">Hello world!</string> + <string name="action_settings">Settings</string> + + <!--Static Text--> + <string name="convert_string">Convert:</string> + <string name="from_string">From:</string> + <string name="to_string">To: </string> + <string name="celsius_string">Celsius</string> + <string name="fahrenheit_string">Fahrenheit</string> + <string name="kelvin_string">Kelvin</string> + <string name="rankine_string">Rankine</string> + <string name="convert_button_string">Convert</string> + + <!--Toasts--> + <string name="convert_error_1_toast">Please input a number to convert!</string> + <string name="convert_error_2_toast">Please select a temperature type!</string> + +</resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 766ab99..084b42b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,8 +1,8 @@ -<resources> - - <!-- Base application theme. --> - <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> - <!-- Customize your theme here. --> - </style> - -</resources> +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + </style> + +</resources> diff --git a/build.gradle b/build.gradle index 1b7886d..92e4303 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +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.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - jcenter() - } -} +// 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.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/gradle.properties b/gradle.properties index 1d3591c..9b6ae2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +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 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 515b11b..46a7c9a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Sep 20 12:32:15 EDT 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +#Sun Sep 20 12:32:15 EDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/gradlew b/gradlew index 91a7e26..583ae08 100644 --- a/gradlew +++ b/gradlew @@ -1,164 +1,164 @@ -#!/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 - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# 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\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -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"` - - # 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 "$@" +#!/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 + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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"` + + # 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 "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..aec9973 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +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 +@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 diff --git a/settings.gradle b/settings.gradle index e7b4def..d3db109 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app' +include ':app' -- GitLab