Make the refresh button animate in-place.

Turn the refresh button into an indeterminate progress icon
while refreshing.

Bug 3388138

Change-Id: Ic0406ff5b857243c3e1e475ddb8b305441eddbb0
This commit is contained in:
Makoto Onuki 2011-01-25 14:46:11 -08:00
parent c850485269
commit 484d220b6e
2 changed files with 36 additions and 3 deletions

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
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="64dip"
android:layout_height="wrap_content"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="?android:attr/indeterminateProgressStyle"
/>
</FrameLayout>

View File

@ -45,7 +45,6 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import java.security.InvalidParameterException;
@ -151,7 +150,6 @@ public class MessageListXL extends Activity implements
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Email.LOG_TAG, "MessageListXL onCreate");
super.onCreate(savedInstanceState);
ActivityHelper.debugSetWindowFlags(this);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.message_list_xl);
ActionBar ab = getActionBar();
@ -703,7 +701,7 @@ public class MessageListXL extends Activity implements
* If we're refreshing the current mailbox, animate the "mailbox refreshing" progress icon.
*/
private void updateProgressIcon() {
setProgressBarIndeterminateVisibility(isProgressActive());
invalidateOptionsMenu();
}
private boolean isProgressActive() {
@ -723,6 +721,12 @@ public class MessageListXL extends Activity implements
MenuItem item = menu.findItem(R.id.refresh);
if (item != null) {
item.setVisible(shouldShowRefreshButton());
if (isProgressActive()) {
// Turn it into a progress icon.
item.setActionView(R.layout.action_bar_indeterminate_progress);
} else {
item.setActionView(null);
}
}
return super.onPrepareOptionsMenu(menu);
}