diff --git a/arch/build.gradle b/arch/build.gradle index 3b849f046..4fdc4fc2e 100644 --- a/arch/build.gradle +++ b/arch/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.library' group = 'com.qmuiteam' -version = "0.0.2" +version = "0.0.3" android { diff --git a/qmui/build.gradle b/qmui/build.gradle index 834a45161..05941bf8d 100644 --- a/qmui/build.gradle +++ b/qmui/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.library' group = 'com.qmuiteam' -version = "1.0.8" // QMUI 发布到 bintray 的版本号 +version = "1.1.0" // QMUI 发布到 bintray 的版本号 //noinspection GroovyMissingReturnStatement android { diff --git a/qmuidemo/build.gradle b/qmuidemo/build.gradle index 582f30110..828096e98 100644 --- a/qmuidemo/build.gradle +++ b/qmuidemo/build.gradle @@ -25,7 +25,7 @@ android { minSdkVersion parent.ext.minSdkVersion targetSdkVersion parent.ext.targetSdkVersion versionCode gitVersion - versionName "1.0.7" + versionName "1.1.0" } buildTypes { debug { diff --git a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/base/BaseFragment.java b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/base/BaseFragment.java index 53828eb38..de3ddf1f7 100644 --- a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/base/BaseFragment.java +++ b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/base/BaseFragment.java @@ -7,6 +7,7 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import com.qmuiteam.qmuidemo.R; import com.qmuiteam.qmuidemo.manager.QDPreferenceManager; +import com.qmuiteam.qmuidemo.manager.QDUpgradeManager; /** * Created by cgspine on 2018/1/7. @@ -35,18 +36,11 @@ private void checkAndShowUpgradeTip() { if (preferenceManager.isNeedShowUpgradeTip()) { preferenceManager.setNeedShowUpgradeTip(false); String title = String.format(getString(R.string.app_upgrade_tip_title), QMUIPackageHelper.getAppVersion(getContext())); - String message = "1. 分离出 arch 模块,用于 fragment 管理,支持手势返回\n" + - "2. 整理 QMUITopbar 的 theme,能够对 QMUITopbar 做更多的差异化处理\n" + - "3. 其它 bugfix: #125、#127、#132、#141"; + CharSequence message = QDUpgradeManager.getInstance(getContext()).getUpgradeWord(getActivity()); new QMUIDialog.MessageDialogBuilder(getContext()) .setTitle(title) .setMessage(message) - .addAction(R.string.ok, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog qmuiDialog, int i) { - qmuiDialog.dismiss(); - } - }) + .create(R.style.ReleaseDialogTheme) .show(); } } diff --git a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDPreferenceManager.java b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDPreferenceManager.java index 0021c4b1b..01d1cf5c8 100644 --- a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDPreferenceManager.java +++ b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDPreferenceManager.java @@ -10,20 +10,20 @@ public class QDPreferenceManager { private static SharedPreferences sPreferences; - private static QDPreferenceManager sQDPerferenceManager = null; + private static QDPreferenceManager sQDPreferenceManager = null; private static final String APP_VERSION_CODE = "app_version_code"; - private static final String APP_NNED_SHOW_UPGRADE_TIP = "app_has_show_upgrade_tip"; + private static final String APP_NEED_SHOW_UPGRADE_TIP = "app_has_show_upgrade_tip"; private QDPreferenceManager(Context context) { sPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); } public static final QDPreferenceManager getInstance(Context context) { - if (sQDPerferenceManager == null) { - sQDPerferenceManager = new QDPreferenceManager(context); + if (sQDPreferenceManager == null) { + sQDPreferenceManager = new QDPreferenceManager(context); } - return sQDPerferenceManager; + return sQDPreferenceManager; } public void setAppVersionCode(int code) { @@ -38,11 +38,11 @@ public int getVersionCode() { public void setNeedShowUpgradeTip(boolean needShowUpgradeTip) { final SharedPreferences.Editor editor = sPreferences.edit(); - editor.putBoolean(APP_NNED_SHOW_UPGRADE_TIP, needShowUpgradeTip); + editor.putBoolean(APP_NEED_SHOW_UPGRADE_TIP, needShowUpgradeTip); editor.apply(); } public boolean isNeedShowUpgradeTip() { - return sPreferences.getBoolean(APP_NNED_SHOW_UPGRADE_TIP, false); + return sPreferences.getBoolean(APP_NEED_SHOW_UPGRADE_TIP, false); } } diff --git a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDUpgradeManager.java b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDUpgradeManager.java index 04c19afcf..e90054b84 100644 --- a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDUpgradeManager.java +++ b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/manager/QDUpgradeManager.java @@ -1,6 +1,18 @@ package com.qmuiteam.qmuidemo.manager; +import android.app.Activity; import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.support.v4.content.ContextCompat; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.view.View; + +import com.qmuiteam.qmui.span.QMUIBlockSpaceSpan; +import com.qmuiteam.qmui.span.QMUITouchableSpan; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmuidemo.R; /** * Created by cgspine on 2018/1/14. @@ -9,43 +21,96 @@ public class QDUpgradeManager { public static final int INVALIDATE_VERSION_CODE = -1; - private static final int VERSION_1_0_7 = 107; - - private static final int sCurrentVersion = VERSION_1_0_7; + private static final int VERSION_1_1_0 = 110; + private static final int sCurrentVersion = VERSION_1_1_0; private static QDUpgradeManager sQDUpgradeManager = null; private Context mContext; - private QDUpgradeManager(Context context){ + private QDUpgradeManager(Context context) { mContext = context.getApplicationContext(); } - public static final QDUpgradeManager getInstance(Context context){ - if(sQDUpgradeManager == null){ + public static final QDUpgradeManager getInstance(Context context) { + if (sQDUpgradeManager == null) { sQDUpgradeManager = new QDUpgradeManager(context); } return sQDUpgradeManager; } - public void check(){ + public void check() { int oldVersion = QDPreferenceManager.getInstance(mContext).getVersionCode(); int currentVersion = sCurrentVersion; - if(currentVersion > oldVersion){ - if(oldVersion == INVALIDATE_VERSION_CODE){ + if (currentVersion > oldVersion) { + if (oldVersion == INVALIDATE_VERSION_CODE) { onNewInstall(currentVersion); - }else{ + } else { onUpgrade(oldVersion, currentVersion); } QDPreferenceManager.getInstance(mContext).setAppVersionCode(currentVersion); } } - private void onUpgrade(int oldVersion, int currentVersion){ + private void onUpgrade(int oldVersion, int currentVersion) { QDPreferenceManager.getInstance(mContext).setNeedShowUpgradeTip(true); } - private void onNewInstall(int currentVersion){ - // 并无法判断是 1.0.7 版本之前升级上来的,还是新装的 + private void onNewInstall(int currentVersion) { QDPreferenceManager.getInstance(mContext).setNeedShowUpgradeTip(true); } + + private void appendBlockSpace(Context context, SpannableStringBuilder builder) { + int start = builder.length(); + builder.append("[space]"); + QMUIBlockSpaceSpan blockSpaceSpan = new QMUIBlockSpaceSpan(QMUIDisplayHelper.dp2px(context, 6)); + builder.setSpan(blockSpaceSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + } + + public CharSequence getUpgradeWord(final Activity activity) { + switch (sCurrentVersion) { + case VERSION_1_1_0: + SpannableStringBuilder text = new SpannableStringBuilder(); + text.append("1. Added QMUILayout, making it easy to implement shadows, radii, and separators.\n"); + appendBlockSpace(activity, text); + text.append("2. Refactored the theme usage of QMUITopbar.\n"); + appendBlockSpace(activity, text); + text.append("3. Refactored QMUIDialog for more flexible configuration.\n"); + appendBlockSpace(activity, text); + text.append("4. Updated arch library to 0.0.3 to provide methods runAfterAnimation and startFragmentForResult.\n"); + appendBlockSpace(activity, text); + text.append("5. Bug fixes: "); + final String[] issues = new String[]{ + "125", "127", "132", "141", "177", "184", "198", "200", "209", "213" + }; + final String issueBaseUrl = "https://github.com/QMUI/QMUI_Android/issues/"; + int start, end; + for (int i = 0; i < issues.length; i++) { + if(i == issues.length - 1){ + text.append("and "); + } + final String issue = issues[i]; + start = text.length(); + text.append("#"); + text.append(issue); + end = text.length(); + int normalColor = ContextCompat.getColor(activity, R.color.app_color_blue); + int pressedColor = ContextCompat.getColor(activity, R.color.app_color_blue_pressed); + text.setSpan(new QMUITouchableSpan(normalColor, pressedColor, 0, 0) { + @Override + public void onSpanClick(View widget) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(issueBaseUrl + issue)); + activity.startActivity(intent); + } + }, start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + if (i < issues.length - 1) { + text.append(", "); + }else{ + text.append("."); + } + } + return text; + } + return "欢迎体验新版本!"; + } } diff --git a/qmuidemo/src/main/res/values/strings.xml b/qmuidemo/src/main/res/values/strings.xml index 07ce9bca2..dec56b47e 100644 --- a/qmuidemo/src/main/res/values/strings.xml +++ b/qmuidemo/src/main/res/values/strings.xml @@ -3,7 +3,7 @@ QMUI 示例图片 - 更新提示(%1$s) + Release Notes (%1$s) 确 定 取 消 diff --git a/qmuidemo/src/main/res/values/styles.xml b/qmuidemo/src/main/res/values/styles.xml index 3a11fdc29..901372b23 100644 --- a/qmuidemo/src/main/res/values/styles.xml +++ b/qmuidemo/src/main/res/values/styles.xml @@ -93,6 +93,12 @@ @style/DialogTheme2MenuItemStyle + + + +