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

Commit 9aad1946 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Check for configuration change in LauncherActivity

parent 4adf3272
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@
            android:resumeWhilePausing="true"
            android:resumeWhilePausing="true"
            android:screenOrientation="nosensor"
            android:screenOrientation="nosensor"
            android:stateNotNeeded="true"
            android:stateNotNeeded="true"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
            android:theme="@style/HomeScreenTheme"
            android:theme="@style/HomeScreenTheme"
            android:windowSoftInputMode="adjustPan">
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
            <intent-filter>
+25 −0
Original line number Original line Diff line number Diff line
@@ -19,10 +19,12 @@ import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -48,6 +50,7 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.TextWatcher;
import android.util.Log;
import android.view.DragEvent;
import android.view.DragEvent;
import android.view.Gravity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
@@ -145,6 +148,8 @@ import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.schedulers.Schedulers;
import me.relex.circleindicator.CircleIndicator;
import me.relex.circleindicator.CircleIndicator;


import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
import static android.view.View.GONE;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.view.View.VISIBLE;


@@ -237,6 +242,14 @@ public class LauncherActivity extends AppCompatActivity implements


    private AppProvider appProvider;
    private AppProvider appProvider;
    private int moveTo;
    private int moveTo;
    private Configuration oldConfig;

    public static LauncherActivity getLauncher(Context context) {
        if (context instanceof LauncherActivity) {
            return (LauncherActivity) context;
        }
        return ((LauncherActivity) ((ContextWrapper) context).getBaseContext());
    }


    @SuppressLint("InflateParams")
    @SuppressLint("InflateParams")
    @Override
    @Override
@@ -246,6 +259,7 @@ public class LauncherActivity extends AppCompatActivity implements


        prepareBroadcastReceivers();
        prepareBroadcastReceivers();


        oldConfig = new Configuration(getResources().getConfiguration());
        mDeviceProfile = BlissLauncher.getApplication(this).getDeviceProfile();
        mDeviceProfile = BlissLauncher.getApplication(this).getDeviceProfile();


        mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager();
        mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager();
@@ -456,6 +470,17 @@ public class LauncherActivity extends AppCompatActivity implements
        BlissLauncher.getApplication(this).getAppProvider().clear();
        BlissLauncher.getApplication(this).getAppProvider().clear();
    }
    }


    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        Log.d(TAG, "onConfigurationChanged() called with: newConfig = [" + newConfig + "]");
        int diff = newConfig.diff(oldConfig);
        if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0) {
            recreate();
        }
        oldConfig.setTo(newConfig);
        super.onConfigurationChanged(newConfig);
    }

    public void onAppAddEvent(AppAddEvent appAddEvent) {
    public void onAppAddEvent(AppAddEvent appAddEvent) {
        moveTo = -1;
        moveTo = -1;
        ApplicationItem applicationItem = AppUtils.createAppItem(this, appAddEvent.getPackageName(),
        ApplicationItem applicationItem = AppUtils.createAppItem(this, appAddEvent.getPackageName(),