当前位置: 首页 > news >正文

鞍山网站制作人才招聘电子商务网站开发的基本原则

鞍山网站制作人才招聘,电子商务网站开发的基本原则,网站建设安全协议书,河南专业网站建设公司ro.wallpaper.fixsize这个节点应该是RK这边导入的,可以通过追这个节点的代码查看具体的实现方式; 最近在开7.0的坑,遇到了一些小问题,记录一下。很大可能这个问题只是我这个芯片的代码上才存在的,不过殊途同归啦。 第…

ro.wallpaper.fixsize这个节点应该是RK这边导入的,可以通过追这个节点的代码查看具体的实现方式;

最近在开7.0的坑,遇到了一些小问题,记录一下。很大可能这个问题只是我这个芯片的代码上才存在的,不过殊途同归啦。
第一个问题就是,我们增加内置可选壁纸,选择这些壁纸后进行设置,会发现拉伸很明显。通过增加打印log发现

 diff --git a/src/com/android/wallpaperpicker/WallpaperCropActivity.java b/src/com/android/wallpaperpicker/WallpaperCropActivity.java
old mode 100644
new mode 100755
index bdb601b..67d1551
--- a/src/com/android/wallpaperpicker/WallpaperCropActivity.java
+++ b/src/com/android/wallpaperpicker/WallpaperCropActivity.java
@@ -337,15 +337,22 @@ public class WallpaperCropActivity extends Activity implements Handler.CallbackPoint inSize = mCropView.getSourceDimensions();Point outSize = WallpaperUtils.getDefaultWallpaperSize(getResources(),getWindowManager());
+               android.util.Log.d(LOGTAG,"inSize.x = " + inSize.x + " inSize.y = " + inSize.y
+                       + " outSize.x = " + outSize.x + " outSize.y = " + outSize.y);RectF crop = Utils.getMaxCropRect(inSize.x, inSize.y, outSize.x, outSize.y, false);// Passing 0, 0 will cause launcher to revert to using the// default wallpaper sizeCropAndFinishHandler onEndCrop = new CropAndFinishHandler(new Point(0, 0),shouldFadeOutOnFinish);CropAndSetWallpaperTask cropTask = new CropAndSetWallpaperTask(streamProvider, this, crop, streamProvider.getRotationFromExif(this),outSize.x, outSize.y, onEndCrop);DialogUtils.executeCropTaskAfterPrompt(this, cropTask, getOnDialogCancelListener());}



我们的壁纸尺寸是1024*600,log打印的inSize都是正确的,但是outSize却变成了1200*1024了,由此产生了壁纸设置后有拉伸的情况。


因此问题就是出在这个Size的变化上,我们继续跟踪源码,会发现

diff --git a/src/com/android/wallpaperpicker/WallpaperUtils.java b/src/com/android/wallpaperpicker/WallpaperUtils.java
old mode 100644
new mode 100755
index 1532190..a4d88d7
--- a/src/com/android/wallpaperpicker/WallpaperUtils.java
+++ b/src/com/android/wallpaperpicker/WallpaperUtils.java
@@ -137,7 +137,7 @@ public final class WallpaperUtils {// We need to ensure that there is enough extra space in the wallpaper// for the intended parallax effects
-            final int defaultWidth, defaultHeight;
+            int defaultWidth, defaultHeight;if (res.getConfiguration().smallestScreenWidthDp >= 720) {defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));defaultHeight = maxDim;
@@ -145,6 +145,11 @@ public final class WallpaperUtils {defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);defaultHeight = maxDim;}
+                       android.util.Log.d("WallpaperCropActivity"," res.getConfiguration().smallestScreenWidthDp = "
+                       + res.getConfiguration().smallestScreenWidthDp + " defaultWidth = " + defaultWidth
+                               + " minDim =" + minDim + " maxDim =" + maxDim);
+            defaultWidth = maxDim;
+            defaultHeight = minDim;sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);}return sDefaultWallpaperSize;


问题的根源就是这个defaultWidth和defaultHeight啦。继续打印log发现maxDim和minDim就是我们正确的壁纸尺寸,这两个变量都是final的更改下修饰符,同时将最终设置的尺寸更改为正确的,辣么设置的壁纸的拉伸问题就暂时解决了。

第二个问题,就是设置sd卡中的图片作为壁纸,这个东西源码分析的过程比较复杂。可以通过dumpsys wallpaper以及dumpsys SurfaceFlinger来查看图片的设置尺寸。更改的地方涉及三处。分别是launcher3、framework/base/core以及SystemUI。

