Move drawer opacity code to lawnchair sourceset
This commit is contained in:
@@ -75,10 +75,7 @@ class PreferenceManager private constructor(private val context: Context) : Base
|
||||
|
||||
// TODO: Add the ability to manually delete empty pages.
|
||||
val allowEmptyPages = BoolPref("pref_allowEmptyPages", false)
|
||||
val drawerOpacity = FloatPref("pref_drawerOpacity", 1F) {
|
||||
LawnchairLauncher.instance?.scrimView?.refreshScrimAlpha()
|
||||
reloadGrid()
|
||||
}
|
||||
val drawerOpacity = FloatPref("pref_drawerOpacity", 1F, reloadGrid)
|
||||
val coloredBackgroundLightness = FloatPref("pref_coloredBackgroundLightness", 0.9F, reloadIcons)
|
||||
val feedProvider = StringPref("pref_feedProvider", "")
|
||||
val ignoreFeedWhitelist = BoolPref("pref_ignoreFeedWhitelist", false)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.lawnchair.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import app.lawnchair.preferences.PreferenceManager
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.Themes
|
||||
import com.android.quickstep.views.ShelfScrimView
|
||||
|
||||
class LawnchairScrimView(context: Context, attrs: AttributeSet?) : ShelfScrimView(context, attrs) {
|
||||
|
||||
init {
|
||||
val prefs = PreferenceManager.getInstance(context)
|
||||
prefs.drawerOpacity.subscribeValues(this) { opacity ->
|
||||
mEndAlpha = (opacity * 255).toInt()
|
||||
mIsScrimDark = if (opacity <= 0.3f) {
|
||||
!Themes.getAttrBoolean(getContext(), R.attr.isWorkspaceDarkText)
|
||||
} else {
|
||||
ColorUtils.calculateLuminance(mEndScrim) < 0.5f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.android.quickstep.views.ShelfScrimView
|
||||
<app.lawnchair.views.LawnchairScrimView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Modifications copyright 2021, Lawnchair
|
||||
*/
|
||||
package com.android.quickstep.views;
|
||||
|
||||
@@ -38,8 +36,6 @@ import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherState;
|
||||
@@ -56,8 +52,6 @@ import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
|
||||
import app.lawnchair.preferences.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Scrim used for all-apps and shelf in Overview
|
||||
* In transposed layout, it behaves as a simple color scrim.
|
||||
@@ -79,7 +73,7 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
|
||||
private boolean mDrawingFlatColor;
|
||||
|
||||
// For shelf mode
|
||||
private int mEndAlpha;
|
||||
protected int mEndAlpha;
|
||||
private final float mRadius;
|
||||
private final int mMaxScrimAlpha;
|
||||
private final Paint mPaint;
|
||||
@@ -115,14 +109,13 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
|
||||
super(context, attrs);
|
||||
mMaxScrimAlpha = Math.round(OVERVIEW.getOverviewScrimAlpha(mLauncher) * 255);
|
||||
|
||||
mEndAlpha = Color.alpha(mEndScrim);
|
||||
mRadius = BOTTOM_CORNER_RADIUS_RATIO * Themes.getDialogCornerRadius(context);
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mOnboardingPrefs = mLauncher.getOnboardingPrefs();
|
||||
|
||||
// Just assume the easiest UI for now, until we have the proper layout information.
|
||||
mDrawingFlatColor = true;
|
||||
|
||||
refreshScrimAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -323,21 +316,4 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
|
||||
public float getVisualTop() {
|
||||
return mShelfTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshScrimAlpha() {
|
||||
PreferenceManager prefs = PreferenceManager.getInstance(getContext());
|
||||
float opacity = prefs.getDrawerOpacity().get();
|
||||
mEndAlpha = (int) (opacity * 255);
|
||||
if (opacity <= 0.3f) {
|
||||
mIsScrimDark = !Themes.getAttrBoolean(getContext(), R.attr.isWorkspaceDarkText);
|
||||
} else {
|
||||
mIsScrimDark = ColorUtils.calculateLuminance(mEndScrim) < 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScrimAlpha() {
|
||||
return mEndAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,13 +544,4 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
|
||||
public float getVisualTop() {
|
||||
return Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public void refreshScrimAlpha() {
|
||||
// Override in inheriting classes
|
||||
}
|
||||
|
||||
public int getScrimAlpha() {
|
||||
// Override in inheriting classes
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user