Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9f9caf8 authored by isimobile's avatar isimobile
Browse files

Change background selection for lockscreen to be more

  consistant on Tablets (2/2)

Change-Id: Ia1a703ce213fa7698a2fb8e1679eefccd521962b
parent 8e5a6d0b
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -45,7 +45,10 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.*;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout.LayoutParams;
import android.util.Log;
import android.media.AudioManager;
import android.provider.MediaStore;
@@ -551,10 +554,29 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
                }
            } else {
                try {
                    layout.getParent();
                    ViewParent parent =  layout.getParent();
                    if (parent != null) {
                        //change parent to show background correctly on scale
                        RelativeLayout rlout = new RelativeLayout(context);
                        ((ViewGroup) parent).removeView(layout);
                        layout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
                        ((ViewGroup) parent).addView(rlout); // change parent to new layout
                        rlout.addView(layout);
                        // create framelayout and add imageview to set background
                        FrameLayout flayout = new FrameLayout(context);
                        flayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
                        ImageView mLockScreenWallpaperImage = new ImageView(flayout.getContext());
                        mLockScreenWallpaperImage.setScaleType(ScaleType.CENTER_CROP);
                        flayout.addView(mLockScreenWallpaperImage, -1, -1);
                        Context settingsContext = context.createPackageContext("com.android.settings", 0);
                        String wallpaperFile = settingsContext.getFilesDir() + "/lockwallpaper";
                        Bitmap background = BitmapFactory.decodeFile(wallpaperFile);
                    layout.setBackgroundDrawable(new BitmapDrawable(background));
                        Drawable d = new BitmapDrawable(context.getResources(), background);
                        mLockScreenWallpaperImage.setImageDrawable(d);
                        // add background to lock screen.
                        rlout.addView(flayout,0);
                    }
                } catch (NameNotFoundException e) {
                }
            }