Преглед на файлове

更改设置界面弹框

ChengJH преди 3 години
родител
ревизия
168e10a8a1

+ 65 - 14
app/src/main/java/com/uas/yuejiahong/fragment/IndexSettingFragment.java

@@ -1,9 +1,8 @@
 package com.uas.yuejiahong.fragment;
 
-import android.app.AlertDialog;
+import android.app.Dialog;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
@@ -355,19 +354,46 @@ public class IndexSettingFragment extends BaseFragment implements View.OnClickLi
                 break;
             case R.id.setting_printer_rl:
                 if (!CommonUtil.appIsInstalled(getActivity(), Constants.CONSTANT.PRINT_SHARE_PACKAGE)) {
-                    new AlertDialog.Builder(getActivity()).setTitle("提示")
-                            .setMessage("您还未安装打印程序,点击确认开始安装")
-                            .setPositiveButton("确认", new DialogInterface.OnClickListener() {
+                    final Dialog dia = new Dialog(getContext());
+                    dia.setContentView(R.layout.alert_dialog);
+
+                    TextView title = dia.findViewById(R.id.title);
+                    TextView tv_cancel = dia.findViewById(R.id.tv_cancel);
+                    TextView tv_ok = dia.findViewById(R.id.tv_ok);
+                    title.setText("您还未安装打印程序,点击确认开始安装");
+                    tv_ok.setText("确认");
+                    //选择true的话点击其他地方可以使dialog消失,为false的话不会消失
+                    dia.setCanceledOnTouchOutside(true); // Sets whether this web_dialog is
+                    tv_ok.setOnClickListener(
+                            new View.OnClickListener() {
                                 @Override
-                                public void onClick(DialogInterface dialog, int which) {
+                                public void onClick(View view) {
                                     Intent intent = new Intent(Intent.ACTION_VIEW);
                                     File assetsFileToCacheDir = FileUtils.getAssetsFileToCacheDir(getActivity(), "PrinterShare.apk");
                                     intent.setDataAndType(Uri.fromFile(assetsFileToCacheDir), "application/vnd.android.package-archive");
                                     getActivity().startActivity(intent);
-
                                 }
-                            })
-                            .setNegativeButton("取消", null).create().show();
+                            });
+                    tv_cancel.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            dia.dismiss();
+                        }
+                    });
+                    dia.show();
+//                    new AlertDialog.Builder(getActivity()).setTitle("提示")
+//                            .setMessage("您还未安装打印程序,点击确认开始安装")
+//                            .setPositiveButton("确认", new DialogInterface.OnClickListener() {
+//                                @Override
+//                                public void onClick(DialogInterface dialog, int which) {
+//                                    Intent intent = new Intent(Intent.ACTION_VIEW);
+//                                    File assetsFileToCacheDir = FileUtils.getAssetsFileToCacheDir(getActivity(), "PrinterShare.apk");
+//                                    intent.setDataAndType(Uri.fromFile(assetsFileToCacheDir), "application/vnd.android.package-archive");
+//                                    getActivity().startActivity(intent);
+//
+//                                }
+//                            })
+//                            .setNegativeButton("取消", null).create().show();
                 } else {
                     Intent intent = new Intent();
                     ComponentName comp = new ComponentName("com.dynamixsoftware.printershare", "com.dynamixsoftware.printershare.ActivityMain");
@@ -383,15 +409,40 @@ public class IndexSettingFragment extends BaseFragment implements View.OnClickLi
                 getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.container_function_fragment, mFragment).commit();
                 break;
             case R.id.setting_exit_current_account_ll:
