Commit 0c5af647 authored by Romain Hunault's avatar Romain Hunault

Merge branch 'sprint_delhi' into 'master'

[RELEASE] Sprint delhi

Closes #172 and #171

See merge request !20
parents a3cf67b6 e5efc5f0
Pipeline #37656 passed with stage
in 4 minutes and 34 seconds
......@@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
// Manifest version information!
def versionMajor = 1
def versionMinor = 3
def versionPatch = 0
def versionPatch = 1
android {
compileSdkVersion rootProject.ext.compileSdkVersion
......
......@@ -48,6 +48,7 @@
android:resumeWhilePausing="true"
android:screenOrientation="nosensor"
android:stateNotNeeded="true"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:theme="@style/HomeScreenTheme"
android:windowSoftInputMode="adjustPan">
<intent-filter>
......
......@@ -54,6 +54,10 @@ public class BlissLauncher extends Application {
return deviceProfile;
}
public void resetDeviceProfile() {
deviceProfile = new DeviceProfile(this);
}
public IconsHandler getIconsHandler() {
if (iconsPackHandler == null) {
iconsPackHandler = new IconsHandler(this);
......
......@@ -10,6 +10,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
......@@ -27,6 +28,7 @@ public class DeviceProfile {
public static Path path;
private final float widthCm;
private final float ratio;
private int statusBarHeight;
public int cellHeightWithoutPaddingPx;
public int hotseatCellHeightWithoutPaddingPx;
......@@ -157,6 +159,7 @@ public class DeviceProfile {
widthPx = realSize.x;
double x = widthPx / dm.xdpi;
ratio = dm.densityDpi / dm.xdpi;
widthCm = (float) (x * 2.540001f);
heightPx = realSize.y;
......@@ -231,7 +234,15 @@ public class DeviceProfile {
iconSizePx = 213;
}*/
float a = 1.578f;
float b = 1.23f;
Log.i(TAG, "updateIconSize: " + (int) a + " " + (int) b);
iconSizePx = (int) (widthPx / widthCm);
if (ratio >= 1) {
iconSizePx = iconSizePx * (int) ratio;
}
iconTextSizePx = (int) (Utilities.pxFromSp(12, dm) * scale);
iconDrawablePaddingPx = (availableWidthPx - iconSizePx * 4) / 5;
......
......@@ -229,6 +229,12 @@ public class Utilities {
return defaultValue;
}
/**
* Ensures that a value is within given bounds. Specifically:
* If value is less than lowerBound, return lowerBound; else if value is greater than upperBound,
* return upperBound; else return value unchanged.
*/
public static int boundToRange(int value, int lowerBound, int upperBound) {
return Math.max(lowerBound, Math.min(value, upperBound));
}
}
......@@ -23,12 +23,13 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import foundation.e.blisslauncher.BlissLauncher;
import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.features.launcher.DetectSwipeGestureListener;
import foundation.e.blisslauncher.features.launcher.LauncherActivity;
import foundation.e.blisslauncher.features.launcher.OnSwipeDownListener;
public class HorizontalPager extends ViewGroup implements Insettable{
public class HorizontalPager extends ViewGroup implements Insettable {
private static final String TAG = "HorizontalPager";
private static final int INVALID_SCREEN = -1;
public static final int SPEC_UNDEFINED = -1;
......@@ -63,6 +64,7 @@ public class HorizontalPager extends ViewGroup implements Insettable{
private boolean mIsUiCreated;
private GestureDetectorCompat gestureDetectorCompat;
private WindowInsets insets;
private float mLastMotionRawY;
public HorizontalPager(Context context, AttributeSet attrs) {
this(context, attrs, 0);
......@@ -276,6 +278,9 @@ public class HorizontalPager extends ViewGroup implements Insettable{
final float x = ev.getX();
final float y = ev.getY();
mLastMotionRawY = ev.getRawY();
switch (action) {
case MotionEvent.ACTION_MOVE:
/*
......@@ -329,7 +334,7 @@ public class HorizontalPager extends ViewGroup implements Insettable{
if (xMoved || yMoved) {
if (yMoved && (y - mLastMotionY) > 0 && yDiff > xDiff && currentPage != 0) {
if (yMoved && (y - mLastMotionY) > 0 && yDiff > xDiff && inThresholdRegion() && currentPage != 0) {
mTouchState = TOUCH_STATE_VERTICAL_SCROLLING;
((OnSwipeDownListener) getContext()).onSwipeStart();
} else if (xMoved && yDiff < xDiff) {
......@@ -351,6 +356,10 @@ public class HorizontalPager extends ViewGroup implements Insettable{
}
}
private boolean inThresholdRegion() {
return (mLastMotionRawY / BlissLauncher.getApplication(getContext()).getDeviceProfile().availableHeightPx) > (float) 1 / 5;
}
void enableChildrenCache() {
setChildrenDrawingCacheEnabled(true);
}
......@@ -539,13 +548,14 @@ public class HorizontalPager extends ViewGroup implements Insettable{
setLayoutParams(lp);
updateInsetsForChildren();
this.insets = insets;
postInvalidate();
}
private void updateInsetsForChildren() {
int childCount = getChildCount();
for (int index = 0; index < childCount; ++index){
for (int index = 0; index < childCount; ++index) {
View child = getChildAt(index);
if(child instanceof Insettable) {
if (child instanceof Insettable) {
Log.d(TAG, "child is instance of insettable");
((Insettable) child).setInsets(insets);
}
......
......@@ -8,19 +8,23 @@ import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.RelativeLayout;
import foundation.e.blisslauncher.BlissLauncher;
import foundation.e.blisslauncher.R;
public class InsettableRelativeLayout extends RelativeLayout {
private final Context mContext;
protected WindowInsets mInsets;
public InsettableRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
BlissLauncher.getApplication(mContext).resetDeviceProfile();
updateChildInsets(insets);
mInsets = new WindowInsets(insets);
return insets;
......
package foundation.e.blisslauncher.core.customviews;
import android.animation.LayoutTransition;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import foundation.e.blisslauncher.core.customviews.pageindicators.PageIndicatorDots;
import foundation.e.blisslauncher.features.launcher.LauncherActivity;
public class Workspace extends PagedView<PageIndicatorDots> implements View.OnTouchListener{
private static final String TAG = "Workspace";
private static final int DEFAULT_PAGE = 0;
private final LauncherActivity mLauncher;
private LayoutTransition mLayoutTransition;
public Workspace(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public Workspace(Context context, AttributeSet attributeSet, int defStyle) {
super(context, attributeSet, defStyle);
mLauncher = LauncherActivity.getLauncher(context);
setHapticFeedbackEnabled(false);
initWorkspace();
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
}
private void initWorkspace() {
mCurrentPage = DEFAULT_PAGE;
setClipToPadding(false);
setupLayoutTransition();
//setWallpaperDimension();
}
private void setupLayoutTransition() {
// We want to show layout transitions when pages are deleted, to close the gap.
mLayoutTransition = new LayoutTransition();
mLayoutTransition.enableTransitionType(LayoutTransition.DISAPPEARING);
mLayoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
mLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
setLayoutTransition(mLayoutTransition);
}
void enableLayoutTransitions() {
setLayoutTransition(mLayoutTransition);
}
void disableLayoutTransitions() {
setLayoutTransition(null);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
}
package foundation.e.blisslauncher.core.customviews.pageindicators
/**
* Base class for a page indicator.
*/
interface PageIndicator {
fun setScroll(currentScroll: Int, totalScroll: Int)
fun setActiveMarker(activePage: Int)
fun setMarkersCount(numMarkers: Int)
}
\ No newline at end of file
package foundation.e.blisslauncher.core.touch;
/**
* Utility methods for overscroll damping and related effect.
*/
public class OverScroll {
private static final float OVERSCROLL_DAMP_FACTOR = 0.07f;
/**
* This curve determines how the effect of scrolling over the limits of the page diminishes
* as the user pulls further and further from the bounds
*
* @param f The percentage of how much the user has overscrolled.
* @return A transformed percentage based on the influence curve.
*/
private static float overScrollInfluenceCurve(float f) {
f -= 1.0f;
return f * f * f + 1.0f;
}
/**
* @param amount The original amount overscrolled.
* @param max The maximum amount that the View can overscroll.
* @return The dampened overscroll amount.
*/
public static int dampedScroll(float amount, int max) {
if (Float.compare(amount, 0) == 0) return 0;
float f = amount / max;
f = f / (Math.abs(f)) * (overScrollInfluenceCurve(Math.abs(f)));
// Clamp this factor, f, to -1 < f < 1
if (Math.abs(f) >= 1) {
f /= Math.abs(f);
}
return Math.round(OVERSCROLL_DAMP_FACTOR * f * max);
}
}
......@@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
......@@ -147,6 +148,8 @@ import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
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.VISIBLE;
......@@ -236,6 +239,7 @@ public class LauncherActivity extends AppCompatActivity implements
private ManagedProfileBroadcastReceiver managedProfileReceiver;
private int moveTo;
private Configuration oldConfig;
private WallpaperChangeReceiver wallpaperChangeReceiver;
public static LauncherActivity getLauncher(Context context) {
......@@ -251,6 +255,7 @@ public class LauncherActivity extends AppCompatActivity implements
super.onCreate(savedInstanceState);
prepareBroadcastReceivers();
oldConfig = new Configuration(getResources().getConfiguration());
mDeviceProfile = BlissLauncher.getApplication(this).getDeviceProfile();
mAppWidgetManager = BlissLauncher.getApplication(this).getAppWidgetManager();
......@@ -478,6 +483,17 @@ public class LauncherActivity extends AppCompatActivity implements
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) {
moveTo = -1;
ApplicationItem applicationItem = AppUtils.createAppItem(this, appAddEvent.getPackageName(),
......@@ -2949,16 +2965,14 @@ public class LauncherActivity extends AppCompatActivity implements
if (currentAnimator != null) {
currentAnimator.cancel();
}
int animationDuration = (int) (blurLayer.getAlpha() * 300);
AnimatorSet set = new AnimatorSet();
/*ValueAnimator blurAnimator = ValueAnimator.ofInt(blurRadius, 18);
blurAnimator.addUpdateListener(animation ->
BlurWallpaperProvider.getInstance(this).blurWithLauncherView(mergedView, (Integer) animation.getAnimatedValue()));*/
set.play(ObjectAnimator.ofFloat(swipeSearchContainer, View.TRANSLATION_Y, 0))
.with(ObjectAnimator.ofFloat(blurLayer, View.ALPHA, 1f))
.with(ObjectAnimator.ofFloat(mHorizontalPager, View.ALPHA, 0f))
.with(ObjectAnimator.ofFloat(mIndicator, View.ALPHA, 0f))
.with(ObjectAnimator.ofFloat(mDock, View.ALPHA, 0f));
set.setDuration(300);
set.setDuration(animationDuration);
set.setInterpolator(new LinearInterpolator());
set.addListener(new AnimatorListenerAdapter() {
@Override
......
......@@ -167,4 +167,6 @@
<string name="tap_to_setup_usageaccess">Tap to setup App Suggestions</string>
<string name="activity_not_found">App isn\'t installed</string>
<string name="default_scroll_format">Page %1$d of %2$d</string>
</resources>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.60'
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
......@@ -10,7 +10,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6'
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment