mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Provide progress indicator for searches.
Searches can be slow, so users need an indicator. The indicator is also used when opening a message list or when refreshing it, or when loading more messages. This also removes some unused code.
This commit is contained in:
parent
ac6c48c2d8
commit
689f69ca49
@ -30,6 +30,14 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</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
|
<TextView
|
||||||
android:id="@+id/actionbar_unread_count"
|
android:id="@+id/actionbar_unread_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
android:textColor="?android:attr/textColorSecondary" />
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
</LinearLayout>
|
</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
|
<TextView
|
||||||
android:id="@+id/actionbar_unread_count"
|
android:id="@+id/actionbar_unread_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -39,15 +47,4 @@
|
|||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
android:textSize="36sp" />
|
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>
|
</LinearLayout>
|
@ -11,8 +11,10 @@ import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
|||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -114,6 +116,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
private LocalSearch mSearch;
|
private LocalSearch mSearch;
|
||||||
private boolean mSingleFolderMode;
|
private boolean mSingleFolderMode;
|
||||||
private boolean mSingleAccountMode;
|
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)
|
* {@code true} if the message list should be displayed as flat list (i.e. no threading)
|
||||||
@ -246,6 +251,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
|
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
|
||||||
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
|
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
|
||||||
mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count);
|
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);
|
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
@ -472,6 +480,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getSupportMenuInflater().inflate(R.menu.message_list_option, menu);
|
getSupportMenuInflater().inflate(R.menu.message_list_option, menu);
|
||||||
mMenu = menu;
|
mMenu = menu;
|
||||||
|
mMenuButtonCheckMail= menu.findItem(R.id.check_mail);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,4 +740,23 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
// Remove action button for remote search
|
// Remove action button for remote search
|
||||||
configureMenu(mMenu);
|
configureMenu(mMenu);
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,9 +378,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
|
|
||||||
private FontSizes mFontSizes = K9.getFontSizes();
|
private FontSizes mFontSizes = K9.getFontSizes();
|
||||||
|
|
||||||
private MenuItem mRefreshMenuItem;
|
|
||||||
private ActionMode mActionMode;
|
private ActionMode mActionMode;
|
||||||
private View mActionBarProgressView;
|
|
||||||
|
|
||||||
private Boolean mHasConnectivity;
|
private Boolean mHasConnectivity;
|
||||||
|
|
||||||
@ -608,16 +606,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void progress(final boolean progress) {
|
private void progress(final boolean progress) {
|
||||||
// Make sure we don't try this before the menu is initialized
|
mFragmentListener.enableActionBarProgress(progress);
|
||||||
// this could happen while the activity is initialized.
|
|
||||||
if (mRefreshMenuItem != null) {
|
|
||||||
if (progress) {
|
|
||||||
mRefreshMenuItem.setActionView(mActionBarProgressView);
|
|
||||||
} else {
|
|
||||||
mRefreshMenuItem.setActionView(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mPullToRefreshView != null && !progress) {
|
if (mPullToRefreshView != null && !progress) {
|
||||||
mPullToRefreshView.onRefreshComplete();
|
mPullToRefreshView.onRefreshComplete();
|
||||||
}
|
}
|
||||||
@ -712,8 +701,6 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
|
|
||||||
View view = inflater.inflate(R.layout.message_list_fragment, container, false);
|
View view = inflater.inflate(R.layout.message_list_fragment, container, false);
|
||||||
|
|
||||||
mActionBarProgressView = inflater.inflate(R.layout.actionbar_indeterminate_progress_actionview, null);
|
|
||||||
|
|
||||||
initializePullToRefresh(inflater, view);
|
initializePullToRefresh(inflater, view);
|
||||||
|
|
||||||
initializeLayout();
|
initializeLayout();
|
||||||
@ -2699,6 +2686,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface MessageListFragmentListener {
|
public interface MessageListFragmentListener {
|
||||||
|
void enableActionBarProgress(boolean enable);
|
||||||
void setMessageListProgress(int level);
|
void setMessageListProgress(int level);
|
||||||
void showThread(Account account, String folderName, long rootId);
|
void showThread(Account account, String folderName, long rootId);
|
||||||
void showMoreFromSameSender(String senderAddress);
|
void showMoreFromSameSender(String senderAddress);
|
||||||
|
Loading…
Reference in New Issue
Block a user