Skip to content

Commit

Permalink
replace xmr.to with SideShift.ai (#710)
Browse files Browse the repository at this point in the history
replace xmr.to with SideShift.ai
random bugfixes
upgrade gradle & dependencies
  • Loading branch information
m2049r authored Feb 12, 2021
1 parent ab60690 commit 57ddddf
Show file tree
Hide file tree
Showing 133 changed files with 3,371 additions and 3,532 deletions.
15 changes: 12 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.m2049r.xmrwallet"
minSdkVersion 21
targetSdkVersion 29
versionCode 602
versionName "1.16.2 'Karmic Nodes'"
versionCode 702
versionName "1.17.2 'Druk'"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
Expand Down Expand Up @@ -56,6 +56,9 @@ android {
debug {
applicationIdSuffix ".debug"
}
applicationVariants.all { variant ->
variant.buildConfigField "String", "ID_A", "\"" + getId("ID_A") + "\""
}
}

externalNativeBuild {
Expand Down Expand Up @@ -109,10 +112,16 @@ android {
}
}

def getId(name) {
def Properties props = new Properties()
props.load(new FileInputStream(new File('monerujo.id')))
return props[name]
}

dependencies {
implementation 'androidx.core:core:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/m2049r/levin/scanner/LevinPeer.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2018 m2049r
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.m2049r.levin.scanner;

import java.net.InetAddress;
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/m2049r/xmrwallet/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017-2020 m2049r et al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.m2049r.xmrwallet;

import android.app.PendingIntent;
Expand Down
84 changes: 39 additions & 45 deletions app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,24 +301,21 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);

toolbar.setOnButtonListener(new Toolbar.OnButtonListener() {
@Override
public void onButton(int type) {
switch (type) {
case Toolbar.BUTTON_BACK:
onBackPressed();
break;
case Toolbar.BUTTON_CLOSE:
finish();
break;
case Toolbar.BUTTON_CREDITS:
CreditsFragment.display(getSupportFragmentManager());
break;
case Toolbar.BUTTON_NONE:
break;
default:
Timber.e("Button " + type + "pressed - how can this be?");
}
toolbar.setOnButtonListener(type -> {
switch (type) {
case Toolbar.BUTTON_BACK:
onBackPressed();
break;
case Toolbar.BUTTON_CLOSE:
finish();
break;
case Toolbar.BUTTON_CREDITS:
CreditsFragment.display(getSupportFragmentManager());
break;
case Toolbar.BUTTON_NONE:
break;
default:
Timber.e("Button " + type + "pressed - how can this be?");
}
});

Expand Down Expand Up @@ -366,34 +363,31 @@ public boolean onWalletSelected(String walletName, boolean streetmode) {
public void onWalletDetails(final String walletName) {
Timber.d("details for wallet .%s.", walletName);
if (checkServiceRunning()) return;
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
final File walletFile = Helper.getWalletFile(LoginActivity.this, walletName);
if (WalletManager.getInstance().walletExists(walletFile)) {
Helper.promptPassword(LoginActivity.this, walletName, true, new Helper.PasswordAction() {
@Override
public void act(String walletName, String password, boolean fingerprintUsed) {
if (checkDevice(walletName, password))
startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS);
}

@Override
public void fail(String walletName, String password, boolean fingerprintUsed) {
}
});
} else { // this cannot really happen as we prefilter choices
Timber.e("Wallet missing: %s", walletName);
Toast.makeText(LoginActivity.this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
}
break;
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
final File walletFile = Helper.getWalletFile(LoginActivity.this, walletName);
if (WalletManager.getInstance().walletExists(walletFile)) {
Helper.promptPassword(LoginActivity.this, walletName, true, new Helper.PasswordAction() {
@Override
public void act(String walletName1, String password, boolean fingerprintUsed) {
if (checkDevice(walletName1, password))
startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS);
}

case DialogInterface.BUTTON_NEGATIVE:
// do nothing
break;
}
@Override
public void fail(String walletName1, String password, boolean fingerprintUsed) {
}
});
} else { // this cannot really happen as we prefilter choices
Timber.e("Wallet missing: %s", walletName);
Toast.makeText(LoginActivity.this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
}
break;

case DialogInterface.BUTTON_NEGATIVE:
// do nothing
break;
}
};

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/m2049r/xmrwallet/ReceiveFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.m2049r.xmrwallet.BuildConfig;
import com.m2049r.xmrwallet.data.BarcodeData;
import com.m2049r.xmrwallet.ledger.LedgerProgressDialog;
import com.m2049r.xmrwallet.model.Wallet;
Expand Down Expand Up @@ -468,7 +469,7 @@ private void generateQr() {
Timber.d("CLEARQR");
return;
}
bcData = new BarcodeData(BarcodeData.Asset.XMR, address, null, notes, xmrAmount);
bcData = new BarcodeData(BarcodeData.Asset.XMR, address, notes, xmrAmount);
int size = Math.max(ivQrCode.getWidth(), ivQrCode.getHeight());
Bitmap qr = generate(bcData.getUriString(), size, size);
if (qr != null) {
Expand Down
45 changes: 38 additions & 7 deletions app/src/main/java/com/m2049r/xmrwallet/TxFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@

package com.m2049r.xmrwallet;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

Expand Down Expand Up @@ -77,6 +81,9 @@ public TxFragment() {
private TextView tvTxXmrToKey;
private TextView tvDestinationBtc;
private TextView tvTxAmountBtc;
private TextView tvXmrToSupport;
private TextView tvXmrToKeyLabel;
private ImageView tvXmrToLogo;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Expand All @@ -88,6 +95,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
tvTxXmrToKey = view.findViewById(R.id.tvTxXmrToKey);
tvDestinationBtc = view.findViewById(R.id.tvDestinationBtc);
tvTxAmountBtc = view.findViewById(R.id.tvTxAmountBtc);
tvXmrToSupport = view.findViewById(R.id.tvXmrToSupport);
tvXmrToKeyLabel = view.findViewById(R.id.tvXmrToKeyLabel);
tvXmrToLogo = view.findViewById(R.id.tvXmrToLogo);

tvAccount = view.findViewById(R.id.tvAccount);
tvAddress = view.findViewById(R.id.tvAddress);
Expand All @@ -104,12 +114,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);

tvTxXmrToKey.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.clipBoardCopy(getActivity(), getString(R.string.label_copy_xmrtokey), tvTxXmrToKey.getText().toString());
Toast.makeText(getActivity(), getString(R.string.message_copy_xmrtokey), Toast.LENGTH_SHORT).show();
}
tvTxXmrToKey.setOnClickListener(v -> {
Helper.clipBoardCopy(getActivity(), getString(R.string.label_copy_xmrtokey), tvTxXmrToKey.getText().toString());
Toast.makeText(getActivity(), getString(R.string.message_copy_xmrtokey), Toast.LENGTH_SHORT).show();
});

Bundle args = getArguments();
Expand Down Expand Up @@ -283,12 +290,36 @@ private void show(TransactionInfo info) {
showBtcInfo();
}

@SuppressLint("SetTextI18n")
void showBtcInfo() {
if (userNotes.xmrtoKey != null) {
cvXmrTo.setVisibility(View.VISIBLE);
tvTxXmrToKey.setText(userNotes.xmrtoKey);
String key = userNotes.xmrtoKey;
if ("xmrto".equals(userNotes.xmrtoTag)) { // legacy xmr.to service :(
key = "xmrto-" + key;
}
tvTxXmrToKey.setText(key);
tvDestinationBtc.setText(userNotes.xmrtoDestination);
tvTxAmountBtc.setText(userNotes.xmrtoAmount + " BTC");
switch (userNotes.xmrtoTag) {
case "xmrto":
tvXmrToSupport.setVisibility(View.GONE);
tvXmrToKeyLabel.setVisibility(View.INVISIBLE);
tvXmrToLogo.setImageResource(R.drawable.ic_xmrto_logo);
break;
case "side": // defaults in layout - just add underline
tvXmrToSupport.setPaintFlags(tvXmrToSupport.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvXmrToSupport.setOnClickListener(v -> {
Uri uri = Uri.parse("https://sideshift.ai/orders/" + userNotes.xmrtoKey);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
});
break;
default:
tvXmrToSupport.setVisibility(View.GONE);
tvXmrToKeyLabel.setVisibility(View.INVISIBLE);
tvXmrToLogo.setVisibility(View.GONE);
}
} else {
cvXmrTo.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package com.m2049r.xmrwallet;


import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;

import com.m2049r.xmrwallet.BuildConfig;
import com.m2049r.xmrwallet.model.NetworkType;
import com.m2049r.xmrwallet.util.DayNightMode;
import com.m2049r.xmrwallet.util.LocaleHelper;
import com.m2049r.xmrwallet.util.NightmodeHelper;

Expand Down
Loading

0 comments on commit 57ddddf

Please sign in to comment.