mirror of
https://github.com/m2049r/xmrwallet
synced 2025-05-19 06:52:38 +02:00
remove save button for notes (#586)
This commit is contained in:
parent
ba79bf87aa
commit
525b38ff53
app/src/main
java/com/m2049r/xmrwallet
res/layout
@ -71,7 +71,6 @@ public class TxFragment extends Fragment {
|
|||||||
private TextView tvTxFee;
|
private TextView tvTxFee;
|
||||||
private TextView tvTxTransfers;
|
private TextView tvTxTransfers;
|
||||||
private TextView etTxNotes;
|
private TextView etTxNotes;
|
||||||
private Button bTxNotes;
|
|
||||||
|
|
||||||
// XMRTO stuff
|
// XMRTO stuff
|
||||||
private View cvXmrTo;
|
private View cvXmrTo;
|
||||||
@ -102,21 +101,9 @@ public class TxFragment extends Fragment {
|
|||||||
tvTxFee = view.findViewById(R.id.tvTxFee);
|
tvTxFee = view.findViewById(R.id.tvTxFee);
|
||||||
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
|
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
|
||||||
etTxNotes = view.findViewById(R.id.etTxNotes);
|
etTxNotes = view.findViewById(R.id.etTxNotes);
|
||||||
bTxNotes = view.findViewById(R.id.bTxNotes);
|
|
||||||
|
|
||||||
etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
|
||||||
bTxNotes.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
info.notes = null; // force reload on next view
|
|
||||||
bTxNotes.setEnabled(false);
|
|
||||||
etTxNotes.setEnabled(false);
|
|
||||||
userNotes.setNote(etTxNotes.getText().toString());
|
|
||||||
activityCallback.onSetNote(info.hash, userNotes.txNotes);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tvTxXmrToKey.setOnClickListener(new View.OnClickListener() {
|
tvTxXmrToKey.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -131,14 +118,6 @@ public class TxFragment extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNotesSet(boolean reload) {
|
|
||||||
bTxNotes.setEnabled(true);
|
|
||||||
etTxNotes.setEnabled(true);
|
|
||||||
if (reload) {
|
|
||||||
loadNotes(this.info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void shareTxInfo() {
|
void shareTxInfo() {
|
||||||
if (this.info == null) return;
|
if (this.info == null) return;
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
@ -315,7 +294,6 @@ public class TxFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -337,9 +315,9 @@ public class TxFragment extends Fragment {
|
|||||||
|
|
||||||
String getTxNotes(String hash);
|
String getTxNotes(String hash);
|
||||||
|
|
||||||
String getTxAddress(int major, int minor);
|
boolean setTxNotes(String txId, String txNotes);
|
||||||
|
|
||||||
void onSetNote(String txId, String notes);
|
String getTxAddress(int major, int minor);
|
||||||
|
|
||||||
void setToolbarButton(int type);
|
void setToolbarButton(int type);
|
||||||
|
|
||||||
@ -357,4 +335,16 @@ public class TxFragment extends Fragment {
|
|||||||
+ " must implement Listener");
|
+ " must implement Listener");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
if (!etTxNotes.getText().toString().equals(userNotes.note)) { // notes have changed
|
||||||
|
// save them
|
||||||
|
userNotes.setNote(etTxNotes.getText().toString());
|
||||||
|
info.notes = userNotes.txNotes;
|
||||||
|
activityCallback.setTxNotes(info.hash, info.notes);
|
||||||
|
}
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
}
|
@ -174,6 +174,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
return getWallet().getUserNote(txId);
|
return getWallet().getUserNote(txId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setTxNotes(String txId, String txNotes) {
|
||||||
|
return getWallet().setUserNote(txId, txNotes);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTxAddress(int major, int minor) {
|
public String getTxAddress(int major, int minor) {
|
||||||
return getWallet().getSubaddress(major, minor);
|
return getWallet().getSubaddress(major, minor);
|
||||||
@ -713,26 +718,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetNotes(final boolean success) {
|
|
||||||
try {
|
|
||||||
final TxFragment txFragment = (TxFragment)
|
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!success) {
|
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.tx_notes_set_failed), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
txFragment.onNotesSet(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
// not in tx fragment
|
|
||||||
Timber.d(ex.getLocalizedMessage());
|
|
||||||
// never mind
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(final String text) {
|
public void onProgress(final String text) {
|
||||||
try {
|
try {
|
||||||
@ -794,21 +779,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetNote(String txId, String notes) {
|
|
||||||
if (mIsBound) { // no point in talking to unbound service
|
|
||||||
Intent intent = new Intent(getApplicationContext(), WalletService.class);
|
|
||||||
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_SETNOTE);
|
|
||||||
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_TX, txId);
|
|
||||||
intent.putExtra(WalletService.REQUEST_CMD_SETNOTE_NOTES, notes);
|
|
||||||
startService(intent);
|
|
||||||
Timber.d("SET NOTE request sent");
|
|
||||||
} else {
|
|
||||||
Timber.e("Service not bound");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareSend(final String tag, final TxData txData) {
|
public void onPrepareSend(final String tag, final TxData txData) {
|
||||||
if (mIsBound) { // no point in talking to unbound service
|
if (mIsBound) { // no point in talking to unbound service
|
||||||
|
@ -173,5 +173,4 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
|
|||||||
return this.hash.compareTo(another.hash);
|
return this.hash.compareTo(another.hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -69,10 +69,6 @@ public class WalletService extends Service {
|
|||||||
public static final String REQUEST_CMD_SEND = "send";
|
public static final String REQUEST_CMD_SEND = "send";
|
||||||
public static final String REQUEST_CMD_SEND_NOTES = "notes";
|
public static final String REQUEST_CMD_SEND_NOTES = "notes";
|
||||||
|
|
||||||
public static final String REQUEST_CMD_SETNOTE = "setnote";
|
|
||||||
public static final String REQUEST_CMD_SETNOTE_TX = "tx";
|
|
||||||
public static final String REQUEST_CMD_SETNOTE_NOTES = "notes";
|
|
||||||
|
|
||||||
public static final int START_SERVICE = 1;
|
public static final int START_SERVICE = 1;
|
||||||
public static final int STOP_SERVICE = 2;
|
public static final int STOP_SERVICE = 2;
|
||||||
|
|
||||||
@ -224,8 +220,6 @@ public class WalletService extends Service {
|
|||||||
|
|
||||||
void onSendTransactionFailed(String error);
|
void onSendTransactionFailed(String error);
|
||||||
|
|
||||||
void onSetNotes(boolean success);
|
|
||||||
|
|
||||||
void onWalletStarted(Wallet.ConnectionStatus walletStatus);
|
void onWalletStarted(Wallet.ConnectionStatus walletStatus);
|
||||||
|
|
||||||
void onWalletOpen(Wallet.Device device);
|
void onWalletOpen(Wallet.Device device);
|
||||||
@ -378,26 +372,6 @@ public class WalletService extends Service {
|
|||||||
if (observer != null) observer.onSendTransactionFailed(error);
|
if (observer != null) observer.onSendTransactionFailed(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (cmd.equals(REQUEST_CMD_SETNOTE)) {
|
|
||||||
Wallet myWallet = getWallet();
|
|
||||||
Timber.d("SET NOTE for wallet: %s", myWallet.getName());
|
|
||||||
String txId = extras.getString(REQUEST_CMD_SETNOTE_TX);
|
|
||||||
String notes = extras.getString(REQUEST_CMD_SETNOTE_NOTES);
|
|
||||||
if ((txId != null) && (notes != null)) {
|
|
||||||
boolean success = myWallet.setUserNote(txId, notes);
|
|
||||||
if (!success) {
|
|
||||||
Timber.e(myWallet.getErrorString());
|
|
||||||
}
|
|
||||||
if (observer != null) observer.onSetNotes(success);
|
|
||||||
if (success) {
|
|
||||||
boolean rc = myWallet.store();
|
|
||||||
Timber.d("wallet stored: %s with rc=%b", myWallet.getName(), rc);
|
|
||||||
if (!rc) {
|
|
||||||
Timber.w("Wallet store failed: %s", myWallet.getErrorString());
|
|
||||||
}
|
|
||||||
if (observer != null) observer.onWalletStored(rc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -225,34 +225,14 @@
|
|||||||
android:padding="8sp"
|
android:padding="8sp"
|
||||||
android:text="@string/tx_notes" />
|
android:text="@string/tx_notes" />
|
||||||
|
|
||||||
<RelativeLayout
|
<EditText
|
||||||
|
android:id="@+id/etTxNotes"
|
||||||
|
style="@style/MoneroEdit"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:backgroundTint="@color/moneroGray"
|
||||||
<EditText
|
android:hint="@string/tx_notes_hint"
|
||||||
android:id="@+id/etTxNotes"
|
android:inputType="textMultiLine" />
|
||||||
style="@style/MoneroEdit"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_toStartOf="@+id/bTxNotes"
|
|
||||||
android:backgroundTint="@color/moneroGray"
|
|
||||||
android:hint="@string/tx_notes_hint"
|
|
||||||
android:inputType="textMultiLine" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/bTxNotes"
|
|
||||||
style="@style/MoneroButton.Small"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:enabled="true"
|
|
||||||
android:paddingStart="8dp"
|
|
||||||
android:paddingEnd="8dp"
|
|
||||||
android:text="@string/tx_button_notes" />
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user