Initial commit

This commit is contained in:
2019-02-23 14:08:10 +11:00
commit c1dc1ee96e
53 changed files with 2027 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

14
.idea/assetWizardSettings.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState />
</value>
</entry>
</map>
</option>
</component>
</project>

BIN
.idea/caches/build_file_checksums.ser generated Normal file

Binary file not shown.

29
.idea/codeStyles/Project.xml generated Normal file
View File

@@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

7
.idea/dictionaries/h_mal.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="h_mal">
<words>
<w>relevent</w>
</words>
</dictionary>
</component>

18
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

34
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

9
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Personal_Project---Currency_Converter-master.iml" filepath="$PROJECT_DIR$/Personal_Project---Currency_Converter-master.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>

12
.idea/runConfigurations.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

1
app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

30
app/build.gradle Normal file
View File

@@ -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'
}

25
app/proguard-rules.pro vendored Normal file
View File

@@ -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

BIN
app/release/app-release.apk Normal file

Binary file not shown.

1
app/release/output.json Normal file
View File

@@ -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":{}}]

View File

@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appttude.h_mal.easycc">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.appttude.h_mal.easycc.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.appttude.h_mal.easycc.CurrencyAppWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/currency_app_widget_info" />
</receiver>
<activity android:name="com.appttude.h_mal.easycc.CurrencyAppWidgetConfigureActivity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -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<String, Void, Double> {
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;
}
}
}

View File

@@ -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<CharSequence> 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) {
}
}
}

View File

@@ -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<String, Void, Double> {
@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<CharSequence> 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;
}
}

View File

@@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#b3001b"
android:endColor="#262626"
android:type="linear"
android:angle="45"/>
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/colour_three"
android:endColor="@color/colour_two"
android:type="linear"
android:angle="45"/>
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="@color/colour_two" />
<corners
android:bottomRightRadius="22dp"
android:bottomLeftRadius="22dp"
android:topLeftRadius="22dp"
android:topRightRadius="22dp" />
</shape>

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:focusable="false"
android:focusableInTouchMode="true"
tools:context="com.appttude.h_mal.easycc.MainActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="12dp">
<LinearLayout
android:id="@+id/whole_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
android:orientation="vertical">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
style="@style/cardview_theme">
<TextView
android:id="@+id/currency_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="Currency One"
android:textColor="@color/colour_five"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:background="@drawable/round_edit_text"
android:ems="10"
android:hint="insert value one"
android:textColorHighlight="#608d91"
android:inputType="numberDecimal"
android:padding="12dp"
android:selectAllOnFocus="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
style="@style/cardview_theme">
<TextView
android:id="@+id/currency_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="Currency Two"
android:textColor="@color/colour_five"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_weight="7"
android:background="@drawable/round_edit_text"
android:ems="10"
android:hint="insert value two"
android:textColorHighlight="#608d91"
android:inputType="numberDecimal"
android:padding="12dp"
android:selectAllOnFocus="true" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateTint="@color/colour_four"
android:indeterminateTintMode="src_atop" />
</RelativeLayout>
</RelativeLayout>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@android:color/transparent"
android:orientation="vertical">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@color/colour_three"
card_view:cardCornerRadius="22dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/confirm_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="Create widget for AUDGBP?"
android:textColor="@color/colour_five" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="horizontal">
<TextView
android:id="@+id/confirm_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@android:string/yes"
android:textColor="@color/colour_five" />
<TextView
android:id="@+id/confirm_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@android:string/no"
android:textColor="@color/colour_five" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View File

@@ -0,0 +1,36 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/widget_view"
android:layout_width="match_parent"
android:layout_height="72dp"
android:orientation="vertical">
<TextView
android:id="@+id/exchangeName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="3dp"
android:layout_weight="1"
android:autoSizeMaxTextSize="100sp"
android:autoSizeMinTextSize="8sp"
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:gravity="center"
android:textColor="#ffffff"
tools:text="AUDGBP" />
<TextView
android:id="@+id/exchangeRate"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:autoSizeMaxTextSize="100sp"
android:autoSizeMinTextSize="6sp"
android:autoSizeStepGranularity="2sp"
android:autoSizeTextType="uniform"
android:gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
tools:text="0.56" />
</LinearLayout>

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/whole_view">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
style="@style/cardview_theme"
android:layout_margin="11dp">
<TextView
android:id="@+id/currency_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="Currency One"
android:textColor="@color/colour_five"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
style="@style/cardview_theme"
android:layout_margin="11dp">
<TextView
android:id="@+id/currency_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="Currency Two"
android:textColor="@color/colour_five"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
<TextView
android:layout_marginTop="12dp"
android:layout_marginRight="22dp"
android:id="@+id/submit_widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/whole_view"
android:layout_alignParentRight="true"
android:textColor="@color/colour_five"
android:text="Submit" />
</RelativeLayout>
</RelativeLayout>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@android:color/transparent"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent"
card_view:cardCornerRadius="22dp"
card_view:cardBackgroundColor="@color/colour_three"
android:layout_marginTop="45dp">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="45dp"
android:layout_marginTop="20dp"
card_view:cardBackgroundColor="@color/colour_three"
card_view:cardCornerRadius="22dp">
<EditText
android:id="@+id/search_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:hint="Search Currency" />
</android.support.v7.widget.CardView>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">0dp</dimen>
</resources>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colour_one">#253031</color>
<color name="colour_two">#315659</color>
<color name="colour_three">#2978A0</color>
<color name="colour_four">#8549ff</color>
<color name="colour_five">#C6E0FF</color>
</resources>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">8dp</dimen>
</resources>

