From 92beb983161805c7cfbb39321e4c791306fc3520 Mon Sep 17 00:00:00 2001
From: 陶汉栋 <2821744554@qq.com>
Date: Tue, 27 Mar 2018 10:59:29 +0800
Subject: [PATCH] no message

---
 app/src/main/java/com/shunzhi/parent/AppConfig.java                                                 |   2 ++
 app/src/main/java/com/shunzhi/parent/api/IsUpdate.java                                              |  17 +++++++++++++++++
 app/src/main/java/com/shunzhi/parent/bean/Version.java                                              |  14 ++++++++++++++
 app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java                                     | 375 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java                                  |  12 ++++++++++--
 app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java |   5 ++---
 app/src/main/java/com/shunzhi/parent/util/CloseUtils.java                                           |  33 +++++++++++++++++++++++++++++++++
 app/src/main/java/com/shunzhi/parent/util/SystemHelper.java                                         | 420 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/src/main/java/com/shunzhi/parent/util/Utils.java                                                |   9 +++++++++
 app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java                                     |  94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/src/main/res/drawable-xhdpi/update.png                                                          | Bin 0 -> 6706 bytes
 app/src/main/res/layout/fragment_mine.xml                                                           |  32 ++++++++++++++++++++++++++++++++
 app/src/main/res/layout/fragment_start.xml                                                          |   1 +
 app/src/main/res/layout/myversiondialog.xml                                                         | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/src/main/res/layout/progress_dialog.xml                                                         |  28 ++++++++++++++++++++++++++++
 app/src/main/res/values/styles.xml                                                                  |  18 ++++++++++++++++++
 16 files changed, 1235 insertions(+), 5 deletions(-)
 create mode 100644 app/src/main/java/com/shunzhi/parent/api/IsUpdate.java
 create mode 100644 app/src/main/java/com/shunzhi/parent/bean/Version.java
 create mode 100644 app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java
 create mode 100644 app/src/main/java/com/shunzhi/parent/util/CloseUtils.java
 create mode 100644 app/src/main/java/com/shunzhi/parent/util/SystemHelper.java
 create mode 100644 app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java
 create mode 100644 app/src/main/res/drawable-xhdpi/update.png
 create mode 100644 app/src/main/res/layout/myversiondialog.xml
 create mode 100644 app/src/main/res/layout/progress_dialog.xml

