mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Refactor all apps to depend on activity context.
The current AllAppsContainerView has been split into a base class and a subclass for activities. The base class allows using all apps with an activity context. A-Z and work profile tabs are supported, but search and the hotseat still require an Activity. Test: Manual. All apps should work the same. Bug: 204696617 Change-Id: I3b146714bc11b3b3555d97623aab5d78ac836482
This commit is contained in:
@@ -23,16 +23,18 @@ import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
/**
|
||||
* Work profile toggle switch shown at the bottom of AllApps work tab
|
||||
*/
|
||||
public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
public class WorkEduCard extends FrameLayout implements
|
||||
View.OnClickListener,
|
||||
Animation.AnimationListener {
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final ActivityContext mActivityContext;
|
||||
Animation mDismissAnim;
|
||||
private int mPosition = -1;
|
||||
|
||||
@@ -46,7 +48,7 @@ public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
public WorkEduCard(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mLauncher = Launcher.getLauncher(getContext());
|
||||
mActivityContext = ActivityContext.lookupContext(getContext());
|
||||
mDismissAnim = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
|
||||
mDismissAnim.setDuration(500);
|
||||
mDismissAnim.setAnimationListener(this);
|
||||
@@ -69,13 +71,14 @@ public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
super.onFinishInflate();
|
||||
findViewById(R.id.action_btn).setOnClickListener(this);
|
||||
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
|
||||
lp.width = mLauncher.getAppsView().getActiveRecyclerView().getTabWidth();
|
||||
lp.width = mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startAnimation(mDismissAnim);
|
||||
mLauncher.getSharedPrefs().edit().putInt(WorkAdapterProvider.KEY_WORK_EDU_STEP, 1).apply();
|
||||
Utilities.getPrefs(getContext()).edit().putInt(WorkAdapterProvider.KEY_WORK_EDU_STEP,
|
||||
1).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,8 +100,8 @@ public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
if (mPosition == -1) {
|
||||
if (getParent() != null) ((ViewGroup) getParent()).removeView(WorkEduCard.this);
|
||||
} else {
|
||||
AllAppsRecyclerView rv = mLauncher.getAppsView()
|
||||
.mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView;
|
||||
AllAppsRecyclerView rv = mActivityContext.getAppsView().mAH.get(
|
||||
ActivityAllAppsContainerView.AdapterHolder.WORK).mRecyclerView;
|
||||
rv.getApps().getAdapterItems().remove(mPosition);
|
||||
rv.getAdapter().notifyItemRemoved(mPosition);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user