Procházet zdrojové kódy

添加隐私弹窗

owen před 5 roky
rodič
revize
3e99a45285

+ 65 - 3
app/src/main/java/com/wiipu/peopleheart/SplashActivity.java

@@ -1,10 +1,17 @@
 package com.wiipu.peopleheart;
 
+import android.app.FragmentManager;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.os.Handler;
 import android.view.View;
+import android.widget.TextView;
 
 import com.wiipu.commonlib.base.BaseActivity;
+import com.wiipu.commonlib.utils.dialog.CommonDialog;
+import com.wiipu.commonlib.utils.dialog.ViewConvertListener;
+import com.wiipu.commonlib.utils.dialog.ViewHolder;
+import com.wiipu.peopleheart.widget.privacy.PrivacyDialog;
 
 
 /**
@@ -12,7 +19,13 @@ import com.wiipu.commonlib.base.BaseActivity;
  */
 
 public class SplashActivity extends BaseActivity {
-    private Handler handler=new Handler();
+
+    public static final String IS_CONFIRM = "is_confirm";
+
+    private Handler handler = new Handler();
+    private boolean isConfirm = false;
+    private SharedPreferences sharedPreferences;
+    private PrivacyDialog privacyDialog;
 
     @Override
     protected int getLayoutId() {
@@ -21,7 +34,8 @@ public class SplashActivity extends BaseActivity {
 
     @Override
     protected void initViews() {
-
+        sharedPreferences = getSharedPreferences("people_heart_privacy", MODE_PRIVATE);
+        isConfirm = sharedPreferences.getBoolean(IS_CONFIRM, false);
     }
 
     @Override
@@ -31,15 +45,63 @@ public class SplashActivity extends BaseActivity {
 
     @Override
     protected void initData() {
+
+        if (isConfirm){
+            goNext();
+        }else {
+            if (null != privacyDialog){
+                privacyDialog.dismiss();
+                privacyDialog = null;
+            }
+
+            privacyDialog = PrivacyDialog.init();
+            privacyDialog.setCancelable(false);
+            privacyDialog = privacyDialog.setConvertListener(new ViewConvertListener() {
+                @Override
+                public void convertView(ViewHolder holder, CommonDialog dialog) {
+                    holder.setOnClickListener(R.id.tv_confirm, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            isConfirm = true;
+                            SharedPreferences.Editor editor = sharedPreferences.edit();
+                            editor.putBoolean(IS_CONFIRM,true);
+                            editor.apply();
+                            goNext();
+                        }
+                    });
+
+                    holder.setOnClickListener(R.id.tv_not_confirm, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View v) {
+                            closeDialog();
+                            finish();
+                        }
+                    });
+                }
+            });
+            privacyDialog.show(getSupportFragmentManager());
+        }
+
+    }
+
+    private void goNext(){
+        closeDialog();
         handler.postDelayed(new Runnable() {
             @Override
             public void run() {
-                    startActivity(new Intent(SplashActivity.this,MainActivity.class));
+                startActivity(new Intent(SplashActivity.this,MainActivity.class));
                 finish();
             }
         },1500);
     }
 
+    private void closeDialog(){
+        if (null != privacyDialog){
+            privacyDialog.dismiss();
+            privacyDialog = null;
+        }
+    }
+
     @Override
     public void onClick(View v) {
 

+ 34 - 0
app/src/main/java/com/wiipu/peopleheart/widget/privacy/PrivacyAdapter.java

@@ -0,0 +1,34 @@
+package com.wiipu.peopleheart.widget.privacy;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.widget.TextView;
+
+import com.wiipu.commonlib.base.BaseAdapter;
+import com.wiipu.commonlib.base.BaseViewHolder;
+import com.wiipu.peopleheart.R;
+
+import java.util.List;
+
+public class PrivacyAdapter extends BaseAdapter<PrivacyContent> {
+
+    public PrivacyAdapter(List<PrivacyContent> datas, Context context){
+        super(datas,context);
+    }
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.item_privacy_dialog;
+    }
+
+    @Override
+    public void convert(BaseViewHolder holder, int position, PrivacyContent data) {
+        TextView tvTitle = holder.getView(R.id.tv_title);
+        TextView tvContent = holder.getView(R.id.tv_content);
+        if (null != data){
+            tvTitle.setText(data.getTitle());
+            tvContent.setText(data.getContent());
+        }
+    }
+}

+ 22 - 0
app/src/main/java/com/wiipu/peopleheart/widget/privacy/PrivacyContent.java

@@ -0,0 +1,22 @@
+package com.wiipu.peopleheart.widget.privacy;
+
+public class PrivacyContent {
+    private String title;
+    private String content;
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 121 - 0
app/src/main/java/com/wiipu/peopleheart/widget/privacy/PrivacyDialog.java


+ 8 - 0
app/src/main/res/drawable/bg_privacy_confirm.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    >
+    <solid android:color="@color/text_light_blue"/>
+    <corners android:radius="@dimen/margin20dp"/>
+
+</shape>

+ 8 - 0
app/src/main/res/drawable/bg_privacy_dialog.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    >
+    <solid android:color="@color/white"/>
+    <corners android:radius="@dimen/margin15dp"/>
+
+</shape>

+ 8 - 0
app/src/main/res/drawable/bg_privacy_not_confirm.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle"
+    >
+    <solid android:color="@color/grey_bg"/>
+    <corners android:radius="@dimen/margin20dp"/>
+
+</shape>

+ 67 - 0
app/src/main/res/layout/dialog_privacy.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/bg_privacy_dialog"
+    >
+
+    <TextView
+        android:id="@+id/tv_privacy_title"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/margin60dp"
+        android:text="@string/tv_title_privacy_dialog"
+        android:layout_gravity="center"
+        android:gravity="center"
+        android:textSize="@dimen/textsize_20"
+        android:textColor="@color/transparent"
+        android:layout_alignParentTop="true"
+        />
+
+    <TextView
+        android:id="@+id/tv_confirm"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/margin50dp"
+        android:layout_marginLeft="@dimen/margin20dp"
+        android:layout_marginRight="@dimen/margin20dp"
+        android:layout_gravity="center"
+        android:gravity="center"
+        android:textColor="@color/white"
+        android:textSize="@dimen/textsize_18"
+        android:text="@string/tv_privacy_confirm"
+        android:background="@drawable/bg_privacy_confirm"
+        android:layout_marginTop="@dimen/margin20dp"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="@dimen/margin80dp"
+        />
+
+    <TextView
+        android:id="@+id/tv_not_confirm"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/margin50dp"
+        android:layout_marginLeft="@dimen/margin20dp"
+        android:layout_marginRight="@dimen/margin20dp"
+        android:layout_gravity="center"
+        android:gravity="center"
+        android:textColor="@color/transparent"
+        android:textSize="@dimen/textsize_18"
+        android:text="@string/tv_privacy_not_confirm"
+        android:background="@drawable/bg_privacy_not_confirm"
+        android:layout_marginTop="@dimen/margin15dp"
+        android:layout_marginBottom="@dimen/margin20dp"
+        android:layout_alignParentBottom="true"
+        />
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/rv_privacy_content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginLeft="@dimen/margin20dp"
+        android:layout_marginRight="@dimen/margin20dp"
+        android:layout_below="@id/tv_privacy_title"
+        android:layout_above="@id/tv_confirm"
+        >
+    </android.support.v7.widget.RecyclerView>
+
+
+</RelativeLayout>

+ 29 - 0
app/src/main/res/layout/item_privacy_dialog.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:id="@+id/tv_title"
+        android:layout_width="match_parent"
+        android:layout_height="40dp"
+        android:textSize="@dimen/textsize_18"
+        android:layout_gravity="center"
+        android:gravity="center|start"
+        android:textColor="@color/transparent"
+        />
+
+    <TextView
+        android:id="@+id/tv_content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="@dimen/textsize_16"
+        android:gravity="center|start"
+        android:layout_gravity="center"
+        android:textColor="@color/transparent"
+        android:layout_marginBottom="@dimen/margin5dp"
+        />
+
+</LinearLayout>

+ 4 - 2
app/src/main/res/values/strings.xml

@@ -9,8 +9,10 @@
     <string name="tv_title_case">全部办件</string>
     <string name="tv_title_info">政策资讯</string>
 
-    <!-- TODO: Remove or change this placeholder text -->
-    <string name="hello_blank_fragment">Hello blank fragment</string>
+    <!-- 隐私弹窗 -->
+    <string name="tv_title_privacy_dialog">用户隐私和隐私政策</string>
+    <string name="tv_privacy_confirm">同意</string>
+    <string name="tv_privacy_not_confirm">不同意</string>
 
     <!-- 首页-->
     <string name="tv_query_case">办件查询</string>