Search in sources :

Example 1 with HtmlView

use of me.yluo.ruisiapp.widget.htmlview.HtmlView in project Ruisi by freedom10086.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
    }
    TextView version = findViewById(R.id.version);
    TextView serverVersion = findViewById(R.id.server_version);
    findViewById(R.id.btn_back).setOnClickListener(view -> finish());
    String ss = "<b>西电睿思手机客户端</b><br />功能不断完善中,bug较多还请多多反馈......<br />" + "bug反馈:<br />" + "1.到 <a href=\"forum.php?mod=viewthread&tid=" + App.POST_TID + "&mobile=2\">本帖</a> 回复<br />" + "2.本站 <a href=\"home.php?mod=space&uid=252553&do=profile&mobile=2\">@谁用了FREEDOM</a><br />" + "3.本站 <a href=\"home.php?mod=space&uid=261098&do=profile&mobile=2\">@wangfuyang</a><br />" + "4.本站 <a href=\"home.php?mod=space&uid=260255&do=profile&mobile=2\">@金鲨鱼</a><br />" + "5.github提交 <a href=\"https://github.com/freedom10086/Ruisi/issues\">点击这儿<br /></a><br />";
    TextView htmlView = findViewById(R.id.html_text);
    HtmlView.parseHtml(ss).into(htmlView);
    PackageInfo info = null;
    PackageManager manager = getPackageManager();
    try {
        info = manager.getPackageInfo(getPackageName(), 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    int versionCode = 0;
    if (info != null) {
        String version_name = info.versionName;
        versionCode = info.versionCode;
        String a = "当前版本:" + version_name;
        version.setText(a);
    }
    findViewById(R.id.fab).setOnClickListener(v -> Snackbar.make(v, "你要提交bug或者建议吗?", Snackbar.LENGTH_LONG).setAction("确定", view -> {
        String user = App.getName(AboutActivity.this);
        if (user != null) {
            user = "by:" + user;
        }
        IntentUtils.sendMail(getApplicationContext(), user);
    }).show());
    int finalVersionCode = versionCode;
    // 检查更新实现 读取我发帖的标题比较版本号
    // 我会把版本号写在标题上[code:xxx]
    HttpUtil.get(App.CHECK_UPDATE_URL, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            int ih = res.indexOf("keywords");
            int h_start = res.indexOf('\"', ih + 15);
            int h_end = res.indexOf('\"', h_start + 1);
            String title = res.substring(h_start + 1, h_end);
            if (title.contains("code")) {
                SharedPreferences.Editor editor = getSharedPreferences(App.MY_SHP_NAME, MODE_PRIVATE).edit();
                editor.putLong(App.CHECK_UPDATE_KEY, System.currentTimeMillis());
                editor.apply();
                int st = title.indexOf("code");
                int code = GetId.getNumber(title.substring(st));
                if (code > finalVersionCode) {
                    serverVersion.setText("检测到新版本点击查看");
                    serverVersion.setOnClickListener(view -> PostActivity.open(AboutActivity.this, App.CHECK_UPDATE_URL, "谁用了FREEDOM"));
                    return;
                }
            }
            serverVersion.setText("当前已是最新版本");
        }

        @Override
        public void onFailure(Throwable e) {
            super.onFailure(e);
            serverVersion.setText("检测新版本失败...");
        }
    });
}
Also used : Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) IntentUtils(me.yluo.ruisiapp.utils.IntentUtils) ContextCompat(android.support.v4.content.ContextCompat) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) GetId(me.yluo.ruisiapp.utils.GetId) PackageInfo(android.content.pm.PackageInfo) R(me.yluo.ruisiapp.R) TextView(android.widget.TextView) SharedPreferences(android.content.SharedPreferences) View(android.view.View) Build(android.os.Build) Snackbar(android.support.design.widget.Snackbar) HttpUtil(me.yluo.ruisiapp.myhttp.HttpUtil) App(me.yluo.ruisiapp.App) HtmlView(me.yluo.ruisiapp.widget.htmlview.HtmlView) PackageManager(android.content.pm.PackageManager) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) PackageInfo(android.content.pm.PackageInfo) TextView(android.widget.TextView)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Snackbar (android.support.design.widget.Snackbar)1 ContextCompat (android.support.v4.content.ContextCompat)1 View (android.view.View)1 TextView (android.widget.TextView)1 App (me.yluo.ruisiapp.App)1 R (me.yluo.ruisiapp.R)1 HttpUtil (me.yluo.ruisiapp.myhttp.HttpUtil)1 ResponseHandler (me.yluo.ruisiapp.myhttp.ResponseHandler)1 GetId (me.yluo.ruisiapp.utils.GetId)1 IntentUtils (me.yluo.ruisiapp.utils.IntentUtils)1 HtmlView (me.yluo.ruisiapp.widget.htmlview.HtmlView)1