修改思路:
1:默认是没有将导航栏显示出来,需要先显示导航栏
2:状态栏和导航栏是加载在一个矩阵中的,因此需要先调整状态栏和导航栏矩阵的上下左右位置使导航栏和状态栏实际位置发送改变
3:调整状态栏,导航栏布局水平方式为垂直方式修改UI显示位置
4:测试系统本地应用和第三方应用是否通过此次修改存在问题
代码修改:
chmod statusbar left and navibar right and statusbar ui,navibar ui
设置导航栏属性为显示
diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index f0f017a..d13cb0e 100644
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
@@ -1845,7 +1845,7 @@
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
- <bool name="config_showNavigationBar">false</bool>
+ <bool name="config_showNavigationBar">true</bool>
设置状态栏高度为320dp(后视镜分辨率为1280x320,mdpi),导航栏宽度为192dp(后面将状态栏和导航栏统一设置为此值)
diff --git a/frameworks/base/core/res/res/values/dimens.xml b/frameworks/base/core/res/res/values/dimens.xml
index d7f5e62..11c6715 100644
--- a/frameworks/base/core/res/res/values/dimens.xml
+++ b/frameworks/base/core/res/res/values/dimens.xml
@@ -33,14 +33,14 @@
<dimen name="toast_y_offset">24dp</dimen>
<!--[begin] modify StatusBarHeight:24dp->42dp. add by ZHua. -->
<!-- Height of the status bar -->
- <dimen name="status_bar_height">30dp</dimen>
+ <dimen name="status_bar_height">320dp</dimen>
<!--[end] -->
<!-- Height of the bottom navigation / system bar. -->
<dimen name="navigation_bar_height">48dp</dimen>
<!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height -->
<dimen name="navigation_bar_height_landscape">48dp</dimen>
<!-- Width of the navigation bar when it is placed vertically on the screen -->
- <dimen name="navigation_bar_width">48dp</dimen>
+ <dimen name="navigation_bar_width">192dp</dimen>
<!-- Height of the bottom navigation / system bar in car mode. -->
<dimen name="navigation_bar_height_car_mode">96dp</dimen>
代码设置导航栏为显示,并且将状态栏宽度跟导航栏宽度设置为同一值(192dp)
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -277,7 +277,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static boolean localLOGV = false;
static boolean DEBUG_INPUT = false;
static boolean DEBUG_KEYGUARD = false;
- static boolean DEBUG_LAYOUT = false;
+ static boolean DEBUG_LAYOUT = true;
static boolean DEBUG_SPLASH_SCREEN = false;
static boolean DEBUG_WAKEUP = false;
static boolean SHOW_SPLASH_SCREENS = true;
@@ -469,6 +469,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mSafeMode;
WindowState mStatusBar = null;
int mStatusBarHeight;
+ int mStatusBarWidth;
WindowState mNavigationBar = null;
boolean mHasNavigationBar = false;
boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
@@ -2283,12 +2284,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
- String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
- if ("1".equals(navBarOverride)) {
- mHasNavigationBar = false;
- } else if ("0".equals(navBarOverride)) {
- mHasNavigationBar = true;
- }
+ //edit by guo 2020/2/13
+// String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
+// if ("1".equals(navBarOverride)) {
+// mHasNavigationBar = false;
+// } else if ("0".equals(navBarOverride)) {
+// mHasNavigationBar = true;
+// }
// For demo purposes, allow the rotation of the HDMI display to be controlled.
// By default, HDMI locks rotation to landscape.
@@ -2736,6 +2738,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mStatusBarHeight =
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+ //add by guo 2020/2/15 config statusbar width
+ mStatusBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
调整状态栏矩阵的位置并且将导航栏设置为右侧(PhoneWndowManager.java)
// Height of the navigation bar when presented horizontally at bottom
mNavigationBarHeightForRotationDefault[mPortraitRotation] =
mNavigationBarHeightForRotationDefault[mUpsideDownRotation] =
@@ -4486,11 +4491,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
overscanRight = 0;
overscanBottom = 0;
}
- mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0;
+ mOverscanScreenLeft = mRestrictedOverscanScreenLeft = mStatusBarWidth;
mOverscanScreenTop = mRestrictedOverscanScreenTop = 0;
- mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth;
+ mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth-mStatusBarWidth;
mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight;
- mSystemLeft = 0;
+ mSystemLeft =mStatusBarWidth;
mSystemTop = 0;
mSystemRight = displayWidth;
mSystemBottom = displayHeight;
@@ -4547,9 +4552,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (!isKeyguardShowing) {
navTranslucent &= areTranslucentBarsAllowed();
}
- boolean statusBarExpandedNotKeyguard = !isKeyguardShowing && mStatusBar != null
- && mStatusBar.getAttrs().height == MATCH_PARENT
- && mStatusBar.getAttrs().width == MATCH_PARENT;
+ boolean statusBarExpandedNotKeyguard = true;
+// !isKeyguardShowing && mStatusBar != null
+// && mStatusBar.getAttrs().height == MATCH_PARENT
+// && mStatusBar.getAttrs().width == MATCH_PARENT;
// When the navigation bar isn't visible, we put up a fake
// input window to catch all touch events. This way we can
@@ -4592,16 +4598,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// decide where the status bar goes ahead of time
if (mStatusBar != null) {
// apply any navigation bar insets
+ //edit by guo 2020/2/11
pf.left = df.left = of.left = mUnrestrictedScreenLeft;
- pf.top = df.top = of.top = mUnrestrictedScreenTop;
- pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft;
- pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight
- + mUnrestrictedScreenTop;
+ pf.top = df.top = of.top =mUnrestrictedScreenTop;
+ pf.right = df.right = of.right = mStatusBarWidth;//mUnrestrictedScreenWidth + mUnrestrictedScreenLeft
+ pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight + mUnrestrictedScreenTop;
vf.left = mStableLeft;
vf.top = mStableTop;
vf.right = mStableRight;
vf.bottom = mStableBottom;
+
mStatusBarLayer = mStatusBar.getSurfaceLayer();
// Let the status bar determine its size.
@@ -4610,7 +4617,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
dcf /* decorFrame */, vf /* stableFrame */, vf /* outsetFrame */);
// For layout, the status bar is always at the top with our fixed height.
- mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
+// mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; edit by guo 2020/2/11
+ mStableLeft=mStatusBarWidth;
boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0;
boolean statusBarTranslucent = (sysui
@@ -4625,8 +4633,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Status bar may go away, so the screen area it occupies
// is available to apps but just covering them when the
// status bar is visible.
- mDockTop = mUnrestrictedScreenTop + mStatusBarHeight;
-
+// mDockTop = mUnrestrictedScreenTop + mStatusBarHeight;//edit by guo 2020/2/11
+ mDockLeft=mStatusBarWidth;//add by guo 2020/2/11
mContentTop = mVoiceContentTop = mCurTop = mDockTop;
mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom;
mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft;
@@ -4645,7 +4653,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// If the opaque status bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
- mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight;
+// mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; edit by guo 2020/2/11
+ mSystemLeft=mStatusBarWidth;//add by guo 2020/2/11
}
if (mStatusBarController.checkHiddenLw()) {
return true;
@@ -4766,14 +4775,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
private int navigationBarPosition(int displayWidth, int displayHeight, int displayRotation) {
- if (mNavigationBarCanMove && displayWidth > displayHeight) {
- if (displayRotation == Surface.ROTATION_270) {
- return NAV_BAR_LEFT;
- } else {
- return NAV_BAR_RIGHT;
- }
- }
- return NAV_BAR_BOTTOM;
+// if (mNavigationBarCanMove && displayWidth > displayHeight) {
+// if (displayRotation == Surface.ROTATION_270) {
+// return NAV_BAR_LEFT;
+// } else {
+// return NAV_BAR_RIGHT;
+// }
+// }
+// return NAV_BAR_BOTTOM;
+ return NAV_BAR_RIGHT;
}
设置状态栏强制不隐藏
/** {@inheritDoc} */
@@ -5699,11 +5709,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
&& !mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID)
&& !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID)) {
if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar");
- if (mStatusBarController.setBarShowingLw(false)) {
- changes |= FINISH_LAYOUT_REDO_LAYOUT;
- } else {
- if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding");
- }
+// if (mStatusBarController.setBarShowingLw(false)) {
+// changes |= FINISH_LAYOUT_REDO_LAYOUT;
+// } else {
+// if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding");
+// } edit by guo 2020/2/14
} else {
if (DEBUG_LAYOUT) Slog.v(TAG, "** SHOWING status bar: top is not fullscreen");
if (mStatusBarController.setBarShowingLw(true)) {
UI修改:
导航栏添加GPS收星,4G信号和天气相关UI
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/navigation_bar.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/navigation_bar.xml
-<com.android.systemui.statusbar.phone.NavigationBarView
- xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.systemui.statusbar.phone.NavigationBarView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res-auto"
- android:layout_height="match_parent"
android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:background="@drawable/system_bar_background">
<com.android.systemui.statusbar.phone.NavigationBarInflaterView
android:id="@+id/navigation_inflater"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:visibility="gone" />
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginRight="30dp"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="94dp"
+ android:id="@+id/navi_layout"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_gps" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/gps"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="5dp"
+ android:text="0"
+ android:textColor="#ffff0000"
+ android:textSize="18sp" />
+
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/signal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ImageView
+ android:id="@+id/type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ </FrameLayout>
+ </LinearLayout>
+
+ <include
+ android:id="@+id/weather_layout"
+ layout="@layout/weather_widget" />
+
+ </LinearLayout>
</com.android.systemui.statusbar.phone.NavigationBarView>
修改状态栏水平为垂直
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/status_bar.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/status_bar.xml
- <LinearLayout android:id="@+id/status_bar_contents"
+ <LinearLayout
+ android:id="@+id/status_bar_contents"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingStart="6dp"
- android:paddingEnd="8dp"
- android:orientation="horizontal"
+ android:gravity="center"
+ android:layout_marginLeft="30dp"
+ android:orientation="vertical"
>
<LinearLayout
android:id="@+id/button_icon_area"
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="horizontal">
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:layout_marginTop="5dp"
+ android:orientation="vertical">
<ImageView
android:id="@+id/btn_back"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="6dp"
- android:paddingRight="6dp"
- android:paddingTop="1dp"
- android:paddingBottom="1dp"
- android:src="@drawable/ic_revert_ksd"
- android:background="@drawable/btn_selector"/>
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_back" />
<ImageView
android:id="@+id/btn_home"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="6dp"
- android:paddingRight="6dp"
- android:paddingTop="1dp"
- android:paddingBottom="1dp"
- android:src="@drawable/ic_home_ksd"
- android:background="@drawable/btn_selector"/>
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_home" />
<com.android.systemui.statusbar.phone.CarImageView
android:id="@+id/btn_brightness"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
+ android:visibility="gone"
android:src="@drawable/ic_brightness_day_def"
android:background="@drawable/btn_selector" />
+
+ <ImageView
+ android:id="@+id/btn_voice"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_voice" />
</LinearLayout>
<!-- [end]add by mqiongling for keycode -->
+
+ <com.android.systemui.statusbar.policy.Clock
+ android:id="@+id/clock"
+ android:textAppearance="@style/TextAppearance.StatusBar.Clock"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:paddingStart="@dimen/status_bar_clock_starting_padding"
+ android:paddingEnd="@dimen/status_bar_clock_end_padding"
+ android:gravity="center_vertical|start"
+ android:textColor="#ffffff"
+ android:textSize="36sp" />
+
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:layout_marginTop="5dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/date"
+ android:textColor="#ffffff"
+ android:textSize="18sp"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/week"
+ android:layout_marginLeft="2dp"
+ android:textColor="#ffffff"
+ android:textSize="18sp"/>
+ </LinearLayout>
+
<LinearLayout android:id="@+id/system_icon_area"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="horizontal"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:orientation="vertical"
>
<include layout="@layout/system_icons" />
-
- <com.android.systemui.statusbar.policy.Clock
- android:id="@+id/clock"
- android:textAppearance="@style/TextAppearance.StatusBar.Clock"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:singleLine="true"
- android:paddingStart="@dimen/status_bar_clock_starting_padding"
- android:paddingEnd="@dimen/status_bar_clock_end_padding"
- android:gravity="center_vertical|start"
- />
</LinearLayout>
</LinearLayout>
添加天气UI
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/weather_widget.xml
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:systemui="http://schemas.android.com/apk/res-auto"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:gravity="center_horizontal"
+ android:layout_marginTop="30dp"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:id="@+id/weather_img"
+ android:background="@drawable/icon_cloudy"/>
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:id="@+id/weather_cloud"
+ android:layout_marginTop="4dp"
+ android:text="@string/cloudy"
+ android:textSize="18sp"
+ android:textColor="#ffffff"/>
+
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:id="@+id/weather_temp"
+ android:text="27~28℃"
+ android:layout_marginTop="4dp"
+ android:textSize="18sp"
+ android:textColor="#ffffff"/>
+
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:id="@+id/weather_region"
+ android:textColor="#ffffff"
+ android:textSize="18sp"
+ android:layout_marginTop="12dp"
+ android:text="@string/shenzhen"/>
+</LinearLayout>
其他相关修改和天气,GPS收星功能添加
状态栏移动信号发送给导航栏(4G)做显示调用
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/vendor/mediatek/proprietary/
index 9589e85..9f25627 100755
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -60,6 +60,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import android.content.Intent;
// Intimately tied to the design of res/layout/signal_cluster_view.xml
public class SignalClusterView extends LinearLayout implements NetworkControllerImpl.SignalCallback,
@@ -76,6 +77,7 @@ public class SignalClusterView extends LinearLayout implements NetworkController
private static final String SLOT_VPN = "vpn";
private final NetworkController mNetworkController;
+
private final SecurityController mSecurityController;
private boolean mNoSimsVisible = false;
@@ -366,10 +368,23 @@ public class SignalClusterView extends LinearLayout implements NetworkController
state.mDataActivityIn = activityIn;
state.mDataActivityOut = activityOut;
/// @ }
-
+ //add by guo 2020/2/19 send broadcast to navibar
+ sendBroadcastToNavi(statusIcon.icon,statusType);
apply();
}
+ //add by guo 2020/2/19
+ private static final String ACTION_TO_NAVIBAR = "systemui.navibar";
+ private static final String SINGLE = "MobileStrengthId";
+ private static final String TYPE = "MobileTypeId";
+ private void sendBroadcastToNavi(int single,int type){
+ Intent intent = new Intent();
+ intent.setAction(ACTION_TO_NAVIBAR);
+ intent.putExtra(SINGLE, single);
+ intent.putExtra(TYPE, type);
+ mContext.sendBroadcast(intent);
+ }
+
//[start]mqiongling status bar display one signal icon
private int getDefaultDataSubId(){
int currentSub = 1;
设置状态栏导航栏的背景为默认颜色黑色
b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -64,7 +64,7 @@ public class BarTransitions {
mTag = "BarTransitions." + view.getClass().getSimpleName();
mView = view;
mBarBackground = new BarBackgroundDrawable(mView.getContext(), gradientResourceId);
- mView.setBackground(mBarBackground);
+// mView.setBackground(mBarBackground); edit by guo 2020/2/13
}
public int getMode() {
状态栏添加日期显示,以及注释隐藏显示system icon代码
b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
@@ -56,6 +56,13 @@ import android.app.Instrumentation;
import android.view.KeyEvent;
import android.content.Intent;
//[end]add by mqiongling for keycode
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import android.widget.TextView;
+import android.widget.ImageView;
+import android.content.pm.PackageManager;
/**
* Contains the collapsed status bar and handles hiding/showing based on disable flags
@@ -80,6 +87,8 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
private final String MODE_STATE = "mode.state";//1:????; 2:???
protected final int TAKE_SCREEN_SHOT_MESSAGE = 10000;
protected Handler mScreenshot = createScreensHotHandler();
+ private View mView;//add by guo 2020/2/18
+ private TextView dateTex,weekTex;//add by guo 2020/2/18
private SignalCallback mSignalCallback = new SignalCallback() {
@Override
@@ -99,9 +108,70 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) {
- return inflater.inflate(R.layout.status_bar, container, false);
+ mView=inflater.inflate(R.layout.status_bar, container, false);
+ initView();
+ startTimeRunnable(getContext());
+ return mView;
}
+ //add by guo init date and week view
+ private void initView(){
+ dateTex=(TextView)mView.findViewById(R.id.date);
+ weekTex=(TextView)mView.findViewById(R.id.week);
+ }
+
+
+ //add by guo 2020/2/18 change get time method
+ public void startTimeRunnable(final Context context) {
+ Log.d(TAG, "startTimeRunnable");
+ handler.sendEmptyMessage(1);
+ }
+ private void stopTimeRunnable() {
+ Log.d(TAG, "stopTimeRunnable");
+ handler.removeMessages(1);
+ }
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ if (msg.what == 1) {
+ Log.d(TAG, "handleMessage");
+ handler.sendEmptyMessageDelayed(1, 1000);
+ getDataAndWeek();
+ }
+ }
+ };
+
+ private void getDataAndWeek(){
+ Date date = new Date();
+ String dateFormat="yyyy-MM-dd";
+ String dateStr = new SimpleDateFormat(dateFormat, Locale.getDefault()).format(date);
+ String week = getContext().getString(convert(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)));
+ dateTex.setText(dateStr);
+ weekTex.setText(week);
+ }
+
+ private static int convert(int i) {
+ switch (i) {
+ case Calendar.SUNDAY:
+ return R.string.sunday;
+ case Calendar.MONDAY:
+ return R.string.monday;
+ case Calendar.TUESDAY:
+ return R.string.tuesday;
+ case Calendar.WEDNESDAY:
+ return R.string.wednesday;
+ case Calendar.THURSDAY:
+ return R.string.thursday;
+ case Calendar.FRIDAY:
+ return R.string.friday;
+ case Calendar.SATURDAY:
+ return R.string.saturday;
+ default:
+ return R.string.sunday;
+ }
+ }
+ //end
+
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@@ -117,6 +187,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
mStatusBar.findViewById(R.id.btn_back).setOnClickListener(mStatusClickListener);
mStatusBar.findViewById(R.id.btn_back).setOnLongClickListener(mStatusLongClickListener);
mStatusBar.findViewById(R.id.btn_home).setOnClickListener(mStatusClickListener);
+ mStatusBar.findViewById(R.id.btn_voice).setOnClickListener(mStatusClickListener);
brightness = (CarImageView) mStatusBar.findViewById(R.id.btn_brightness);
brightness.setOnClickListener(mStatusClickListener);
setBrightnessMode();
@@ -151,6 +222,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
@Override
public void onDestroyView() {
super.onDestroyView();
+ stopTimeRunnable();//add by guo 2020/2/18
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(mSignalClusterView);
Dependency.get(StatusBarIconController.class).removeIconGroup(mDarkIconManager);
if (mNetworkController.hasEmergencyCryptKeeperText()) {
@@ -226,11 +298,13 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
}
public void hideSystemIconArea(boolean animate) {
- animateHide(mSystemIconArea, animate);
+
+// animateHide(mSystemIconArea, animate); edit by guo 2020/2/19 set systemicon invisible
}
public void showSystemIconArea(boolean animate) {
- animateShow(mSystemIconArea, animate);
+
+// animateShow(mSystemIconArea, animate); edit by guo 2020/2/19 set systemicon invisible
}
public void hideNotificationIconArea(boolean animate) {
@@ -346,6 +420,12 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
getContext().sendBroadcast(intent);
}
break;
+ case R.id.btn_voice:
+ PackageManager packageManager = getContext().getPackageManager();
+ Intent intent = packageManager.getLaunchIntentForPackage("com.aispeech.aios");
+ if(intent != null)
+ getContext().startActivity(intent);
+ break;
}
}
};
导航栏添加天气显示相关逻辑代码
diff --git b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -81,11 +81,29 @@ import com.android.systemui.statusbar.CommandQueue.Callbacks;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.KeyButtonView;
import com.android.systemui.statusbar.stack.StackStateAnimator;
+import com.android.systemui.statusbar.phone.Weather;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
import java.util.Locale;
+import android.graphics.Bitmap;
+import com.android.systemui.statusbar.phone.SignalDrawable;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.location.GpsSatellite;
+import android.location.GpsStatus;
+import android.location.LocationManager;
+import java.util.Iterator;
+import android.location.Location;
+import android.location.LocationListener;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.app.ActivityCompat;
+import android.Manifest.permission;
+
+import android.Manifest;
+import android.content.pm.PackageManager;
+import android.os.Build;
/**
* Fragment containing the NavigationBarFragment. Contains logic for what happens
@@ -126,7 +144,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
// private LightBarController mLightBarController;//mqiongling rm LightBar 20180906
public boolean mHomeBlockedThisTouch;
-
+ private Weather weather;
// ----- Fragment Lifecycle Callbacks -----
@Override
@@ -159,8 +177,142 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
+// judgePermission();
+
+ }
+
+ //6.0֮<BA><F3>Ҫ<B6><AF>̬<BB><F1>ȡȨ<CF>ޣ<AC><D6><D8>Ҫ<A3><A1><A3><A1><A3><A1>
+ protected void judgePermission() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ String[] locationPermission = {Manifest.permission.ACCESS_FINE_LOCATION};
+ if (ContextCompat.checkSelfPermission(getContext(), locationPermission[0]) != PackageManager.PERMISSION_GRANTED) {
+// ActivityCompat.requestPermissions(getContext(), locationPermission, 300);
+ }
+ String[] ACCESS_COARSE_LOCATION = {Manifest.permission.ACCESS_COARSE_LOCATION};
+ if (ContextCompat.checkSelfPermission(getContext(), ACCESS_COARSE_LOCATION[0]) != PackageManager.PERMISSION_GRANTED) {
+// ActivityCompat.requestPermissions(getContext(), ACCESS_COARSE_LOCATION, 400);
+ }
+ }
+ }
+
+ //add by guo 2020/2/17 listen weather and statusbar broadcast
+ private static final String WEATHER_RESULT = "com.wwc2.weather.WEATHER_INFO";
+ private static final String WEATHER_GET = "com.wwc2.weather.GET_WEATHER";
+ private static final String ACTION_TO_NAVIBAR = "systemui.navibar";
+ private BroadcastReceiver weatherResultReceiver;
+ private void registerBroadcast(){
+ if (weatherResultReceiver == null) {
+ weatherResultReceiver = new WeatherResultReceiver();
:
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(WEATHER_RESULT);
+ filter.addAction(ACTION_TO_NAVIBAR);
+ getContext().registerReceiver(weatherResultReceiver, filter);
+ }
+ }
+
+ private class WeatherResultReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (WEATHER_RESULT.equals(intent.getAction())) {
+ String city = intent.getStringExtra("city");
+ String tem = intent.getStringExtra("degree");
+ String wea = intent.getStringExtra("wea");
+ Bitmap bitmap = intent.getParcelableExtra("bitmap");
+ Log.d(TAG,"city:" + city + "\n" + "tem:" + tem + "\n" + "wea:" + wea);
+ if(weather!=null) {
+ weather.setWeatherImg(bitmap);
+ weather.setWeatherCloud(wea);
+ weather.setWeatherTemp(tem);
+ weather.setWeatherRegion(city);
+ }
+ }else if(ACTION_TO_NAVIBAR.equals(intent.getAction())){
+ int mobileStrengthId=intent.getIntExtra("MobileStrengthId",-1);
+ int mobileTypeId=intent.getIntExtra("MobileTypeId",-1);
+ Log.d(TAG,"mobileStrengthId==>"+mobileStrengthId+" mobileTypeId ==>"+mobileTypeId);
+ if(mobileStrengthId!=-1&&mobileTypeId!=-1){
+ mobileType.setImageResource(mobileTypeId);
+ mobileSingle.getDrawable().setLevel(mobileStrengthId);
+ }
+
+ }
+ }
}
导航栏添加GPS收星相关代码
+ //end by guo
+
+ //add by guo listen gps status 2020/2/21
+// private LocationManager manager;
+// private void listenGpsStatus(){
+// manager = (LocationManager)getContext().getSystemService(Context.LOCATION_SERVICE);
+// manager.addGpsStatusListener(gpsStatusListener);
+// manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 1.0f,ll);// locationListener
+// }
+//
+// LocationListener ll = new LocationListener() {
+//
+// @Override
+// public void onLocationChanged(Location location) {
+//
+// }
+//
+// @Override
+// public void onStatusChanged(String provider, int status,
+// Bundle extras) {
+//
+// }
+//
+// @Override
+// public void onProviderEnabled(String provider) {
+//
+// }
+//
+// @Override
+// public void onProviderDisabled(String provider) {
+//
+// }
+//
+// };
+//
+//
+// private GpsStatus.Listener gpsStatusListener = new GpsStatus.Listener() {
+// @Override
+// public void onGpsStatusChanged(int event) {
+// switch (event) {
+// case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+// GpsStatus gpsStatus = manager.getGpsStatus(null);
+// int maxSatellites = gpsStatus.getMaxSatellites();
+// Iterator<GpsSatellite> iters = gpsStatus.getSatellites().iterator();
+// int count = 0;
+// StringBuilder sb = new StringBuilder();
+// while (iters.hasNext() && count <= maxSatellites) {
+// count++;
+// GpsSatellite s = iters.next();
+// // <CE><C0><D0>ǵ<C4><D0><C5><D4><EB><B1><C8>
+// float snr = s.getSnr();
+// sb.append("第").append(count).append("颗 ").append("信号:").append(snr).append("\n");
+// }
+// Log.e(TAG, sb.toString());
+// mGpsText.setText(count);
+// break;
+// default:
+// break;
+// }
+// }
+// };
+//end by guo
+
+
@Override
public void onDestroy() {
super.onDestroy();
添加GPS,天气UI初始化代码,并去掉最近任务按钮操作逻辑
@@ -179,12 +331,28 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
Bundle savedInstanceState) {
- return inflater.inflate(R.layout.navigation_bar, container, false);
+ View view=inflater.inflate(R.layout.navigation_bar, container, false);
+ weather=new Weather(getContext(),view);
+ initView(view);
+ registerBroadcast();
+// listenGpsStatus();
+ return view;
+ }
+
+ //add by guo init view 2020/2/19
+ private ImageView mobileSingle,mobileType;
+ private TextView mGpsText;
+ private void initView(View view){
+ mobileSingle=(ImageView)view.findViewById(R.id.signal);
+ mobileType=(ImageView)view.findViewById(R.id.type);
+ mobileSingle.setImageDrawable(new SignalDrawable(getContext()));
+ mGpsText=(TextView)view.findViewById(R.id.gps);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ getContext().sendBroadcast(new Intent(WEATHER_GET));//add by guo 2020/2/17
mNavigationBarView = (NavigationBarView) view;
mNavigationBarView.setDisabledFlags(mDisabledFlags1);
@@ -207,6 +375,11 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
@Override
public void onDestroyView() {
super.onDestroyView();
+ try {
+ getContext().unregisterReceiver(weatherResultReceiver);//add by guo 2020/2/17
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ }
mNavigationBarView.getLightTransitionsController().destroy(getContext());
getContext().unregisterReceiver(mBroadcastReceiver);
}
@@ -385,12 +558,12 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
private void prepareNavigationBarView() {
mNavigationBarView.reorient();
-
- ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton();
- recentsButton.setOnClickListener(this::onRecentsClick);
- recentsButton.setOnTouchListener(this::onRecentsTouch);
- recentsButton.setLongClickable(true);
- recentsButton.setOnLongClickListener(this::onLongPressBackRecents);
+ //edit by guo 2020/2/17
+// ButtonDispatcher recentsButton = mNavigationBarView.getRecentsButton();
+// recentsButton.setOnClickListener(this::onRecentsClick);
+// recentsButton.setOnTouchListener(this::onRecentsTouch);
+// recentsButton.setLongClickable(true);
+// recentsButton.setOnLongClickListener(this::onLongPressBackRecents);
ButtonDispatcher backButton = mNavigationBarView.getBackButton();
backButton.setLongClickable(true);
diff --git b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -522,7 +522,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
- getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);
+// getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE); edit by guo 2020/2/13
}
private boolean inLockTask() {
@@ -650,7 +650,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
}
private void updateRecentsIcon() {
- getRecentsButton().setImageDrawable(mDockedStackExists ? mDockedIcon : mRecentIcon);
+// getRecentsButton().setImageDrawable(mDockedStackExists ? mDockedIcon : mRecentIcon); edit by guo 2020/2/13
mBarTransitions.reapplyDarkIntensity();
}
@@ -861,7 +861,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
dumpButton(pw, "back", getBackButton());
dumpButton(pw, "home", getHomeButton());
- dumpButton(pw, "rcnt", getRecentsButton());
+// dumpButton(pw, "rcnt", getRecentsButton()); edit by guo 2020/2/13
dumpButton(pw, "menu", getMenuButton());
dumpButton(pw, "a11y", getAccessibilityButton());
隐藏下拉通知栏显示
diff --git b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -879,6 +879,8 @@ public class NotificationPanelView extends PanelView implements
@Override
public boolean onTouchEvent(MotionEvent event) {
+ if(true)
+ return false;//add by guo 2020/2/13 disable notification
// if (mBlockTouches) {// || (mQs != null && mQs.isCustomizing())) {
// return false;
// }
diff --git
b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1131,7 +1131,8 @@ public class StatusBar extends SystemUI implements DemoMode,
try {
boolean showNav = mWindowManagerService.hasNavigationBar();
- if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
+// if (DEBUG)
+ Log.v(TAG, "hasNavigationBar=" + showNav);
if (showNav) {
createNavigationBar();
}
添加天气UI代码
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/Weather.java
@@ -0,0 +1,47 @@
+
+package com.android.systemui.statusbar.phone;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.view.View;
+import com.android.systemui.R;
+
+public class Weather{
+ private Context mContext;
+ private View view;
+ private ImageView WeatherImg;
+ private TextView WeatherCloud,WeatherTemp,WeatherRegion;
+
+
+
+ public void setWeatherImg(Bitmap b) {
+ WeatherImg.setImageBitmap(b);
+ }
+
+ public void setWeatherCloud(String cloud) {
+ WeatherCloud.setText(cloud);
+ }
+
+
+ public void setWeatherTemp(String temp) {
+ WeatherTemp.setText(temp);
+ }
+
+ public void setWeatherRegion(String region) {
+ WeatherRegion.setText(region);
+ }
+
+ public Weather(Context mContext, View view) {
+ this.mContext=mContext;
+ this.view=view;
+ initView();
+ }
+
+ private void initView(){
+ WeatherImg=(ImageView)view.findViewById(R.id.weather_img);
+ WeatherCloud=(TextView) view.findViewById(R.id.weather_cloud);
+ WeatherTemp=(TextView)view.findViewById(R.id.weather_temp);
+ WeatherRegion=(TextView)view.findViewById(R.id.weather_region);
+ }
+}
以上为整个Android 8.1状态栏,导航栏修改至左侧和右侧的代码,写于此,留作笔记,仅供大家参考,如果有什么好的建议,欢迎读者留言,本人将虚心接受,谢谢!