View File

@@ -0,0 +1,163 @@
<resources>
<string name="app_name">easyCC</string>
<string-array name="currency_arrays">
<item>ALL - Albanian Lek</item>
<item>AFN - Afghan Afghani</item>
<item>DZD - Algerian Dinar</item>
<item>AOA - Angolan Kwanza</item>
<item>ARS - Argentine Peso</item>
<item>AMD - Armenian Dram</item>
<item>AWG - Aruban Florin</item>
<item>AUD - Australian Dollar</item>
<item>AZN - Azerbaijani Manat</item>
<item>BSD - Bahamian Dollar</item>
<item>BHD - Bahraini Dinar</item>
<item>BDT - Bangladeshi Taka</item>
<item>BBD - Barbadian Dollar</item>
<item>BYR - Belarusian Ruble</item>
<item>BZD - Belize Dollar</item>
<item>BTN - Bhutanese Ngultrum</item>
<item>BTC - Bitcoin</item>
<item>BOB - Bolivian Boliviano</item>
<item>BAM - Bosnia And Herzegovina Konvertibilna Marka</item>
<item>BWP - Botswana Pula</item>
<item>BRL - Brazilian Real</item>
<item>GBP - British Pound</item>
<item>BND - Brunei Dollar</item>
<item>BGN - Bulgarian Lev</item>
<item>BIF - Burundi Franc</item>
<item>KHR - Cambodian Riel</item>
<item>CAD - Canadian Dollar</item>
<item>CVE - Cape Verdean Escudo</item>
<item>KYD - Cayman Islands Dollar</item>
<item>XAF - Central African CFA Franc</item>
<item>XPF - CFP Franc</item>
<item>CLP - Chilean Peso</item>
<item>CNY - Chinese Yuan</item>
<item>COP - Colombian Peso</item>
<item>KMF - Comorian Franc</item>
<item>CDF - Congolese Franc</item>
<item>CRC - Costa Rican Colon</item>
<item>HRK - Croatian Kuna</item>
<item>CUP - Cuban Peso</item>
<item>CZK - Czech Koruna</item>
<item>DKK - Danish Krone</item>
<item>DJF - Djiboutian Franc</item>
<item>DOP - Dominican Peso</item>
<item>XCD - East Caribbean Dollar</item>
<item>EGP - Egyptian Pound</item>
<item>ERN - Eritrean Nakfa</item>
<item>ETB - Ethiopian Birr</item>
<item>EUR - Euro</item>
<item>FKP - Falkland Islands Pound</item>
<item>FJD - Fijian Dollar</item>
<item>GMD - Gambian Dalasi</item>
<item>GEL - Georgian Lari</item>
<item>GHS - Ghanaian Cedi</item>
<item>GIP - Gibraltar Pound</item>
<item>GTQ - Guatemalan Quetzal</item>
<item>GNF - Guinean Franc</item>
<item>GYD - Guyanese Dollar</item>
<item>HTG - Haitian Gourde</item>
<item>HNL - Honduran Lempira</item>
<item>HKD - Hong Kong Dollar</item>
<item>HUF - Hungarian Forint</item>
<item>ISK - Icelandic Kr\u00f3na</item>
<item>INR - Indian Rupee</item>
<item>IDR - Indonesian Rupiah</item>
<item>IRR - Iranian Rial</item>
<item>IQD - Iraqi Dinar</item>
<item>ILS - Israeli New Sheqel</item>
<item>JMD - Jamaican Dollar</item>
<item>JPY - Japanese Yen</item>
<item>JOD - Jordanian Dinar</item>
<item>KZT - Kazakhstani Tenge</item>
<item>KES - Kenyan Shilling</item>
<item>KWD - Kuwaiti Dinar</item>
<item>KGS - Kyrgyzstani Som</item>
<item>LAK - Lao Kip</item>
<item>LVL - Latvian Lats</item>
<item>LBP - Lebanese Lira</item>
<item>LSL - Lesotho Loti</item>
<item>LRD - Liberian Dollar</item>
<item>LYD - Libyan Dinar</item>
<item>MOP - Macanese Pataca</item>
<item>MKD - Macedonian Denar</item>
<item>MGA - Malagasy Ariary</item>
<item>MWK - Malawian Kwacha</item>
<item>MYR - Malaysian Ringgit</item>
<item>MVR - Maldivian Rufiyaa</item>
<item>MRO - Mauritanian Ouguiya</item>
<item>MUR - Mauritian Rupee</item>
<item>MXN - Mexican Peso</item>
<item>MDL - Moldovan Leu</item>
<item>MNT - Mongolian Tugrik</item>
<item>MAD - Moroccan Dirham</item>
<item>MZN - Mozambican Metical</item>
<item>MMK - Myanma Kyat</item>
<item>NAD - Namibian Dollar</item>
<item>NPR - Nepalese Rupee</item>
<item>ANG - Netherlands Antillean Gulden</item>
<item>TWD - New Taiwan Dollar</item>
<item>NZD - New Zealand Dollar</item>
<item>NIO - Nicaraguan Cordoba</item>
<item>NGN - Nigerian Naira</item>
<item>KPW - North Korean Won</item>
<item>NOK - Norwegian Krone</item>
<item>OMR - Omani Rial</item>
<item>TOP - Paanga</item>
<item>PKR - Pakistani Rupee</item>
<item>PAB - Panamanian Balboa</item>
<item>PGK - Papua New Guinean Kina</item>
<item>PYG - Paraguayan Guarani</item>
<item>PEN - Peruvian Nuevo Sol</item>
<item>PHP - Philippine Peso</item>
<item>PLN - Polish Zloty</item>
<item>QAR - Qatari Riyal</item>
<item>RON - Romanian Leu</item>
<item>RUB - Russian Ruble</item>
<item>RWF - Rwandan Franc</item>
<item>SHP - Saint Helena Pound</item>
<item>WST - Samoan Tala</item>
<item>STD - Sao Tome And Principe Dobra</item>
<item>SAR - Saudi Riyal</item>
<item>RSD - Serbian Dinar</item>
<item>SCR - Seychellois Rupee</item>
<item>SLL - Sierra Leonean Leone</item>
<item>SGD - Singapore Dollar</item>
<item>SBD - Solomon Islands Dollar</item>
<item>SOS - Somali Shilling</item>
<item>ZAR - South African Rand</item>
<item>KRW - South Korean Won</item>
<item>XDR - Special Drawing Rights</item>
<item>LKR - Sri Lankan Rupee</item>
<item>SDG - Sudanese Pound</item>
<item>SRD - Surinamese Dollar</item>
<item>SZL - Swazi Lilangeni</item>
<item>SEK - Swedish Krona</item>
<item>CHF - Swiss Franc</item>
<item>SYP - Syrian Pound</item>
<item>TJS - Tajikistani Somoni</item>
<item>TZS - Tanzanian Shilling</item>
<item>THB - Thai Baht</item>
<item>TTD - Trinidad and Tobago Dollar</item>
<item>TND - Tunisian Dinar</item>
<item>TRY - Turkish New Lira</item>
<item>TMT - Turkmenistan Manat</item>
<item>AED - UAE Dirham</item>
<item>UGX - Ugandan Shilling</item>
<item>UAH - Ukrainian Hryvnia</item>
<item>USD - United States Dollar</item>
<item>UYU - Uruguayan Peso</item>
<item>UZS - Uzbekistani Som</item>
<item>VUV - Vanuatu Vatu</item>
<item>VEF - Venezuelan Bolivar</item>
<item>VND - Vietnamese Dong</item>
<item>XOF - West African CFA Franc</item>
<item>YER - Yemeni Rial</item>
<item>ZMW - Zambian Kwacha</item>
</string-array>
<string name="configure">Configure</string>
<string name="add_widget">Add widget</string>
</resources>

