Commit 8a35305d authored by Mark Stevens's avatar Mark Stevens
Browse files

fix bootanimation loop glitch on first color

parent 2fc30902
......@@ -474,11 +474,11 @@ bool BootAnimation::vendor()
initTexture(&mVendor[0], mAssets, "images/buzztime-logo-mask.png");
GLfloat colorCues[][4]= {
{(float)0x9E / 255.0, (float)0x9E / 255.0, (float)0x9E / 255.0, 1.0 },
{(float)0x00 / 255.0, (float)0xA7 / 255.0, (float)0xE1 / 255.0, 1.0 },
{(float)0x81 / 255.0, (float)0x22 / 255.0, (float)0xB0 / 255.0, 1.0 },
{(float)0x24 / 255.0, (float)0x87 / 255.0, (float)0x49 / 255.0, 1.0 },
{(float)0xEA / 255.0, (float)0x6E / 255.0, (float)0x2F / 255.0, 1.0 },
{(float)0x9E / 255.0, (float)0x9E / 255.0, (float)0x9E / 255.0, 1.0 }, // grey
{(float)0x00 / 255.0, (float)0xA7 / 255.0, (float)0xE1 / 255.0, 1.0 }, // blue
{(float)0x81 / 255.0, (float)0x22 / 255.0, (float)0xB0 / 255.0, 1.0 }, // purple
{(float)0x24 / 255.0, (float)0x87 / 255.0, (float)0x49 / 255.0, 1.0 }, // Green
{(float)0xEA / 255.0, (float)0x6E / 255.0, (float)0x2F / 255.0, 1.0 }, // orange
{0.0, 0.0, 0.0, 1.0 }
};
......@@ -486,7 +486,7 @@ bool BootAnimation::vendor()
int colorCuesCount = (sizeof(colorCues) / (sizeof(GLfloat)*4 ) ) -1;
int color_cue = 0;
GLfloat *colorS = colorCues[colorCuesCount+1]; // start on black.. move to grey
GLfloat *colorS = colorCues[colorCuesCount]; // start on black.. move to grey
GLfloat *colorE = colorCues[0];
GLfloat colorIn[] = {0.0, 0.0, 0.0, 1.0 }; // buffer for the current interpolated color
......@@ -542,7 +542,7 @@ bool BootAnimation::vendor()
dacc += parts[part];
}
// figoure out the color and adjust start/end if it has changed
// figure out the color and adjust start/end if it has changed
int color_offset = int(di) % colorCuesCount;
//ALOGD("secs: %f, pt:%d, dt: %f, di: %f, dp: %f", dt, part, dt, di, dpart);
if (color_offset != color_cue){
......
......@@ -23,6 +23,9 @@ import android.os.Bundle;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.Button;
import com.android.internal.R;
/**
* An activity that follows the visual style of an AlertDialog.
......@@ -88,6 +91,7 @@ public abstract class AlertActivity extends Activity implements DialogInterface
protected void setupAlert() {
mAlertParams.apply(mAlert);
mAlert.installContent();
}
@Override
......
......@@ -29,9 +29,12 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import com.android.internal.app.AlertActivity;
......@@ -47,6 +50,10 @@ public class UsbDebuggingActivity extends AlertActivity
private UsbDisconnectedReceiver mDisconnectedReceiver;
private String mKey;
private int countdown = 1000;
private Button mBtnCancel = null;
private Button mBtnOk = null;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
......@@ -82,8 +89,11 @@ public class UsbDebuggingActivity extends AlertActivity
if (DEBUG_CONFIRM && SystemProperties.getBoolean("debug.update.autoconfirm", false)) {
mAlwaysAllow.setChecked(true);
onClick(null, AlertDialog.BUTTON_POSITIVE);
}else
}else {
setupAlert();
mBtnCancel = (Button) findViewById(com.android.internal.R.id.button2);
mBtnCancel.postDelayed(mAutoCancelRunnable, 10000);
}
}
private class UsbDisconnectedReceiver extends BroadcastReceiver {
......@@ -114,6 +124,8 @@ public class UsbDebuggingActivity extends AlertActivity
@Override
protected void onStop() {
if (mBtnCancel!=null)
mBtnCancel.removeCallbacks(mAutoCancelRunnable);
if (mDisconnectedReceiver != null) {
unregisterReceiver(mDisconnectedReceiver);
}
......@@ -137,4 +149,30 @@ public class UsbDebuggingActivity extends AlertActivity
}
finish();
}
private Runnable mAutoCancelRunnable = new Runnable() {
@Override
public void run() {
// start the countdown, if needed
if (countdown > 100){
countdown = 30;
}
if (countdown > 0) {
if (--countdown <= 10) {
String text = (String) mBtnCancel.getText();
if (text.contains("(")) {
text = text.replaceAll("\\(\\d+\\)", "(" + countdown + ")");
} else {
text += " (" + countdown + ")";
}
//text += "-";
mBtnCancel.setText(text);
((ViewGroup) mBtnCancel.getParent()).invalidate();
}
mBtnCancel.postDelayed(this, DateUtils.SECOND_IN_MILLIS);
} else
mBtnCancel.performClick();
}
};
}
......@@ -27,11 +27,14 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
......@@ -306,6 +309,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
mItems.add(getBugReportAction());
mItems.add(new AutoBootModeToggleAction());
mItems.add(getSettingsAction());
if (!"user".equals(SystemProperties.get("ro.build.type", "user"))) {
mItems.add(new PowerFactoryResetAction());
}
}
} else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) {
if (mShowSilentToggle) {
......@@ -467,6 +473,40 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
}
private final class PowerFactoryResetAction extends SinglePressAction implements LongPressAction {
private PowerFactoryResetAction() {
super(R.drawable.ic_menu_revert,
R.string.reboot_to_reset_title);
}
@Override
public boolean onLongPress() {
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON,
"Power dialog factory reset");
mContext.sendBroadcast(intent);
//mWindowManagerFuncs.shutdown(false /* confirm */);
return true;
}
@Override
public boolean showDuringKeyguard() {
return true;
}
@Override
public boolean showBeforeProvisioning() {
return true;
}
@Override
public void onPress() {
// shutdown by making sure radio and power are handled accordingly.
//mWindowManagerFuncs.shutdown(false /* confirm */);
}
}
//using silent mode for the strings
private class AutoBootModeToggleAction extends ToggleAction implements LongPressAction {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment