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

Commit ad5b210f authored by Danesh Mondegarian's avatar Danesh Mondegarian
Browse files

Lockscreen background extension

Add background change capability to password,
pin and pattern lockscreens.

Change-Id: Id08c43edfe9bde9ce11a4169e9d21778cbf925a8
parent 0d6e46d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#70000000"
    android:id="@+id/password"
    android:gravity="center_horizontal">

    <LinearLayout
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#70000000"
    android:id="@+id/password"
    android:gravity="center_horizontal">

    <!-- "Enter PIN(Password) to unlock" -->
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#70000000"
    android:id="@+id/pattern"
        >

    <!-- left side: instructions and emergency call button -->
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:background="#70000000"
    android:id="@+id/pattern"
    >

    <RelativeLayout
+25 −21
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
        KeyguardUpdateMonitor.SimStateCallback, SlidingTab.OnTriggerListener, RotarySelector.OnDialTriggerListener,
        OnGesturePerformedListener{

    private String LOCK_WALLPAPER;
    private static final boolean DBG = false;
    private static final String TAG = "LockScreen";
    private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
@@ -295,30 +294,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM

        final LayoutInflater inflater = LayoutInflater.from(context);
        if (DBG) Log.v(TAG, "Creation orientation = " + mCreationOrientation);
        try {
            LOCK_WALLPAPER = mContext.createPackageContext("com.cyanogenmod.cmparts", 0).getFilesDir()+"/lockwallpaper";
        } catch (NameNotFoundException e1) {
            LOCK_WALLPAPER = "";
        }
        ViewGroup lockWallpaper = null;
        if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {
            inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true);
            lockWallpaper = (RelativeLayout) findViewById(R.id.root);
        } else {
            inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true);
            lockWallpaper = (LinearLayout) findViewById(R.id.root);
        }
        if (!LOCK_WALLPAPER.equals("")){
            String mLockBack = Settings.System.getString(context.getContentResolver(), Settings.System.LOCKSCREEN_BACKGROUND);
            if (mLockBack != null){
                if (mLockBack.length() == 0){
                    Bitmap lockb = BitmapFactory.decodeFile(LOCK_WALLPAPER);
                    lockWallpaper.setBackgroundDrawable(new BitmapDrawable(lockb));
                }else{
                    lockWallpaper.setBackgroundColor(Integer.parseInt(mLockBack));
                }
            }
        }
        ViewGroup lockWallpaper = (ViewGroup) findViewById(R.id.root);
        setBackground(mContext,lockWallpaper);
        mCarrier = (TextView) findViewById(R.id.carrier);
        // Required for Marquee to work
        mCarrier.setSelected(true);
@@ -587,6 +569,28 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
        resetStatusInfo(updateMonitor);
    }

    static void setBackground(Context bcontext, ViewGroup layout){
        String mLockBack = Settings.System.getString(bcontext.getContentResolver(), Settings.System.LOCKSCREEN_BACKGROUND);
        if (mLockBack!=null){
            if (!mLockBack.isEmpty()){
                try {
                    layout.setBackgroundColor(Integer.parseInt(mLockBack));
                }catch(NumberFormatException e){
                }
            }else{
                String lockWallpaper = "";
                try {
                    lockWallpaper = bcontext.createPackageContext("com.cyanogenmod.cmparts", 0).getFilesDir()+"/lockwallpaper";
                } catch (NameNotFoundException e1) {
                }
                if (!lockWallpaper.isEmpty()){
                    Bitmap lockb = BitmapFactory.decodeFile(lockWallpaper);
                    layout.setBackgroundDrawable(new BitmapDrawable(lockb));
                }
            }
        }
    }

    private boolean isSilentMode() {
        return mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL;
    }
Loading