commit c1dc1ee96ef4ac9f0e760f8b1a958b51da50ab38 Author: hmalik144 Date: Sat Feb 23 14:08:10 2019 +1100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..6b96cf0 --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..2c56865 Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/h_mal.xml b/.idea/dictionaries/h_mal.xml new file mode 100644 index 0000000..83b0d42 --- /dev/null +++ b/.idea/dictionaries/h_mal.xml @@ -0,0 +1,7 @@ + + + + relevent + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..99202cc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ed919ec --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..72f2f08 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,30 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + buildToolsVersion '27.0.3' + defaultConfig { + applicationId "com.appttude.h_mal.easycc" + minSdkVersion 16 + targetSdkVersion 26 + versionCode 2 + versionName "1.1" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support:cardview-v7:26.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..38e067c --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\HAIMALIK\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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..a47a83d Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json new file mode 100644 index 0000000..8a74f32 --- /dev/null +++ b/app/release/output.json @@ -0,0 +1 @@ +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/androidTest/java/com/appttude/h_mal/easycc/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/appttude/h_mal/easycc/ExampleInstrumentedTest.java new file mode 100644 index 0000000..27f81ff --- /dev/null +++ b/app/src/androidTest/java/com/appttude/h_mal/easycc/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.appttude.h_mal.easycc; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static junit.framework.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.appttude.h_mal.easycc", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9aa2755 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidget.java b/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidget.java new file mode 100644 index 0000000..c44bb51 --- /dev/null +++ b/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidget.java @@ -0,0 +1,159 @@ +package com.appttude.h_mal.easycc; + +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.Context; +import android.content.Intent; +import android.os.AsyncTask; +import android.text.TextUtils; +import android.util.Log; +import android.widget.RemoteViews; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.net.URL; + +import static com.appttude.h_mal.easycc.CurrencyAppWidgetConfigureActivity.loadTitlePref; +import static com.appttude.h_mal.easycc.PublicMethods.UriBuilder; +import static com.appttude.h_mal.easycc.PublicMethods.createUrl; +import static com.appttude.h_mal.easycc.PublicMethods.makeHttpRequest; +import static com.appttude.h_mal.easycc.PublicMethods.round; + +/** + * Implementation of App Widget functionality. + * App Widget Configuration implemented in {@link CurrencyAppWidgetConfigureActivity CurrencyAppWidgetConfigureActivity} + */ +public class CurrencyAppWidget extends AppWidgetProvider { + + static String LOG_TAG = CurrencyAppWidget.class.getSimpleName(); + + static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, + int appWidgetId) { + + String s1 = loadTitlePref(context,appWidgetId,0); + String s2 = loadTitlePref(context,appWidgetId,1); + + String URL = UriBuilder(s1,s2); + WidgetAsyncTask widgetAsyncTask = new WidgetAsyncTask(context,appWidgetId,appWidgetManager,s1.substring(0,3),s2.substring(0,3)); + widgetAsyncTask.execute(URL); + + } + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + // There may be multiple widgets active, so update all of them + for (int appWidgetId : appWidgetIds) { + updateAppWidget(context, appWidgetManager, appWidgetId); + } + } + + @Override + public void onDeleted(Context context, int[] appWidgetIds) { + // When the user deletes the widget, delete the preference associated with it. + for (int appWidgetId : appWidgetIds) { + CurrencyAppWidgetConfigureActivity.deleteTitlePref(context, appWidgetId); + } + } + + @Override + public void onEnabled(Context context) { + // Enter relevant functionality for when the first widget is created + } + + @Override + public void onDisabled(Context context) { + // Enter relevant functionality for when the last widget is disabled + } + + private static class WidgetAsyncTask extends AsyncTask { + + private Context context; + private int appWidgetId; + private AppWidgetManager appWidgetManager; + private String s1; + private String s2; + + public WidgetAsyncTask(Context context, int appWidgetId, AppWidgetManager appWidgetManager, String s1, String s2) { + this.context = context; + this.appWidgetId = appWidgetId; + this.appWidgetManager = appWidgetManager; + this.s1 = s1; + this.s2 = s2; + } + + @Override + protected Double doInBackground(String... urlString) { + String jsonResponse = null; + + if (urlString.length < 1 || urlString[0] == null) { + return null; + } + try { + URL url = createUrl(urlString[0]); + jsonResponse = makeHttpRequest(url); + + } catch (IOException e) { + Log.e(getClass().getSimpleName(), "Problem making the HTTP request.", e); + } + + + return extractFeatureFromJson(jsonResponse, s1, s2); + + } + + @Override + protected void onPostExecute(Double result) { + super.onPostExecute(result); + + RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.currency_app_widget); + views.setTextViewText(R.id.exchangeName, s1 + s2); + views.setTextViewText(R.id.exchangeRate, round(result,2)+""); + + float opacity = 0.3f; //opacity = 0: fully transparent, opacity = 1: no transparancy + int backgroundColor = 0x000000; //background color (here black) + views.setInt( R.id.widget_view, "setBackgroundColor", (int)(opacity * 0xFF) << 24 | backgroundColor); + + Intent clickIntentTemplate = new Intent(context, MainActivity.class); + + clickIntentTemplate.setAction(Intent.ACTION_MAIN); + clickIntentTemplate.addCategory(Intent.CATEGORY_LAUNCHER); + clickIntentTemplate.putExtra("parse_1",s1); + clickIntentTemplate.putExtra("parse_2",s2); + clickIntentTemplate.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + + PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, clickIntentTemplate, PendingIntent.FLAG_UPDATE_CURRENT); + views.setOnClickPendingIntent(R.id.widget_view, configPendingIntent); + + // Instruct the widget manager to update the widget + appWidgetManager.updateAppWidget(appWidgetId, views); + + } + + private static double extractFeatureFromJson(String newsJSON, String s1, String s2) { + double conversionValue = 0.00; + + Log.i(LOG_TAG, "extractFeatureFromJson: " + newsJSON); + + Log.i(LOG_TAG, "extractFeatureFromJson: " + s1 + "_" + s2); + + if (TextUtils.isEmpty(newsJSON)) { + return 0.00; + } + + try { + JSONObject jObject = new JSONObject(newsJSON); + conversionValue = jObject.getDouble(s1 + "_" + s2); + + } catch (JSONException e) { + + Log.e("MainActivity", "Problem parsing the JSON results", e); + } + return conversionValue; + } + + } +} + diff --git a/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidgetConfigureActivity.java b/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidgetConfigureActivity.java new file mode 100644 index 0000000..be96982 --- /dev/null +++ b/app/src/main/java/com/appttude/h_mal/easycc/CurrencyAppWidgetConfigureActivity.java @@ -0,0 +1,225 @@ +package com.appttude.h_mal.easycc; + +import android.app.Activity; +import android.app.Dialog; +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.TextView; + +/** + * The configuration screen for the {@link CurrencyAppWidget CurrencyAppWidget} AppWidget. + */ +public class CurrencyAppWidgetConfigureActivity extends Activity { + + private static final String PREFS_NAME = "com.example.haimalik.myapplication.CurrencyAppWidget"; + private static final String PREF_PREFIX_KEY = "appwidget_"; + private static final int PRIMARY = 0; + private static final int SECONDARY = 1; + int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; + + + View.OnClickListener mOnClickListener = new View.OnClickListener() { + public void onClick(View v) { + final Context context = CurrencyAppWidgetConfigureActivity.this; + + final Dialog dialog = new Dialog(context); + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); + dialog.setCancelable(false); + dialog.setContentView(R.layout.confirm_dialog); + + TextView text = (TextView) dialog.findViewById(R.id.confirm_text); + text.setText(new StringBuilder().append("Create widget for ") + .append(loadTitlePref(context, mAppWidgetId, PRIMARY)) + .append(loadTitlePref(context, mAppWidgetId, SECONDARY)) + .append("?").toString()); + + TextView yes = dialog.findViewById(R.id.confirm_yes); + yes.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //do for yes + // It is the responsibility of the configuration activity to update the app widget + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); + CurrencyAppWidget.updateAppWidget(context, appWidgetManager, mAppWidgetId); + + // Make sure we pass back the original appWidgetId + Intent resultValue = new Intent(); + resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); + setResult(RESULT_OK, resultValue); + finish(); + } + }); + + TextView no = dialog.findViewById(R.id.confirm_no); + no.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.dismiss(); + } + }); + + dialog.show(); + + } + }; + + public CurrencyAppWidgetConfigureActivity() { + super(); + } + + // Write the prefix to the SharedPreferences object for this widget + static void saveCurrencyPref(Context context, int appWidgetId, String text, int item) { + SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit(); + prefs.putString(PREF_PREFIX_KEY + appWidgetId + "_" + item, text); + prefs.apply(); + } + + // Read the prefix from the SharedPreferences object for this widget. + // If there is no preference saved, get the default from a resource + static String loadTitlePref(Context context, int appWidgetId, int item) { + SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0); + String titleValue = prefs.getString(PREF_PREFIX_KEY + appWidgetId + "_" + item, null); + if (titleValue != null) { + return titleValue; + } else { + return context.getResources().getStringArray(R.array.currency_arrays)[0].substring(0,3); + } + } + + static void deleteTitlePref(Context context, int appWidgetId) { + SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit(); + prefs.remove(PREF_PREFIX_KEY+ appWidgetId + "_0"); + prefs.remove(PREF_PREFIX_KEY+ appWidgetId + "_1"); + prefs.apply(); + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + // Set the result to CANCELED. This will cause the widget host to cancel + // out of the widget placement if the user presses the back button. + setResult(RESULT_CANCELED); + + setContentView(R.layout.currency_app_widget_configure); + + final TextView currencyOne = findViewById(R.id.currency_one); + final TextView currencyTwo = findViewById(R.id.currency_two); + TextView submit = findViewById(R.id.submit_widget); + + // Find the widget id from the intent. + Intent intent = getIntent(); + Bundle extras = intent.getExtras(); + if (extras != null) { + mAppWidgetId = extras.getInt( + AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + } + + // If this activity was started with an intent without an app widget ID, finish with an error. + if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { + finish(); + return; + } + + + currencyOne.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomDialogClass dialogClass = new CustomDialogClass(CurrencyAppWidgetConfigureActivity.this,currencyOne,PRIMARY); + dialogClass.show(); + } + }); + + + currencyTwo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomDialogClass dialogClass = new CustomDialogClass(CurrencyAppWidgetConfigureActivity.this,currencyTwo,SECONDARY); + dialogClass.show(); + } + }); + + submit.setOnClickListener(mOnClickListener); + + } + + private class CustomDialogClass extends Dialog implements android.view.View.OnClickListener{ + + Context context; + ListView listView; + TextView textView; + EditText editText; + int item; + + public CustomDialogClass(@NonNull Context context, TextView textView, int item) { + super(context); + this.context = context; + this.textView = textView; + this.item = item; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.custom_dialog); + + getWindow().setBackgroundDrawableResource(android.R.color.transparent); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + + listView = (ListView) findViewById(R.id.list_view); + editText = (EditText) findViewById(R.id.search_text) ; + + final ArrayAdapter arrayAdapter = ArrayAdapter.createFromResource(context,R.array.currency_arrays,android.R.layout.simple_list_item_1); + listView.setAdapter(arrayAdapter); + + editText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + arrayAdapter.getFilter().filter(charSequence); + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + String text = adapterView.getItemAtPosition(i).toString().substring(0,3); + textView.setText(adapterView.getItemAtPosition(i).toString()); + saveCurrencyPref(context,mAppWidgetId,text,item); + dismiss(); + } + }); + } + + @Override + public void onClick(View view) { + + } + } + +} + diff --git a/app/src/main/java/com/appttude/h_mal/easycc/MainActivity.java b/app/src/main/java/com/appttude/h_mal/easycc/MainActivity.java new file mode 100644 index 0000000..eae6912 --- /dev/null +++ b/app/src/main/java/com/appttude/h_mal/easycc/MainActivity.java @@ -0,0 +1,376 @@ +package com.appttude.h_mal.easycc; + +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.AsyncTask; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.util.Log; +import android.view.View; +import android.view.WindowManager; +import android.view.animation.AlphaAnimation; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.net.URL; + +import java.text.DecimalFormat; + +import static com.appttude.h_mal.easycc.PublicMethods.UriBuilder; +import static com.appttude.h_mal.easycc.PublicMethods.createUrl; +import static com.appttude.h_mal.easycc.PublicMethods.makeHttpRequest; + +public class MainActivity extends AppCompatActivity { + + EditText currencyOneEditText; + EditText currencyTwoEditText; + TextView currencyOne; + TextView currencyTwo; + double conversionRateOne; + ProgressBar spinner; + LinearLayout wholeView; + + private String URL = "https://free.currencyconverterapi.com/api/v3/convert?"; + private String CURRENCY_ONE = "currency_one_pref"; + private String CURRENCY_TWO = "currency_two_pref"; + + private static final String LOG_TAG = MainActivity.class.getSimpleName(); + + SharedPreferences pref; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE); + this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); +// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + currencyOneEditText = (EditText) findViewById(R.id.editText); + currencyTwoEditText = (EditText) findViewById(R.id.editText2); + + currencyOne = (TextView) findViewById(R.id.currency_one); + currencyTwo = (TextView) findViewById(R.id.currency_two); + + if (getIntent().getExtras() != null) { + Bundle b = getIntent().getExtras(); + currencyOne.setText(arrayEntry(b.getString("parse_1"))); + currencyTwo.setText(arrayEntry(b.getString("parse_2"))); + }else{ + if (pref != null) { + currencyOne.setText(pref.getString(CURRENCY_ONE, String.valueOf(getResources().getTextArray(R.array.currency_arrays)[0]))); + currencyTwo.setText(pref.getString(CURRENCY_TWO, String.valueOf(getResources().getTextArray(R.array.currency_arrays)[0]))); + }else{ + currencyOne.setText(getResources().getTextArray(R.array.currency_arrays)[0]); + currencyTwo.setText(getResources().getTextArray(R.array.currency_arrays)[0]); + } + } + + currencyOneEditText.addTextChangedListener(TextWatcherClass); + currencyTwoEditText.addTextChangedListener(TextWatcherClass2); + + spinner = (ProgressBar) findViewById(R.id.progressBar); + spinner.setVisibility(View.GONE); + + wholeView = findViewById(R.id.whole_view); + +// addListenerOnSpinnerItemSelection(); + + currencyOne.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomDialogClass dialogClass = new CustomDialogClass(MainActivity.this,currencyOne); + dialogClass.show(); + } + }); + + currencyTwo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomDialogClass dialogClass = new CustomDialogClass(MainActivity.this,currencyTwo); + dialogClass.show(); + } + }); + + String stringURL = UriBuilder(currencyOne.getText().toString().substring(0,3), + currencyTwo.getText().toString().substring(0,3)); + MyAsyncTask task = new MyAsyncTask(); + task.execute(stringURL); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + if (getIntent().getExtras() != null) { + Bundle b = getIntent().getExtras(); + currencyOne.setText(arrayEntry(b.getString("parse_1"))); + currencyTwo.setText(arrayEntry(b.getString("parse_2"))); + } + } + + private TextWatcher TextWatcherClass = new TextWatcher() { + + @Override + public void onTextChanged(CharSequence s, int start, int before, + int count) { + currencyTwoEditText.removeTextChangedListener(TextWatcherClass2); + if(currencyOneEditText.getText().toString().isEmpty()){ + currencyTwoEditText.setText(""); + return; + } + + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + } + + @Override + public void afterTextChanged(Editable s) { + + try{ + + Double topValue = Double.parseDouble(currencyOneEditText.getText().toString()); + Double bottomValue = topValue * conversionRateOne; + DecimalFormat df = new DecimalFormat("#.##"); + bottomValue = Double.valueOf(df.format(bottomValue)); + currencyTwoEditText.setText(bottomValue.toString()); + + } + catch (NumberFormatException e){ + Log.e(LOG_TAG, "no numbers inserted"); + } + currencyTwoEditText.addTextChangedListener(TextWatcherClass2); + } + + }; + + private TextWatcher TextWatcherClass2 = new TextWatcher() { + + @Override + public void onTextChanged(CharSequence s, int start, int before, + int count) { + currencyOneEditText.removeTextChangedListener(TextWatcherClass); + if(currencyTwoEditText.getText().toString().isEmpty()){ + currencyOneEditText.setText(""); + } + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + } + + @Override + public void afterTextChanged(Editable s) { + + try{ + + Double bottomValue = Double.parseDouble(currencyTwoEditText.getText().toString()); + Double topValue = bottomValue * (1 / conversionRateOne); + DecimalFormat df = new DecimalFormat("#.##"); + topValue = Double.valueOf(df.format(topValue)); + currencyOneEditText.setText(topValue.toString()); + + + } + catch (NumberFormatException e){ + Log.e(LOG_TAG, "no numbers inserted"); + } + currencyOneEditText.addTextChangedListener(TextWatcherClass); + } + + }; + + + + private double extractFeatureFromJson(String newsJSON) { + double conversionValue = 0.00; + + Log.i(LOG_TAG, "extractFeatureFromJson: " + newsJSON); + + String currencyOneVal = currencyOne.getText().toString().substring(0,3); + String currencyTwoVal = currencyTwo.getText().toString().substring(0,3); + + Log.i(LOG_TAG, "extractFeatureFromJson: " + currencyOneVal + "_" + currencyTwoVal); + + if (TextUtils.isEmpty(newsJSON)) { + return 0.00; + } + + try { + JSONObject jObject = new JSONObject(newsJSON); + conversionValue = jObject.getDouble(currencyOneVal + "_" + currencyTwoVal); + + } catch (JSONException e) { + + Log.e("MainActivity", "Problem parsing the JSON results", e); + } + return conversionValue; + } + + protected class MyAsyncTask extends AsyncTask { + + @Override + protected Double doInBackground(String... urlString) { + String jsonResponse = null; + + if (urlString.length < 1 || urlString[0] == null) { + return null; + } + try { + URL url = createUrl(urlString[0]); + jsonResponse = makeHttpRequest(url); + + } catch (IOException e) { + Log.e(LOG_TAG, "Problem making the HTTP request.", e); + } + + if (jsonResponse.equals("")){ + return null; + } + + return extractFeatureFromJson(jsonResponse); + + } + + @Override + protected void onPreExecute() { + super.onPreExecute(); + spinner.setVisibility(View.VISIBLE); + AlphaAnimation animation1 = new AlphaAnimation(1.0f, 0.2f); + animation1.setDuration(200); + wholeView.startAnimation(animation1); + wholeView.setAlpha(0.2f); + } + + @Override + protected void onPostExecute(Double result) { + super.onPostExecute(result); + + spinner.setVisibility(View.GONE); + wholeView.setAlpha(1.0f); + + if (result == null){ + Toast.makeText(MainActivity.this, "Failed to retrieve exchange rate", Toast.LENGTH_SHORT).show(); + }else{ + conversionRateOne = result; + } + + } + + } + + private class CustomDialogClass extends Dialog implements android.view.View.OnClickListener{ + + Context context; + ListView listView; + TextView textView; + EditText editText; + int selection; + + public CustomDialogClass(@NonNull Context context, TextView textView) { + super(context); + this.context = context; + this.textView = textView; + if (textView.getId() == R.id.currency_one){ + selection = 1; + }else{ + selection = 2; + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.custom_dialog); + + getWindow().setBackgroundDrawableResource(android.R.color.transparent); + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + + listView = (ListView) findViewById(R.id.list_view); + editText = (EditText) findViewById(R.id.search_text) ; + + final ArrayAdapter arrayAdapter = ArrayAdapter.createFromResource(context,R.array.currency_arrays,android.R.layout.simple_list_item_1); + listView.setAdapter(arrayAdapter); + + editText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + arrayAdapter.getFilter().filter(charSequence); + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + textView.setText(adapterView.getItemAtPosition(i).toString()); + SharedPreferences.Editor editor = pref.edit(); + if (selection == 1) { + editor.putString(CURRENCY_ONE,adapterView.getItemAtPosition(i).toString()); + }else{ + editor.putString(CURRENCY_TWO,adapterView.getItemAtPosition(i).toString()); + } + editor.apply(); + currencyOneEditText.setText(""); + currencyTwoEditText.setText(""); + String stringURL = UriBuilder(currencyOne.getText().toString().substring(0,3), + currencyTwo.getText().toString().substring(0,3)); + MyAsyncTask task = new MyAsyncTask(); + task.execute(stringURL); + dismiss(); + } + }); + } + + @Override + public void onClick(View view) { + + } + } + + private String arrayEntry (String s){ + String[] strings = getResources().getStringArray(R.array.currency_arrays); + String returnString = strings[0]; + for (String string : strings) { + if (s.equals(string.substring(0, 3))) { + returnString = string; + + } + } + + return returnString; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/appttude/h_mal/easycc/PublicMethods.java b/app/src/main/java/com/appttude/h_mal/easycc/PublicMethods.java new file mode 100644 index 0000000..470f503 --- /dev/null +++ b/app/src/main/java/com/appttude/h_mal/easycc/PublicMethods.java @@ -0,0 +1,110 @@ +package com.appttude.h_mal.easycc; + +import android.net.Uri; +import android.util.Log; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; + +public class PublicMethods { + + private static String TAG = PublicMethods.class.getSimpleName(); + private static String URL = "https://free.currencyconverterapi.com/api/v3/convert?"; + + public PublicMethods() { + } + + static String UriBuilder(String s1, String s2){ + s1 = s1.substring(0,3); + s2 = s2.substring(0,3); + + Log.i(TAG, "UriBuilder: " + s1 + "_" + s2); + + Uri baseUri = Uri.parse(URL); + Uri.Builder builder = baseUri.buildUpon(); + builder.appendQueryParameter("q", s1 + "_" + s2) + .appendQueryParameter("compact", "ultra") + .appendQueryParameter("apiKey", "a4f93cc2ff05dd772321"); + + return builder.build().toString(); + + } + + static java.net.URL createUrl(String stringUrl) { + URL url = null; + try { + url = new URL(stringUrl); + } catch (MalformedURLException e) { + Log.e(TAG, "Error with creating URL ", e); + } + return url; + } + + + static String makeHttpRequest(URL url) throws IOException { + String jsonResponse = ""; + + if (url == null) { + return jsonResponse; + } + + HttpURLConnection urlConnection = null; + InputStream inputStream = null; + try { + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setReadTimeout(30000); + urlConnection.setConnectTimeout(30000); + urlConnection.setRequestMethod("GET"); + urlConnection.connect(); + + if (urlConnection.getResponseCode() == 200) { + inputStream = urlConnection.getInputStream(); + jsonResponse = readFromStream(inputStream); + } else { + Log.e(TAG, "Error response code: " + urlConnection.getResponseCode()); + } + } catch (IOException e) { + Log.e(TAG, "Problem retrieving the JSON results.", e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + if (inputStream != null) { + inputStream.close(); + } + } + return jsonResponse; + } + + private static String readFromStream(InputStream inputStream) throws IOException { + StringBuilder output = new StringBuilder(); + if (inputStream != null) { + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8")); + BufferedReader reader = new BufferedReader(inputStreamReader); + String line = ""; + while (line != null) { + output.append(line); + line = reader.readLine(); + } + } + Log.d(TAG, output.toString()); + return output.toString(); + + } + + public static double round(double value, int places) { + if (places < 0) throw new IllegalArgumentException(); + + long factor = (long) Math.pow(10, places); + value = value * factor; + long tmp = Math.round(value); + return (double) tmp / factor; + } + +} diff --git a/app/src/main/res/drawable-nodpi/easyycc_widget_preview.png b/app/src/main/res/drawable-nodpi/easyycc_widget_preview.png new file mode 100644 index 0000000..144292e Binary files /dev/null and b/app/src/main/res/drawable-nodpi/easyycc_widget_preview.png differ diff --git a/app/src/main/res/drawable-nodpi/gradient.xml b/app/src/main/res/drawable-nodpi/gradient.xml new file mode 100644 index 0000000..42142be --- /dev/null +++ b/app/src/main/res/drawable-nodpi/gradient.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-nodpi/gradient_colour.xml b/app/src/main/res/drawable-nodpi/gradient_colour.xml new file mode 100644 index 0000000..6037c6c --- /dev/null +++ b/app/src/main/res/drawable-nodpi/gradient_colour.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-nodpi/round_edit_text.xml b/app/src/main/res/drawable-nodpi/round_edit_text.xml new file mode 100644 index 0000000..f0b8224 --- /dev/null +++ b/app/src/main/res/drawable-nodpi/round_edit_text.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..cb3b4c5 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/confirm_dialog.xml b/app/src/main/res/layout/confirm_dialog.xml new file mode 100644 index 0000000..d015cad --- /dev/null +++ b/app/src/main/res/layout/confirm_dialog.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/currency_app_widget.xml b/app/src/main/res/layout/currency_app_widget.xml new file mode 100644 index 0000000..05edee8 --- /dev/null +++ b/app/src/main/res/layout/currency_app_widget.xml @@ -0,0 +1,36 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/currency_app_widget_configure.xml b/app/src/main/res/layout/currency_app_widget_configure.xml new file mode 100644 index 0000000..451a8ed --- /dev/null +++ b/app/src/main/res/layout/currency_app_widget_configure.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_dialog.xml b/app/src/main/res/layout/custom_dialog.xml new file mode 100644 index 0000000..4da1fed --- /dev/null +++ b/app/src/main/res/layout/custom_dialog.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..1f3bf2a Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..1f3bf2a Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..57849c1 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..5c3a46e Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b5816aa Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..3adf9d8 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..57849c1 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..5c3a46e Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b5816aa Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..3adf9d8 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values-v14/dimens.xml b/app/src/main/res/values-v14/dimens.xml new file mode 100644 index 0000000..4db8c59 --- /dev/null +++ b/app/src/main/res/values-v14/dimens.xml @@ -0,0 +1,10 @@ + + + + + 0dp + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..3683cb2 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,12 @@ + + + #3F51B5 + #303F9F + #FF4081 + + #253031 + #315659 + #2978A0 + #8549ff + #C6E0FF + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..fdececf --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,10 @@ + + + + + 8dp + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..7167edf --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,163 @@ + + easyCC + + + ALL - Albanian Lek + AFN - Afghan Afghani + DZD - Algerian Dinar + AOA - Angolan Kwanza + ARS - Argentine Peso + AMD - Armenian Dram + AWG - Aruban Florin + AUD - Australian Dollar + AZN - Azerbaijani Manat + BSD - Bahamian Dollar + BHD - Bahraini Dinar + BDT - Bangladeshi Taka + BBD - Barbadian Dollar + BYR - Belarusian Ruble + BZD - Belize Dollar + BTN - Bhutanese Ngultrum + BTC - Bitcoin + BOB - Bolivian Boliviano + BAM - Bosnia And Herzegovina Konvertibilna Marka + BWP - Botswana Pula + BRL - Brazilian Real + GBP - British Pound + BND - Brunei Dollar + BGN - Bulgarian Lev + BIF - Burundi Franc + KHR - Cambodian Riel + CAD - Canadian Dollar + CVE - Cape Verdean Escudo + KYD - Cayman Islands Dollar + XAF - Central African CFA Franc + XPF - CFP Franc + CLP - Chilean Peso + CNY - Chinese Yuan + COP - Colombian Peso + KMF - Comorian Franc + CDF - Congolese Franc + CRC - Costa Rican Colon + HRK - Croatian Kuna + CUP - Cuban Peso + CZK - Czech Koruna + DKK - Danish Krone + DJF - Djiboutian Franc + DOP - Dominican Peso + XCD - East Caribbean Dollar + EGP - Egyptian Pound + ERN - Eritrean Nakfa + ETB - Ethiopian Birr + EUR - Euro + FKP - Falkland Islands Pound + FJD - Fijian Dollar + GMD - Gambian Dalasi + GEL - Georgian Lari + GHS - Ghanaian Cedi + GIP - Gibraltar Pound + GTQ - Guatemalan Quetzal + GNF - Guinean Franc + GYD - Guyanese Dollar + HTG - Haitian Gourde + HNL - Honduran Lempira + HKD - Hong Kong Dollar + HUF - Hungarian Forint + ISK - Icelandic Kr\u00f3na + INR - Indian Rupee + IDR - Indonesian Rupiah + IRR - Iranian Rial + IQD - Iraqi Dinar + ILS - Israeli New Sheqel + JMD - Jamaican Dollar + JPY - Japanese Yen + JOD - Jordanian Dinar + KZT - Kazakhstani Tenge + KES - Kenyan Shilling + KWD - Kuwaiti Dinar + KGS - Kyrgyzstani Som + LAK - Lao Kip + LVL - Latvian Lats + LBP - Lebanese Lira + LSL - Lesotho Loti + LRD - Liberian Dollar + LYD - Libyan Dinar + MOP - Macanese Pataca + MKD - Macedonian Denar + MGA - Malagasy Ariary + MWK - Malawian Kwacha + MYR - Malaysian Ringgit + MVR - Maldivian Rufiyaa + MRO - Mauritanian Ouguiya + MUR - Mauritian Rupee + MXN - Mexican Peso + MDL - Moldovan Leu + MNT - Mongolian Tugrik + MAD - Moroccan Dirham + MZN - Mozambican Metical + MMK - Myanma Kyat + NAD - Namibian Dollar + NPR - Nepalese Rupee + ANG - Netherlands Antillean Gulden + TWD - New Taiwan Dollar + NZD - New Zealand Dollar + NIO - Nicaraguan Cordoba + NGN - Nigerian Naira + KPW - North Korean Won + NOK - Norwegian Krone + OMR - Omani Rial + TOP - Paanga + PKR - Pakistani Rupee + PAB - Panamanian Balboa + PGK - Papua New Guinean Kina + PYG - Paraguayan Guarani + PEN - Peruvian Nuevo Sol + PHP - Philippine Peso + PLN - Polish Zloty + QAR - Qatari Riyal + RON - Romanian Leu + RUB - Russian Ruble + RWF - Rwandan Franc + SHP - Saint Helena Pound + WST - Samoan Tala + STD - Sao Tome And Principe Dobra + SAR - Saudi Riyal + RSD - Serbian Dinar + SCR - Seychellois Rupee + SLL - Sierra Leonean Leone + SGD - Singapore Dollar + SBD - Solomon Islands Dollar + SOS - Somali Shilling + ZAR - South African Rand + KRW - South Korean Won + XDR - Special Drawing Rights + LKR - Sri Lankan Rupee + SDG - Sudanese Pound + SRD - Surinamese Dollar + SZL - Swazi Lilangeni + SEK - Swedish Krona + CHF - Swiss Franc + SYP - Syrian Pound + TJS - Tajikistani Somoni + TZS - Tanzanian Shilling + THB - Thai Baht + TTD - Trinidad and Tobago Dollar + TND - Tunisian Dinar + TRY - Turkish New Lira + TMT - Turkmenistan Manat + AED - UAE Dirham + UGX - Ugandan Shilling + UAH - Ukrainian Hryvnia + USD - United States Dollar + UYU - Uruguayan Peso + UZS - Uzbekistani Som + VUV - Vanuatu Vatu + VEF - Venezuelan Bolivar + VND - Vietnamese Dong + XOF - West African CFA Franc + YER - Yemeni Rial + ZMW - Zambian Kwacha + + Configure + Add widget + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..17566b6 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,32 @@ + + + + + + + + + + diff --git a/app/src/main/res/xml/currency_app_widget_info.xml b/app/src/main/res/xml/currency_app_widget_info.xml new file mode 100644 index 0000000..8837ecc --- /dev/null +++ b/app/src/main/res/xml/currency_app_widget_info.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/app/src/test/java/com/appttude/h_mal/easycc/ExampleUnitTest.java b/app/src/test/java/com/appttude/h_mal/easycc/ExampleUnitTest.java new file mode 100644 index 0000000..c345ab4 --- /dev/null +++ b/app/src/test/java/com/appttude/h_mal/easycc/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.appttude.h_mal.easycc; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..55db43f --- /dev/null +++ b/build.gradle @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.1.4' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + google() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aac7c9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# 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. +org.gradle.jvmargs=-Xmx1536m + +# 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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f2b30ef --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Nov 04 16:25:28 AEST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -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 "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'