mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Merge remote-tracking branch 'zjw/progress_indicators'
* zjw/progress_indicators: Provide a progress indicator while loading remote search results. Remove the progress bar from the message list footer. Provide progress indicator for searches. Conflicts: src/com/fsck/k9/activity/MessageList.java
This commit is contained in:
commit
841e565a49
@ -30,6 +30,14 @@
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -30,6 +30,14 @@
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
@ -39,15 +47,4 @@
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="36sp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/actionbar_remote_search"
|
||||
android:gravity="center_vertical"
|
||||
android:focusable="false"
|
||||
android:layout_marginRight="3dip"
|
||||
android:background="?attr/iconActionRemoteSearch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/action_remote_search"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
@ -6,13 +6,6 @@
|
||||
android:background="@drawable/message_list_item_footer_background"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<ProgressBar
|
||||
android:id="@+id/message_list_progress"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:paddingRight="10dip"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/main_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
|
@ -11,8 +11,10 @@ import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -114,6 +116,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private LocalSearch mSearch;
|
||||
private boolean mSingleFolderMode;
|
||||
private boolean mSingleAccountMode;
|
||||
private ProgressBar mActionBarProgress;
|
||||
private MenuItem mMenuButtonCheckMail;
|
||||
private View mActionButtonIndeterminateProgress;
|
||||
|
||||
/**
|
||||
* {@code true} if the message list should be displayed as flat list (i.e. no threading)
|
||||
@ -252,6 +257,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
|
||||
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
|
||||
mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count);
|
||||
mActionBarProgress = (ProgressBar) customView.findViewById(R.id.actionbar_progress);
|
||||
mActionButtonIndeterminateProgress =
|
||||
getLayoutInflater().inflate(R.layout.actionbar_indeterminate_progress_actionview, null);
|
||||
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
@ -469,6 +477,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getSupportMenuInflater().inflate(R.menu.message_list_option, menu);
|
||||
mMenu = menu;
|
||||
mMenuButtonCheckMail= menu.findItem(R.id.check_mail);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -741,4 +750,24 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
onShowFolderList();
|
||||
}
|
||||
}
|
||||
|
||||
public void enableActionBarProgress(boolean enable) {
|
||||
if (mMenuButtonCheckMail != null && mMenuButtonCheckMail.isVisible()) {
|
||||
mActionBarProgress.setVisibility(ProgressBar.GONE);
|
||||
if (enable) {
|
||||
mMenuButtonCheckMail
|
||||
.setActionView(mActionButtonIndeterminateProgress);
|
||||
} else {
|
||||
mMenuButtonCheckMail.setActionView(null);
|
||||
}
|
||||
} else {
|
||||
if (mMenuButtonCheckMail != null)
|
||||
mMenuButtonCheckMail.setActionView(null);
|
||||
if (enable) {
|
||||
mActionBarProgress.setVisibility(ProgressBar.VISIBLE);
|
||||
} else {
|
||||
mActionBarProgress.setVisibility(ProgressBar.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -804,6 +804,9 @@ public class MessagingController implements Runnable {
|
||||
threadPool.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (listener != null) {
|
||||
listener.enableProgressIndicator(true);
|
||||
}
|
||||
try {
|
||||
Store remoteStore = account.getRemoteStore();
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
@ -822,6 +825,10 @@ public class MessagingController implements Runnable {
|
||||
} catch (MessagingException e) {
|
||||
Log.e(K9.LOG_TAG, "Exception in loadSearchResults: " + e);
|
||||
addErrorMessage(account, null, e);
|
||||
} finally {
|
||||
if (listener != null) {
|
||||
listener.enableProgressIndicator(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -207,4 +207,6 @@ public class MessagingListener {
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public void controllerCommandCompleted(boolean moreCommandsToRun) {}
|
||||
|
||||
public void enableProgressIndicator(boolean enable) { }
|
||||
}
|
||||
|
@ -382,9 +382,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
|
||||
private FontSizes mFontSizes = K9.getFontSizes();
|
||||
|
||||
private MenuItem mRefreshMenuItem;
|
||||
private ActionMode mActionMode;
|
||||
private View mActionBarProgressView;
|
||||
|
||||
private Boolean mHasConnectivity;
|
||||
|
||||
@ -454,11 +452,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void updateFooter(final String message, final boolean showProgress) {
|
||||
public void updateFooter(final String message) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessageListFragment.this.updateFooter(message, showProgress);
|
||||
MessageListFragment.this.updateFooter(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -622,16 +620,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
}
|
||||
|
||||
private void progress(final boolean progress) {
|
||||
// Make sure we don't try this before the menu is initialized
|
||||
// this could happen while the activity is initialized.
|
||||
if (mRefreshMenuItem != null) {
|
||||
if (progress) {
|
||||
mRefreshMenuItem.setActionView(mActionBarProgressView);
|
||||
} else {
|
||||
mRefreshMenuItem.setActionView(null);
|
||||
}
|
||||
}
|
||||
|
||||
mFragmentListener.enableActionBarProgress(progress);
|
||||
if (mPullToRefreshView != null && !progress) {
|
||||
mPullToRefreshView.onRefreshComplete();
|
||||
}
|
||||
@ -658,7 +647,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mExtraSearchResults.size());
|
||||
} else {
|
||||
mExtraSearchResults = null;
|
||||
updateFooter("", false);
|
||||
updateFooter("");
|
||||
}
|
||||
|
||||
mController.loadSearchResults(mAccount, mCurrentFolder.name, toProcess, mListener);
|
||||
@ -726,8 +715,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
|
||||
View view = inflater.inflate(R.layout.message_list_fragment, container, false);
|
||||
|
||||
mActionBarProgressView = inflater.inflate(R.layout.actionbar_indeterminate_progress_actionview, null);
|
||||
|
||||
initializePullToRefresh(inflater, view);
|
||||
|
||||
initializeLayout();
|
||||
@ -1533,9 +1520,13 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
@Override
|
||||
public void remoteSearchStarted(Account acct, String folder) {
|
||||
mHandler.progress(true);
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_sending_query), true);
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_sending_query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableProgressIndicator(boolean enable) {
|
||||
mHandler.progress(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteSearchFinished(Account acct, String folder, int numResults, List<Message> extraResults) {
|
||||
@ -1543,9 +1534,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mHandler.remoteSearchFinished();
|
||||
mExtraSearchResults = extraResults;
|
||||
if (extraResults != null && extraResults.size() > 0) {
|
||||
mHandler.updateFooter(String.format(mContext.getString(R.string.load_more_messages_fmt), acct.getRemoteSearchNumResults()), false);
|
||||
mHandler.updateFooter(String.format(mContext.getString(R.string.load_more_messages_fmt), acct.getRemoteSearchNumResults()));
|
||||
} else {
|
||||
mHandler.updateFooter("", false);
|
||||
mHandler.updateFooter("");
|
||||
}
|
||||
mFragmentListener.setMessageListProgress(Window.PROGRESS_END);
|
||||
|
||||
@ -1555,9 +1546,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
public void remoteSearchServerQueryComplete(Account account, String folderName, int numResults) {
|
||||
mHandler.progress(true);
|
||||
if (account != null && account.getRemoteSearchNumResults() != 0 && numResults > account.getRemoteSearchNumResults()) {
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading_limited, account.getRemoteSearchNumResults(), numResults), true);
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading_limited, account.getRemoteSearchNumResults(), numResults));
|
||||
} else {
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading, numResults), true);
|
||||
mHandler.updateFooter(mContext.getString(R.string.remote_search_downloading, numResults));
|
||||
}
|
||||
mFragmentListener.setMessageListProgress(Window.PROGRESS_START);
|
||||
}
|
||||
@ -1865,8 +1856,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mFooterView = mInflater.inflate(R.layout.message_list_item_footer, parent, false);
|
||||
mFooterView.setId(R.layout.message_list_item_footer);
|
||||
FooterViewHolder holder = new FooterViewHolder();
|
||||
holder.progress = (ProgressBar) mFooterView.findViewById(R.id.message_list_progress);
|
||||
holder.progress.setIndeterminate(true);
|
||||
holder.main = (TextView) mFooterView.findViewById(R.id.main_text);
|
||||
mFooterView.setTag(holder);
|
||||
}
|
||||
@ -1878,7 +1867,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
if (!mSearch.isManualSearch() && mCurrentFolder != null && mAccount != null) {
|
||||
if (mCurrentFolder.loading) {
|
||||
final boolean showProgress = true;
|
||||
updateFooter(mContext.getString(R.string.status_loading_more), showProgress);
|
||||
updateFooter(mContext.getString(R.string.status_loading_more));
|
||||
} else {
|
||||
String message;
|
||||
if (!mCurrentFolder.lastCheckFailed) {
|
||||
@ -1891,26 +1880,25 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
message = mContext.getString(R.string.status_loading_more_failed);
|
||||
}
|
||||
final boolean showProgress = false;
|
||||
updateFooter(message, showProgress);
|
||||
updateFooter(message);
|
||||
}
|
||||
} else {
|
||||
final boolean showProgress = false;
|
||||
updateFooter(null, showProgress);
|
||||
updateFooter(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFooter(final String text, final boolean progressVisible) {
|
||||
public void updateFooter(final String text) {
|
||||
if (mFooterView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FooterViewHolder holder = (FooterViewHolder) mFooterView.getTag();
|
||||
|
||||
holder.progress.setVisibility(progressVisible ? ProgressBar.VISIBLE : ProgressBar.GONE);
|
||||
if (text != null) {
|
||||
holder.main.setText(text);
|
||||
}
|
||||
if (progressVisible || holder.main.getText().length() > 0) {
|
||||
if (holder.main.getText().length() > 0) {
|
||||
holder.main.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.main.setVisibility(View.GONE);
|
||||
@ -1918,7 +1906,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
}
|
||||
|
||||
static class FooterViewHolder {
|
||||
public ProgressBar progress;
|
||||
public TextView main;
|
||||
}
|
||||
|
||||
@ -2744,6 +2731,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
}
|
||||
|
||||
public interface MessageListFragmentListener {
|
||||
void enableActionBarProgress(boolean enable);
|
||||
void setMessageListProgress(int level);
|
||||
void showThread(Account account, String folderName, long rootId);
|
||||
void showMoreFromSameSender(String senderAddress);
|
||||
|
Loading…
Reference in New Issue
Block a user