Commit 3eecf6d3 by lihuaikun

fix:

parent 76f2f54a
......@@ -104,7 +104,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.3.9'
PUBLISH_VERSION = '1.3.9.1'
}
uploadArchives {
......
......@@ -2374,6 +2374,57 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
/**
* 找一个空位放cell
*
* @param cellXY
* @param spanX
* @param spanY
* @return
*/
public boolean findEmptyCellForSpan(ItemInfo lastItenInfo, int[] cellXY, int spanX, int spanY) {
int numColumns = getDeviceProfile().inv.numColumns;
int numRows = getDeviceProfile().inv.numRows;
ItemInfo itemInfo = lastItenInfo;
if (itemInfo.cellX >= 0) {
if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows && itemInfo.cellX + itemInfo.spanX - 1 + spanX >= numColumns) {
// 需要添加的cell长度已经不足以放下
Logger.e(TAG, "itemInfo.cellY(" + itemInfo.cellY + ") + itemInfo.spanY(" + itemInfo.spanY + ") - 1 + " + spanY + " >= " + numRows);
return false;
}
if (itemInfo.cellX + itemInfo.spanX - 1 + spanX < numColumns) {
cellXY[0] = itemInfo.cellX + itemInfo.spanX;
if (spanY == 1) {
cellXY[1] = itemInfo.cellY;
return true;
} else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows) {
return false;
}
} else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY < numRows) {
cellXY[0] = 0;
cellXY[1] = itemInfo.cellY + 1;
return true;
// 在最后一个cell的末尾添加不了 那就在下一行计算
}
} else {
// 一个空屏
if (spanX < numColumns && spanY < numRows) {
cellXY[0] = 0;
cellXY[1] = 0;
return true;
}
}
return false;
}
/**
* 新增的app快捷方式 在这里workspace中的坐标会重新计算
*
* @param added
......@@ -2395,6 +2446,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
long lastScreenId = currentLastScreenId;
// 在新的CellLayout创建快捷方式的位置
int index = 0;
// 是否是第一次添加桌面图标
boolean isFirst = true;
// 上一个添加Cell的位置信息
ItemInfo lastInfo = new ItemInfo();
CellLayout lastCellLayout = (CellLayout) mWorkspace.getChildAt(mWorkspace.getChildCount() - 1);
final ContentWriter writer = new ContentWriter(getApplicationContext());
final ContentResolver cr = getApplicationContext().getContentResolver();
......@@ -2403,7 +2458,14 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
for (int i = 0; i < shortcutInfos.size(); i++) {
ShortcutInfo shortcutInfo = shortcutInfos.get(i);
int[] cell = new int[2];
boolean finded = lastCellLayout.findEmptyCellForSpan(cell, 1, 1);
boolean finded = false;
if (isFirst) {
finded = lastCellLayout.findEmptyCellForSpan(cell, 1, 1);
isFirst = false;
} else {
finded = findEmptyCellForSpan(lastInfo, cell, 1, 1);
}
long itemId = LauncherSettings.Settings.call(cr, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getLong(LauncherSettings.Settings.EXTRA_VALUE);
if (finded) {
......@@ -2411,6 +2473,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
shortcutInfo.cellX = cell[0];
shortcutInfo.cellY = cell[1];
lastInfo = shortcutInfo;
} else {
// 将图标放在下一屏
lastScreenId = LauncherSettings.Settings.call(cr,
......@@ -2424,6 +2488,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
index += 1;
lastInfo = shortcutInfo;
}
shortcutInfo.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
......@@ -2449,7 +2515,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
ops.add(ContentProviderOperation.newInsert(favoritesUri).withValues(values).build());
Logger.e(TAG,"bindShortcutsAdd\t"+shortcutInfo.toString());
// cr.insert(favoritesUri,values);
Logger.e(TAG, "bindShortcutsAdd\t" + shortcutInfo.toString());
}
......@@ -2459,7 +2526,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
LauncherModel.updateWorkspaceScreenOrder(getApplicationContext(), workspaceScreens);
Logger.e(TAG,"bindShortcutsAdd insertNewWorkspaceScreen");
Logger.e(TAG, "bindShortcutsAdd insertNewWorkspaceScreen");
}
return shortcutInfos;
......
......@@ -871,12 +871,20 @@ public class LauncherManager {
}
/**
* 跳转debug信息页面
* @param context
*/
public void jumpDebugInfo(Context context){
Intent intent=new Intent(context, DebugInfoActivity.class);
context.startActivity(intent);
}
/**
* 跳转查询app是否可用页面
* @param context
*/
public void jumpSearchAppCanUse(Context context){
Intent intent=new Intent(context, SearchAppCanUseActivity.class);
context.startActivity(intent);
......
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