Commit d1dee091 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Merge branch 'sprint-alexandria' [Release v1.2.4]

parents 87f3523d d6d2bff0
Pipeline #32489 passed with stage
in 7 minutes and 57 seconds
......@@ -4,7 +4,7 @@ apply plugin: 'io.fabric'
// Manifest version information!
def versionMajor = 1
def versionMinor = 2
def versionPatch = 3
def versionPatch = 4
android {
compileSdkVersion rootProject.ext.compileSdkVersion
......@@ -77,7 +77,8 @@ android {
dependencies {
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:1.0.0'
apiNougatImplementation 'org.cyanogenmod:platform.sdk:6.0'
apiOreoImplementation files('libs/lineage-sdk.jar')
......
......@@ -8,7 +8,9 @@ import foundation.e.blisslauncher.core.DeviceProfile;
import foundation.e.blisslauncher.core.IconsHandler;
import foundation.e.blisslauncher.core.customviews.WidgetHost;
import foundation.e.blisslauncher.features.launcher.AppProvider;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
import io.github.inflationx.viewpump.ViewPump;
public class BlissLauncher extends Application {
private IconsHandler iconsPackHandler;
......@@ -25,9 +27,12 @@ public class BlissLauncher extends Application {
public void onCreate() {
super.onCreate();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("Roboto-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
ViewPump.init(ViewPump.builder()
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath("Roboto-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()))
.build());
sAppWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.os.Build;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
......@@ -12,6 +13,7 @@ import android.view.ViewGroup;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.regex.Matcher;
......@@ -157,4 +159,22 @@ public class Utilities {
return result;
}
public static boolean isBootCompleted() {
return "1".equals(getSystemProperty("sys.boot_completed", "1"));
}
public static String getSystemProperty(String property, String defaultValue) {
try {
Class clazz = Class.forName("android.os.SystemProperties");
Method getter = clazz.getDeclaredMethod("get", String.class);
String value = (String) getter.invoke(null, property);
if (!TextUtils.isEmpty(value)) {
return value;
}
} catch (Exception e) {
Log.d(TAG, "Unable to read system properties");
}
return defaultValue;
}
}
......@@ -6,7 +6,6 @@ import android.content.Intent;
import android.os.Process;
import android.util.Log;
import foundation.e.blisslauncher.BlissLauncher;
import foundation.e.blisslauncher.core.events.AppAddEvent;
import foundation.e.blisslauncher.core.events.AppChangeEvent;
......@@ -57,6 +56,16 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
EventRelay.getInstance().push(event);
BlissLauncher.getApplication(ctx).getAppProvider().reload();
}
if("android.intent.action.MEDIA_MOUNTED".equals(action)) {
Intent launchIntent = ctx.getPackageManager().getLaunchIntentForPackage(packageName);
if (launchIntent != null) {
BlissLauncher.getApplication(ctx).getIconsHandler().resetIconDrawableForPackage(
launchIntent.getComponent(), user);
AppChangeEvent appChangeEvent = new AppChangeEvent(packageName, user);
EventRelay.getInstance().push(appChangeEvent);
}
}
}
@Override
......
......@@ -25,6 +25,8 @@ public class ApplicationItem extends LauncherItem {
public static final int TYPE_CALENDAR = 746;
public static final int TYPE_DEFAULT = 111;
public boolean isDisabled = false;
/**
* Indicates the type of app item ie. Clock or Calendar (in case of none, It will be )
*/
......
package foundation.e.blisslauncher.core.utils;
import java.util.ArrayList;
import java.util.HashMap;
public class MultiHashMap<K, V> extends HashMap<K, ArrayList<V>> {
public MultiHashMap() { }
public MultiHashMap(int size) {
super(size);
}
public void addToList(K key, V value) {
ArrayList<V> list = get(key);
if (list == null) {
list = new ArrayList<>();
list.add(value);
put(key, list);
} else {
list.add(value);
}
}
@Override
public MultiHashMap<K, V> clone() {
MultiHashMap<K, V> map = new MultiHashMap<>(size());
for (Entry<K, ArrayList<V>> entry : entrySet()) {
map.put(entry.getKey(), new ArrayList<V>(entry.getValue()));
}
return map;
}
}
......@@ -2,6 +2,7 @@ package foundation.e.blisslauncher.features.launcher;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
......@@ -10,6 +11,7 @@ import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Process;
import android.os.UserManager;
import android.provider.MediaStore;
......@@ -25,6 +27,7 @@ import java.util.List;
import java.util.Map;
import foundation.e.blisslauncher.BlissLauncher;
import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.core.Utilities;
import foundation.e.blisslauncher.core.broadcast.PackageAddedRemovedHandler;
import foundation.e.blisslauncher.core.database.DatabaseManager;
......@@ -36,6 +39,7 @@ import foundation.e.blisslauncher.core.executors.AppExecutors;
import foundation.e.blisslauncher.core.utils.AppUtils;
import foundation.e.blisslauncher.core.utils.Constants;
import foundation.e.blisslauncher.core.utils.GraphicsUtil;
import foundation.e.blisslauncher.core.utils.MultiHashMap;
import foundation.e.blisslauncher.core.utils.UserHandle;
import foundation.e.blisslauncher.features.launcher.tasks.LoadAppsTask;
import foundation.e.blisslauncher.features.launcher.tasks.LoadDatabaseTask;
......@@ -81,6 +85,8 @@ public class AppProvider {
public static HashSet<String> DISABLED_PACKAGES = new HashSet<>();
private MultiHashMap<UserHandle, String> pendingPackages = new MultiHashMap<>();
static {
DISABLED_PACKAGES.add(MICROG_PACKAGE);
DISABLED_PACKAGES.add(MUPDF_PACKAGE);
......@@ -93,6 +99,7 @@ public class AppProvider {
private static AppProvider sInstance;
private boolean isLoading;
private boolean mStopped;
private boolean isSdCardReady;
private AppProvider(Context context) {
this.mContext = context;
......@@ -206,7 +213,9 @@ public class AppProvider {
public synchronized void reload() {
Log.d(TAG, "reload() called");
if(mLauncherItems != null && mLauncherItems.size() > 0) {
isSdCardReady = Utilities.isBootCompleted();
if (mLauncherItems != null && mLauncherItems.size() > 0) {
mAppsRepository.updateAppsRelay(mLauncherItems);
}
......@@ -288,8 +297,38 @@ public class AppProvider {
if (databaseItem.itemType == Constants.ITEM_TYPE_APPLICATION) {
ApplicationItem applicationItem = mApplicationItems.get(databaseItem.id);
if (applicationItem == null) {
DatabaseManager.getManager(mContext).removeLauncherItem(databaseItem.id);
continue;
UserHandle userHandle = null;
int index = databaseItem.id.lastIndexOf((int) '/');
if (index > -1) {
String serialText = databaseItem.id.substring(index);
try {
long serial = Long.parseLong(serialText);
userHandle = new UserHandle(serial, Process.myUserHandle());
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
if(userHandle == null){
userHandle = new UserHandle();
}
if (isAppOnSdcard(databaseItem.packageName, userHandle) || !isSdCardReady) {
Log.d(TAG, "Missing package: " + databaseItem.packageName);
Log.d(TAG, "Is App on Sdcard " + isAppOnSdcard(databaseItem.packageName, databaseItem.user));
Log.d(TAG, "Is Sdcard ready " + isSdCardReady);
pendingPackages.addToList(userHandle, databaseItem.packageName);
applicationItem = new ApplicationItem();
applicationItem.title = databaseItem.title;
applicationItem.user = userHandle;
applicationItem.componentName = databaseItem.getTargetComponent();
applicationItem.packageName = databaseItem.packageName;
applicationItem.icon = getContext().getDrawable(R.drawable.default_icon);
applicationItem.isDisabled = true;
} else {
DatabaseManager.getManager(mContext).removeLauncherItem(databaseItem.id);
continue;
}
}
applicationItem.container = databaseItem.container;
......@@ -368,6 +407,25 @@ public class AppProvider {
return mLauncherItems;
}
private boolean isAppOnSdcard(String packageName, UserHandle userHandle) {
ApplicationInfo info = null;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
info = ((LauncherApps) mContext.getSystemService(
Context.LAUNCHER_APPS_SERVICE)).getApplicationInfo(
packageName, PackageManager.MATCH_UNINSTALLED_PACKAGES, userHandle.getRealHandle());
return info != null && (info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
} else {
info = getContext().getPackageManager()
.getApplicationInfo(packageName, PackageManager.MATCH_UNINSTALLED_PACKAGES);
return info != null && info.enabled;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
}
private ShortcutItem prepareShortcutForNougat(LauncherItem databaseItem) {
ShortcutItem shortcutItem = new ShortcutItem();
shortcutItem.id = databaseItem.id;
......@@ -452,7 +510,7 @@ public class AppProvider {
});
mLauncherItems.addAll(pinnedItems);
Log.i(TAG, "prepareDefaultLauncherItems: "+mLauncherItems.size());
Log.i(TAG, "prepareDefaultLauncherItems: " + mLauncherItems.size());
return mLauncherItems;
}
......
package foundation.e.blisslauncher.features.launcher;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
......@@ -139,6 +136,7 @@ import foundation.e.blisslauncher.features.weather.WeatherUtils;
import foundation.e.blisslauncher.features.widgets.WidgetManager;
import foundation.e.blisslauncher.features.widgets.WidgetViewBuilder;
import foundation.e.blisslauncher.features.widgets.WidgetsActivity;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
......@@ -146,7 +144,9 @@ import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import me.relex.circleindicator.CircleIndicator;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
public class LauncherActivity extends AppCompatActivity implements
AutoCompleteAdapter.OnSuggestionClickListener, OnSwipeDownListener {
......@@ -310,6 +310,7 @@ public class LauncherActivity extends AppCompatActivity implements
maxDistanceForFolderCreation = (int) (0.45f * mDeviceProfile.iconSizePx);
scrollCorner = mDeviceProfile.iconDrawablePaddingPx / 2;
wobbleAnimation = AnimationUtils.loadAnimation(this, R.anim.wobble);
wobbleReverseAnimation = AnimationUtils.loadAnimation(this, R.anim.wobble_reverse);
getWindow().getDecorView().setSystemUiVisibility(
......@@ -356,7 +357,7 @@ public class LauncherActivity extends AppCompatActivity implements
}
protected void attachBaseContext(Context context) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(context));
super.attachBaseContext(ViewPumpContextWrapper.wrap(context));
}
public CompositeDisposable getCompositeDisposable() {
......@@ -1717,12 +1718,20 @@ public class LauncherActivity extends AppCompatActivity implements
if (launcherItem.itemType == Constants.ITEM_TYPE_SHORTCUT) {
startShortcutIntentSafely(context, intent, launcherItem);
} else if (user == null || user.equals(Process.myUserHandle())) {
context.startActivity(intent);
} else {
((LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE))
.startMainActivity(intent.getComponent(), user, intent.getSourceBounds(), null);
ApplicationItem applicationItem = (ApplicationItem) launcherItem;
if (applicationItem.isDisabled) {
Toast.makeText(this, "Package not available or disabled", Toast.LENGTH_SHORT).show();
} else {
if (user == null || user.equals(Process.myUserHandle())) {
context.startActivity(intent);
} else {
((LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE))
.startMainActivity(intent.getComponent(), user, intent.getSourceBounds(), null);
}
}
}
}
private void startShortcutIntentSafely(Context context, Intent intent, LauncherItem appItem) {
......@@ -2123,11 +2132,41 @@ public class LauncherActivity extends AppCompatActivity implements
return true;
}
GridLayout page = pages.get(getCurrentAppsPageNumber());
if (cX < mDeviceProfile.availableWidthPx - scrollCorner
&& cX > scrollCorner) {
if ((cX - mDeviceProfile.iconSizePx / 10) > mDeviceProfile.availableWidthPx - 2 * scrollCorner) {
if (getCurrentAppsPageNumber() + 1 < pages.size()) {
mHorizontalPager.scrollRight(300);
} else if (getCurrentAppsPageNumber() + 1 == pages.size()
&& getGridFromPage(page).getChildCount() > 1) {
GridLayout layout = preparePage();
pages.add(layout);
ImageView dot = new ImageView(LauncherActivity.this);
dot.setImageDrawable(getDrawable(R.drawable.dot_off));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
getResources().getDimensionPixelSize(
R.dimen.dotSize),
getResources().getDimensionPixelSize(
R.dimen.dotSize)
);
dot.setLayoutParams(params);
mIndicator.addView(dot);
mHorizontalPager.addView(layout);
}
} else if ((cX + mDeviceProfile.iconSizePx / 10) < 2 * scrollCorner) {
if (getCurrentAppsPageNumber() == 0) {
return true;
}
if (getCurrentAppsPageNumber() - 1 >= 0) {
mHorizontalPager.scrollLeft(300);
} else if (getCurrentAppsPageNumber() + 1 == pages.size() - 2
&& getGridFromPage(pages.get(pages.size() - 1)).getChildCount()
<= 0) {
mIndicator.removeViewAt(pages.size());
mHorizontalPager.removeViewAt(pages.size());
pages.remove(pages.size() - 1);
}
} else {
int index = getIndex(page, cX, cY);
// If hovering over self, ignore drag/drop
......@@ -2184,40 +2223,6 @@ public class LauncherActivity extends AppCompatActivity implements
mReorderAlarm.setOnAlarmListener(reorderAlarmListener);
mReorderAlarm.setAlarm(REORDER_TIMEOUT);
}
} else {
if (cX > mDeviceProfile.availableWidthPx - scrollCorner) {
if (getCurrentAppsPageNumber() + 1 < pages.size()) {
mHorizontalPager.scrollRight(300);
} else if (getCurrentAppsPageNumber() + 1 == pages.size()
&& getGridFromPage(page).getChildCount() > 1) {
GridLayout layout = preparePage();
pages.add(layout);
ImageView dot = new ImageView(LauncherActivity.this);
dot.setImageDrawable(getDrawable(R.drawable.dot_off));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
getResources().getDimensionPixelSize(
R.dimen.dotSize),
getResources().getDimensionPixelSize(
R.dimen.dotSize)
);
dot.setLayoutParams(params);
mIndicator.addView(dot);
mHorizontalPager.addView(layout);
}
} else if (cX < scrollCorner) {
if (getCurrentAppsPageNumber() == 0) {
return true;
}
if (getCurrentAppsPageNumber() - 1 >= 0) {
mHorizontalPager.scrollLeft(300);
} else if (getCurrentAppsPageNumber() + 1 == pages.size() - 2
&& getGridFromPage(pages.get(pages.size() - 1)).getChildCount()
<= 0) {
mIndicator.removeViewAt(pages.size());
mHorizontalPager.removeViewAt(pages.size());
pages.remove(pages.size() - 1);
}
}
}
} else if (dragEvent.getAction() == DragEvent.ACTION_DROP) {
cleanupReorder(true);
......
......@@ -9,7 +9,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'io.fabric.tools:gradle:1.26.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6'
......
#Fri Jul 26 14:58:52 IST 2019
#Tue Oct 29 16:08:45 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Supports Markdown
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