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

如何做设计网站页面设计闵行西安网站建设

如何做设计网站页面设计,闵行西安网站建设,红杉树装修公司怎么样,网站推广网摘要:android原生有双屏的机制,但需要芯片厂商适配框架后在底层实现。本文在基于芯发8766已实现底层适配的基础上,仅针对上层Launcher部分对系统进行改造,从而实现在开机后副屏显示一张待机图片。 副屏布局 由于仅显示一张图片&…

摘要:android原生有双屏的机制,但需要芯片厂商适配框架后在底层实现。本文在基于芯发8766已实现底层适配的基础上,仅针对上层Launcher部分对系统进行改造,从而实现在开机后副屏显示一张待机图片。

副屏布局

由于仅显示一张图片,故布局仅需填充ImageView

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_image.xml
===================================================================
--- vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_image.xml	(不存在的)
+++ vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_image.xml	(版本 1687)
@@ -0,0 +1,6 @@
+<ImageView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/image_view"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:scaleType="centerInside" />

关于android:scaleType的详细说明和用法,可参考官网API
或者以下BLOG:
Android的ImageView scaleType八大属性,你都了解吗?
android学习笔记之ImageView的scaleType属性

准备一张符合副屏分辨率的图片

博主所使用的副屏为320x240,图片格式为JPG

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/res/mipmap-hdpi/presents.jpg

副屏图片管理类

新增图换图片功能,在显示以上图片的基础上,如果所指定路径有替换的图片文件,则使用替换的图片文件。

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/ImagePresentation.java
===================================================================
--- vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/ImagePresentation.java	(不存在的)
+++ vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/ImagePresentation.java	(版本 1687)
@@ -0,0 +1,48 @@
+package com.android.launcher3.presentation;
+
+import android.app.Presentation;
+import android.content.Context;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+import android.view.Display;
+import android.widget.ImageView;
+
+import com.android.launcher3.R;
+
+import java.io.File;
+
+public class ImagePresentation extends Presentation {
+    private static final String TAG = "ImagePresentation";
+
+    ImageView imageView;
+
+    public ImagePresentation(Context context, Display display) {
+        super(context, display);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.presentation_image);
+
+        imageView = findViewById(R.id.image_view);
+        imageView.setImageResource(R.mipmap.presents);
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/presents_replace.jpg";
+        File imageFile = new File(path);
+        if (imageFile.exists()) {
+            imageView.setImageURI(Uri.fromFile(new File(path)));
+        } else {
+            Log.d(TAG, "The replacement image does not exist, use the original image");
+        }
+    }
+}

在Launcher部分的实现