View File

@@ -0,0 +1,32 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colour_two</item>
<item name="colorPrimaryDark">@color/colour_two</item>
<item name="colorAccent">@color/colour_two</item>
<item name="android:windowBackground">@drawable/gradient_colour</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:editTextColor">@color/colour_five</item>
<item name="android:textColorPrimary">@color/colour_five</item>
</style>
<style name="cardview_theme" parent="CardView">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="cardBackgroundColor">@color/colour_three</item>
<item name="cardCornerRadius">22dp</item>
<!--<item name="cardElevation">0dp</item>-->
</style>
<style name="edittext_theme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:ems">10</item>
<item name="android:inputType">numberDecimal</item>
<item name="android:selectAllOnFocus">true</item>
</style>
</resources>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="com.appttude.h_mal.easycc.CurrencyAppWidgetConfigureActivity"
android:initialKeyguardLayout="@layout/currency_app_widget"
android:initialLayout="@layout/currency_app_widget"
android:minHeight="40dp"
android:minWidth="110dp"
android:minResizeHeight="40dp"
android:minResizeWidth="40dp"
android:previewImage="@drawable/easyycc_widget_preview"
android:resizeMode="horizontal"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen">
</appwidget-provider>

View File

@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

25
build.gradle Normal file
View File

@@ -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
}

17
gradle.properties Normal file
View File

@@ -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

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -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

160
gradlew vendored Normal file
View File

@@ -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 "$@"

90
gradlew.bat vendored Normal file
View File

@@ -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

1
settings.gradle Normal file
View File

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