Commit 704faad6 authored by cfabio's avatar cfabio

Add ability to choose which indicators to display and fix some minor UI glitches

parent 491db3b5
......@@ -7,8 +7,8 @@ android {
applicationId "eu.uwot.fabio.altcoinprices"
minSdkVersion 14
targetSdkVersion 27
versionCode 53
versionName '1.5.12'
versionCode 54
versionName '1.5.13'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
......
......@@ -24,63 +24,80 @@ class GraphUrl {
" \"enable_publishing\": false,\n" +
" \"withdateranges\": true,\n" +
" \"save_image\": false,\n" +
" \"hideideas\": true,\n" +
" \"studies\": [\n" +
" \"BB@tv-basicstudies\",\n" +
" \"RSI@tv-basicstudies\"\n" +
" ]\n" +
"});\n" +
" \"hideideas\": true,\n";
private final String URL4 = "});\n" +
"</script>\n" +
"<!-- TradingView Widget END -->\n";
private final Context context;
private SharedPreferences prefs;
public GraphUrl(Context context) {
this.context = context.getApplicationContext();
prefs = context.getSharedPreferences("Settings", 0);
}
public String getUrl(String altcoinName) {
SharedPreferences prefs = context.getApplicationContext().getSharedPreferences("Settings", 0);
Coin coin = new Coin(context, true);
String period = prefs.getString("period", "30");
String exchange = coin.getCoinExchange(altcoinName);
/*String currency = prefs.getString("currency", "EUR");
if (currency.equals("BTC")) {
currency = "USD";
}*/
String currency = "USD";
String timezone = prefs.getString("timezone", "Etc/UTC");
String url;
String indicators = getIndicators();
switch (altcoinName) {
case "BTCUSD":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
case "ETHUSD":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
case "BTC":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
case "BCH":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
case "ETH":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
case "LTC":
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + currency + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
default:
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + coin.coinsLabelGraph.get(altcoinName) + URL1 + period + URL2 + timezone + URL3;
url = URL0 + exchange + ":" + altcoinName.toUpperCase() + coin.coinsLabelGraph.get(altcoinName) + URL1 + period + URL2 + timezone + URL3 + indicators + URL4;
break;
}
return url;
}
private String getIndicators() {
String res = "";
boolean bollingerBandsStatus = prefs.getBoolean("bollingerBandsStatus", false);
boolean macdCheckBoxStatus = prefs.getBoolean("macdCheckBoxStatus", false);
boolean ichimokuCheckBoxStatus = prefs.getBoolean("ichimokuCheckBoxStatus", false);
boolean rsiCheckBoxStatus = prefs.getBoolean("rsiCheckBoxStatus", false);
if (bollingerBandsStatus) {
res += " \"BB@tv-basicstudies\",\n";
}
if (macdCheckBoxStatus) {
res += " \"MACD@tv-basicstudies\",\n";
}
if (ichimokuCheckBoxStatus) {
res += " \"IchimokuCloud@tv-basicstudies\",\n";
}
if (rsiCheckBoxStatus) {
res += " \"RSI@tv-basicstudies\",\n";
}
if (!res.equals("")) {
res = " \"studies\": [\n" + res + "\n],";
}
return res;
}
}
......@@ -13,6 +13,7 @@ import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
......@@ -39,6 +40,14 @@ public class SettingsActivity extends AppCompatActivity implements AdapterView.O
private String timezone;
private final String DEFAULT_PERIOD = "60";
private final String DEFAULT_TIMEZONE = "Etc/UTC";
private CheckBox bollingerBandsCheckBox;
private boolean bollingerBandsStatus;
private CheckBox macdCheckBox;
private boolean macdCheckBoxStatus;
private CheckBox ichimokuCheckBox;
private boolean ichimokuCheckBoxStatus;
private CheckBox rsiCheckBox;
private boolean rsiCheckBoxStatus;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -51,6 +60,10 @@ public class SettingsActivity extends AppCompatActivity implements AdapterView.O
currency = prefs.getString("currency", "EUR");
this.period = prefs.getString("period", DEFAULT_PERIOD);
this.timezone = prefs.getString("timezone", DEFAULT_TIMEZONE);
this.bollingerBandsStatus = prefs.getBoolean("bollingerBandsStatus", false);
this.macdCheckBoxStatus = prefs.getBoolean("macdCheckBoxStatus", false);
this.ichimokuCheckBoxStatus = prefs.getBoolean("ichimokuCheckBoxStatus", false);
this.rsiCheckBoxStatus = prefs.getBoolean("rsiCheckBoxStatus", false);
// set currency //
currencySpinner = findViewById(R.id.currencySpinner);
......@@ -100,6 +113,66 @@ public class SettingsActivity extends AppCompatActivity implements AdapterView.O
int timezoneSpinnerPosition = timezoneAdapter.getPosition(timezoneSpinnerLabel);
timezoneSpinner.setSelection(timezoneSpinnerPosition);
// select indicators //
bollingerBandsCheckBox = findViewById(R.id.bollingerBandsCheckBox);
bollingerBandsCheckBox.setChecked(bollingerBandsStatus);
bollingerBandsCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bollingerBandsCheckBox.isChecked()) {
editor.putBoolean("bollingerBandsStatus", true);
} else {
editor.putBoolean("bollingerBandsStatus", false);
}
editor.apply();
}
});
macdCheckBox = findViewById(R.id.macdCheckBox);
macdCheckBox.setChecked(macdCheckBoxStatus);
macdCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (macdCheckBox.isChecked()) {
editor.putBoolean("macdCheckBoxStatus", true);
} else {
editor.putBoolean("macdCheckBoxStatus", false);
}
editor.apply();
}
});
ichimokuCheckBox = findViewById(R.id.ichimokuCheckBox);
ichimokuCheckBox.setChecked(ichimokuCheckBoxStatus);
ichimokuCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ichimokuCheckBox.isChecked()) {
editor.putBoolean("ichimokuCheckBoxStatus", true);
} else {
editor.putBoolean("ichimokuCheckBoxStatus", false);
}
editor.apply();
}
});
rsiCheckBox = findViewById(R.id.rsiCheckBox);
rsiCheckBox.setChecked(rsiCheckBoxStatus);
rsiCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rsiCheckBox.isChecked()) {
editor.putBoolean("rsiCheckBoxStatus", true);
} else {
editor.putBoolean("rsiCheckBoxStatus", false);
}
editor.apply();
}
});
// importSettings - open file picker and select file to import data from //
TextView importSettings = findViewById(R.id.importSettings);
importSettings.setOnClickListener(new View.OnClickListener() {
......@@ -216,7 +289,7 @@ public class SettingsActivity extends AppCompatActivity implements AdapterView.O
else if (v instanceof String)
editor.putString(key, ((String) v));
}
editor.commit();
editor.apply();
return true;
} catch (FileNotFoundException e) {
e.printStackTrace();
......
......@@ -10,6 +10,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="4dp"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
......@@ -19,7 +20,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -10,6 +10,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="4dp"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
......@@ -18,7 +19,7 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -9,21 +9,24 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginTop="0dp">
<TextView
<TextView
android:id="@+id/currencyDescription"
android:layout_width="0dp"
android:layout_height="50dp"
......@@ -36,7 +39,8 @@
android:textAppearance="@style/TextAppearance.AppCompat"
android:textColor="@color/colorTextSeconday"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="8dp" />
<Spinner
android:id="@+id/currencySpinner"
......@@ -69,7 +73,8 @@
android:textAppearance="@style/TextAppearance.AppCompat"
android:textColor="@color/colorTextSeconday"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/separator0" />
app:layout_constraintTop_toBottomOf="@+id/separator0"
android:layout_marginStart="8dp" />
<Spinner
android:id="@+id/periodSpinner"
......@@ -102,7 +107,8 @@
android:textAppearance="@style/TextAppearance.AppCompat"
android:textColor="@color/colorTextSeconday"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/separator1" />
app:layout_constraintTop_toBottomOf="@+id/separator1"
android:layout_marginStart="8dp" />
<Spinner
android:id="@+id/timezoneSpinner"
......@@ -116,13 +122,71 @@
app:layout_constraintTop_toBottomOf="@+id/separator1" />
<View
android:id="@+id/separator2"
android:id="@+id/separator12"
style="@style/HorizontalDivider"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/timezoneDescription" />
<CheckBox
android:id="@+id/bollingerBandsCheckBox"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/bollingerBandsCheckBox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indicatorsDescription" />
<CheckBox
android:id="@+id/macdCheckBox"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/macdCheckBox"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indicatorsDescription" />
<CheckBox
android:id="@+id/ichimokuCheckBox"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/ichimokuCheckBox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bollingerBandsCheckBox" />
<CheckBox
android:id="@+id/rsiCheckBox"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/rsiCheckBox"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/macdCheckBox" />
<View
android:id="@+id/separator2"
style="@style/HorizontalDivider"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ichimokuCheckBox" />
<TextView
android:id="@+id/importSettings"
android:layout_width="wrap_content"
......@@ -206,6 +270,20 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/aboutTitle" />
<TextView
android:id="@+id/indicatorsDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/indicatorsTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/separator12" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
......
......@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:gravity="left"
android:textSize="16sp"
android:gravity="start"
android:textColor="@color/colorTextMain"
android:padding="5dip" />
......@@ -63,6 +63,12 @@
<string name="skip">Skip</string>
<string name="indicatorsTitle">Indicators</string>
<string name="bollingerBandsCheckBox">Bollinger Bands</string>
<string name="macdCheckBox">MACD</string>
<string name="ichimokuCheckBox">Ichimoku Cloud</string>
<string name="rsiCheckBox">RSI</string>
<string-array name="currencyArray">
<item>EUR</item>
<item>USD</item>
......
# CHANGELOG
### Version 1.5.13
* Add ability to choose which indicators to display and fix some minor UI glitches
### Version 1.5.12
* Bugfix, change app icon and add option to modify portfolio item's bought time
......
......@@ -3,10 +3,10 @@
Altcoin Prices is the first and only FLOSS
(Free Libre Open Source Software) GPLv3 licensed cryptocurrency
portfolio management app for Android.
Altcoin Prices do not rely on any central infrastucture, data are
Altcoin Prices does not rely on any central infrastucture, data are
gathered directly and anonymously from public sources like
(cryptocompare, coinmarketcap, etc).
Users data never leave the device, the app do not include any tracking
cryptocompare, coinmarketcap, etc.
Users data never leave the device, the app does not include any tracking
or malicious library or component, both in its literal sense and as in
freedom restricting.
All the most important coins are supported and new ones are added every
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment