Commit f34b6b72 authored by Amit Kumar's avatar Amit Kumar

Merge branch 'dev' with version 1.2.1

parents 06b0a65d cfc87bfe
Pipeline #20873 passed with stage
in 5 minutes and 36 seconds
......@@ -4,7 +4,7 @@ apply plugin: 'io.fabric'
// Manifest version information!
def versionMajor = 1
def versionMinor = 2
def versionPatch = 0
def versionPatch = 1
android {
compileSdkVersion rootProject.ext.compileSdkVersion
......
......@@ -226,7 +226,6 @@ public class IconsHandler {
cacheStoreDrawable(userHandle.addUserSuffixToString(componentName.flattenToString(), '/'), badgedIcon);
}
}
}
}
......
......@@ -32,10 +32,11 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
return;
}
BlissLauncher.getApplication(ctx).getIconsHandler().clearAll();
BlissLauncher.getApplication(ctx).resetIconsHandler();
AppAddEvent event = new AppAddEvent(packageName, user);
EventRelay.getInstance().push(event);
BlissLauncher.getApplication(ctx).getAppProvider().reload();
}
if ("android.intent.action.PACKAGE_CHANGED".equalsIgnoreCase(action)) {
......@@ -45,14 +46,16 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
launchIntent.getComponent(), user);
}
BlissLauncher.getApplication(ctx).getIconsHandler().clearAll();
BlissLauncher.getApplication(ctx).resetIconsHandler();
AppChangeEvent event = new AppChangeEvent(packageName, user);
EventRelay.getInstance().push(event);
BlissLauncher.getApplication(ctx).getAppProvider().reload();
}
if ("android.intent.action.PACKAGE_REMOVED".equals(action) && !replacing) {
AppRemoveEvent event = new AppRemoveEvent(packageName, user);
EventRelay.getInstance().push(event);
BlissLauncher.getApplication(ctx).getAppProvider().reload();
}
}
......
......@@ -30,6 +30,8 @@ public class RoundedWidgetView extends AppWidgetHostView {
private long _down;
private boolean mChildrenFocused;
private boolean activated = false;
public RoundedWidgetView(Context context) {
super(context);
this.mContext = context;
......@@ -144,12 +146,18 @@ public class RoundedWidgetView extends AppWidgetHostView {
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
resizeBorder.setLayoutParams(layoutParams);
addView(resizeBorder);
activated = true;
}
public void removeBorder() {
if (resizeBorder != null) {
removeView(resizeBorder);
resizeBorder = null;
activated = false;
}
}
public boolean isWidgetActivated() {
return activated;
}
}
......@@ -192,7 +192,7 @@ public class AppProvider {
synchronized (AppProvider.class) {
if (sInstance == null) {
sInstance = new AppProvider(context);
//sInstance.reload(false);
sInstance.reload();
}
}
}
......@@ -205,6 +205,11 @@ public class AppProvider {
public synchronized void reload() {
Log.d(TAG, "reload() called");
if(mLauncherItems != null && mLauncherItems.size() > 0) {
mAppsRepository.updateAppsRelay(mLauncherItems);
}
initializeAppLoading(new LoadAppsTask());
if (Utilities.ATLEAST_OREO) {
initializeShortcutsLoading(new LoadShortcutTask());
......@@ -400,6 +405,7 @@ public class AppProvider {
shortcutItem.container = databaseItem.container;
shortcutItem.screenId = databaseItem.screenId;
shortcutItem.cell = databaseItem.cell;
shortcutItem.user = new UserHandle();
return shortcutItem;
}
......@@ -450,7 +456,7 @@ public class AppProvider {
}
public void clear() {
sInstance.mContext = null;
sInstance = null;
}
public synchronized boolean isRunning() {
......
......@@ -237,12 +237,13 @@ public class LauncherActivity extends AppCompatActivity implements
private boolean forceReload;
private AppProvider appProvider;
private int moveTo;
@SuppressLint("InflateParams")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
appProvider = BlissLauncher.getApplication(this).getAppProvider();
prepareBroadcastReceivers();
......@@ -288,7 +289,6 @@ public class LauncherActivity extends AppCompatActivity implements
startService(notificationServiceIntent);
createOrUpdateIconGrid();
BlissLauncher.getApplication(this).getAppProvider().reload();
}
private void setupViews() {
......@@ -332,7 +332,11 @@ public class LauncherActivity extends AppCompatActivity implements
.subscribeWith(new DisposableObserver<List<LauncherItem>>() {
@Override
public void onNext(List<LauncherItem> launcherItems) {
showApps(launcherItems, forceReload);
if (launcherItems == null || launcherItems.size() <= 0) {
BlissLauncher.getApplication(LauncherActivity.this).getAppProvider().reload();
} else if (!allAppsDisplayed) {
showApps(launcherItems);
}
}
@Override
......@@ -445,6 +449,7 @@ public class LauncherActivity extends AppCompatActivity implements
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy() called");
TimeChangeBroadcastReceiver.unregister(this, timeChangedReceiver);
ManagedProfileBroadcastReceiver.unregister(this, managedProfileReceiver);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mWeatherReceiver);
......@@ -454,10 +459,15 @@ public class LauncherActivity extends AppCompatActivity implements
}
public void onAppAddEvent(AppAddEvent appAddEvent) {
moveTo = -1;
ApplicationItem applicationItem = AppUtils.createAppItem(this, appAddEvent.getPackageName(),
appAddEvent.getUserHandle());
addLauncherItem(applicationItem);
DatabaseManager.getManager(this).saveLayouts(pages, mDock);
if (moveTo != -1) {
mHorizontalPager.setCurrentPage(moveTo);
moveTo = -1;
}
}
public void onAppRemoveEvent(AppRemoveEvent appRemoveEvent) {
......@@ -472,9 +482,15 @@ public class LauncherActivity extends AppCompatActivity implements
}
public void onShortcutAddEvent(ShortcutAddEvent shortcutAddEvent) {
moveTo = -1;
updateOrAddShortcut(shortcutAddEvent.getShortcutItem());
DatabaseManager.getManager(this).saveLayouts(pages, mDock);
Toast.makeText(this, "Shortcut has been added", Toast.LENGTH_SHORT).show();
Log.i(TAG, "onShortcutAddEvent: " + moveTo);
if (moveTo != -1) {
mHorizontalPager.setCurrentPage(moveTo);
moveTo = -1;
}
}
private void addLauncherItem(LauncherItem launcherItem) {
......@@ -506,6 +522,7 @@ public class LauncherActivity extends AppCompatActivity implements
launcherItem.cell = pages.get(current).getChildCount() - 1;
launcherItem.container = Constants.CONTAINER_DESKTOP;
addAppToGrid(pages.get(current), view);
moveTo = current + 1;
}
}
......@@ -591,10 +608,10 @@ public class LauncherActivity extends AppCompatActivity implements
launcherItem);
gridLayout.removeViewAt(j);
addAppToGrid(gridLayout, blissFrameLayout, j);
moveTo = i + 1;
return;
}
}
}
} else {
if (launcherItem.itemType == Constants.ITEM_TYPE_SHORTCUT) {
......@@ -603,6 +620,7 @@ public class LauncherActivity extends AppCompatActivity implements
BlissFrameLayout blissFrameLayout = prepareLauncherItem(shortcutItem);
gridLayout.removeViewAt(j);
addAppToGrid(gridLayout, blissFrameLayout, j);
moveTo = i + 1;
return;
}
}
......@@ -868,9 +886,9 @@ public class LauncherActivity extends AppCompatActivity implements
addLauncherItem(updatedAppItem);
}
public void showApps(List<LauncherItem> launcherItems, boolean force) {
public void showApps(List<LauncherItem> launcherItems) {
mProgressBar.setVisibility(GONE);
if(isWobbling)
if (isWobbling)
handleWobbling(false);
createUI(launcherItems);
subscribeToEvents();
......@@ -882,9 +900,6 @@ public class LauncherActivity extends AppCompatActivity implements
createIndicator();
createOrUpdateBadgeCount();
allAppsDisplayed = true;
if (force) {
forceReload = false;
}
}
private void subscribeToEvents() {
......@@ -1679,10 +1694,8 @@ 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())) {
Log.i(TAG, "startActivitySafely: here");
context.startActivity(intent);
} else {
Log.i(TAG, "startActivitySafely: here2");
((LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE))
.startMainActivity(intent.getComponent(), user, intent.getSourceBounds(), null);
}
......@@ -2632,11 +2645,7 @@ public class LauncherActivity extends AppCompatActivity implements
*/
@Override
public void onBackPressed() {
if (activeRoundedWidgetView != null) {
hideWidgetResizeContainer();
} else {
returnToHomeScreen();
}
returnToHomeScreen();
}
private void displayFolder(FolderItem app, BlissFrameLayout v) {
......@@ -2797,6 +2806,8 @@ public class LauncherActivity extends AppCompatActivity implements
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "onNewIntent() called with: intent = [" + intent + "]");
final boolean alreadyOnHome = hasWindowFocus() &&
((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
......@@ -2804,8 +2815,7 @@ public class LauncherActivity extends AppCompatActivity implements
boolean shouldMoveToDefaultScreen =
alreadyOnHome && swipeSearchContainer.getVisibility() != VISIBLE && !isWobbling
&& mFolderWindowContainer.getVisibility() != View.VISIBLE
&& activeRoundedWidgetView == null;
&& (activeRoundedWidgetView == null || !activeRoundedWidgetView.isWidgetActivated());
if (shouldMoveToDefaultScreen) {
mHorizontalPager.setCurrentPage(1);
......@@ -2815,7 +2825,7 @@ public class LauncherActivity extends AppCompatActivity implements
}
private void returnToHomeScreen() {
if (activeRoundedWidgetView != null) {
if (activeRoundedWidgetView != null && activeRoundedWidgetView.isWidgetActivated()) {
hideWidgetResizeContainer();
}
......@@ -3169,14 +3179,6 @@ public class LauncherActivity extends AppCompatActivity implements
}
}
public void reload() {
forceReload = true;
}
public void loadAllApps() {
}
/**
* Adapter for folder apps.
*/
......
......@@ -10,6 +10,8 @@ import android.support.v7.app.AppCompatActivity;
@TargetApi(Build.VERSION_CODES.O)
public class AddItemActivity extends AppCompatActivity {
private static final String TAG = "AddItemActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
......@@ -10,7 +10,6 @@ import android.os.Parcelable;
import android.os.UserManager;
import android.util.Log;
import org.greenrobot.eventbus.EventBus;
import java.io.ByteArrayOutputStream;
......@@ -18,6 +17,7 @@ import foundation.e.blisslauncher.BlissLauncher;
import foundation.e.blisslauncher.core.IconsHandler;
import foundation.e.blisslauncher.core.Utilities;
import foundation.e.blisslauncher.core.database.model.ShortcutItem;
import foundation.e.blisslauncher.core.events.EventRelay;
import foundation.e.blisslauncher.core.events.ShortcutAddEvent;
import foundation.e.blisslauncher.core.utils.Constants;
import foundation.e.blisslauncher.core.utils.UserHandle;
......@@ -51,7 +51,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return;
}
ShortcutItem shortcutItem = createShortcutItem(data, context);
EventBus.getDefault().post(new ShortcutAddEvent(shortcutItem));
EventRelay.getInstance().push(new ShortcutAddEvent(shortcutItem));
context.startActivity(new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
.setPackage(context.getPackageName())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
public static void queueShortcut(ShortcutInfoCompat info, Context context) {
......@@ -68,11 +72,14 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
shortcutItem.icon = BlissLauncher.getApplication(context).getIconsHandler().convertIcon(
icon);
shortcutItem.launchIntent = info.makeIntent();
EventBus.getDefault().post(new ShortcutAddEvent(shortcutItem));
EventRelay.getInstance().push(new ShortcutAddEvent(shortcutItem));
context.startActivity(new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
.setPackage(context.getPackageName())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
private static ShortcutItem createShortcutItem(Intent data, Context context) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
......
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