Commit e789fcf2 authored by fabio's avatar fabio

Initial release

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?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="/mnt/data/Documents/Programming/Android/AltcoinPrices" />
<option value="/mnt/data/Documents/Programming/Android/AltcoinPrices/Altcoin Prices" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<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="4">
<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="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" 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="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" 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>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file:///mnt/data/Documents/Programming/Android/AltcoinPrices/Altcoin Prices/Altcoin Prices.iml" filepath="/mnt/data/Documents/Programming/Android/AltcoinPrices/Altcoin Prices/Altcoin Prices.iml" />
<module fileurl="file:///mnt/data/Documents/Programming/Android/AltcoinPrices/AltcoinPrices.iml" filepath="/mnt/data/Documents/Programming/Android/AltcoinPrices/AltcoinPrices.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?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>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="/mnt/data/Documents/Programming/Android/AltcoinPrices" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "eu.uwot.fabio.altcoinprices"
minSdkVersion 21
targetSdkVersion 25
versionCode 0
versionName '0.3a'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/fabio/Programs/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
package eu.uwot.fabio.altcoinprices;
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 org.junit.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("eu.uwot.fabio.altcoinprices", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.uwot.fabio.altcoinprices">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="Settings"
android:parentActivityName=".MainActivity">
</activity>
</application>
</manifest>
\ No newline at end of file
package eu.uwot.fabio.altcoinprices;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
String URL0 = "<!-- TradingView Widget BEGIN -->\n" +
"<script type=\"text/javascript\" src=\"https://s3.tradingview.com/tv.js\"></script>\n" +
"<script type=\"text/javascript\">\n" +
"new TradingView.widget({\n" +
" \"autosize\": true,\n" +
" \"symbol\": \"KRAKEN:";
String URL1 = "\",\n" +
" \"interval\": ";
String URL2 = ",\n" +
" \"timezone\": \"Europe/Rome\",\n" +
" \"theme\": \"Light\",\n" +
" \"style\": \"1\",\n" +
" \"locale\": \"en\",\n" +
" \"toolbar_bg\": \"#f1f3f6\",\n" +
" \"enable_publishing\": false,\n" +
" \"withdateranges\": true,\n" +
" \"save_image\": false,\n" +
" \"hideideas\": true,\n" +
" \"studies\": [\n" +
" \"RSI@tv-basicstudies\"\n" +
" ]\n" +
"});\n" +
"</script>\n" +
"<!-- TradingView Widget END -->\n";
String currency;
String altcoin;
String period;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
/* load user settings */
SharedPreferences prefs =getApplicationContext().getSharedPreferences("Settings", 0);
SharedPreferences.Editor editor = prefs.edit();
this.currency = prefs.getString("currency", "EUR");
this.altcoin = prefs.getString("altcoin", "XMR");
this.period = prefs.getString("period", "30");
editor.commit();
/* end load user settings */
/* data from kraken.com */
String url = URL0 + this.altcoin + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
//CookieManager.getInstance().setAcceptCookie(true);
view.loadData(url, null, null);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
startActivity(new Intent(this, SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_xmr) {
saveLastState("XMR");
String url = URL0 + "XMR" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_xbt) {
saveLastState("XBT");
String url = URL0 + "XBT" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_bch) {
saveLastState("BCH");
String url = URL0 + "BCH" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_dash) {
saveLastState("DASH");
String url = URL0 + "DASH" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_eth) {
saveLastState("ETH");
String url = URL0 + "ETH" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_etc) {
saveLastState("ETC");
String url = URL0 + "ETC" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_ltc) {
saveLastState("LTC");
String url = URL0 + "LTC" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_rep) {
saveLastState("REP");
String url = URL0 + "REP" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_xrp) {
saveLastState("XRP");
String url = URL0 + "XRP" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_zec) {
saveLastState("ZEC");
String url = URL0 + "ZEC" + this.currency + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_eos) {
saveLastState("EOS");
String url = URL0 + "XMR" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_gno) {
saveLastState("GNO");
String url = URL0 + "GNO" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_icn) {
saveLastState("ICN");
String url = URL0 + "ICN" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_mln) {
saveLastState("MLN");
String url = URL0 + "MLN" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_xdg) {
saveLastState("XDG");
String url = URL0 + "XDG" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
} else if (id == R.id.nav_xlm) {
saveLastState("XLM");
String url = URL0 + "XLM" + "XBT" + URL1 + this.period + URL2;
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadData(url, null, null);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
private boolean saveLastState (String altcoin) {
SharedPreferences prefs = getApplicationContext().getSharedPreferences("Settings", 0); // 0 for private mode
SharedPreferences.Editor editor = prefs.edit();
editor.putString("altcoin", altcoin);
editor.commit();
return true;
}
}
package eu.uwot.fabio.altcoinprices;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
public class SettingsActivity extends AppCompatActivity {
SharedPreferences prefs;
SharedPreferences.Editor editor;
Switch currencySwitch;
String currency;
EditText periodInput;
String period;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
/* load user settings */
prefs = getApplicationContext().getSharedPreferences("Settings", 0); // 0 for private mode
editor = prefs.edit();
this.currency = prefs.getString("currency", "EUR");
this.period = prefs.getString("period", "30");
editor.commit();
/* end load user settings */
/* currency switch */
currencySwitch = (Switch) findViewById(R.id.currency_switch);
currencySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean bChecked) {
if (bChecked) {