1
mirror of https://github.com/m2049r/xmrwallet synced 2025-09-06 02:27:11 +02:00

Compare commits

...

12 Commits

Author SHA1 Message Date
m2049r
807d217aac Merge pull request #16 from m2049r/feature_txrecipient
show destinations in tx view
2017-08-22 13:10:14 +02:00
m2049r
0421bcfac3 show destination in tx view 2017-08-22 13:02:31 +02:00
m2049r
b6c4e06fda Merge pull request #15 from m2049r/feature_spend_redo
enable dispose of prepared transaction
2017-08-22 11:10:19 +02:00
m2049r
3ee8343074 enable dispose of prepared transaction 2017-08-22 11:05:43 +02:00
m2049r
110621824a Merge pull request #14 from m2049r/hotfix_priority
passing of transaction priority fixed
2017-08-22 10:56:07 +02:00
m2049r
7194580fbe passing of transaction priority fixed 2017-08-22 10:54:16 +02:00
m2049r
48dcd37740 Update build.gradle 2017-08-22 00:19:53 +02:00
m2049r
8e619756b9 Merge pull request #13 from m2049r/feature_service_notification
start WalletService as foreground service
2017-08-21 17:33:08 +02:00
m2049r
6c6b47db7d Merge pull request #12 from m2049r/bugfix
don't show Send Button on mainnet (instead of crashing when clicked)
2017-08-21 17:31:45 +02:00
m2049r
a126844272 start WalletService as foreground service preventing it from being killed by the system 2017-08-21 15:58:22 +02:00
m2049r
9b3086ff2e don't show Send Button on mainnet (instead of crashing when clicked) 2017-08-21 10:14:19 +02:00
m2049r
89d1842d59 Update README.md 2017-08-21 00:22:57 +02:00
13 changed files with 122 additions and 25 deletions

View File

@@ -43,3 +43,6 @@ No need to build. Binaries are included:
If you want to build them yourself (recommended) check out [the instructions](doc/BUILDING-external-libs.md)
Then, fire up Android Studio and build the APK.
### Donations
4AdkPJoxn7JCvAby9szgnt93MSEwdnxdhaASxbTBm6x5dCwmsDep2UYN4FhStDn5i11nsJbpU7oj59ahg8gXb1Mg3viqCuk

View File

