Li Bo teaches you how to perform one-click memory cleanup desktop shortcut Animation: graphic Jinshan battery doctor

Source: Internet
Author: User

You can click the "quick clean" shortcut on the desktop to play an animation and then prompt you How much memory and processes you have cleaned up, it looks cool, but the biggest advantage of this is that users Reduce Unnecessary operations by two times: Click to execute the cleanup operation and exit the software operation.

Today, we will take Kingsoft battery doctor for graphic analysis:

If you have used Kingsoft battery doctor, it will create a "fast power-saving" shortcut on the desktop of your mobile phone when you open the software for the first time. If you want to clean up the process with one click, click it.

At first, I thought it was a widget, but it was not necessary to think about it. When I really wanted to add a "Window widget", I found the mystery:

You will find that the shortcut icon and the picture for playing the animation are misplaced. Haha, do you want to say that this is not just a trick for kids?

Yes, it is actually a blind eye: when a user clicks a shortcut, the activity actually directs to the shortcut, but this activity is a dialog style and only plays an animation in it,

After the memory cleanup operation is completed, the animation ends, and the toast result is sent to the user, and the user finishes the operation.

The detailed procedure is as follows:

1. Now, an activty is declared in androidmanifest. XML, which is also the form to be started by the shortcut:

        <activity            android:name=".onekey.OneKeyActivity"            android:excludeFromRecents="true"            android:exported="true"             android:icon="@drawable/shortcut_onekey"            android:label="@string/shortcut_onekey"            android:taskAffinity="com.souapp.screenlockmanager"            android:theme="@android:style/Theme.Translucent.NoTitleBar" >            <intent-filter>                <action android:name="android.intent.category.MAIN" />                <action android:name="android.intent.action.CREATE_SHORTCUT" />              </intent-filter>        </activity>

2. How do you create shortcuts for your program?

3. Briefly describe onekeyactivity

Create a layout file in layout: shortcut_onekey.xml

<?xml version="1.0" encoding="UTF-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/main"    android:layout_width="fill_parent"    android:layout_height="fill_parent" >    <FrameLayout        android:id="@+id/anim_layout"        android:layout_width="60.0dip"        android:layout_height="60.0dip"        android:background="@drawable/shortcut_onekey_bg"        android:visibility="invisible" >        <ImageView            android:id="@+id/anim_image"            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:background="@drawable/shortcut_onekey_rotate"            android:visibility="invisible" />        <ImageView            android:id="@+id/cover_image"            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:background="@drawable/shortcut_onekey_cover"            android:visibility="visible" />    </FrameLayout></RelativeLayout>

In fact, this layout file is just a few pictures.

Then, create the shortcut_onekey.xml file in the anim directory.

<?xml version="1.0" encoding="UTF-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" >    <rotate        android:duration="1200"        android:fromDegrees="0.0"        android:pivotX="50.0%"        android:pivotY="50.0%"        android:toDegrees="1440.0" /></set>

The following is the main code of onekeyactivity:

@ Override public void oncreate (bundle) {super. oncreate (bundle); intent = getintent (); setcontentview (R. layout. shortcut_onekey); BG = (framelayout) findviewbyid (R. id. anim_layout); rect = intent. getsourcebounds (); If (rect! = NULL) {// int I = getresources (). getdimensionpixelsize (0x7f0b001d); int I = 20; Int J = rect. left + rect. width ()/2; int K = I + rect. top; android. widget. relativelayout. layoutparams = (Android. widget. relativelayout. layoutparams) BG. getlayoutparams (); layoutparams. leftmargin = J-layoutparams. width/2; layoutparams. topmargin = k-layoutparams. height/2; BG. setlayoutparams (layoutparams);} play (this); mhandler. sendemptymessagedelayed (1, 1000);} public static void play (onekeyactivity) {onekeyactivity. BG. setvisibility (0); imageview = (imageview) onekeyactivity. findviewbyid (R. id. anim_image); imageview. setvisibility (0); imageview. startanimation (animationutils. loadanimation (onekeyactivity, R. anim. shortcut_onekey);} private handler mhandler = new handler () {public void handlemessage (Message MSG) {toast. maketext (getapplicationcontext (), "Kill N processes", toast. length_short ). show (); if (1 = MSG. what) finish (); // The animation playback ends and our activity interface ends }};

On the whole, it is relatively simple. However, I don't think programmers and artists can come up with this design. It should be because product managers are close to users, put forward similar usage requirements. It seems that it is not easy to do anything, especially when the app is not making money. We also need to find ways to improve the user experience and get user approval. Only large companies have this resource, A group of people have spare time to do this.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.