diff --git a/app/src/main/java/com/shunzhi/parent/AppConfig.java b/app/src/main/java/com/shunzhi/parent/AppConfig.java
index 335dc84..0a51b78 100644
--- a/app/src/main/java/com/shunzhi/parent/AppConfig.java
+++ b/app/src/main/java/com/shunzhi/parent/AppConfig.java
@@ -47,6 +47,7 @@ public class AppConfig {
     public static String BASE_URL="http://campus.myjxt.com/";
     public static String BASE_URL_ORDER="http://parent.myjxt.com/";
     public static String BASE_URL_FILE="http://manage.myjxt.com";
+    public static final String url_version = BASE_URL + "api/Common/AppVersion?appType=3";
 
 
     //默认日志保存的路径
@@ -61,6 +62,7 @@ public class AppConfig {
 
     private static AppConfig appConfig = null;
     private static Context mContext = null;
+    public static String url_apk="http://update.myjxt.com/zh_parent.apk";
 
     public static AppConfig getAppConfig(Context context) {
         if (appConfig == null) {
diff --git a/app/src/main/java/com/shunzhi/parent/api/IsUpdate.java b/app/src/main/java/com/shunzhi/parent/api/IsUpdate.java
new file mode 100644
index 0000000..7229c3b
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/api/IsUpdate.java
@@ -0,0 +1,17 @@
+package com.shunzhi.parent.api;
+
+import com.google.gson.JsonObject;
+
+import io.reactivex.Observable;
+import retrofit2.http.GET;
+
+/**
+ * Created by ToaHanDong on 2018/3/26.
+ */
+
+public interface IsUpdate {
+
+    @GET("api/Common/AppVersion?appType=4")
+    Observable<JsonObject> isUpdateVersion();
+
+}
diff --git a/app/src/main/java/com/shunzhi/parent/bean/Version.java b/app/src/main/java/com/shunzhi/parent/bean/Version.java
new file mode 100644
index 0000000..b3daab4
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/bean/Version.java
@@ -0,0 +1,14 @@
+package com.shunzhi.parent.bean;
+
+import java.io.Serializable;
+
+/**
+ * Created by xf on 2015/9/23.
+ */
+public class Version implements Serializable {
+    public String verNo;
+    public String content;
+    public String inTime;
+
+}
+
diff --git a/app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java b/app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java
new file mode 100644
index 0000000..ea715b1
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/manager/UpdateManager.java
@@ -0,0 +1,375 @@
+package com.shunzhi.parent.manager;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.app.AlertDialog;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.share.mvpsdk.RxManager;
+import com.share.mvpsdk.helper.RetrofitCreateHelper;
+import com.share.mvpsdk.helper.RxHelper;
+import com.share.mvpsdk.utils.ToastUtils;
+import com.shunzhi.parent.AppConfig;
+import com.shunzhi.parent.R;
+import com.shunzhi.parent.api.IsUpdate;
+import com.shunzhi.parent.bean.Version;
+import com.shunzhi.parent.util.CloseUtils;
+import com.shunzhi.parent.util.SystemHelper;
+import com.shunzhi.parent.util.Utils;
+import com.shunzhi.parent.views.MyVersionDialog;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+
+import io.reactivex.functions.Consumer;
+import timber.log.Timber;
+
+public class UpdateManager {
+
+    AlertDialog dialogShowCheckingDialog;
+    /**
+     * 是否正在检查更新
+     */
+    public boolean ischeckingForUpdate = false;
+    /* 下载中 */
+    private static final int DOWNLOAD = 1;
+    /* 下载结束 */
+    private static final int DOWNLOAD_FINISH = 2;
+    /**
+     * 是否人为打断检查更新状态
+     */
+    private boolean isChechingInterrupted = false;
+    /**
+     * 结束正在获取更新
+     */
+    /* 保存解析的XML信息 */
+    static HashMap<String, String> mHashMap;
+    /* 下载保存路径 */
+    private String mSavePath;
+    /* 记录进度条数量 */
+    private int progress;
+    /* 是否取消更新 */
+    private static boolean cancelUpdate = false;
+
+    private static Context mContext;
+    /* 更新进度条 */
+    private ProgressBar mProgress;
+    private TextView mProgressText;
+    private Dialog mDownloadDialog;
+    double serviceCode = 1;
+    int versionCode = 1;
+
+    //mHandler
+//region
+    private Handler mHandler = new Handler() {
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                // 正在下载
+                case DOWNLOAD:
+                    // 设置进度条位置
+                    mProgress.setProgress(progress);
+                    mProgressText.setText(progress + "%");
+                    break;
+                case DOWNLOAD_FINISH:
+                    mDownloadDialog.dismiss();
+                    File apkfile = new File(mSavePath, mHashMap.get("name"));
+                    SystemHelper.installAPK(mContext, apkfile.toString());
+                    break;
+                default:
+                    break;
+            }
+        }
+    };
+
+    //endregion
+    private UpdateManager() {
+        mHashMap = new HashMap<String, String>();
+        mHashMap.put("url", AppConfig.url_apk);
+        mHashMap.put("name", "XSTApp.apk");
+
+    }
+
+    public UpdateManager(Context context) {
+        this.mContext = null;
+        this.mContext = context;
+        //获取更新版本和url
+        mHashMap = new HashMap<String, String>();
+        mHashMap.put("url", AppConfig.url_apk);
+        mHashMap.put("name", "XSTApp.apk");
+
+    }
+
+    /**
+     * 检查软件是否有更新版本
+     *
+     * @return
+     */
+    String date = "";
+
+    /**
+     * @param shouldInterruptDialogShow 是否显示打断检查更新的对话框
+     */
+    RxManager rxManager=new RxManager();
+    public void isUpdate(final boolean shouldInterruptDialogShow) {
+        date = new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date());
+        // 获取当前软件版本
+        if (!ischeckingForUpdate) {
+            isChechingInterrupted = false;
+            if (shouldInterruptDialogShow) showCheckingDialog(mContext);
+            ischeckingForUpdate = true;
+            versionCode = SystemHelper.getAppVersionCode(mContext);
+            rxManager.register( RetrofitCreateHelper.getInstance().createApi(IsUpdate.class,AppConfig.BASE_URL)
+                    .isUpdateVersion().compose(RxHelper.<JsonObject>rxSchedulerHelper()).subscribe(new Consumer<JsonObject>() {
+                        @Override
+                        public void accept(JsonObject jsonObject) throws Exception {
+                            try {
+                                Gson gson=new Gson();
+                                Version version=gson.fromJson(jsonObject.get("data").getAsJsonObject().toString(),Version.class);
+                                serviceCode = Double.parseDouble(version.verNo);
+                                double currentVersion = serviceCode / 100;
+                                Timber.d("66666%s","currentVersion="+currentVersion+"serviceCode="+serviceCode+"versionCode="+versionCode);
+                                if ((serviceCode > versionCode) && ischeckingForUpdate && !isChechingInterrupted) {
+                                    showNoticeDialog(currentVersion, version.content, isChechingInterrupted);
+                                } else if (!(serviceCode > versionCode) && shouldInterruptDialogShow && !isChechingInterrupted) {
+                                    Toast.makeText(mContext, "已经是最新版本啦!", Toast.LENGTH_SHORT).show();
+                                    mContext = null;
+                                }
+
+                            }catch (Exception e){
+                                e.printStackTrace();
+                            }finally {
+                                ischeckingForUpdate = false;
+                            }
+                        }
+                    }, new Consumer<Throwable>() {
+                        @Override
+                        public void accept(Throwable throwable) throws Exception {
+                            ToastUtils.showToast("更新失败:"+throwable.toString());
+                        }
+                    }));
+
+//            Timber.d("sign:%s", Utils.getSignStr());
+            /*Ion.with(mContext)
+                    .load(Constants.url_version)
+                    .setHeader("sign", Utils.getSignStr())
+                    .setTimeout(5000)
+                    .asJsonObject()
+                    .setCallback(new FutureCallback<JsonObject>() {
+                        @Override
+                        public void onCompleted(Exception e, JsonObject result) {
+                            try {
+                                Timber.i("exception : %s",e);
+                                Timber.i("result : %s", result);
+                                if (dialogShowCheckingDialog != null)
+                                    dialogShowCheckingDialog.dismiss();
+                                Gson gson = new Gson();
+                                String s = gson.toJson(result.getAsJsonObject("data"));
+                                Version serverVersion = gson.fromJson(s, new TypeToken<Version>() {
+                                }.getType());
+                                serviceCode = Double.parseDouble(serverVersion.verNo);
+                                double currentVersion = serviceCode / 100;
+                                if ((serviceCode > versionCode) && ischeckingForUpdate && !isChechingInterrupted) {
+                                    showNoticeDialog(currentVersion, serverVersion.content, isChechingInterrupted);
+                                } else if (!(serviceCode > versionCode) && shouldInterruptDialogShow && !isChechingInterrupted) {
+                                    Toast.makeText(mContext, "已经是最新版本啦!", Toast.LENGTH_SHORT).show();
+                                    mContext = null;
+                                }
+                            } catch (Exception ee) {
+                                ee.printStackTrace();
+                                if (shouldInterruptDialogShow)
+                                    Toast.makeText(mContext, "版本检测失败", Toast.LENGTH_LONG).show();
+                                mContext = null;
+                            } finally {
+                                ischeckingForUpdate = false;
+                            }
+                        }
+                    });*/
+        }
+    }
+
+
+    public UpdateManager setContext(Context ctx) {
+        mContext = ctx;
+        return this;
+    }
+
+    public static UpdateManager getInstance() {
+
+        return SingletonHolder.sInstance;
+    }
+
+    private static class SingletonHolder {
+        private static final UpdateManager sInstance = new UpdateManager();
+    }
+
+    /**
+     * 显示软件更新对话框
+     */
+    public void showNoticeDialog(double serviceCode, String content, Boolean isInterrupted) {
+        final MyVersionDialog dialog = new MyVersionDialog(mContext, "V" + serviceCode, "10.1M",
+                    content, R.style.dialog, new MyVersionDialog.OnCustomDialogListener() {
+            @Override
+            public void clickSure() {
+                showDownloadDialog();
+            }
+
+            @Override
+            public void clickCancel() {
+                mContext = null;
+            }
+        });
+        dialog.setCanceledOnTouchOutside(false);
+        if (!dialog.isShowing())
+            dialog.show();
+        ischeckingForUpdate = false;
+    }
+
+    private void showCheckingDialog(Context ctx) {
+        dialogShowCheckingDialog = Utils.styleDialogBuilder(ctx)
+                .setMessage("正在检查更新...")
+                .setTitle("提示")
+                .setNegativeButton("取消", new OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        isChechingInterrupted = true;
+                        mContext = null;
+                        dialog.dismiss();
+                    }
+                }).create();
+        dialogShowCheckingDialog.setCanceledOnTouchOutside(false);
+        if (!dialogShowCheckingDialog.isShowing()) {
+            dialogShowCheckingDialog.show();
+        }
+    }
+
+    /**
+     * 显示软件下载对话框
+     */
+    private void showDownloadDialog() {
+        // 构造软件下载对话框
+        AlertDialog.Builder builder = Utils.styleDialogBuilder(mContext);
+        builder.setTitle("更新中");
+        // 给下载对话框增加进度条
+        final LayoutInflater inflater = LayoutInflater.from(mContext);
+        View v = inflater.inflate(R.layout.progress_dialog, null);
+        mProgress = (ProgressBar) v.findViewById(R.id.pbar);
+        mProgressText = (TextView) v.findViewById(R.id.txt_wait);
+        builder.setView(v);
+        // 取消更新
+        builder.setNegativeButton("取消", new OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                dialog.dismiss();
+                // 设置取消状态
+                File APKfile = new File(mSavePath);
+                //FileUtil.deleteFile(APKfile, APKfile + "/" + mHashMap.get("name"));
+                cancelUpdate = true;
+            }
+        });
+        mDownloadDialog = builder.create();
+        mDownloadDialog.setCanceledOnTouchOutside(false);
+        mDownloadDialog.show();
+        // 现在文件
+        downloadApk();
+    }
+
+    /**
+     * 下载apk文件
+     */
+    private void downloadApk() {
+        // 启动新线程下载软件
+        cancelUpdate = false;
+        downloadApkThread downloadThread = new downloadApkThread();
+        downloadThread.start();
+    }
+
+    /**
+     * 下载文件线程
+     *
+     * @author coolszy
+     * @date 2012-4-26
+     * @blog http://blog.92coding.com
+     */
+    private class downloadApkThread extends Thread {
+        HttpURLConnection conn = null;
+        InputStream is = null;
+        FileOutputStream fos = null;
+
+        @Override
+        public void run() {
+            //cancelUpdate = false;
+            try {
+                // 判断SD卡是否存在,并且是否具有读写权限
+                if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+                    // 获得存储卡的路径
+                    String sdpath = Environment.getExternalStorageDirectory() + "/";
+                    mSavePath = sdpath + "download";
+                    URL url = new URL(mHashMap.get("url"));
+                    // 创建连接
+                    conn = (HttpURLConnection) url.openConnection();
+                    conn.connect();
+                    // 获取文件大小
+                    int length = conn.getContentLength();//服务端要设置 content length属性
+                    // 创建输入流
+                    is = conn.getInputStream();
+
+                    File file = new File(mSavePath);
+                    // 判断文件目录是否存在
+                    if (!file.exists()) {
+                        if (!file.mkdir()) file.mkdirs();//创建文件失败,则创建文件夹
+                    }
+                    File apkFile = new File(mSavePath, mHashMap.get("name"));
+                    fos = new FileOutputStream(apkFile);
+                    int count = 0;
+                    // 缓存
+                    byte buf[] = new byte[1024];
+                    // 写入到文件中
+                    while (!cancelUpdate) {
+                        int numread = is.read(buf);
+                        count += numread;
+                        progress = (int) (((float) count / length) * 100);// 计算进度条位置
+                        mHandler.sendEmptyMessage(DOWNLOAD);// 更新进度
+                        if (numread <= 0) {
+                            // 下载完成
+                            mHandler.sendEmptyMessage(DOWNLOAD_FINISH);
+                            break;
+                        }
+                        // 写入文件
+                        fos.write(buf, 0, numread);
+                    } // 点击取消就停止下载.
+
+                }
+            } catch (MalformedURLException e) {
+                Timber.d(e + "");
+                e.printStackTrace();
+            } catch (IOException e) {
+                Timber.d(e + "");
+                e.printStackTrace();
+            } finally {
+                conn.disconnect();
+                CloseUtils.closeQuietly(fos, is);
+            }
+            // 取消下载对话框显示
+            Thread.currentThread().interrupt();
+            rxManager.unSubscribe();
+        }
+    }
+}
diff --git a/app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java b/app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
index 7b183be..1b763f6 100644
--- a/app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
+++ b/app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
@@ -24,6 +24,7 @@ import com.shunzhi.parent.bean.message.PHMessageSession;
 import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract;
 import com.shunzhi.parent.contract.mine.MineContract;
 import com.shunzhi.parent.manager.MessageManager;
