1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fix the upper refresh button in MessageList

This commit is contained in:
Sander Bogaert 2012-07-17 09:07:15 -04:00 committed by Andrew Chen
parent 1b9abb2b9b
commit 6c27d3e7ef
3 changed files with 31 additions and 39 deletions

View File

@ -1,30 +1,14 @@
<!-- <?xml version="1.0" encoding="utf-8"?>
Copyright 2011 The Android Open Source Project <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:paddingRight="12dp" android:paddingRight="12dp"
android:paddingLeft="12dp"> android:paddingLeft="12dp"
<!-- FrameLayout ignores margins on android 2.x so we use this padding android:gravity="center_vertical">
to make sure the total is the same width as the icon we
replace and no visual shifting occurs -->
<ProgressBar android:layout_width="32dp" <ProgressBar android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_gravity="center" android:layout_alignParentRight="true"
style="?android:attr/indeterminateProgressStyle" /> style="?android:attr/indeterminateProgressStyle" />
</FrameLayout>
</RelativeLayout>

View File

@ -6,7 +6,7 @@
android:focusable="true" > android:focusable="true" >
<ImageButton <ImageButton
android:id="@+id/imageButton1" android:id="@+id/actionbar_refresh_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:background="@null"

View File

@ -313,7 +313,9 @@ public class MessageList
private MenuItem mRefreshMenuItem; private MenuItem mRefreshMenuItem;
private View mActionBarProgressView; private View mActionBarProgressView;
private View mCustomRefreshView;
private ActionBarNavigationSpinner mNavigationSpinner; private ActionBarNavigationSpinner mNavigationSpinner;
private ActionBar mActionBar;
private Bundle mState = null; private Bundle mState = null;
/** /**
@ -558,9 +560,9 @@ public class MessageList
} }
if (progress) { if (progress) {
mRefreshMenuItem.setActionView(mActionBarProgressView); mActionBar.setCustomView(mActionBarProgressView);
} else { } else {
mRefreshMenuItem.setActionView(null); mActionBar.setCustomView(mCustomRefreshView);
} }
} }
@ -901,14 +903,26 @@ public class MessageList
private void initializeActionBar() { private void initializeActionBar() {
requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS);
ActionBar actionBar = getSupportActionBar(); mActionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.actionbar_top_custom);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, mCustomRefreshView = mInflater.inflate(R.layout.actionbar_top_custom, null);
ImageButton mCustomRefresh = (ImageButton) mCustomRefreshView.findViewById(R.id.actionbar_refresh_button);
mCustomRefresh.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mFolderName != null) {
checkMail(mAccount, mFolderName);
}
}
});
mActionBar.setCustomView(mCustomRefreshView);
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM); ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayShowTitleEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this); mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this);
actionBar.setListNavigationCallbacks(mNavigationSpinner, this); mActionBar.setListNavigationCallbacks(mNavigationSpinner, this);
} }
private void initializeLayout() { private void initializeLayout() {
@ -1568,12 +1582,6 @@ public class MessageList
} }
switch (itemId) { switch (itemId) {
case R.id.check_mail: {
if (mFolderName != null) {
checkMail(mAccount, mFolderName);
}
return true;
}
case R.id.send_messages: { case R.id.send_messages: {
mController.sendPendingMessages(mAccount, mAdapter.mListener); mController.sendPendingMessages(mAccount, mAdapter.mListener);
return true; return true;