Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/.idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 1 addition & 0 deletions app/.idea/gradle.xml

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

92 changes: 77 additions & 15 deletions app/.idea/workspace.xml

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

4 changes: 2 additions & 2 deletions app/src/main/java/com/brian/stocks/home/CashFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
private void showAlert() {
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setIcon(R.mipmap.ic_launcher_round)
.setTitle("Alert")
.setMessage("Coming soon")
.setTitle("Coming soon")
.setMessage(" Make sure no one can access")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
31 changes: 27 additions & 4 deletions app/src/main/java/com/brian/stocks/home/CoinsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -82,6 +83,7 @@ public class CoinsFragment extends Fragment {
private Socket mSocket;
private String mOnramperApikey;
private String onRamperCoins="";
private String xanpoolApikey;

{
try {
Expand Down Expand Up @@ -147,14 +149,18 @@ public void OnDeposit(int position) {
}

@Override
public void OnRamp(final int position) {
public void OnBuyNow(final int position) {
final CoinInfo coin = coinList.get(position);
CoinSymbol = coin.getCoinSymbol();
CoinId = coin.getCoinId();
if(coin.getBuyNowOption() == 2) { // btc, eth, usdc, dai
if(coin.getBuyNowOption() >= 2) { // btc, eth, usdc, dai
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
View view = getLayoutInflater().inflate(R.layout.dialog_coin_buy_option, null);
final RadioGroup coinRdg = view.findViewById(R.id.coin_rdg);
if(coin.getBuyNowOption() == 2) {
RadioButton rdb3 = view.findViewById(R.id.coin_rdb_3);
rdb3.setVisibility(View.GONE);
}
alert.setView(view)
.setIcon(R.mipmap.ic_launcher_round)
.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
Expand All @@ -164,6 +170,7 @@ public void onClick(DialogInterface dialog, int which) {
if (coinRdg.getCheckedRadioButtonId() == R.id.coin_rdb_1)
doGenerateWalletAddress("", 1); // ramp
else if(coinRdg.getCheckedRadioButtonId() == R.id.coin_rdb_2)doGenerateWalletAddress("", 2); // onramp
else if(coinRdg.getCheckedRadioButtonId() == R.id.coin_rdb_3)doGenerateWalletAddress("", 3); // xanpool
else {
Toast.makeText(getContext(), "Please select option", Toast.LENGTH_SHORT).show();
return;
Expand Down Expand Up @@ -232,7 +239,7 @@ public void onClick(DialogInterface dialog, int id) {
}

private void showWalletAddressDialog(JSONObject data) {
if (data.has("deposit_amount")) {
if (CoinSymbol.equals("XMT")) {
DepositERC20Dialog DepositDialogERC20;
DepositDialogERC20 = new DepositERC20Dialog(R.layout.fragment_coin_deposit_erc20, data, CoinSymbol);
DepositDialogERC20.setListener(new DepositERC20Dialog.Listener() {
Expand Down Expand Up @@ -343,6 +350,7 @@ public void onResponse(JSONObject response) {
mTotalEffect.setText(response.getString("total_effect")+" %");
mUSDBalance.setText(response.getString("usd_balance"));
mOnramperApikey = response.getString("onramper_api_key");
xanpoolApikey = response.getString("xanpool_api_key");
if(response.getString("total_effect").startsWith("-"))
mTotalEffect.setTextColor(RED);
else mTotalEffect.setTextColor(GREEN);
Expand Down Expand Up @@ -422,14 +430,29 @@ else if(type == 1){
// "https://ri-widget-staging-ropsten.firebaseapp.com/"
);
rampInstantSDK.show();
} else {
} else if(type == 2){
String coin_address = CoinSymbol+":["+address+"]";
String excludeCryptos = "&excludeCryptos=EOS,USDT,XLM,BUSD,GUSD,HUSD,PAX,USDS";
String url = "https://widget.onramper.dev?color=1d2d50&apiKey="+mOnramperApikey+"&defaultCrypto="+CoinSymbol+excludeCryptos+"&defaultAddrs="+coin_address+"&onlyCryptos="+onRamperCoins;
Intent browserIntent = new Intent(getActivity(), WebViewActivity.class);
browserIntent.putExtra("uri", url);
startActivity(browserIntent);
}
else if(type == 3){ //xanpool
String base = "https://checkout.xanpool.com/";
String apikey = "?apiKey="+xanpoolApikey;
String wallet = "&wallet=" + address;
String cryptoCurrency = "&cryptoCurrency=" + CoinSymbol;
String transactionType = "&transactionType=buy";
String isWebview = "&isWebview=true";
String partnerData = "&partnerData=88824d8683434f4e";

String url = base + apikey + wallet + cryptoCurrency + transactionType + isWebview;
Log.d("xanpool url:", url);
Intent browserIntent = new Intent(getActivity(), WebViewActivity.class);
browserIntent.putExtra("uri", url);
startActivity(browserIntent);
}
}
else
Toast.makeText(getContext(), response.optString("error"), Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void onResponse(JSONObject response) {
refreshLayout.setRefreshing(false);
stocksList.clear();
try {
Log.d("invested stocks response", response.toString());
mTotalBalance.setText("$ " + response.getString("total_balance"));
mStockBalance.setText("$ " + response.getString("stock_balance"));
mTextStockProfit.setText("$ " + response.getString("stock_profit"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ public void onClick(View v) {
public void onClick(DialogInterface dialog, int which) {
if (TextUtils.isEmpty(editEmail.getText().toString())) {
editEmail.setError("!");
Toast.makeText(getContext(), "Please fill into form.", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(editName.getText().toString())) {
editName.setError("!");
Toast.makeText(getContext(), "Please fill into form.", Toast.LENGTH_SHORT).show();
return;
}
Pattern p = Pattern.compile("\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b");
final Matcher m = p.matcher(editEmail.getText().toString());
if (!m.find()) {
editEmail.setError("Invalid email format");
Toast.makeText(getContext(), "Invalid email format.", Toast.LENGTH_SHORT).show();
return;
}
sendContact();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class OrderViewHolder extends RecyclerView.ViewHolder {
TextView tvCoinName, tvCoinRate, tvCoinEstAmount, tvCoinBalance, tvCoinEffect;
ImageView coinIcon;
LinearLayout llCoinBalance;
Button btnDeposit, btnRamp;
Button btnDeposit, btnBuyNow;

public OrderViewHolder(View view) {
super(view);
Expand All @@ -53,7 +53,7 @@ public OrderViewHolder(View view) {
coinIcon = view.findViewById(R.id.coin_icon);
llCoinBalance = view.findViewById(R.id.ll_coin_balance);
btnDeposit = view.findViewById(R.id.btn_deposit);
btnRamp = view.findViewById(R.id.btn_ramp);
btnBuyNow = view.findViewById(R.id.btn_coin_buy);
}
}

Expand Down Expand Up @@ -118,19 +118,19 @@ public void onClick(View view) {
listener.OnDeposit(position);
}
});
holder.btnRamp.setOnClickListener(new View.OnClickListener() {
holder.btnBuyNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listener.OnRamp(position);
listener.OnBuyNow(position);
}
});
String coins = "BTC ETH DAI XDAI USDC DOT";
// if(coins.contains(item.getCoinSymbol())) {
if(item.getBuyNowOption() != 0 && item.getBuyNowOption() != 3) {
holder.btnRamp.setVisibility(View.VISIBLE);
if(item.getBuyNowOption() != 0 && item.getBuyNowOption() != 100) {
holder.btnBuyNow.setVisibility(View.VISIBLE);
}
else {
holder.btnRamp.setVisibility(View.GONE);
holder.btnBuyNow.setVisibility(View.GONE);
}

}
Expand All @@ -153,6 +153,6 @@ public interface Listener {
* @param position
*/
void OnDeposit(int position);
void OnRamp(int position);
void OnBuyNow(int position);
}
}
18 changes: 14 additions & 4 deletions app/src/main/java/com/brian/stocks/model/StocksInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public String getStocksName() {

public String getStocksNameOther() {
try {
return data.getString("name");
String name = data.getString("name");
if(name.equals("null")) name="";
return name;
} catch (JSONException e) {
e.printStackTrace();
return null;
Expand Down Expand Up @@ -85,7 +87,7 @@ public String getStockAvgPrice(){

public String getStocksPrice() {
try {
return data.getString("vw");
return String.format("%.2f", Double.parseDouble(data.getString("vw")));
} catch (JSONException e) {
e.printStackTrace();
return "0.0";
Expand All @@ -102,7 +104,7 @@ public void setStockAggregate(JSONArray aggregate) {

public String getStockTodayChange() {
try {
return data.getString("todaysChange");
return String.format("%.4f", Double.parseDouble(data.getString("todaysChange")));
} catch (JSONException e) {
e.printStackTrace();
return "0.0";
Expand All @@ -111,7 +113,7 @@ public String getStockTodayChange() {

public String getStockTodayChangePercent() {
try {
return data.getString("todaysChangePerc");
return String.format("%.4f", Double.parseDouble(data.getString("todaysChangePerc")));
} catch (JSONException e) {
e.printStackTrace();
return "0.0";
Expand Down Expand Up @@ -156,6 +158,14 @@ public String getStockOrderID(){
}
}

public String getStockOrderCost(){
try {
return data.getString("est_cost");
} catch (JSONException e) {
return "";
}
}

public String getStockOrderDate(){
try {
return data.getString("created_at").split(" ")[0];
Expand Down
Loading