-                new AlertDialog.Builder(getActivity()).setTitle("提示").setMessage("确定要退出当前账号吗?")
-                        .setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {
+                final Dialog dia = new Dialog(getContext());
+                dia.setContentView(R.layout.alert_dialog);
+                TextView tv_cancel = dia.findViewById(R.id.tv_cancel);
+                TextView tv_ok = dia.findViewById(R.id.tv_ok);
+                //选择true的话点击其他地方可以使dialog消失,为false的话不会消失
+                dia.setCanceledOnTouchOutside(true); // Sets whether this web_dialog is
+                tv_ok.setOnClickListener(
+                        new View.OnClickListener() {
                             @Override
-                            public void onClick(DialogInterface dialog, int which) {
+                            public void onClick(View view) {
                                 progressDialog.show();
                                 //传递Handler对象给Volley
                                 VolleyUtil.setVolleyHandler(mHandler);
                                 //连接服务器
                                 VolleyUtil.getVolleyUtil().requestConnectServer(getActivity(), GloableParams.ADDRESS_LOGOUT_APPLY, VolleyUtil.METHOD_GET, VolleyUtil.FRAGMENT_LOGOUT);
+                                dia.dismiss();
+                            }
+                        });
+                    tv_cancel.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            dia.dismiss();
+                        }
+                    });
+                    dia.show();
+//                new AlertDialog.Builder(getActivity()).setTitle("提示").setMessage("确定要退出当前账号吗?")
+//                        .setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {
+//                            @Override
+//                            public void onClick(DialogInterface dialog, int which) {
+//                                progressDialog.show();
+//                                //传递Handler对象给Volley
+//                                VolleyUtil.setVolleyHandler(mHandler);
+//                                //连接服务器
+//                                VolleyUtil.getVolleyUtil().requestConnectServer(getActivity(), GloableParams.ADDRESS_LOGOUT_APPLY, VolleyUtil.METHOD_GET, VolleyUtil.FRAGMENT_LOGOUT);
 
                                 /*PdaApplication.mRequestQueue.cancelAll(TAG + "logout");
 
@@ -426,8 +477,8 @@ public class IndexSettingFragment extends BaseFragment implements View.OnClickLi
                                 mStringRequest.setTag(TAG + "logout");
                                 PdaApplication.mRequestQueue.add(mStringRequest);*/
 
-                            }
-                        }).setNegativeButton(getString(R.string.cancel), null).create().show();
+//                            }
+//                        }).setNegativeButton(getString(R.string.cancel), null).create().show();
 
                 break;
             case R.id.setting_style_rl:

+ 9 - 0
app/src/main/res/drawable/common_linear_divider_horizontal.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!-- 通用垂直分隔线 -->
+
+    <solid android:color="#000" />
+    <size android:width="1dp" />
+
+</shape>

+ 9 - 0
app/src/main/res/drawable/common_linear_divider_vertical.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!-- 通用水平分隔线 -->
+
+    <solid android:color="#EFEEFD" />
+    <size android:height="0.5dp" />
+
+</shape>

+ 9 - 0
app/src/main/res/drawable/shape_bg_common_dialog.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+    <solid android:color="#ffffff" />
+    <corners android:radius="20dp" />
+
+
+</shape>

+ 79 - 0
app/src/main/res/layout/alert_dialog.xml

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="300dp"
+    android:layout_height="wrap_content"
+    android:layout_gravity="center"
+    android:background="@drawable/shape_bg_common_dialog"
+    android:divider="@drawable/common_linear_divider_vertical"
+    android:orientation="vertical"
+    android:showDividers="middle">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
+        <LinearLayout
+            android:layout_marginBottom="@dimen/textsize_20"
+            android:layout_marginTop="@dimen/textsize_20"
+            android:id="@+id/ll_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:minHeight="60dp"
+            android:orientation="vertical">
+            <TextView
+                android:layout_gravity="center"
+                android:text="提示"
+                android:textSize="30dp"
+                android:textColor="#333"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content">
+            </TextView>
+            <TextView
+                android:layout_gravity="center"
+                android:layout_marginTop="10dp"
+                android:id="@+id/title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:text="确定要退出当前账号吗?"
+                android:textColor="#333"
+                android:textSize="16dp" />
+        </LinearLayout>
+
+    </LinearLayout>
+
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:divider="@drawable/common_linear_divider_horizontal"
+        android:orientation="horizontal"
+        android:dividerPadding="5dp"
+        android:showDividers="middle">
+
+        <TextView
+            android:id="@+id/tv_cancel"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:paddingBottom="12dp"
+            android:paddingTop="12dp"
+            android:text="取消"
+            android:textColor="#009688"
+            android:textSize="18dp" />
+
+        <TextView
+            android:id="@+id/tv_ok"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:paddingBottom="12dp"
+            android:paddingTop="12dp"
+            android:text="确定"
+            android:textColor="#009688"
+            android:textSize="18dp" />
+    </LinearLayout>
+
+</LinearLayout>

+ 1 - 0
app/src/main/res/layout/fragment_setting.xml

@@ -151,6 +151,7 @@
                 android:background="@color/background_color_first">
 
                 <RelativeLayout
+                    android:visibility="gone"
                     android:id="@+id/setting_printer_rl"
                     style="@style/SettingListItemStyle">
 

+ 2 - 1
app/src/main/res/values/color.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-
+    <color name="color2">#248BFD</color>
+    <color name="color_del_textdefault">#666666</color>
     <color name="search_gray">#dedbdb</color>
     <color name="bg_loading">#66000000</color>
     <color name="bg_content">#F9F9FB</color>