Don't modify UI from email-sending thread
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
0.3.1
|
||||
* Fixed crash when clicking "Create new contact" button
|
||||
* Fixed crash when sending email
|
||||
* Fixed occasional crashes when Bote connects to / disconnects from the network
|
||||
* Improved robustness and user feedback for email checking
|
||||
* Added "Copy to clipboard" button to identities and contacts
|
||||
|
||||
@@ -41,12 +41,14 @@ import i2p.bote.android.service.Init.RouterChoice;
|
||||
import i2p.bote.android.util.MoveToDialogFragment;
|
||||
import i2p.bote.fileencryption.PasswordCacheListener;
|
||||
import i2p.bote.folder.EmailFolder;
|
||||
import i2p.bote.folder.FolderListener;
|
||||
import i2p.bote.network.NetworkStatusListener;
|
||||
|
||||
public class EmailListActivity extends ActionBarActivity implements
|
||||
EmailListFragment.OnEmailSelectedListener,
|
||||
MoveToDialogFragment.MoveToDialogListener,
|
||||
PasswordCacheListener,
|
||||
FolderListener,
|
||||
NetworkStatusListener {
|
||||
private I2PAndroidHelper mHelper;
|
||||
private RouterChoice mRouterChoice;
|
||||
@@ -108,7 +110,7 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
|
||||
// Set the list of folders
|
||||
// TODO: This is slow, needs a loader
|
||||
mFolderAdapter.setData(I2PBote.getInstance().getEmailFolders());
|
||||
mFolderAdapter.setData(I2PBote.getInstance().getEmailFolders(), this);
|
||||
|
||||
// Set a custom shadow that overlays the main content when the drawer opens
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
@@ -289,42 +291,42 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// The action bar home/up action should open or close the drawer.
|
||||
// ActionBarDrawerToggle will take care of this.
|
||||
if(mDrawerToggle.onOptionsItemSelected(item)) {
|
||||
if (mDrawerToggle.onOptionsItemSelected(item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_start_bote:
|
||||
// Init from settings
|
||||
Init init = new Init(this);
|
||||
mRouterChoice = init.initialize(mHelper);
|
||||
case R.id.action_start_bote:
|
||||
// Init from settings
|
||||
Init init = new Init(this);
|
||||
mRouterChoice = init.initialize(mHelper);
|
||||
|
||||
if (mRouterChoice == RouterChoice.ANDROID) {
|
||||
if (!mHelper.isI2PAndroidInstalled()) {
|
||||
// I2P Android not installed
|
||||
mHelper.promptToInstall(this);
|
||||
} else if (!mHelper.isI2PAndroidRunning()) {
|
||||
// Ask user to start I2P Android
|
||||
mHelper.requestI2PAndroidStart(this);
|
||||
if (mRouterChoice == RouterChoice.ANDROID) {
|
||||
if (!mHelper.isI2PAndroidInstalled()) {
|
||||
// I2P Android not installed
|
||||
mHelper.promptToInstall(this);
|
||||
} else if (!mHelper.isI2PAndroidRunning()) {
|
||||
// Ask user to start I2P Android
|
||||
mHelper.requestI2PAndroidStart(this);
|
||||
} else
|
||||
startBote();
|
||||
} else
|
||||
startBote();
|
||||
} else
|
||||
startBote();
|
||||
return true;
|
||||
return true;
|
||||
|
||||
case R.id.action_stop_bote:
|
||||
Intent stop = new Intent(this, BoteService.class);
|
||||
stopService(stop);
|
||||
supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
case R.id.action_stop_bote:
|
||||
Intent stop = new Intent(this, BoteService.class);
|
||||
stopService(stop);
|
||||
supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
|
||||
case R.id.action_settings:
|
||||
Intent si = new Intent(this, SettingsActivity.class);
|
||||
startActivity(si);
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
Intent si = new Intent(this, SettingsActivity.class);
|
||||
startActivity(si);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,6 +418,38 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
});
|
||||
}
|
||||
|
||||
// FolderListener
|
||||
|
||||
@Override
|
||||
public void elementAdded(String messageId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFolderAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementUpdated() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFolderAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementRemoved(String messageId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFolderAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NetworkStatusListener
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class FolderListAdapter extends ArrayAdapter<EmailFolder> implements FolderListener {
|
||||
public class FolderListAdapter extends ArrayAdapter<EmailFolder> {
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
public FolderListAdapter(Context context) {
|
||||
@@ -22,16 +22,16 @@ public class FolderListAdapter extends ArrayAdapter<EmailFolder> implements Fold
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
public void setData(List<EmailFolder> folders) {
|
||||
public void setData(List<EmailFolder> folders, FolderListener folderListener) {
|
||||
// Remove previous FolderListeners
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
getItem(i).removeFolderListener(this);
|
||||
getItem(i).removeFolderListener(folderListener);
|
||||
}
|
||||
clear();
|
||||
if (folders != null) {
|
||||
for (EmailFolder folder : folders) {
|
||||
add(folder);
|
||||
folder.addFolderListener(this);
|
||||
folder.addFolderListener(folderListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,21 +53,4 @@ public class FolderListAdapter extends ArrayAdapter<EmailFolder> implements Fold
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
// FolderListener
|
||||
|
||||
@Override
|
||||
public void elementAdded(String messageId) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementUpdated() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementRemoved(String messageId) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user