mirror of https://github.com/m2049r/xmrwallet.git
tweaks - mostly keyboard & UI
This commit is contained in:
parent
3239bdeb33
commit
56132e26ed
|
@ -9,26 +9,31 @@ import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
// TODO: somehow show which net we are generating for
|
||||||
|
|
||||||
public class GenerateFragment extends Fragment {
|
public class GenerateFragment extends Fragment {
|
||||||
|
|
||||||
EditText etWalletName;
|
EditText etWalletName;
|
||||||
EditText etWalletPassword;
|
EditText etWalletPassword;
|
||||||
Button bGenerate;
|
Button bGenerate;
|
||||||
LinearLayout llAccept;
|
LinearLayout llAccept;
|
||||||
|
TextView tvWalletAddress;
|
||||||
TextView tvWalletMnemonic;
|
TextView tvWalletMnemonic;
|
||||||
Button bAccept;
|
Button bAccept;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -39,14 +44,20 @@ public class GenerateFragment extends Fragment {
|
||||||
etWalletPassword = (EditText) view.findViewById(R.id.etWalletPassword);
|
etWalletPassword = (EditText) view.findViewById(R.id.etWalletPassword);
|
||||||
bGenerate = (Button) view.findViewById(R.id.bGenerate);
|
bGenerate = (Button) view.findViewById(R.id.bGenerate);
|
||||||
llAccept = (LinearLayout) view.findViewById(R.id.llAccept);
|
llAccept = (LinearLayout) view.findViewById(R.id.llAccept);
|
||||||
|
tvWalletAddress = (TextView) view.findViewById(R.id.tvWalletAddress);
|
||||||
tvWalletMnemonic = (TextView) view.findViewById(R.id.tvWalletMnemonic);
|
tvWalletMnemonic = (TextView) view.findViewById(R.id.tvWalletMnemonic);
|
||||||
bAccept = (Button) view.findViewById(R.id.bAccept);
|
bAccept = (Button) view.findViewById(R.id.bAccept);
|
||||||
|
|
||||||
|
boolean testnet = WalletManager.getInstance().isTestNet();
|
||||||
|
tvWalletMnemonic.setTextIsSelectable(testnet);
|
||||||
|
|
||||||
etWalletName.requestFocus();
|
etWalletName.requestFocus();
|
||||||
|
Helper.showKeyboard(getActivity());
|
||||||
|
setGenerateEnabled();
|
||||||
etWalletName.addTextChangedListener(new TextWatcher() {
|
etWalletName.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable editable) {
|
public void afterTextChanged(Editable editable) {
|
||||||
setGenerateEnabled();
|
showMnemonic("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,14 +71,15 @@ public class GenerateFragment extends Fragment {
|
||||||
etWalletName.setOnClickListener(new View.OnClickListener() {
|
etWalletName.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
Helper.showKeyboard(getActivity());
|
||||||
imm.showSoftInput(etWalletName, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
etWalletName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
etWalletPassword.requestFocus();
|
if (etWalletName.length() > 0) {
|
||||||
|
etWalletPassword.requestFocus();
|
||||||
|
} // otherwise ignore
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -77,14 +89,27 @@ public class GenerateFragment extends Fragment {
|
||||||
etWalletPassword.setOnClickListener(new View.OnClickListener() {
|
etWalletPassword.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
Helper.showKeyboard(getActivity());
|
||||||
imm.showSoftInput(etWalletPassword, InputMethodManager.SHOW_IMPLICIT);
|
}
|
||||||
|
});
|
||||||
|
etWalletPassword.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
showMnemonic("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
etWalletPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
Helper.hideKeyboard(getActivity());
|
||||||
generateWallet();
|
generateWallet();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +120,7 @@ public class GenerateFragment extends Fragment {
|
||||||
bGenerate.setOnClickListener(new View.OnClickListener() {
|
bGenerate.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// TODO make keyboard go away
|
Helper.hideKeyboard(getActivity());
|
||||||
generateWallet();
|
generateWallet();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -108,6 +133,7 @@ public class GenerateFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
bAccept.setEnabled(false);
|
bAccept.setEnabled(false);
|
||||||
|
llAccept.setVisibility(View.GONE);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -115,8 +141,8 @@ public class GenerateFragment extends Fragment {
|
||||||
private void generateWallet() {
|
private void generateWallet() {
|
||||||
String name = etWalletName.getText().toString();
|
String name = etWalletName.getText().toString();
|
||||||
if (name.length() == 0) return;
|
if (name.length() == 0) return;
|
||||||
File walletFile = new File(activityCallback.getStorageRoot(), name + ".keys");
|
String walletPath = Helper.getWalletPath(getActivity(), name);
|
||||||
if (walletFile.exists()) {
|
if (WalletManager.getInstance().walletExists(walletPath)) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.generate_wallet_exists), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.generate_wallet_exists), Toast.LENGTH_LONG).show();
|
||||||
etWalletName.requestFocus();
|
etWalletName.requestFocus();
|
||||||
return;
|
return;
|
||||||
|
@ -137,23 +163,18 @@ public class GenerateFragment extends Fragment {
|
||||||
bGenerate.setEnabled(etWalletName.length() > 0);
|
bGenerate.setEnabled(etWalletName.length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
setGenerateEnabled();
|
|
||||||
etWalletName.requestFocus();
|
|
||||||
InputMethodManager imgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
imgr.showSoftInput(etWalletName, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showMnemonic(String mnemonic) {
|
public void showMnemonic(String mnemonic) {
|
||||||
setGenerateEnabled();
|
setGenerateEnabled();
|
||||||
if (mnemonic.length() > 0) {
|
if (mnemonic.length() > 0) {
|
||||||
tvWalletMnemonic.setText(mnemonic);
|
tvWalletMnemonic.setText(mnemonic);
|
||||||
bAccept.setEnabled(true);
|
bAccept.setEnabled(true);
|
||||||
|
llAccept.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
tvWalletMnemonic.setText(getActivity().getString(R.string.generate_seed));
|
if (llAccept.getVisibility() != View.GONE) {
|
||||||
bAccept.setEnabled(false);
|
tvWalletMnemonic.setText(getActivity().getString(R.string.generate_seed));
|
||||||
|
bAccept.setEnabled(false);
|
||||||
|
llAccept.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -64,18 +65,26 @@ public class LoginActivity extends Activity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adapted from http://www.mkyong.com/android/android-prompt-user-input-dialog-example/
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletSelected(final String wallet) {
|
public void onWalletSelected(final String walletName) {
|
||||||
Log.d(TAG, "selected wallet is ." + wallet + ".");
|
Log.d(TAG, "selected wallet is ." + walletName + ".");
|
||||||
if (wallet.equals(getString(R.string.generate_title))) {
|
if (walletName.equals(':' + getString(R.string.generate_title))) {
|
||||||
startGenerateFragment();
|
startGenerateFragment();
|
||||||
} else {
|
} else {
|
||||||
promptPassword(wallet);
|
// now it's getting real, check if wallet exists
|
||||||
|
String walletPath = Helper.getWalletPath(this, walletName);
|
||||||
|
if (WalletManager.getInstance().walletExists(walletPath)) {
|
||||||
|
promptPassword(walletName);
|
||||||
|
} else { // this cannot really happen as we prefilter choices
|
||||||
|
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AlertDialog passwordDialog = null; // for preventing multiple clicks in wallet list
|
||||||
|
|
||||||
void promptPassword(final String wallet) {
|
void promptPassword(final String wallet) {
|
||||||
|
if (passwordDialog != null) return; // we are already asking for password
|
||||||
Context context = LoginActivity.this;
|
Context context = LoginActivity.this;
|
||||||
LayoutInflater li = LayoutInflater.from(context);
|
LayoutInflater li = LayoutInflater.from(context);
|
||||||
View promptsView = li.inflate(R.layout.prompt_password, null);
|
View promptsView = li.inflate(R.layout.prompt_password, null);
|
||||||
|
@ -94,37 +103,40 @@ public class LoginActivity extends Activity
|
||||||
.setPositiveButton("OK",
|
.setPositiveButton("OK",
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
String pass = etPassword.getText().toString();
|
String pass = etPassword.getText().toString();
|
||||||
processPasswordEntry(wallet, pass);
|
processPasswordEntry(wallet, pass);
|
||||||
|
passwordDialog = null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("Cancel",
|
.setNegativeButton("Cancel",
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
|
passwordDialog = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilder.create();
|
passwordDialog = alertDialogBuilder.create();
|
||||||
// request keyboard
|
Helper.showKeyboard(passwordDialog);
|
||||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
|
||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
String pass = etPassword.getText().toString();
|
String pass = etPassword.getText().toString();
|
||||||
alertDialog.cancel();
|
passwordDialog.cancel();
|
||||||
processPasswordEntry(wallet, pass);
|
processPasswordEntry(wallet, pass);
|
||||||
|
passwordDialog = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
alertDialog.show();
|
passwordDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkWalletPassword(String walletName, String password) {
|
private boolean checkWalletPassword(String walletName, String password) {
|
||||||
|
@ -191,7 +203,7 @@ public class LoginActivity extends Activity
|
||||||
} else {
|
} else {
|
||||||
String msg = getString(R.string.message_strorage_not_permitted);
|
String msg = getString(R.string.message_strorage_not_permitted);
|
||||||
Log.e(TAG, msg);
|
Log.e(TAG, msg);
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||||
//throw new IllegalStateException(msg);
|
//throw new IllegalStateException(msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -298,9 +310,10 @@ public class LoginActivity extends Activity
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(LoginActivity.this,
|
Toast.makeText(LoginActivity.this,
|
||||||
getString(R.string.generate_wallet_create_failed), Toast.LENGTH_SHORT).show();
|
getString(R.string.generate_wallet_create_failed_1), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
newWallet.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String walletPath = new File(getStorageRoot(), name).getAbsolutePath();
|
final String walletPath = new File(getStorageRoot(), name).getAbsolutePath();
|
||||||
|
@ -317,7 +330,7 @@ public class LoginActivity extends Activity
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Wallet store failed to " + walletPath);
|
Log.e(TAG, "Wallet store failed to " + walletPath);
|
||||||
Toast.makeText(LoginActivity.this,
|
Toast.makeText(LoginActivity.this,
|
||||||
getString(R.string.generate_wallet_create_failed), Toast.LENGTH_SHORT).show();
|
getString(R.string.generate_wallet_create_failed_2), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -325,4 +338,5 @@ public class LoginActivity extends Activity
|
||||||
}
|
}
|
||||||
, "AcceptWallet", MoneroHandlerThread.THREAD_STACK_SIZE).start();
|
, "AcceptWallet", MoneroHandlerThread.THREAD_STACK_SIZE).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,7 @@ import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
@ -39,6 +37,7 @@ import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -108,19 +107,18 @@ public class LoginFragment extends Fragment {
|
||||||
tbMainNet = (ToggleButton) view.findViewById(R.id.tbMainNet);
|
tbMainNet = (ToggleButton) view.findViewById(R.id.tbMainNet);
|
||||||
etDaemonAddress = (EditText) view.findViewById(R.id.etDaemonAddress);
|
etDaemonAddress = (EditText) view.findViewById(R.id.etDaemonAddress);
|
||||||
|
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
Helper.hideKeyboard(getActivity());
|
||||||
|
|
||||||
etDaemonAddress.setOnClickListener(new View.OnClickListener() {
|
etDaemonAddress.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
Helper.showKeyboard(getActivity());
|
||||||
imm.showSoftInput(etDaemonAddress, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
etDaemonAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etDaemonAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
Helper.hideKeyboard(getActivity());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -155,7 +153,9 @@ public class LoginFragment extends Fragment {
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
EditText tvDaemonAddress = (EditText) getView().findViewById(R.id.etDaemonAddress);
|
EditText tvDaemonAddress = (EditText) getView().findViewById(R.id.etDaemonAddress);
|
||||||
if (tvDaemonAddress.getText().toString().length() == 0) {
|
if (tvDaemonAddress.getText().toString().length() == 0) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.prompt_daemon_missing), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.prompt_daemon_missing), Toast.LENGTH_SHORT).show();
|
||||||
|
tvDaemonAddress.requestFocus();
|
||||||
|
Helper.showKeyboard(getActivity());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class LoginFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkAndSetWalletDaemon(getDaemon(), !isMainNet())) {
|
if (!checkAndSetWalletDaemon(getDaemon(), !isMainNet())) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.warn_daemon_unavailable), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.warn_daemon_unavailable), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ public class LoginFragment extends Fragment {
|
||||||
savePrefs(false);
|
savePrefs(false);
|
||||||
|
|
||||||
String wallet = itemValue.substring(WALLETNAME_PREAMBLE_LENGTH);
|
String wallet = itemValue.substring(WALLETNAME_PREAMBLE_LENGTH);
|
||||||
|
if (itemValue.charAt(1) == '-') wallet = ':' + wallet;
|
||||||
activityCallback.onWalletSelected(wallet);
|
activityCallback.onWalletSelected(wallet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -200,11 +200,6 @@ public class WalletActivity extends Activity implements WalletFragment.Listener,
|
||||||
Intent intent = new Intent(getApplicationContext(), WalletService.class);
|
Intent intent = new Intent(getApplicationContext(), WalletService.class);
|
||||||
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_STORE);
|
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_STORE);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(getApplicationContext(), getString(R.string.status_wallet_unloading), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Log.d(TAG, "STORE request sent");
|
Log.d(TAG, "STORE request sent");
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Service not bound");
|
Log.e(TAG, "Service not bound");
|
||||||
|
@ -259,6 +254,15 @@ public class WalletActivity extends Activity implements WalletFragment.Listener,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalletStored() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_unloaded), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(final String text) {
|
public void onProgress(final String text) {
|
||||||
//Log.d(TAG, "PROGRESS: " + text);
|
//Log.d(TAG, "PROGRESS: " + text);
|
||||||
|
|
|
@ -191,6 +191,8 @@ public class WalletService extends Service {
|
||||||
void onProgress(String text);
|
void onProgress(String text);
|
||||||
|
|
||||||
void onProgress(int n);
|
void onProgress(int n);
|
||||||
|
|
||||||
|
void onWalletStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
String progressText = null;
|
String progressText = null;
|
||||||
|
@ -257,6 +259,7 @@ public class WalletService extends Service {
|
||||||
Log.d(TAG, "storing wallet: " + myWallet.getName());
|
Log.d(TAG, "storing wallet: " + myWallet.getName());
|
||||||
getWallet().store();
|
getWallet().store();
|
||||||
Log.d(TAG, "wallet stored: " + myWallet.getName());
|
Log.d(TAG, "wallet stored: " + myWallet.getName());
|
||||||
|
if (observer != null) observer.onWalletStored();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,10 +18,13 @@ package com.m2049r.xmrwallet.util;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.R;
|
import com.m2049r.xmrwallet.R;
|
||||||
|
|
||||||
|
@ -82,4 +85,26 @@ public class Helper {
|
||||||
return Environment.MEDIA_MOUNTED.equals(state);
|
return Environment.MEDIA_MOUNTED.equals(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public void showKeyboard(Activity act) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(act.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void hideKeyboard(Activity act) {
|
||||||
|
if (act.getCurrentFocus() == null) {
|
||||||
|
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
} else {
|
||||||
|
InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow((null == act.getCurrentFocus()) ? null : act.getCurrentFocus().getWindowToken(),
|
||||||
|
InputMethodManager.HIDE_NOT_ALWAYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void showKeyboard(Dialog dialog) {
|
||||||
|
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void hideKeyboardAlways(Activity act) {
|
||||||
|
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
android:id="@+id/bGenerate"
|
android:id="@+id/bGenerate"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
@ -67,6 +67,21 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="visible">
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvWalletAddress"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/generate_address_placeholder"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/menu_background_color"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvWalletMnemonic"
|
android:id="@+id/tvWalletMnemonic"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -75,10 +90,10 @@
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/generate_seed"
|
android:text="@string/generate_mnemonic_placeholder"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/menu_background_color"
|
android:textColor="@color/menu_background_color"
|
||||||
android:textSize="24sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bAccept"
|
android:id="@+id/bAccept"
|
||||||
|
|
|
@ -11,13 +11,15 @@
|
||||||
<string name="status_walletlist_loading">Loading Wallet List</string>
|
<string name="status_walletlist_loading">Loading Wallet List</string>
|
||||||
<string name="status_wallet_loading">Loading Wallet …</string>
|
<string name="status_wallet_loading">Loading Wallet …</string>
|
||||||
<string name="status_wallet_unloading">Saving Wallet</string>
|
<string name="status_wallet_unloading">Saving Wallet</string>
|
||||||
|
<string name="status_wallet_unloaded">Wallet saved</string>
|
||||||
<string name="status_wallet_connecting">Connecting …</string>
|
<string name="status_wallet_connecting">Connecting …</string>
|
||||||
<string name="status_working">Working on it …</string>
|
<string name="status_working">Working on it …</string>
|
||||||
|
|
||||||
<string name="prompt_password">Password for</string>
|
<string name="prompt_password">Password for</string>
|
||||||
<string name="bad_password">Bad password!</string>
|
<string name="bad_password">Bad password!</string>
|
||||||
|
<string name="bad_wallet">Wallet does not exists!</string>
|
||||||
<string name="prompt_daemon_missing">Daemon address must be set!</string>
|
<string name="prompt_daemon_missing">Daemon address must be set!</string>
|
||||||
<string name="prompt_wrong_net">Daemon type does not fit to wallet!</string>
|
<string name="prompt_wrong_net">Wallet does not match selected net</string>
|
||||||
<string name="warn_daemon_unavailable">Cannot connect to daemon! Try again.</string>
|
<string name="warn_daemon_unavailable">Cannot connect to daemon! Try again.</string>
|
||||||
<string name="panic">Something\'s wrong!</string>
|
<string name="panic">Something\'s wrong!</string>
|
||||||
|
|
||||||
|
@ -49,8 +51,11 @@
|
||||||
<string name="generate_buttonGenerate">Do it already!</string>
|
<string name="generate_buttonGenerate">Do it already!</string>
|
||||||
<string name="generate_seed">Mnemonic Seed</string>
|
<string name="generate_seed">Mnemonic Seed</string>
|
||||||
<string name="generate_buttonAccept">I have noted this mnemonic seed\nNow, I want to loose all my money!</string>
|
<string name="generate_buttonAccept">I have noted this mnemonic seed\nNow, I want to loose all my money!</string>
|
||||||
<string name="generate_wallet_exists">Wallet exists!\nChoose another name</string>
|
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
||||||
<string name="generate_wallet_created">Wallet created</string>
|
<string name="generate_wallet_created">Wallet created</string>
|
||||||
<string name="generate_wallet_create_failed">Wallet create failed</string>
|
<string name="generate_wallet_create_failed_1">Wallet create failed (1/2)</string>
|
||||||
|
<string name="generate_wallet_create_failed_2">Wallet create failed (2/2)</string>
|
||||||
|
<string name="generate_address_placeholder">9tDC52GsMjTNt4dpnRCwAF7ekVBkbkgkXGaMKTcSTpBhGpqkPX56jCNRydLq9oGjbbAQBsZhLfgmTKsntmxRd3TaJFYM2f8</string>
|
||||||
|
<string name="generate_mnemonic_placeholder">camp feline inflamed memoir afloat eight alerts females gutter cogs menu waveform gather tawny judge gusts yahoo doctor females biscuit alchemy reef agony austere camp</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue