Launcher3 desktop wallpaper is stretched blur modified _launcher3

Source: Internet
Author: User

Recently very busy, record, Launcher3 wallpaper modification. Lest forget. It took me nearly half a day.

Environment: RK3288 + Androidll

Step: Enter Launcher3, long press the desktop blank section, set up a built-in wallpaper.

Phenomenon: The discovery is blurred because it has been stretched.

The first article of this kind. Talk about the solution to the idea.

Train of thought: This kind of view is relatively simple question. Start with the UI. (for people with less experience). The problem is not on the Launcher3, it's on the Wallpapermanagerservice. Starting from Launcher3 ...
Layout:actionbar_set_wallpaper can be found by string ...

See the code Wallpapercropactivity.java.

<strong>protected void init () {
        ...

        //Action Bar
        /show the custom Action bar view
        final Actionbar Actionbar = Getactionbar ();
        Actionbar.setcustomview (r.layout.actionbar_set_wallpaper);
        Actionbar.getcustomview (). Setonclicklistener (
                new View.onclicklistener () {
                    @Override public
                    Void OnClick (View v) {
                        Boolean finishactivitywhendone = true;
                        Cropimageandsetwallpaper (Imageuri, NULL, Finishactivitywhendone);
                    }
                );
}
</strong>


Keep watching Cropimageandsetwallpaper.

<strong>protected void Cropimageandsetwallpaper (resources res, int resid, final Boolean finishactivityw Hendone) {//crop this image and scale it down to the default wallpaper size for//This device I
        NT rotation = getrotationfromexif (res, resid);
        Point insize = Mcropview.getsourcedimensions ();
        Point outsize = Getdefaultwallpapersize (Getresources (), Getwindowmanager ());
        RECTF crop = Getmaxcroprect (insize.x, Insize.y, outsize.x, Outsize.y, false); Runnable Onendcrop = new Runnable () {public void run () {//passing 0, 0 'll cause launcher
                To revert to using the//default wallpaper size updatewallpaperdimensions (0, 0);
                    if (finishactivitywhendone) {setresult (ACTIVITY.RESULT_OK);
                Finish ();
        }
            }
        }; Bitmapcroptask Croptask = nEW Bitmapcroptask (This, res, resid, crop, rotation, outsize.x, Outsize.y, True, false, Onendcrop);
    Croptask.execute (); } </strong>

Here, Bitmapcroptask is the actual setting. You don't have to post code.

The outsize here is the key point of being stretched. There's gotta be a check here.

Later found that the log was hit. It is found that the exact size is not the same as the actual size.

Getdefaultwallpapersize

Look at this piece of code.

<strong>static protected Point Getdefaultwallpapersize (Resources res, WindowManager WindowManager) {if (sDe
            Faultwallpapersize = = null) {Point mindims = new Point ();
            Point maxdims = new Point ();

            Windowmanager.getdefaultdisplay (). Getcurrentsizerange (Mindims, maxdims);
            int Maxdim = Math.max (maxdims.x, MAXDIMS.Y);

            int Mindim = Math.max (mindims.x, MINDIMS.Y); if (Android.os.Build.VERSION.SDK_INT >= Android.os.Build.VERSION_CODES.
                JELLY_BEAN_MR1) {Point realsize = new Point ();
                Windowmanager.getdefaultdisplay (). Getrealsize (Realsize);
                Maxdim = Math.max (realsize.x, realsize.y);
            Mindim = Math.min (realsize.x, realsize.y); }//We need to ensure so there is enough extra spaces in the wallpaper//for the intended para
            Llax effects Final int defaultwidth, defaultheight; if (IsscreenlaRge (res)) {defaultwidth = (int) (Maxdim * Wallpapertraveltoscreenwidthratio (Maxdim, Mindim));
            DefaultHeight = Maxdim;
                else {defaultwidth = Math.max (int) (Mindim * wallpaper_screens_span), Maxdim);
            DefaultHeight = Maxdim;
        } sdefaultwallpapersize = new Point (DefaultWidth, defaultheight);
    return sdefaultwallpapersize; } </strong>

Take a look here and log and find that DefaultHeight and defaultwidth are not the same values. The size is very large. It must have been properly stretched. Conform to the analysis of the phenomenon.


How to modify: Make a real size and get it done.

<strong> point            realsize = new Point ();
            Windowmanager.getdefaultdisplay (). Getrealsize (realsize);
            Final int defaultwidth, defaultheight;
            if (/*isscreenlarge (res) */false) {
                defaultwidth = (int) (Maxdim * Wallpapertraveltoscreenwidthratio (Maxdim, MinDim ));
                DefaultHeight = Maxdim;
            } else {
                //defaultwidth = math.max (int) (Mindim * wallpaper_screens_span), Maxdim);
                DefaultHeight = Maxdim;
                DefaultWidth = realsize.x;
                DefaultHeight = realsize.y;
            }
</strong>


Modification completed. That's it. Wallpaper is not stretched. You don't have to keep watching Wallpapermanagerservice.


Summary. Previously felt very simple code, found that after the change or will forget. Never mind. or write down to the ...

Scheme company out of the people, there is no product, no code, but reading the framework to read application reading foreign language documents have the ability.

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.