@@ -7,8 +7,8 @@ android {
applicationId "com.m2049r.xmrwallet"
minSdkVersion 21
targetSdkVersion 25
versionCode 4
versionName "0.4.0"
versionCode 6
versionName "0.4.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {

View File

@@ -19,6 +19,7 @@
android:name=".WalletActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/wallet_activity_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<activity

View File

@@ -17,8 +17,6 @@
package com.m2049r.xmrwallet;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -26,7 +24,6 @@ import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -40,8 +37,6 @@ import android.widget.Spinner;
import android.widget.TextView;
import com.m2049r.xmrwallet.model.PendingTransaction;
import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Transfer;
import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.util.Helper;
@@ -57,6 +52,7 @@ public class SendFragment extends Fragment {
Spinner sMixin;
Spinner sPriority;
Button bPrepareSend;
Button bDispose;
Button bPaymentId;
LinearLayout llConfirmSend;
TextView tvTxAmount;
@@ -86,6 +82,7 @@ public class SendFragment extends Fragment {
bSweep = (Button) view.findViewById(R.id.bSweep);
bPrepareSend = (Button) view.findViewById(R.id.bPrepareSend);
bPaymentId = (Button) view.findViewById(R.id.bPaymentId);
bDispose = (Button) view.findViewById(R.id.bDispose);
llConfirmSend = (LinearLayout) view.findViewById(R.id.llConfirmSend);
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
@@ -191,6 +188,14 @@ public class SendFragment extends Fragment {
}
});
bDispose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activityCallback.onDisposeRequest();
enableEdit();
}
});
bPaymentId.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -304,6 +309,7 @@ public class SendFragment extends Fragment {
bPaymentId.setEnabled(true);
bSweep.setEnabled(true);
bPrepareSend.setEnabled(true);
llConfirmSend.setVisibility(View.GONE);
}
private void send() {
@@ -327,6 +333,8 @@ public class SendFragment extends Fragment {
String getWalletAddress();
void onDisposeRequest();
}
@Override
@@ -350,7 +358,6 @@ public class SendFragment extends Fragment {
tvTxAmount.setText(Wallet.getDisplayAmount(pendingTransaction.getAmount()));
tvTxFee.setText(Wallet.getDisplayAmount(pendingTransaction.getFee()));
tvTxDust.setText(Wallet.getDisplayAmount(pendingTransaction.getDust()));
bSend.setEnabled(true);
}
public void onCreatedTransactionFailed(String errorText) {

View File

@@ -41,6 +41,8 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
public class TxFragment extends Fragment {
@@ -60,6 +62,7 @@ public class TxFragment extends Fragment {
TextView tvTxTimestamp;
TextView tvTxId;
TextView tvTxKey;
TextView tvDestination;
TextView tvTxPaymentId;
TextView tvTxBlockheight;
TextView tvTxAmount;
@@ -78,6 +81,7 @@ public class TxFragment extends Fragment {
tvTxTimestamp = (TextView) view.findViewById(R.id.tvTxTimestamp);
tvTxId = (TextView) view.findViewById(R.id.tvTxId);
tvTxKey = (TextView) view.findViewById(R.id.tvTxKey);
tvDestination = (TextView) view.findViewById(R.id.tvDestination);
tvTxPaymentId = (TextView) view.findViewById(R.id.tvTxPaymentId);
tvTxBlockheight = (TextView) view.findViewById(R.id.tvTxBlockheight);
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
@@ -154,11 +158,11 @@ public class TxFragment extends Fragment {
boolean comma = false;
for (Transfer transfer : info.transfers) {
if (comma) {
sb.append(",");
sb.append(", ");
} else {
comma = true;
}
sb.append("[").append(transfer.address.substring(0, 6)).append("] ");
sb.append(transfer.address).append(": ");
sb.append(Wallet.getDisplayAmount(transfer.amount));
}
} else {
@@ -202,10 +206,13 @@ public class TxFragment extends Fragment {
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
Set<String> destinations = new HashSet<>();
StringBuffer sb = new StringBuffer();
StringBuffer dstSb = new StringBuffer();
if (info.transfers != null) {
boolean newline = false;
for (Transfer transfer : info.transfers) {
destinations.add(transfer.address);
if (newline) {
sb.append("\n");
} else {
@@ -214,10 +221,21 @@ public class TxFragment extends Fragment {
sb.append("[").append(transfer.address.substring(0, 6)).append("] ");
sb.append(Wallet.getDisplayAmount(transfer.amount));
}
newline = false;
for (String dst : destinations) {
if (newline) {
dstSb.append("\n");
} else {
newline = true;
}
dstSb.append(dst);
}
} else {
sb.append("-");
dstSb.append(info.direction == TransactionInfo.Direction.Direction_In ? activityCallback.getWalletAddress() : "-");
}
tvTxTransfers.setText(sb.toString());
tvDestination.setText(dstSb.toString());
this.info = info;
bCopy.setEnabled(true);
}

View File

@@ -16,7 +16,6 @@
package com.m2049r.xmrwallet;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
@@ -36,9 +35,7 @@ import android.widget.Toast;
import com.m2049r.xmrwallet.model.PendingTransaction;
import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.service.WalletService;
import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.TxData;
public class WalletActivity extends AppCompatActivity implements WalletFragment.Listener,
@@ -545,4 +542,9 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
replaceFragment(new GenerateReviewFragment(), null, extras);
}
}
@Override
public void onDisposeRequest() {
getWallet().disposePendingTransaction();
}
}

View File

@@ -38,6 +38,7 @@ import com.m2049r.xmrwallet.layout.TransactionInfoAdapter;
import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Transfer;
import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager;
import java.text.NumberFormat;
import java.util.List;
@@ -117,7 +118,7 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
}
public void onSynced() {
if (!activityCallback.isWatchOnly()) {
if (!activityCallback.isWatchOnly() && WalletManager.getInstance().isTestNet()) {
bSend.setVisibility(View.VISIBLE);
bSend.setEnabled(true);
}

View File

@@ -179,14 +179,15 @@ public class Wallet {
long amount, int mixin_count,
PendingTransaction.Priority priority) {
disposePendingTransaction();
long txHandle = createTransactionJ(dst_addr, payment_id, amount, mixin_count, priority);
int _priority = priority.getValue();
long txHandle = createTransactionJ(dst_addr, payment_id, amount, mixin_count, _priority);
pendingTransaction = new PendingTransaction(txHandle);
return pendingTransaction;
}
private native long createTransactionJ(String dst_addr, String payment_id,
long mount, int mixin_count,
PendingTransaction.Priority priority);
long amount, int mixin_count,
int priority);
public PendingTransaction createSweepUnmixableTransaction() {

View File

@@ -16,8 +16,13 @@
package com.m2049r.xmrwallet.service;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -25,9 +30,11 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.WalletActivity;
import com.m2049r.xmrwallet.model.PendingTransaction;
import com.m2049r.xmrwallet.model.TransactionHistory;
import com.m2049r.xmrwallet.model.Wallet;
@@ -38,6 +45,7 @@ import com.m2049r.xmrwallet.util.TxData;
public class WalletService extends Service {
final static String TAG = "WalletService";
final static int NOTIFICATION_ID = 2049;
public static final String REQUEST_WALLET = "wallet";
public static final String REQUEST = "request";
@@ -432,7 +440,7 @@ public class WalletService extends Service {
msg.setData(intent.getExtras());
mServiceHandler.sendMessage(msg);
//Log.d(TAG, "onStartCommand() message sent");
return START_NOT_STICKY;
return START_STICKY;
}
@Override
@@ -454,6 +462,7 @@ public class WalletService extends Service {
}
private void start(String walletName, String walletPassword) {
startNotfication();
// if there is an listener it is always started / syncing
Log.d(TAG, "start()");
showProgress(getString(R.string.status_wallet_loading));
@@ -488,6 +497,7 @@ public class WalletService extends Service {
Log.d(TAG, "stop() closed");
listener = null;
}
stopForeground(true);
stopSelf();
}
@@ -532,4 +542,16 @@ public class WalletService extends Service {
}
return wallet;
}
private void startNotfication() {
Intent notificationIntent = new Intent(this, WalletActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = new Notification.Builder(this)
.setContentTitle(getString(R.string.service_description))
.setSmallIcon(R.drawable.ic_notification_sync_32_32)
.setContentIntent(pendingIntent)
.build();
startForeground(NOTIFICATION_ID, notification);
}
}

View File

@@ -75,4 +75,19 @@ public class TxData implements Parcelable {
return 0;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("dst_addr:");
sb.append(dst_addr);
sb.append(",paymentId:");
sb.append(paymentId);
sb.append(",amount:");
sb.append(amount);
sb.append(",mixin:");
sb.append(mixin);
sb.append(",priority:");
sb.append(priority.toString());
return sb.toString();
}
}

View File

@@ -64,8 +64,8 @@
android:layout_weight="2"
android:background="@color/colorPrimary"
android:enabled="true"
android:textSize="12sp"
android:text="@string/send_generate_paymentid_hint" />
android:text="@string/send_generate_paymentid_hint"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
@@ -94,8 +94,8 @@
android:layout_weight="2"
android:background="@color/colorPrimary"
android:enabled="true"
android:visibility="invisible"
android:text="@string/send_sweep_hint" />
android:text="@string/send_sweep_hint"
android:visibility="invisible" />
</LinearLayout>
<Button
@@ -112,8 +112,8 @@
android:id="@+id/pbProgress"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:id="@+id/llConfirmSend"
@@ -122,6 +122,16 @@
android:orientation="vertical"
android:visibility="gone">
<Button
android:id="@+id/bDispose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@color/colorPrimary"
android:text="@string/send_dispose_hint" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -221,7 +231,6 @@
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@color/colorPrimary"
android:enabled="false"
android:text="@string/send_send_hint" />
</LinearLayout>

View File

@@ -46,6 +46,22 @@
android:textIsSelectable="true" />
</TableRow>
<TableRow>
<TextView
android:gravity="right"
android:padding="8dp"
android:text="@string/tx_destination"
android:textColor="@color/colorAccent" />
<TextView
android:id="@+id/tvDestination"
android:gravity="left"
android:padding="8dip"
android:selectAllOnFocus="true"
android:textIsSelectable="true" />
</TableRow>
<TableRow>
<TextView

View File

@@ -107,6 +107,7 @@
<string name="send_sweep_hint">Sweep</string>
<string name="send_generate_paymentid_hint">Generate</string>
<string name="send_prepare_hint">Prepare</string>
<string name="send_dispose_hint">Dispose (Undo)</string>
<string name="send_send_hint">Spend my sweet Moneroj</string>
<string name="send_preparing_progress">Preparing transaction</string>
@@ -121,6 +122,7 @@
<string name="tx_timestamp">Timestamp</string>
<string name="tx_id">TX ID</string>
<string name="tx_key">TX Key</string>
<string name="tx_destination">Destination</string>
<string name="tx_paymentId">Payment ID</string>
<string name="tx_blockheight">Block</string>
<string name="tx_amount">Amount</string>