由于需要开机后显示待机的图片,并且副屏的内容默认是投射填充主屏的内容,故开机后会有准备阶段,主要显示一部分Launcher的内容,在完全准备好后,再显示副屏的待机图片。

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
===================================================================
--- vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java	(版本 1678)
+++ vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java	(版本 1687)
@@ -70,6 +70,7 @@import android.app.NotificationChannel;import android.app.NotificationManager;import android.app.PendingIntent;
+import android.app.Presentation;import android.appwidget.AppWidgetHostView;import android.appwidget.AppWidgetManager;import android.content.ActivityNotFoundException;
@@ -86,6 +87,7 @@import android.graphics.Bitmap;import android.graphics.Rect;import android.graphics.RectF;
+import android.hardware.display.DisplayManager;import android.os.Build;import android.os.Bundle;import android.os.CancellationSignal;
@@ -99,6 +101,7 @@import android.text.method.TextKeyListener;import android.util.Log;import android.util.SparseArray;
+import android.view.Display;import android.view.KeyEvent;import android.view.KeyboardShortcutGroup;import android.view.KeyboardShortcutInfo;
@@ -168,6 +171,7 @@import com.android.launcher3.popup.PopupContainerWithArrow;import com.android.launcher3.popup.PopupDataProvider;import com.android.launcher3.popup.SystemShortcut;
+import com.android.launcher3.presentation.ImagePresentation;import com.android.launcher3.qsb.QsbContainerView;import com.android.launcher3.statemanager.StateManager;import com.android.launcher3.statemanager.StateManager.StateHandler;
@@ -387,6 +391,11 @@private StringCache mStringCache;+    // @ + {
+    private DisplayManager mDisplayManager;
+    private Presentation secondaryPresentation;
+    // @ + }
+@Override@TargetApi(Build.VERSION_CODES.S)protected void onCreate(Bundle savedInstanceState) {
@@ -453,6 +462,34 @@super.onCreate(savedInstanceState);+        // @ + {
+        mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
+        mDisplayManager.registerDisplayListener(new DisplayManager.DisplayListener() {
+            @Override
+            public void onDisplayAdded(int displayId) {
+                Log.d(TAG, "onDisplayAdded");
+            }
+
+            @Override
+            public void onDisplayRemoved(int displayId) {
+                Log.d(TAG, "onDisplayRemoved");
+            }
+
+            @Override
+            public void onDisplayChanged(int displayId) {}
+        }, null);
+
+        Display[] displays = mDisplayManager.getDisplays();
+        for (Display display : displays) {
+            if (display.getDisplayId() != Display.DEFAULT_DISPLAY) {
+                secondaryPresentation = new ImagePresentation(this, display);
+                //secondaryPresentation = new VideoPresentation(this, display);
+                secondaryPresentation.show();
+                break;
+            }
+        }
+        // @ + }
+LauncherAppState app = LauncherAppState.getInstance(this);mOldConfig = new Configuration(getResources().getConfiguration());mModel = app.getModel();
@@ -1718,6 +1755,12 @@mOverlayManager.onActivityDestroyed(this);mUserChangedCallbackCloseable.close();
+
+        // @ + {
+        if (secondaryPresentation != null && secondaryPresentation.isShowing()) {
+            secondaryPresentation.dismiss();
+        }
+        // @ + }}public LauncherAccessibilityDelegate getAccessibilityDelegate() {

扩展 —— 副屏视频布局

能显示图片,自然也能播放视频

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_video.xml
===================================================================
--- vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_video.xml	(不存在的)
+++ vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/presentation_video.xml	(版本 1687)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<VideoView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/video_view"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:scaleType="centerCrop" />

准备一段符合副屏分辨率的视频

博主所使用的副屏为320x240,视频格式为MP4

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/res/raw/video_320_240.mp4

副屏视频管理类

播放的视频内容需要根据副屏的比例进行缩放,并且根据实际情况实现循环播放。

Index: vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/VideoPresentation.java
===================================================================
--- vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/VideoPresentation.java	(不存在的)
+++ vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/presentation/VideoPresentation.java	(版本 1687)
@@ -0,0 +1,68 @@
+package com.android.launcher3.presentation;
+
+import android.app.Presentation;
+import android.content.Context;
+import android.graphics.Point;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Display;
+import android.view.ViewGroup;
+import android.widget.VideoView;
+
+import com.android.launcher3.R;
+
+public class VideoPresentation extends Presentation {
+    private static final String TAG = "VideoPresentation";
+    private VideoView videoView;
+
+    public VideoPresentation(Context context, Display display) {
+        super(context, display);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.presentation_video);
+        videoView = findViewById(R.id.video_view);
+
+        Uri videoUri = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + R.raw.video_320_240);
+        videoView.setVideoURI(videoUri);
+
+        videoView.setOnPreparedListener(mp -> {
+            int videoWidth = mp.getVideoWidth();
+            int videoHeight = mp.getVideoHeight();
+
+            Point screenSize = new Point();
+            getDisplay().getRealSize(screenSize);
+            int screenWidth = screenSize.x;
+            int screenHeight = screenSize.y;
+
+            float widthRatio = (float) screenWidth / videoWidth;
+            float heightRatio = (float) screenHeight / videoHeight;
+            float scale = Math.min(widthRatio, heightRatio);
+
+            ViewGroup.LayoutParams params = videoView.getLayoutParams();
+            params.width = (int) (videoWidth * scale);
+            params.height = (int) (videoHeight * scale);
+            videoView.setLayoutParams(params);
+        });
+
+        videoView.setOnCompletionListener(mp -> {
+            videoView.start(); // replay
+        });
+
+        
+
+        videoView.start();
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        if (videoView != null) {
+            videoView.stopPlayback();
+        }
+    }
+}
+