+import com.shunzhi.parent.manager.UpdateManager;
 import com.shunzhi.parent.presenter.mine.MinePresenter;
 import com.shunzhi.parent.ui.activity.LoginAndRegistActivity;
 import com.shunzhi.parent.ui.activity.MyChildActivity;
@@ -36,8 +37,9 @@ import com.shunzhi.parent.ui.activity.orderdetail.OrderDetailActivity;
 public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel>
         implements MineContract.IMineView, View.OnClickListener {
 
-    LinearLayout childlayout, personinfo, layout_orderDetail, layout_order, layout_cache, layout_about, layout_feedback, top_layout, layout_afterLogin
-            ,layout_message;
+    LinearLayout childlayout, personinfo, layout_orderDetail, layout_order, layout_cache,
+            layout_about, layout_feedback, top_layout, layout_afterLogin
+            ,layout_message,layout_update;
 
     RoundedImageView user_photo;
     TextView user_name, user_mobile, tvExit, binding_state,tvMessageCount;
@@ -66,6 +68,9 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract
         layout_feedback = view.findViewById(R.id.layout_feedback);
         tvMessageCount=view.findViewById(R.id.tvMessageCount);
         layout_message=view.findViewById(R.id.layout_message);
+        layout_update=view.findViewById(R.id.layout_update);
+
+        layout_update.setOnClickListener(this);
         layout_message.setOnClickListener(this);
         layout_about.setOnClickListener(this);
         layout_feedback.setOnClickListener(this);
@@ -164,6 +169,9 @@ startNewActivity(MesageActivity.class);
                 WebViewActivity.getInstance(getActivity(), AppConfig.BASE_URL_ORDER + "FeedBack.aspx?userid=" + AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_ID), -1);
 
                 break;
