Skip to content

Commit

Permalink
Merge pull request #1 from D3nn7/v0.2
Browse files Browse the repository at this point in the history
v0.2:
  - Darkmode fixed
  - Binance Button fixed
  - Offlinemode fixed
  - Disabled APP Rotation.
  - add custom amount of Dogecoin feature
  • Loading branch information
D3nn7 authored Apr 17, 2021
2 parents 7c5be96 + b926f6b commit da8f229
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ Dogecoin Price is an Android app that allows you to see the current Dogecoin pri

### Versions

- [v0.2](https://github.com/D3nn7/Dogecoin-Price-Android/releases/tag/v0.2)
- Darkmode fixed
- Binance Button fixed
- Offlinemode fixed
- Disabled APP Rotation.
- add custom amount of Dogecoin feature
- [v0.1](https://github.com/D3nn7/Dogecoin-Price-Android/releases/tag/v0.1) UI & Basic funcionality

## License – Much license ⚖️
Dogecoin Price is released under the terms of the MIT license. See
[opensource.org](https://opensource.org/licenses/MIT)

## Special Thanks to️
- [Dogecoin](https://dogecoin.com) for the best Coin i ever seen.
- [Binance](https://binance.com) for current price data.
- [FontAwesome](https://fontawesome.com) for the icons. [License](https://fontawesome.com/license)
- [Volley Library](https://github.com/google/volley) for the HTTP Libary. [License](https://github.com/google/volley/blob/master/LICENSE)
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CryptKurs">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.danny.cryptkurs.InfoActivity" android:parentActivityName="com.danny.cryptkurs.MainActivity"/>
<activity android:name="com.danny.cryptkurs.OfflineActivity" android:parentActivityName="com.danny.cryptkurs.MainActivity"/>
<activity android:name="com.danny.cryptkurs.InfoActivity" android:screenOrientation="portrait" android:parentActivityName="com.danny.cryptkurs.MainActivity"/>
<activity android:name="com.danny.cryptkurs.OfflineActivity" android:screenOrientation="portrait" android:parentActivityName="com.danny.cryptkurs.MainActivity"/>
</application>

</manifest>
130 changes: 120 additions & 10 deletions app/src/main/java/com/danny/cryptkurs/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package com.danny.cryptkurs;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
Expand All @@ -26,18 +30,43 @@
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {

SharedPreferences preferences = null;
String storedDoge = "1";
TextView DogeAmount = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

DogeAmount = (TextView)findViewById(R.id.doge);
RelativeLayout BuyBTN =(RelativeLayout)findViewById(R.id.buyBTN);
LinearLayout changeDogeAmount =(LinearLayout)findViewById(R.id.doge_container);

preferences = getSharedPreferences("com.danny.cryptkurs", 0);
if (preferences.getBoolean("firstrun", true)) {

SharedPreferences.Editor preferencesEditor = preferences.edit();
preferencesEditor.putString("AMOUNT", "1");
preferencesEditor.apply();

preferences.edit().putBoolean("firstrun", false).apply();
} else {
preferences = getSharedPreferences("com.danny.cryptkurs", 0);
storedDoge = preferences.getString("AMOUNT", "1");
}


DogeAmount.setText(storedDoge);

BuyBTN.setOnClickListener(new View.OnClickListener(){
@Override
Expand All @@ -49,16 +78,64 @@ public void onClick(View v){
}
});

changeDogeAmount.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
changeDoge();
}
});

content();

}

private void changeDoge()
{
preferences = getSharedPreferences("com.danny.cryptkurs", 0);
String getAmount = preferences.getString("AMOUNT", "1");

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.set_doge_message);
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.setRawInputType(Configuration.KEYBOARD_12KEY);
input.setText(getAmount);
builder.setView(input);
builder.setPositiveButton(R.string.set, new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog,int id){
String newDogeAmount = input.getText().toString();

SharedPreferences.Editor preferencesEditor = preferences.edit();
preferencesEditor.putString("AMOUNT", newDogeAmount);
preferencesEditor.apply();

String getNewAmount = preferences.getString("AMOUNT", "1");
DogeAmount = (TextView)findViewById(R.id.doge);
DogeAmount.setText(getNewAmount);

dialog.dismiss();
content();
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
if(dialog!=null){
dialog.dismiss();
}
}
});

AlertDialog alertDialog=builder.create();
alertDialog.show();
}

private void content()
{
getDogePrice("https://api.binance.com/api/v3/ticker/price?symbol=DOGEEUR");
getDogePrice("https://api.binance.com/api/v3/ticker/price?symbol=DOGEBUSD");
getDogePrice("https://api.binance.com/api/v3/ticker/price?symbol=DOGEBTC");
refresh(15000);
refresh(8000);
}

private void refresh(int milliseconds)
Expand Down Expand Up @@ -89,6 +166,7 @@ public void onResponse(String string) {
public void onErrorResponse(VolleyError volleyError) {
if (volleyError instanceof NetworkError) {
setErrorIntent();

} else {
Toast.makeText(getApplicationContext(), "can't get data...", Toast.LENGTH_SHORT).show();
}
Expand All @@ -103,6 +181,7 @@ private void setErrorIntent()
{
Intent offlineIntent = new Intent(this, OfflineActivity.class);
startActivity(offlineIntent);
finish();
}

public void parseJsonData(String jsonString) {
Expand All @@ -111,18 +190,29 @@ public void parseJsonData(String jsonString) {
String currencyPrice = object.getString("price");
String currencySymbol = object.getString("symbol");

preferences = getSharedPreferences("com.danny.cryptkurs", 0);
storedDoge = preferences.getString("AMOUNT", "1");

DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
df.setMaximumFractionDigits(340);
String calculateCurrencyPrice = df.format(Double.parseDouble(currencyPrice) * Integer.parseInt(storedDoge));
String calculatedPrice = null;

switch (currencySymbol) {
case "DOGEEUR":
calculatedPrice = round(calculateCurrencyPrice, false);
TextView DogeEuroTextView = (TextView) findViewById(R.id.euroPrice);
DogeEuroTextView.setText(currencyPrice);
DogeEuroTextView.setText(calculatedPrice);
break;
case "DOGEBTC":
calculatedPrice = round(calculateCurrencyPrice, true);
TextView DogeBTCTextView = (TextView) findViewById(R.id.btcPrice);
DogeBTCTextView.setText(currencyPrice);
DogeBTCTextView.setText(calculatedPrice);
break;
case "DOGEBUSD":
calculatedPrice = round(calculateCurrencyPrice, false);
TextView DogeBUSDTextView = (TextView) findViewById(R.id.usdPrice);
DogeBUSDTextView.setText(currencyPrice);
DogeBUSDTextView.setText(calculatedPrice);
break;
default:
break;
Expand All @@ -132,6 +222,26 @@ public void parseJsonData(String jsonString) {
}
}

private String round(String stringValue, boolean isBTC) {
double value = Double.parseDouble(stringValue);

if (isBTC) {
value = value * 10000000;
value = (int) value;
value = (double) value / 10000000;
} else {
value = value * 1000;
value = (int) value;
value = (double) value / 1000;
}

DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
df.setMaximumFractionDigits(340);
String result = df.format(value);

return result;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.doge_info, menu);
Expand Down
Binary file added app/src/main/res/drawable/pen_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 23 additions & 1 deletion app/src/main/res/layout/activity_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/links"
android:id="@+id/thirdparty"
android:layout_marginTop="20dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<TextView
android:id="@+id/third_party"
Expand Down Expand Up @@ -139,5 +139,27 @@
android:textSize="17sp" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/version"
android:layout_marginStart="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/current_version"
android:layout_marginStart="5dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Loading

0 comments on commit da8f229

Please sign in to comment.