文章转载自:

http://6KULUtwI.sryyt.cn
http://3T2q0CQV.sryyt.cn
http://yuSo0qCM.sryyt.cn
http://btRGn7z3.sryyt.cn
http://7Ustz0XN.sryyt.cn
http://LEuKDHJ1.sryyt.cn
http://JENDJeYl.sryyt.cn
http://ATuW0FDz.sryyt.cn
http://3QTw34Vq.sryyt.cn
http://U61iWZjE.sryyt.cn
http://spE9DR3G.sryyt.cn
http://QRGJpxxe.sryyt.cn
http://o9QmGldD.sryyt.cn
http://z3BY0VK5.sryyt.cn
http://C7CQw43p.sryyt.cn
http://bxqICm2S.sryyt.cn
http://qrQu0hK4.sryyt.cn
http://ycXsr61a.sryyt.cn
http://fbOeOB93.sryyt.cn
http://lXr0Sy7u.sryyt.cn
http://9dSxBPIx.sryyt.cn
http://p0zwqfzq.sryyt.cn
http://BgqiwQhW.sryyt.cn
http://bobQ374d.sryyt.cn
http://rK4Qe0PY.sryyt.cn
http://h77rbgBD.sryyt.cn
http://cwHjHpLk.sryyt.cn
http://o3AovtIK.sryyt.cn
http://sBUW3XT1.sryyt.cn
http://1SfC9Fus.sryyt.cn
http://www.dtcms.com/wzjs/681168.html

相关文章:

  • 如何推销企业建设网站设计导航精选最好的设计网站大全
  • 乐清网站定制公司怎么样做电商赚钱
  • 网站建设需要域名技术先进的网站建设
  • 建设部网站1667号西安官网seo推广
  • 制作网站要多少费用云服务器建设网站软件
  • 网站界面设计实训的意义博客网站开发环境
  • 点读软件网站建设奉贤区网站建设
  • 茂名建站公司模板网站托管服务适合用于哪种类型的网站
  • 舞蹈东莞网站建设曲靖高端网站制作
  • 我局 负责 建设 网站北京网站建设签约
  • 新手怎么做电商在哪个网站网站后期维护费用
  • 做教育网站需要规划哪些内容需求网站建设
  • 我想做一个网站怎么办建设部注册中心网站
  • 中国建设银行复核网站国外工程建筑网站
  • 做问卷调查的网站有哪些内容app 手机软件
  • 网站建设网络推广代理公司毕业设计网站可以做什么
  • seo网站设计点击软件如何介绍设计的网站
  • 朝阳网站建设公司建站软件公司
  • pos机网站报单怎么做wordpress博客功能
  • 微信营销软件商城网站建设优化收费
  • 网站直接做标准曲线得物app开发用了多少钱
  • 刚做优化的网站什么能更新爱客影院wordpress
  • 网站友情链接对方网站没有加入本站链接对本站有没有影响?代理ip访问网站
  • 怎么建设网站电话网站分站如何做
  • 浙江建设继续教育学院网站480元做网站
  • 自助建站视频网站网站建设投资
  • 网站建设关键词分类塘下春华网站建设
  • 自适应网站导航怎么做青海西宁高端网站建设
  • 怎么在本地搭建网站建设网站选什么地方的主机
  • 用python做购物网站域名可以做网站吗