UI原生风格是两个按钮竖排放的,要改成横排防的;
前面用了个取巧的方法 dialog listView旋转90度,后面发现系统共用一个listView,其它dialog list也会旋转,所以重新写了布局,没有二级确认菜单,逻辑和一级一样;代码比较简单:
styles.xml
+ <style name="popupDialog" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:backgroundDimAmount">1</item><!-- 灰度 -->
+ <item name="android:windowFullscreen">true</item>
+ </style>
frameworks/base/services/core/java/com/android/server/policy/GlobalActions.java
private void handleShow() {
- awakenIfNecessary();
+ /*awakenIfNecessary();
mDialog = createDialog();
prepareDialog();
@@ -232,8 +243,102 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
attrs.dimAmount=1.0f;
Log.e("lyl","qqqqq "+attrs.height);
mDialog.getWindow().setAttributes(attrs);
- }
+ }*/
+ createDialogShow(true);//创建dialog
}
+ private void createDialogShow(boolean lsReboot) {
+
+ // Window initialization
+ Window window = d.getWindow();
+ window.getAttributes().width = ViewGroup.LayoutParams.MATCH_PARENT;
+ window.getAttributes().height = ViewGroup.LayoutParams.MATCH_PARENT;
+ window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND
+ | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
+ window.addFlags(
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ );
+ View decorView = d.getWindow().getDecorView();
+ int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
+ decorView.setSystemUiVisibility(uiOptions);
+ d.setContentView(R.layout.shutdown_dialog_new);
+ d.setCancelable(true);
+ ImageView shutdownIcon = (ImageView)d.findViewById(R.id.shutdown_icon);
+ ImageView restartIcon = (ImageView)d.findViewById(R.id.restart_icon);
+ TextView message = (TextView)d.findViewById(R.id.shutdown_message);
+ TextView restartMessage = (TextView)d.findViewById(R.id.restart_message);
+ message.setText(com.android.internal.R.string.power_off);
+ restartMessage.setText(com.android.internal.R.string.global_action_restart);
+
+ shutdownIcon.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mWindowManagerFuncs.shutdown(false /* confirm */);
+ d.dismiss();
+ }
+ });
+ restartIcon.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mWindowManagerFuncs.reboot(false /* confirm */);
+ d.dismiss();
+ }
+ });
+ LinearLayout mLinearLayout = (LinearLayout)d.findViewById(R.id.shutdown_linearlayout);
+ mLinearLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ d.dismiss();
+ }
+ });
+ mLinearLayout.setOnLongClickListener(new OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ d.dismiss();
+ return false;
+ }
+ });
+
+ d.setOnDismissListener(new OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ d.dismiss();
+ }
+ });
+
+ d.show();
+
+ }
其它一些小问题仿照原生的就可以,布局文件用简单的布局就ok了,