+            case R.id.layout_update:
+                UpdateManager.getInstance().setContext(getContext()).isUpdate(true);
+                break;
             default:
                 break;
         }
diff --git a/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java b/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
index 99b5684..30d018e 100644
--- a/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
+++ b/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
@@ -146,8 +146,8 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist
             getActivity().finish();
         } else if (type == 1) {
             PopupWindow popupWindow = new PopupWindow();
-            popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
-            popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
+            popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
+            popupWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
             backgroundAlpha(0.5f);
             View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_view, null);
             TextView dialogInfo = view.findViewById(R.id.dialog_info);
@@ -294,7 +294,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist
         }
     };
 
-
     public void backgroundAlpha(float bgAlpha) {
         WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
         lp.alpha = bgAlpha; //0.0-1.0
diff --git a/app/src/main/java/com/shunzhi/parent/util/CloseUtils.java b/app/src/main/java/com/shunzhi/parent/util/CloseUtils.java
new file mode 100644
index 0000000..18f446c
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/util/CloseUtils.java
@@ -0,0 +1,33 @@
+package com.shunzhi.parent.util;
+
+import android.support.annotation.Nullable;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Created by zdf on 2016/1/20.
+ */
+public class CloseUtils {
+    private CloseUtils() {
+    }
+
+    /**
+     *
+     * @param closeable 所有实现Closeable接口的类的实例(常用有输入、输出流、Cursor等)
+     * @return 关闭成功
+     */
+    public static boolean closeQuietly(@Nullable Closeable... closeable) {
+        if (closeable != null && closeable.length > 0) {
+            try {
+                for (Closeable c : closeable) {
+                    if (c != null) c.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/app/src/main/java/com/shunzhi/parent/util/SystemHelper.java b/app/src/main/java/com/shunzhi/parent/util/SystemHelper.java
new file mode 100644
index 0000000..6a9d95f
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/util/SystemHelper.java
@@ -0,0 +1,420 @@
+/**
+ * ClassName: MyApp.java
+ * created on 2013-1-24
+ * Copyrights 2013-1-24 hjgang All rights reserved.
+ * site: http://t.qq.com/hjgang2012
+ * email: hjgang@yahoo.cn
+ */
+package com.shunzhi.parent.util;
+
+import android.Manifest;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.Intent.ShortcutIconResource;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.State;
+import android.net.Uri;
+import android.os.Build;
+import android.support.v4.app.ActivityCompat;
+import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
+import android.view.Window;
+import android.view.WindowManager;
+
+import com.shunzhi.parent.R;
+
+import java.io.File;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import timber.log.Timber;
+
+
+/**
+ * 获取系统信息的工具类
+ * @author hjgang
+ */
+public class SystemHelper {
+    private SystemHelper() {
+    }
+
+    /**
+     * 创建本应用的桌面快捷方式<br/>
+     * 注意:需要添加权限&lt;uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/&gt;
+     * @param
+     */
+    public static void createShortcut(Context context, Class<?> clazz) {
+        Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
+
+        //快捷方式的名称
+        shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getString(R.string.app_name));
+        shortcut.putExtra("duplicate", false); //不允许重复创建
+
+        Intent localIntent2 = new Intent(context, clazz);
+        localIntent2.setAction(Intent.ACTION_MAIN);
+        localIntent2.addCategory(Intent.CATEGORY_LAUNCHER);
+
+        shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, localIntent2);//指定快捷方式要启动的Activity类型
+
+        //快捷方式的图标
+        ShortcutIconResource iconResource = ShortcutIconResource.fromContext(context, R.drawable.logo);
+        shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
+
+        context.sendBroadcast(shortcut);
+    }
+
+    /**
+     * 字符串转换成date
+     * @param time
+     * @return
+     */
+    public static Date getDateTime1(String time) {
+        Date newtime = null;
+        SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        try {
+            if (time != null && !time.equals("0")) {
+                newtime = sdfDateFormat.parse(time);
+            }
+        } catch (Exception err) {
+
+        }
+        return newtime;
+    }
+
+    /**
+     * 将字符串转为  时间戳
+     * @param time
+     * @return
+     */
+    public static String getTimestamp(String time) {
+        Date newtime = null;
+        SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        try {
+            if (time != null && !time.equals("0")) {
+                newtime = sdfDateFormat.parse(time);
+            }
+        } catch (Exception err) {
+
+        }
+        return newtime.getTime() + "";
+    }
+
+    /**
+     * 将时间戳转为 字符串
+     * yyyy-MM-dd HH:mm
+     * */
+    public static String getTimeStr(String time) {
+
+        String newtime = null;
+        SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        if (time != null && !time.equals("0")) {
+            newtime = sdfDateFormat.format(new Timestamp(Long.parseLong(time)));
+        }
+        return newtime;
+    }
+
+    /**
+     * 将时间戳转为 字符串
+     * yyyy-MM-dd
+     * */
+    public static String getTimeStr3(String time) {
+        String newtime = null;
+        SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        if (time != null && !time.equals("0")) {
+            newtime = sdfDateFormat.format(new Date(Long.parseLong(time) * 1000));
+        }
+        return newtime;
+    }
+
+    // 将字符串转为时间戳
+    public static String getTime(String time) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日hh时mm分");
+        Date date = null;
+        if (time == null || "".equals(time) || "null".equals(time)) {
+            return "0";
+        }
+        if (time.contains("年")) {
+            int year = Integer.parseInt(time.substring(0, time.indexOf("年")));
+            if (year <= 1970) {
+                return "0";
+            }
+        }
+        try {
+            date = format.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return null;
+        }
+        return date.getTime() / 1000 + "";
+    }
+
+    // 将字符串转为时间戳
+    public static String getTime2(String time) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
+        Date date = null;
+        if (time == null || "".equals(time) || "null".equals(time)) {
+            return "0";
+        }
+        int year = Integer.parseInt(time.substring(0, time.indexOf("年")));
+        if (year <= 1970) {
+            return "0";
+        }
+        try {
+            date = format.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return date.getTime() / 1000 + "";
+    }
+
+    /**
+     * @author LuoB.
+     * @param oldTime 较小的时间
+     * @param newTime 较大的时间 (如果为空   默认当前时间 ,表示和当前时间相比)
+     * @return -1 :同一天.    0:昨天 .   1 :至少是前天.
+     * @throws ParseException 转换异常
+     */
+    public static int isYeaterday(Date oldTime, Date newTime) throws ParseException {
+        if (newTime == null) {
+            newTime = new Date();
+        }
+        //将下面的 理解成  yyyy-MM-dd 00:00:00 更好理解点
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String todayStr = format.format(newTime);
+        Date today = format.parse(todayStr);
+        //昨天 86400000=24*60*60*1000 一天
+        if ((today.getTime() - oldTime.getTime()) > 0 && (today.getTime() - oldTime.getTime()) <= 86400000) {
+            return 0;
+        } else if ((today.getTime() - oldTime.getTime()) <= 0) { //至少是今天
+            return -1;
+        } else { //至少是前天
+            return 1;
+        }
+    }
+
+    /**
+     * 检查是否已经创建了桌面快捷方式<br/>
+     * 注意:需要添加权限&lt;uses-permission android:name="com.android.launcher.permission.READ_SETTINGS"/&gt;
+     * @param context
+     * @return
+     */
+    public static boolean hasShortCut(Context context) {
+        String url = "";
+        if (Build.VERSION.SDK_INT < 8) {
+            url = "content://com.android.launcher.settings/favorites?notify=true";
+        } else {
+            url = "content://com.android.launcher2.settings/favorites?notify=true";
+        }
+        ContentResolver resolver = context.getContentResolver();
+        Cursor cursor = resolver.query(Uri.parse(url), null, "title=?",
+                new String[]{context.getString(R.string.app_name)}, null);
+
+        if (cursor != null && cursor.moveToFirst()) {
+            cursor.close();
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * 获取当前机器的屏幕信息对象<br/>
+     * 另外:通过android.os.Build类可以获取当前系统的相关信息
+     *
+     * @param context
+     * @return
+     */
+    public static DisplayMetrics getScreenInfo(Context context) {
+        WindowManager windowManager = (WindowManager) context
+                .getSystemService(Context.WINDOW_SERVICE);
+        DisplayMetrics dm = new DisplayMetrics();
+        windowManager.getDefaultDisplay().getMetrics(dm);
+        // dm.widthPixels;//寬度
+        // dm.heightPixels; //高度
+        // dm.density; //密度
+        return dm;
+    }
+
+    public static int dip2px(Context context, double dipValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (dipValue * scale + 0.5f);
+    }
+
+    public static int px2dip(Context context, double pxValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (pxValue / scale + 0.5f);
+    }
+
+    /**
+     * 获取手机号<br/>
+     * 注意:需要添加权限&lt;uses-permission
+     * android:name="android.permission.READ_PHONE_STATE"/&gt;。另外很多手机不能获取到当前手机号
+     *
+     * @param context
+     * @return
+     */
+    public static String getMobileNumber(Context context) {
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            // TODO: Consider calling
+            //    ActivityCompat#requestPermissions
+            // here to request the missing permissions, and then overriding
+            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+            //                                          int[] grantResults)
+            // to handle the case where the user grants the permission. See the documentation
+            // for ActivityCompat#requestPermissions for more details.
+        }
+        String deviceid = tm.getDeviceId();//获取智能设备唯一编号
+        String te1 = tm.getLine1Number();//获取本机号码
+        String imei = tm.getSimSerialNumber();//获得SIM卡的序号
+        String imsi = tm.getSubscriberId();//得到用户Id
+        return tm.getLine1Number();
+    }
+
+    /**
+     * 检测当前的网络连接是否可用<br/>
+     * 注意:需要添加权限&lt;uses-permission
+     * android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
+     *
+     * @param context
+     * @return
+     */
+    public static boolean isConnected(Context context) {
+        boolean flag = false;
+        try {
+            ConnectivityManager connManager = (ConnectivityManager) context
+                    .getSystemService(Context.CONNECTIVITY_SERVICE);
+            if (null != connManager) {
+                NetworkInfo info = connManager.getActiveNetworkInfo();
+                if (null != info && info.isAvailable()) {
+                    flag = true;
+                }
+            }
+        } catch (Exception e) {
+            Timber.d(e + "");
+        }
+        return flag;
+    }
+
+    /**
+     * 检测当前网络连接的类型<br/>
+     * 注意:需要添加权限&lt;uses-permission
+     * android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
+     *
+     * @param context
+     * @return 返回0代表GPRS网络;返回1,代表WIFI网络;返回-1代表网络不可用
+     */
+    public static int getNetworkType(Context context) {
+        int code = -1;
+        try {
+            ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+            if (null != connManager) {
+                State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
+                if (State.CONNECTED == state) {
+                    code = ConnectivityManager.TYPE_WIFI;
+                } else {
+                    state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
+                    if (State.CONNECTED == state) {
+                        code = ConnectivityManager.TYPE_MOBILE;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            Timber.d(e + "");
+        }
+        return code;
+    }
+
+    /**
+     * 返回当前程序版本代码,如:1
+     * @param context
+     * @return 当前程序版本代码
+     */
+    public static int getAppVersionCode(Context context) {
+        int versionCode = -1;
+        try {
+            PackageManager pm = context.getApplicationContext().getPackageManager();
+            PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
+            versionCode = pi.versionCode;
+
+        } catch (Exception e) {
+            Timber.d("66666%s" ,e.toString()+ "");
+        }
+        return versionCode;
+    }
+
+    /**
+     * 返回当前程序版本名,如:1.0.1
+     *
+     * @param context
+     * @return 当前程序版本名
+     */
+    public static String getAppVersionName(Context context) {
+        String versionName = "";
+        try {
+            PackageManager pm = context.getPackageManager();
+            PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
+            versionName = pi.versionName;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return versionName;
+    }
+
+    /**
+     * 安装指定的APK文件,主要用于本应用程序的更新
+     *
+     * @param context
+     * @param apk
+     *            apk文件的全路径名
+     */
+    public static void installAPK(Context context, String apk) {
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.setDataAndType(Uri.fromFile(new File(apk)), "application/vnd.android.package-archive");
+        context.startActivity(intent);
+        android.os.Process.killProcess(android.os.Process.myPid());
+    }
+
+    public static void remoteAPK(Context context) {
+        Uri packageURI = Uri.parse("package:net.shunzhi");
+        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
+        context.startActivity(uninstallIntent);
+    }
+
+//    public static void setSystemBar(Context context, boolean on, int color) {
+//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+//            SystemHelper.setTranslucentStatus(context, on);
+//            SystemBarTintManager mTintManager = new SystemBarTintManager((Activity) context);
+//            mTintManager.setStatusBarTintEnabled(true);
+//            //mTintManager.setNavigationBarTintEnabled(true);
+//            mTintManager.setStatusBarTintResource(color);
+//
+//            //SystemBarTintManager.SystemBarConfig config = mTintManager.getConfig();
+//            //listViewDrawer.setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom());
+//        }
+//    }
+
+    @TargetApi(19)
+    public static void setTranslucentStatus(Context context, boolean on) {
+        Window win = ((Activity) context).getWindow();
+        WindowManager.LayoutParams winParams = win.getAttributes();
+        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
+        if (on) {
+            winParams.flags |= bits;
+        } else {
+            winParams.flags &= ~bits;
+        }
+        win.setAttributes(winParams);
+    }
+}
diff --git a/app/src/main/java/com/shunzhi/parent/util/Utils.java b/app/src/main/java/com/shunzhi/parent/util/Utils.java
index 0825343..c185280 100644
--- a/app/src/main/java/com/shunzhi/parent/util/Utils.java
+++ b/app/src/main/java/com/shunzhi/parent/util/Utils.java
@@ -1,5 +1,10 @@
 package com.shunzhi.parent.util;
 
+import android.content.Context;
+import android.support.v7.app.AlertDialog;
+
+import com.shunzhi.parent.R;
+
 public class Utils {
     private Utils() {}
 
@@ -33,4 +38,8 @@ public class Utils {
         return "";
     }
 
+    public static AlertDialog.Builder styleDialogBuilder(Context context) {
+        return new AlertDialog.Builder(context, R.style.AlertDialogCustom);
+    }
+
 }
diff --git a/app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java b/app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java
new file mode 100644
index 0000000..88fc675
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/views/MyVersionDialog.java
@@ -0,0 +1,94 @@
+package com.shunzhi.parent.views;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.shunzhi.parent.R;
+
+
+/**
+ * 自定义dialog
+ * @author Mr.Xu
+ *
+ */
+public class MyVersionDialog extends Dialog {
+    //定义回调事件,用于dialog的点击事件
+    public interface OnCustomDialogListener{
+        public void clickSure();
+        public void clickCancel();
+    }
+
+    private OnCustomDialogListener customDialogListener;
+    String version = "",size="",content ="";
+    public MyVersionDialog(Context context, String pVerion, String pSize, String pContent, int style, OnCustomDialogListener customDialogListener) {
+        super(context, style);
+        this.customDialogListener = customDialogListener;
+        version = pVerion;
+        size = pSize;
+        content = pContent;
+        Window window = getWindow();
+        WindowManager.LayoutParams params = window.getAttributes();
+        //set width,height by density and gravity
+        float density = getDensity(context);
+        params.width = (int) (300*density);
+        params.height = (int) (90*density);
+        params.gravity = Gravity.CENTER;
+
+
+        //WindowManager.LayoutParams p = getWindow().getAttributes();  //获取对话框当前的参数值
+        //Display d = window.getDefaultDisplay();  //为获取屏幕宽、高
+        //p.height = (int) (d.getHeight() * 0.6);   //高度设置为屏幕的0.6
+        //p.width = (int) (d.getWidth() * 0.95);    //宽度设置为屏幕的0.95
+
+        window.setAttributes(params);
+
+    }
+    private float getDensity(Context context) {
+        Resources resources = context.getResources();
+        DisplayMetrics dm = resources.getDisplayMetrics();
+        return dm.density;
+    }
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.myversiondialog);
+        Button clickBtn = (Button) findViewById(R.id.btnSure);
+        clickBtn.setOnClickListener(clickListener);
+        Button clearBtn = (Button) findViewById(R.id.btnCancel);
+        clearBtn.setOnClickListener(clearListener);
+
+        TextView txtVersionNum = (TextView) findViewById(R.id.txtVersionNum);
+        txtVersionNum.setText(version);
+
+        TextView txtSizeNum = (TextView) findViewById(R.id.txtSizeNum);
+        txtSizeNum.setText(size);
+
+        TextView txtContent = (TextView) findViewById(R.id.txtContent);
+        txtContent.setText(content);
+        txtContent.setMovementMethod(ScrollingMovementMethod.getInstance()) ;
+    }
+
+    private View.OnClickListener clickListener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            customDialogListener.clickSure();
+            MyVersionDialog.this.dismiss();
+        }
+    };
+    private View.OnClickListener clearListener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            customDialogListener.clickCancel();
+            MyVersionDialog.this.dismiss();
+        }
+    };
+}
diff --git a/app/src/main/res/drawable-xhdpi/update.png b/app/src/main/res/drawable-xhdpi/update.png
new file mode 100644
index 0000000..650b056
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/update.png differ
diff --git a/app/src/main/res/layout/fragment_mine.xml b/app/src/main/res/layout/fragment_mine.xml
index 1489e9e..fcebbe9 100644
--- a/app/src/main/res/layout/fragment_mine.xml
+++ b/app/src/main/res/layout/fragment_mine.xml
@@ -272,6 +272,38 @@
                     android:background="@color/bottomline" />
 
                 <LinearLayout
+                    android:id="@+id/layout_update"
+                    android:layout_width="match_parent"
+                    android:layout_height="?android:actionBarSize"
+                    android:gravity="center_vertical"
+
+                    >
+
+                    <TextView
+                        android:layout_width="25dp"
+                        android:layout_height="25dp"
+                        android:layout_marginLeft="15dp"
+                        android:layout_marginRight="30dp"
+                        android:background="@drawable/update" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_gravity="center_vertical"
+                        android:layout_weight="1"
+                        android:text="版本更新"
+                        android:textSize="@dimen/txtsize_title" />
+
+                </LinearLayout>
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="0.5dp"
+                    android:layout_marginLeft="15dp"
+                    android:layout_marginRight="15dp"
+                    android:background="@color/bottomline" />
+
+                <LinearLayout
                     android:id="@+id/layout_cache"
                     android:layout_width="match_parent"
                     android:layout_height="?android:actionBarSize"
diff --git a/app/src/main/res/layout/fragment_start.xml b/app/src/main/res/layout/fragment_start.xml
index e0e5d30..735040c 100644
--- a/app/src/main/res/layout/fragment_start.xml
+++ b/app/src/main/res/layout/fragment_start.xml
@@ -14,6 +14,7 @@
 
     <cn.jzvd.JZVideoPlayerStandard
         android:id="@+id/jiecaoVideo"
+        android:visibility="gone"
         android:layout_width="match_parent"
         android:layout_height="match_parent"></cn.jzvd.JZVideoPlayerStandard>
 
diff --git a/app/src/main/res/layout/myversiondialog.xml b/app/src/main/res/layout/myversiondialog.xml
new file mode 100644
index 0000000..63818dc
--- /dev/null
+++ b/app/src/main/res/layout/myversiondialog.xml
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/layoutRoot"
+    android:layout_width="250dp"
+    android:layout_height="wrap_content"
+    android:background="@drawable/shape_radius8_whit"
+    android:orientation="vertical"
+    android:windowIsFloating="true">
+
+
+    <RelativeLayout
+        android:id="@+id/layoutTitle"
+        android:layout_width="fill_parent"
+        android:layout_height="50dp">
+
+        <TextView
+            android:id="@+id/txtTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:text="发现新版本"
+            android:textColor="@color/textColor"
+            android:textSize="@dimen/textSize18" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:layout_alignParentBottom="true"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentStart="false"
+            android:background="@color/textColor" />
+
+    </RelativeLayout>
+
+    <LinearLayout
+        android:id="@+id/layoutContent"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:padding="10dp">
+
+
+        <RelativeLayout
+            android:id="@+id/layoutVersion"
+            android:layout_width="match_parent"
+            android:layout_height="20dp">
+
+            <TextView
+                android:id="@+id/txtVersion"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentLeft="true"
+                android:layout_centerVertical="true"
+                android:text="新版本:"
+                android:textColor="@color/textColor"
+                android:textSize="@dimen/size_dp_14" />
+
+            <TextView
+                android:id="@+id/txtVersionNum"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toRightOf="@+id/txtVersion"
+                android:text="V1.1.1"
+                android:textColor="@color/textColor"
+                android:textSize="@dimen/size_dp_14" />
+        </RelativeLayout>
+
+        <RelativeLayout
+            android:visibility="gone"
+            android:id="@+id/layoutSize"
+            android:layout_width="match_parent"
+            android:layout_height="20dp">
+
+            <TextView
+                android:id="@+id/txtSize"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentLeft="true"
+                android:layout_centerVertical="true"
+                android:text="新版本大小:"
+                android:textColor="@color/textColor"
+                android:textSize="@dimen/size_dp_14" />
+
+            <TextView
+                android:id="@+id/txtSizeNum"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toRightOf="@+id/txtSize"
+                android:text="24.86M"
+                android:textColor="@color/textColor"
+                android:textSize="@dimen/size_dp_14" />
+        </RelativeLayout>
+
+        <TextView
+            android:id="@+id/txtUpdate"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/dlgTtile"
+            android:layout_centerHorizontal="true"
+            android:text="更新内容"
+            android:textColor="@color/textColor"
+            android:textSize="@dimen/size_dp_14" />
+
+        <TextView
+            android:id="@+id/txtContent"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/dlgTtile"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="5dp"
+            android:maxHeight="100dp"
+            android:maxLines="4"
+            android:scrollbars="vertical"
+            android:text="这是确定消息"
+            android:textColor="@color/textColor"
+            android:textSize="@dimen/size_dp_14" />
+
+    </LinearLayout>
+
+    <RelativeLayout
+        android:id="@+id/layoutBottom"
+        android:layout_width="fill_parent"
+        android:layout_height="35dp"
+        android:layout_marginBottom="10dp">
+
+        <Button
+            android:id="@+id/btnSure"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginRight="10dp"
+            android:layout_toLeftOf="@+id/line2"
+            android:layout_weight="1"
+            android:background="@color/xueqing_blue"
+            android:gravity="center"
+            android:paddingBottom="5dp"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
+            android:paddingTop="5dp"
+            android:text="立即更新"
+            android:textColor="@color/white"
+            android:textSize="@dimen/size_dp_14" />
+
+        <Button
+            android:id="@+id/btnCancel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="false"
+            android:layout_alignParentEnd="false"
+            android:layout_alignParentRight="false"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="10dp"
+            android:layout_toRightOf="@+id/line2"
+            android:layout_weight="1"
+            android:background="@color/textBlue"
+            android:gravity="center"
+            android:paddingBottom="5dp"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
+            android:paddingTop="5dp"
+            android:text="以后再说"
+            android:textColor="@color/white"
+            android:textSize="@dimen/size_dp_14" />
+
+        <View
+            android:id="@+id/line2"
+            android:layout_width="0dp"
+            android:layout_height="50dp"
+            android:layout_alignParentTop="true"
+            android:layout_centerHorizontal="true"
+            android:layout_centerVertical="true"
+            android:layout_weight="0"
+            android:background="@color/gray" />
+
+    </RelativeLayout>
+
+
+</LinearLayout>
diff --git a/app/src/main/res/layout/progress_dialog.xml b/app/src/main/res/layout/progress_dialog.xml
new file mode 100644
index 0000000..276523a
--- /dev/null
+++ b/app/src/main/res/layout/progress_dialog.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:layout_gravity="center"
+    android:gravity="center"
+    android:orientation="vertical">
+    <ProgressBar
+        android:id="@+id/pbar"
+        style="?android:attr/progressBarStyleHorizontal"
+        android:layout_width="300dp"
+        android:layout_height="wrap_content"
+        android:max="100"
+        android:progress="0" />
+
+    <TextView
+        android:id="@+id/txt_wait"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:layout_marginTop="8.0dip"
+        android:focusable="false"
+        android:singleLine="true"
+        android:text="加载中..."
+        android:textColor="@color/textColor"
+        android:textSize="12.0sp" />
+
+</LinearLayout>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index e08d0f9..43a4397 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -8,6 +8,24 @@
         <item name="colorAccent">@color/colorAccent</item>
     </style>
 
+    <style name="dialog" parent="Theme.AppCompat.Light.Dialog.Alert">
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:windowIsTranslucent">false</item>
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:background">@android:color/transparent</item>
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:backgroundDimEnabled">true</item>
+    </style>
+
+    <style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorAccent">@color/colorAccent</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+    </style>
 
     <style name="TextView_Wrap_16">
         <item name="android:layout_width">wrap_content</item>
--
libgit2 0.21.0