Merge "[Work Profile] Fix NPE on WorkModeSwitch" into sc-v2-dev
This commit is contained in:
commit
c46c83c8c8
|
@ -485,8 +485,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||||
mViewPager = (AllAppsPagedView) newView;
|
mViewPager = (AllAppsPagedView) newView;
|
||||||
mViewPager.initParentViews(this);
|
mViewPager.initParentViews(this);
|
||||||
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
|
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
|
||||||
mWorkManager.attachWorkModeSwitch();
|
if (mWorkManager.attachWorkModeSwitch()) {
|
||||||
mWorkManager.getWorkModeSwitch().post(() -> mAH[AdapterHolder.WORK].applyPadding());
|
mWorkManager.getWorkModeSwitch().post(() -> mAH[AdapterHolder.WORK].applyPadding());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mWorkManager.detachWorkModeSwitch();
|
mWorkManager.detachWorkModeSwitch();
|
||||||
mViewPager = null;
|
mViewPager = null;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
|
@ -127,11 +128,11 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
|
||||||
/**
|
/**
|
||||||
* Creates and attaches for profile toggle button to {@link AllAppsContainerView}
|
* Creates and attaches for profile toggle button to {@link AllAppsContainerView}
|
||||||
*/
|
*/
|
||||||
public void attachWorkModeSwitch() {
|
public boolean attachWorkModeSwitch() {
|
||||||
if (!mAllApps.getAppsStore().hasModelFlag(
|
if (!mAllApps.getAppsStore().hasModelFlag(
|
||||||
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)) {
|
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)) {
|
||||||
Log.e(TAG, "Unable to attach widget; Missing required permissions");
|
Log.e(TAG, "unable to attach work mode switch; Missing required permissions");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (mWorkModeSwitch == null) {
|
if (mWorkModeSwitch == null) {
|
||||||
mWorkModeSwitch = (WorkModeSwitch) mAllApps.getLayoutInflater().inflate(
|
mWorkModeSwitch = (WorkModeSwitch) mAllApps.getLayoutInflater().inflate(
|
||||||
|
@ -144,6 +145,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
|
||||||
getAH().applyPadding();
|
getAH().applyPadding();
|
||||||
}
|
}
|
||||||
mWorkModeSwitch.updateCurrentState(mCurrentState == STATE_ENABLED);
|
mWorkModeSwitch.updateCurrentState(mCurrentState == STATE_ENABLED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,6 +167,7 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
|
||||||
return mMatcher;
|
return mMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public WorkModeSwitch getWorkModeSwitch() {
|
public WorkModeSwitch getWorkModeSwitch() {
|
||||||
return mWorkModeSwitch;
|
return mWorkModeSwitch;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue