In the Android system porting to do their own mobile devices, will certainly encounter changes on the boot or shutdown screen, configure their own product logo this is necessary, these are to be modified in the source code, and then compiled, the following to introduce a shutdown animation, a simple example!
File path: Frameworks\base\services\core\java\com\android\server\power\shutdownthread.java
In the Beginshutdownsequence () method:
private static void Beginshutdownsequence (context context) {...
3//Throw up a indeterminate system dialog to indicate radio are//shutting down.
The system defaults to dialog ***********************/*progressdialog pd = new ProgressDialog (context);
Pd.settitle (Context.gettext (Com.android.internal.r.string.power_off));
Pd.setmessage (Context.gettext (com.android.internal.r.string.shutdown_progress));
Pd.setindeterminate (TRUE);
Pd.setcancelable (FALSE);
Pd.getwindow (). SetType (WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
Pd.show (); *///*********************** replaced with a custom Full-screen dialog *********************** Point outsize = new Point (); Dialog Dialog = new Dialog (context, Android.
R.style.theme_black_notitlebar_fullscreen);
Indeterminateprogressbar view = new Indeterminateprogressbar (context);
Dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); Dialog.getwindow (). Getwindowmanager (). Getdefaultdisplay (). GetSize (outsize); //Get screen width high dialog.setcontentview (view, New Layoutparams (outsize.x, outsize.y));
Set the custom view width to full screen dialog.show (); ......
}
Note: You must set Dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); I forgot to add, and I didn't show anything.
Alternate Custom View:
Class Indeterminateprogressbar extends View {static final String TAG = "ProgressBar";
private int delaymillis = 30;
Private Handler Mhandler;
Private arraylist<entity> entities;
private int width = 0;
private int height = 0;
private int r = 15;
private int shift = 20;
private int radius = 3;
private int color = Color.White;
Private long time = 0;
Private Boolean started = false;
Public Indeterminateprogressbar {Super (context);
Init (); @Override protected void OnLayout (Boolean changed, int left, int. top, int right, int bottom) {super.onlay
Out (changed, left, top, right, bottom);
width = Getlayoutparams (). Width/2;
Height = getlayoutparams (). Height;
if (Width > 0) {radius = WIDTH/20;
R = 2 * WIDTH/5;
shift = WIDTH/2;
shift = WIDTH/1; }} private void Init () {Setbackgroundresource (Android).
R.color.transparent); Mhandler = new Handler (New HaNdler.
Callback () {@Override public boolean handlemessage (msg) {for (Entity e:entities) {
E.update ();
} invalidate ();
Mhandler.sendemptymessagedelayed (0, Delaymillis);
Time + = Delaymillis;
return false;
}
});
public void SetColor (int color) {this.color = color;
public void Stop () {mhandler.removemessages (0);
started = false;
Invalidate ();
public Boolean Isstart () {return started;
public void Start () {if (started) return;
started = true;
Time = 0;
entities = new arraylist<indeterminateprogressbar.entity> ();
float s =. 25f;
Entities.add (New Entity (0, color, 0));
Entities.add (New Entity (1 * s, color, Delaymillis * 4));
Entities.add (New Entity (2 * s, color, Delaymillis * 8));
Entities.add (New Entity (3 * s, color, Delaymillis * 12));
Entities.add (New Entity (4 * s, color, Delaymillis * 16)); EntitIes.add (New Entity (5 * s, color, Delaymillis * 20));
if (Mhandler!= null) mhandler.sendemptymessage (0);
@Override protected void OnDraw (Canvas Canvas) {if entities!= null && entities.size () > 0) {
for (Entity e:entities) {e.draw (canvas);
} super.ondraw (canvas);
Class Entity {private float x;
private float y;
private int color;
Private Paint Paint;
Private double sp = 0;
private long delay;
private int sec = 0;
Private float pec = 0;
Boolean visiable = true;
public float getinterpolation (float input) {return (float) (Math.Cos (input + 1) * Math.PI)/2.0f) + 0.5f;
Public Entity (float sp, int color, int delay) {paint = new paint ();
Paint.setantialias (TRUE);
Paint.setstyle (Paint.Style.FILL);
This.color = color;
THIS.SP = SP;
This.delay = delay; Paint. SetColor (This.color);
public void Update () {if (Time < delay) return;
Visiable = true;
Pec + 0.03;
if (Pec > 1) {pec = 0; SEC = ++sec = 3?
0:sec; Delay = sec = 0?
Time + delaymillis * 22:time + delaymillis * 3; visiable = sec = 0?
False:true; } doubleθ= Math.PI *. 5 + (sec = 0? 0:sec * math.pi/sec)-(sec = 0?) 0:SP) + (Math.PI * (sec = 1 2:1)-(sec = 0 sp:0) + (sec = 2? sp:0)) * getInt
Erpolation (PEC);
x = (float) (R/2 * math.cos (θ)) + shift/2;
y = (float) (R/2 * Math.sin (θ)) + shift/2;
} public void Draw (Canvas Canvas) {if (!visiable | | | x = = 0 | | | y = = 0) return;
Canvas.save ();
Canvas.translate (x, y);
Canvas.drawcircle (x, y, radius, paint);
Canvas.restore ();
} } @Override protected void Onattachedtowindow () {Super.onattachedtowindow ();
if (getvisibility () = = view.visible) {start ();
}} @Override protected void Ondetachedfromwindow () {Super.ondetachedfromwindow ();
Stop ();
The public void Setdelaymillis (int delaymillis) {this.delaymillis = Delaymillis; }
}
Effect Chart:
Thank you for reading, I hope to help you, thank you for your support for this site!