packages/apps/Launcher3
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 38545e2..ecd3ad6 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -177,7 +177,7 @@ public class InvariantDeviceProfile {(int) (largeSide * wallpaperTravelToScreenWidthRatio(largeSide, smallSide)),largeSide);} else {
-            defaultWallpaperSize = new Point(Math.max(smallSide * 2, largeSide), largeSide);
+            defaultWallpaperSize = new Point(largeSide, largeSide);}}frameworks/base
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -55,6 +55,7 @@ import android.os.SystemProperties;import android.os.UserHandle;import android.text.TextUtils;import android.util.Log;
+import android.view.WindowManager;import android.view.WindowManagerGlobal;import libcore.io.IoUtils;
@@ -310,7 +311,7 @@ public class WallpaperManager {mCachedWallpaper = null;mCachedWallpaperUserId = 0;try {
-                    mCachedWallpaper = getCurrentWallpaperLocked(userId);
+                    mCachedWallpaper = getCurrentWallpaperLocked(context,userId);mCachedWallpaperUserId = userId;} catch (OutOfMemoryError e) {Log.w(TAG, "No memory load current wallpaper", e);
@@ -342,7 +343,7 @@ public class WallpaperManager {}}-        private Bitmap getCurrentWallpaperLocked(int userId) {
+        private Bitmap getCurrentWallpaperLocked(Context context,int userId) {if (mService == null) {Log.w(TAG, "WallpaperService not running");return null;
@@ -354,7 +355,15 @@ public class WallpaperManager {params, userId);if (fd != null) {try {
+                       WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+                       int wW = mWindowManager.getDefaultDisplay().getWidth();
+                       int wH = mWindowManager.getDefaultDisplay().getHeight();BitmapFactory.Options options = new BitmapFactory.Options();
+                       options.inJustDecodeBounds = true;
+                       BitmapFactory.decodeFileDescriptor(
+                               fd.getFileDescriptor(), null, options);
+                       options.inSampleSize = calculateInSampleSize(options, wW,wH);
+                       options.inJustDecodeBounds = false;return BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(), null, options);} catch (OutOfMemoryError e) {
@@ -369,11 +378,30 @@ public class WallpaperManager {return null;}+        private int calculateInSampleSize(BitmapFactory.Options options,int reqWidth, int reqHeight){
+                  int width = options.outWidth;
+                  int height = options.outHeight;
+                  int inSampleSize = 1;
+                  if (width > reqWidth && height > reqHeight){
+                int widthRatio = Math.round((float) width / (float) reqWidth);
+                int heightRatio = Math.round((float) width / (float) reqWidth);
+                inSampleSize = Math.max(widthRatio, heightRatio);
+                  }
+                  return inSampleSize;
+        }
+private Bitmap getDefaultWallpaper(Context context, @SetWallpaperFlags int which) {
+            WindowManager mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+            int wW = mWindowManager.getDefaultDisplay().getWidth();
+            int wH = mWindowManager.getDefaultDisplay().getHeight();InputStream is = openDefaultWallpaper(context, which);if (is != null) {try {BitmapFactory.Options options = new BitmapFactory.Options();
+                    options.inJustDecodeBounds = true;
+                    BitmapFactory.decodeStream(is, null, options);
+                    options.inSampleSize = calculateInSampleSize(options, wW,wH);
+                    options.inJustDecodeBounds = false;return BitmapFactory.decodeStream(is, null, options);} catch (OutOfMemoryError e) {Log.w(TAG, "Can't decode stream", e);diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index c88931d..fecc47e 100755
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -229,14 +229,15 @@ public class ImageWallpaper extends WallpaperService {surfaceHeight = Math.max(displayInfo.logicalHeight, mBackgroundHeight);}-            if (FIXED_SIZED_SURFACE) {
+           //Log.d(TAG,"----surfaceWidth = "+surfaceWidth+" surfaceHeight= "+surfaceHeight);
+            /*if (FIXED_SIZED_SURFACE) {// Used a fixed size surface, because we are special.  We can do// this because we know the current design of window animations doesn't// cause this to break.surfaceHolder.setFixedSize(surfaceWidth, surfaceHeight);mLastRequestedWidth = surfaceWidth;mLastRequestedHeight = surfaceHeight;
-            } else {
+            } else*/ {surfaceHolder.setSizeFromLayout();}return hasWallpaper;
http://www.yayakq.cn/news/10913/

相关文章:

  • 做全屏轮播的网站有哪些如何修改wordpress登录域名
  • 网站建设收费标准策划网站基本信息设置
  • 网站下载不了的视频怎么下载高端企业网站建设服务商
  • 金阊做网站价格做网站团队的人员安排
  • 手机网站建设经典教程企业如何建设网站
  • 手机网站开发制作网站重新备案 需要关闭网站么
  • 镇海区住房和建设交通局网站无锡网站建设无锡网络推广
  • 常州语言网站建设青岛网站定制开发
  • 会声会影免费模板网站搭建wordpress配置
  • 塔城建设局网站网站开发价格多少
  • js网站开发教程关于南宁网页的介绍
  • 河南建设厅八大员查询网站贵州企业网站建设
  • 合肥网站建设制作学生网页设计模板
  • 服务于中小企业建网站微餐饮网站建设用途
  • 在线图片编辑网站源码网站做的支付宝接口
  • 自己网站做seo宣传片制作拍摄公司
  • 网站建设公众号小程序属于什么湖北省建设工程人力资源网站
  • 油漆网站设计ppt那个网站做的好
  • 设计网站页面注意事项山东网页制作网站
  • 网站建设需要注意哪些问题商业计划书ppt免费模板下载
  • 做啥网站wordpress菜单底部导航
  • 网站建设策划案怎样做关键词网站
  • 单县城乡住房建设局网站东莞网络推广价格
  • 做网站设计的论文中摘要怎么写设计制作商城网站
  • 阿里云的网站建设方案汽车网址都有哪些
  • 最好的免费logo设计网站钟落潭有没有做网站的
  • 如果网站设计时中国建设工程造价管理协会网站
  • 网站建设找客户智能产品
  • 网站 简约百度网站认证
  • 网站打不开 其它能打开网站建设公司的市场营销方案模板