mirror of
https://github.com/wownero/wownerujo.git
synced 2026-11-17 22:03:58 +01:00
list context menu + tweaks
This commit is contained in:
@@ -23,8 +23,11 @@ import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -177,6 +180,7 @@ public class LoginFragment extends Fragment {
|
||||
android.R.layout.simple_list_item_1, android.R.id.text1, this.displayedList);
|
||||
|
||||
listView.setAdapter(adapter);
|
||||
registerForContextMenu(listView);
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
@@ -215,7 +219,7 @@ public class LoginFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
/* listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// Difference to opening wallet is that we don't need a daemon set
|
||||
@@ -239,6 +243,7 @@ public class LoginFragment extends Fragment {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
*/
|
||||
loadList();
|
||||
return view;
|
||||
}
|
||||
@@ -386,4 +391,44 @@ public class LoginFragment extends Fragment {
|
||||
mgr.setDaemon(daemonAddress, testnet, username, password);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenu.ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
inflater.inflate(R.menu.list_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_info:
|
||||
String listItem = (String) listView.getItemAtPosition(info.position);
|
||||
return showInfo(listItem);
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean showInfo(String listItem) {
|
||||
|
||||
if (listItem.length() <= (WALLETNAME_PREAMBLE_LENGTH)) {
|
||||
Toast.makeText(getActivity(), getString(R.string.panic), Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
String wallet = listItem.substring(WALLETNAME_PREAMBLE_LENGTH);
|
||||
String x = isMainNet() ? "4" : "9A";
|
||||
if (x.indexOf(listItem.charAt(1)) < 0) {
|
||||
Toast.makeText(getActivity(), getString(R.string.prompt_wrong_net), Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
checkAndSetWalletDaemon("", !isMainNet()); // just set selected net
|
||||
|
||||
activityCallback.onWalletDetails(wallet);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user