"Log in" and "Clear password" actions on email list
This commit is contained in:
4
TODO
4
TODO
@@ -8,9 +8,7 @@ Fixes:
|
||||
- Get pull-to-check working for empty inbox
|
||||
|
||||
Tasks:
|
||||
- Show logged-in status somewhere
|
||||
-- Persistent notification
|
||||
-- Logout action
|
||||
- Show logged-in status in persistent notification
|
||||
- More layouts for intro and setup (tune for each screen size)
|
||||
- Create and bundle better network status icons
|
||||
- Subclass EmailListFragment for each default mailbox
|
||||
|
||||
@@ -39,6 +39,7 @@ import i2p.bote.android.intro.SetupActivity;
|
||||
import i2p.bote.android.service.BoteService;
|
||||
import i2p.bote.android.service.Init;
|
||||
import i2p.bote.android.service.Init.RouterChoice;
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
import i2p.bote.android.util.MoveToDialogFragment;
|
||||
import i2p.bote.folder.EmailFolder;
|
||||
import i2p.bote.network.NetworkStatusListener;
|
||||
|
||||
@@ -61,6 +61,9 @@ public class EmailListFragment extends ListFragment implements
|
||||
private EmailListAdapter mAdapter;
|
||||
private EmailFolder mFolder;
|
||||
|
||||
private MenuItem mLogIn;
|
||||
private MenuItem mClearPassword;
|
||||
|
||||
// The Controller which provides CHOICE_MODE_MULTIPLE_MODAL-like functionality
|
||||
private MultiSelectionUtil.Controller mMultiSelectController;
|
||||
private ModalChoiceListener mModalChoiceListener;
|
||||
@@ -162,6 +165,7 @@ public class EmailListFragment extends ListFragment implements
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
setPasswordActionsState();
|
||||
initializeList();
|
||||
}
|
||||
|
||||
@@ -186,6 +190,8 @@ public class EmailListFragment extends ListFragment implements
|
||||
initializeList();
|
||||
}
|
||||
}
|
||||
|
||||
setPasswordActionsState();
|
||||
}
|
||||
|
||||
private boolean listInitialized;
|
||||
@@ -241,11 +247,42 @@ public class EmailListFragment extends ListFragment implements
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.email_list, menu);
|
||||
mLogIn = menu.findItem(R.id.action_log_in);
|
||||
mClearPassword = menu.findItem(R.id.action_clear_password);
|
||||
setPasswordActionsState();
|
||||
}
|
||||
|
||||
private void setPasswordActionsState() {
|
||||
if (mLogIn != null)
|
||||
mLogIn.setVisible(I2PBote.getInstance().isPasswordRequired());
|
||||
if (mClearPassword != null)
|
||||
mClearPassword.setVisible(I2PBote.getInstance().isPasswordInCache());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_log_in:
|
||||
// Request a password from the user.
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
@Override
|
||||
public void onPasswordVerified() {
|
||||
setPasswordActionsState();
|
||||
initializeList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordCanceled() {
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
||||
case R.id.action_clear_password:
|
||||
BoteHelper.clearPassword();
|
||||
destroyList();
|
||||
setPasswordActionsState();
|
||||
return true;
|
||||
|
||||
case R.id.action_new_email:
|
||||
if (I2PBote.getInstance().isPasswordRequired()) {
|
||||
BoteHelper.requestPassword(getActivity(), new BoteHelper.RequestPasswordListener() {
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_log_in"
|
||||
android:icon="@drawable/ic_device_access_secure"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/log_in"
|
||||
android:visible="false"
|
||||
i2pandroid:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_clear_password"
|
||||
android:icon="@drawable/ic_device_access_not_secure"
|
||||
android:orderInCategory="2"
|
||||
android:title="@string/clear_password"
|
||||
android:visible="false"
|
||||
i2pandroid:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_new_email"
|
||||
android:icon="@drawable/ic_content_new_email"
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<string name="setup_finished_2">To send and receive emails, Bote needs to connect to the distributed network. You can do this from the menu.</string>
|
||||
<string name="setup_finished_3">While Bote is offline, you can read emails that have already been downloaded. You can also write emails and put them in the Outbox; they will be sent the next time Bote is online.</string>
|
||||
<string name="go_to_inbox">Go to inbox</string>
|
||||
<string name="log_in">Log in</string>
|
||||
<string name="clear_password">Clear password</string>
|
||||
<string name="action_new_email">New email</string>
|
||||
<string name="action_send_email">Send email</string>
|
||||
<string name="action_start_bote">Connect to network</string>
|
||||
|
||||
Reference in New Issue
Block a user