remove save button for notes (#586)

This commit is contained in:
m2049r 2019-05-12 00:17:07 +02:00 committed by GitHub
parent ba79bf87aa
commit 525b38ff53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 115 deletions

View File

@ -71,7 +71,6 @@ public class TxFragment extends Fragment {
private TextView tvTxFee;
private TextView tvTxTransfers;
private TextView etTxNotes;
private Button bTxNotes;
// XMRTO stuff
private View cvXmrTo;
@ -102,21 +101,9 @@ public class TxFragment extends Fragment {
tvTxFee = view.findViewById(R.id.tvTxFee);
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
etTxNotes = view.findViewById(R.id.etTxNotes);
bTxNotes = view.findViewById(R.id.bTxNotes);
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() {
@Override
public void onClick(View v) {
@ -131,14 +118,6 @@ public class TxFragment extends Fragment {
return view;
}
public void onNotesSet(boolean reload) {
bTxNotes.setEnabled(true);
etTxNotes.setEnabled(true);
if (reload) {
loadNotes(this.info);
}
}
void shareTxInfo() {
if (this.info == null) return;
StringBuffer sb = new StringBuffer();
@ -315,7 +294,6 @@ public class TxFragment extends Fragment {
}
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -337,9 +315,9 @@ public class TxFragment extends Fragment {
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);
@ -357,4 +335,16 @@ public class TxFragment extends Fragment {
+ " 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();
}
}

View File

@ -174,6 +174,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
return getWallet().getUserNote(txId);
}
@Override
public boolean setTxNotes(String txId, String txNotes) {
return getWallet().setUserNote(txId, txNotes);
}
@Override
public String getTxAddress(int major, int 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
public void onProgress(final String text) {
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
public void onPrepareSend(final String tag, final TxData txData) {
if (mIsBound) { // no point in talking to unbound service

View File

@ -173,5 +173,4 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
return this.hash.compareTo(another.hash);
}
}
}
}

View File

@ -69,10 +69,6 @@ public class WalletService extends Service {
public static final String REQUEST_CMD_SEND = "send";
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 STOP_SERVICE = 2;
@ -224,8 +220,6 @@ public class WalletService extends Service {
void onSendTransactionFailed(String error);
void onSetNotes(boolean success);
void onWalletStarted(Wallet.ConnectionStatus walletStatus);
void onWalletOpen(Wallet.Device device);
@ -378,26 +372,6 @@ public class WalletService extends Service {
if (observer != null) observer.onSendTransactionFailed(error);
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;

View File

@ -225,34 +225,14 @@
android:padding="8sp"
android:text="@string/tx_notes" />
<RelativeLayout
<EditText
android:id="@+id/etTxNotes"
style="@style/MoneroEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/etTxNotes"
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>
android:layout_height="wrap_content"
android:backgroundTint="@color/moneroGray"
android:hint="@string/tx_notes_hint"
android:inputType="textMultiLine" />
</TableRow>
<TableRow>