Password restrictions
This commit is contained in:
@@ -46,7 +46,6 @@ import uk.co.senab.actionbarpulltorefresh.library.Options;
|
||||
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;
|
||||
|
||||
public class EmailListFragment extends ListFragment implements
|
||||
BoteHelper.RequestPasswordListener,
|
||||
LoaderManager.LoaderCallbacks<List<Email>>,
|
||||
MoveToDialogFragment.MoveToDialogListener,
|
||||
EmailListAdapter.EmailSelector, OnRefreshListener {
|
||||
@@ -160,7 +159,18 @@ public class EmailListFragment extends ListFragment implements
|
||||
BoteHelper.getFolderDisplayName(getActivity(), mFolder));
|
||||
if (I2PBote.getInstance().isPasswordRequired()) {
|
||||
// Request a password from the user.
|
||||
BoteHelper.requestPassword(getActivity(), this);
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
initializeList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordCanceled() {
|
||||
setEmptyText(getResources().getString(
|
||||
R.string.not_authed));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Password is cached, or not set.
|
||||
initializeList();
|
||||
@@ -168,15 +178,6 @@ public class EmailListFragment extends ListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
public void onPasswordVerified() {
|
||||
initializeList();
|
||||
}
|
||||
|
||||
public void onPasswordCanceled() {
|
||||
setEmptyText(getResources().getString(
|
||||
R.string.not_authed));
|
||||
}
|
||||
|
||||
/**
|
||||
* Start loading the list of emails from this folder.
|
||||
* Only called when we have a password cached, or no
|
||||
@@ -217,8 +218,21 @@ public class EmailListFragment extends ListFragment implements
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_new_email:
|
||||
Intent nei = new Intent(getActivity(), NewEmailActivity.class);
|
||||
startActivity(nei);
|
||||
if (I2PBote.getInstance().isPasswordRequired()) {
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
initializeList();
|
||||
startNewEmail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordCanceled() {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startNewEmail();
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -226,6 +240,11 @@ public class EmailListFragment extends ListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
private void startNewEmail() {
|
||||
Intent nei = new Intent(getActivity(), NewEmailActivity.class);
|
||||
startActivity(nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView parent, View view, int pos, long id) {
|
||||
super.onListItemClick(parent, view, pos, id);
|
||||
|
||||
@@ -3,6 +3,7 @@ package i2p.bote.android.addressbook;
|
||||
import i2p.bote.I2PBote;
|
||||
import i2p.bote.android.R;
|
||||
import i2p.bote.android.util.BetterAsyncTaskLoader;
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
import i2p.bote.fileencryption.PasswordException;
|
||||
import i2p.bote.packet.dht.Contact;
|
||||
|
||||
@@ -58,6 +59,32 @@ public class AddressBookFragment extends ListFragment implements
|
||||
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
if (I2PBote.getInstance().isPasswordRequired()) {
|
||||
// Request a password from the user.
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
initializeList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordCanceled() {
|
||||
setEmptyText(getResources().getString(
|
||||
R.string.not_authed));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Password is cached, or not set.
|
||||
initializeList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start loading the address book.
|
||||
* Only called when we have a password cached, or no
|
||||
* password is required.
|
||||
*/
|
||||
private void initializeList() {
|
||||
setListShown(false);
|
||||
setEmptyText(getResources().getString(
|
||||
R.string.address_book_empty));
|
||||
@@ -73,8 +100,21 @@ public class AddressBookFragment extends ListFragment implements
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_new_contact:
|
||||
Intent nci = new Intent(getActivity(), EditContactActivity.class);
|
||||
getActivity().startActivityForResult(nci, AddressBookActivity.ALTER_CONTACT_LIST);
|
||||
if (I2PBote.getInstance().isPasswordRequired()) {
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
initializeList();
|
||||
startNewContact();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordCanceled() {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startNewContact();
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -82,6 +122,11 @@ public class AddressBookFragment extends ListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
private void startNewContact() {
|
||||
Intent nci = new Intent(getActivity(), EditContactActivity.class);
|
||||
getActivity().startActivityForResult(nci, AddressBookActivity.ALTER_CONTACT_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView parent, View view, int pos, long id) {
|
||||
mCallback.onContactSelected(mAdapter.getItem(pos));
|
||||
|
||||
Reference in New Issue
Block a user