长按图标变大
dimens.xml
<!-- When dragging an item, how much bigger (fixed dps) the dragged view
should be. If 0, it will not be scaled at all. -->
<dimen name="dragViewScale">55dp</dimen>
代码处理
DragView.java
public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY,
int left, int top, int width, int height, final float initialScale) {
super(launcher);
mDragLayer = launcher.getDragLayer();
mInitialScale = initialScale;
final Resources res = getResources();
final float offsetX = res.getDimensionPixelSize(R.dimen.dragViewOffsetX);
final float offsetY = res.getDimensionPixelSize(R.dimen.dragViewOffsetY);
final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale);
final float scale = (width + scaleDps) / width;
...
如果是文件夹图标
packages\apps\Launcher3\src\com\android\launcher3\Workspace.java
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY,
boolean insert, boolean computeXYFromRank) {
...
// if (!(child instanceof Folder)) {
if (true) {
child.setHapticFeedbackEnabled(false);
child.setOnLongClickListener(mLongClickListener);
}
...
}
============================
hotseat 增加或减少
DynamicGrid.java
class DeviceProfile {
...
numHotseatIcons = 7;//Math.round(invDistWeightedInterpolate(minWidth, minHeight, points)); 设为 7 个图标
...
}
hotseat背景设置hotseat.xml
<com.android.launcher3.Hotseat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
android:background="#80ffffff">
<com.android.launcher3.CellLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center" />
</com.android.launcher3.Hotseat>
添加小部件(由于4.4 launcher3在系统里的权限少了,Launcher3默认拿不到系统BIND_APPWIDGET权限,因此无法预置AppWidget。
如果要预置AppWidget,需要Launcher3获取到系统权限,因此要修改Launcher3的Android.mk,增加LOCAL_CERTIFICATE := shared LOCAL_PRIVILEGED_MODULE := true,这样build出来的Launcher3.apk会生成到/system/priv-app目录下,可以预置appwidget。)
或者以下方案:
在RK的方案中,发现即使是default_workspace.xml 写了添加的小部件,结果还是没有显示出来的。
index b198937..8f76c82 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2297,7 +2297,7 @@
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:label="@string/permlab_bindGadget"
android:description="@string/permdesc_bindGadget"
- android:protectionLevel="signature|system" />
+ android:protectionLevel="normal" />
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 7e1442d..d62435c 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1822,13 +1822,12 @@ public class LauncherModel extends BroadcastReceiver {
String savedProvider = c.getString(appWidgetProviderIndex);
id = c.getLong(idIndex);
-
final AppWidgetProviderInfo provider =
widgets.getAppWidgetInfo(appWidgetId);
- if (!isSafeMode && (provider == null || provider.provider == null ||
+ if ( (provider == null || provider.provider == null ||
provider.provider.getPackageName() == null)) {
- String log = "Deleting widget that isn't installed anymore: id="
+ String log = provider+"Deleting widget that isn't installed anymore: id="
+ id + " appWidgetId=" + appWidgetId;
Log.e(TAG, log);
Launcher.addDumpLog(TAG, log, false);
make android