mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-25 00:43:31 +08:00
release to 1.1.1
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
group = 'com.qmuiteam'
|
||||
version = "1.1.0" // QMUI 发布到 bintray 的版本号
|
||||
version = "1.1.1" // QMUI 发布到 bintray 的版本号
|
||||
|
||||
//noinspection GroovyMissingReturnStatement
|
||||
android {
|
||||
|
||||
@@ -25,7 +25,7 @@ android {
|
||||
minSdkVersion parent.ext.minSdkVersion
|
||||
targetSdkVersion parent.ext.targetSdkVersion
|
||||
versionCode gitVersion
|
||||
versionName "1.1.0"
|
||||
versionName "1.1.1"
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
|
||||
@@ -27,21 +27,8 @@ public abstract class BaseFragment extends QMUIFragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
checkAndShowUpgradeTip();
|
||||
QDUpgradeManager.getInstance(getContext()).runUpgradeTipTaskIfExist(getActivity());
|
||||
|
||||
}
|
||||
|
||||
private void checkAndShowUpgradeTip() {
|
||||
QDPreferenceManager preferenceManager = QDPreferenceManager.getInstance(getContext());
|
||||
if (preferenceManager.isNeedShowUpgradeTip()) {
|
||||
preferenceManager.setNeedShowUpgradeTip(false);
|
||||
String title = String.format(getString(R.string.app_upgrade_tip_title), QMUIPackageHelper.getAppVersion(getContext()));
|
||||
CharSequence message = QDUpgradeManager.getInstance(getContext()).getUpgradeWord(getActivity());
|
||||
new QMUIDialog.MessageDialogBuilder(getContext())
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.create(R.style.ReleaseDialogTheme)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ public class QDPreferenceManager {
|
||||
private static QDPreferenceManager sQDPreferenceManager = null;
|
||||
|
||||
private static final String APP_VERSION_CODE = "app_version_code";
|
||||
private static final String APP_NEED_SHOW_UPGRADE_TIP = "app_has_show_upgrade_tip";
|
||||
|
||||
private QDPreferenceManager(Context context) {
|
||||
sPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
@@ -35,14 +34,4 @@ public class QDPreferenceManager {
|
||||
public int getVersionCode() {
|
||||
return sPreferences.getInt(APP_VERSION_CODE, QDUpgradeManager.INVALIDATE_VERSION_CODE);
|
||||
}
|
||||
|
||||
public void setNeedShowUpgradeTip(boolean needShowUpgradeTip) {
|
||||
final SharedPreferences.Editor editor = sPreferences.edit();
|
||||
editor.putBoolean(APP_NEED_SHOW_UPGRADE_TIP, needShowUpgradeTip);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public boolean isNeedShowUpgradeTip() {
|
||||
return sPreferences.getBoolean(APP_NEED_SHOW_UPGRADE_TIP, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,6 @@ 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.
|
||||
@@ -21,9 +10,11 @@ import com.qmuiteam.qmuidemo.R;
|
||||
public class QDUpgradeManager {
|
||||
public static final int INVALIDATE_VERSION_CODE = -1;
|
||||
|
||||
private static final int VERSION_1_1_0 = 110;
|
||||
private static final int sCurrentVersion = VERSION_1_1_0;
|
||||
public static final int VERSION_1_1_0 = 110;
|
||||
public static final int VERSION_1_1_1 = 111;
|
||||
private static final int sCurrentVersion = VERSION_1_1_1;
|
||||
private static QDUpgradeManager sQDUpgradeManager = null;
|
||||
private UpgradeTipTask mUpgradeTipTask;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -52,65 +43,17 @@ public class QDUpgradeManager {
|
||||
}
|
||||
|
||||
private void onUpgrade(int oldVersion, int currentVersion) {
|
||||
QDPreferenceManager.getInstance(mContext).setNeedShowUpgradeTip(true);
|
||||
mUpgradeTipTask = new UpgradeTipTask(oldVersion, currentVersion);
|
||||
}
|
||||
|
||||
private void onNewInstall(int currentVersion) {
|
||||
QDPreferenceManager.getInstance(mContext).setNeedShowUpgradeTip(true);
|
||||
mUpgradeTipTask = new UpgradeTipTask(INVALIDATE_VERSION_CODE, currentVersion);
|
||||
}
|
||||
|
||||
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;
|
||||
public void runUpgradeTipTaskIfExist(Activity activity) {
|
||||
if (mUpgradeTipTask != null) {
|
||||
mUpgradeTipTask.upgrade(activity);
|
||||
mUpgradeTipTask = null;
|
||||
}
|
||||
return "欢迎体验新版本!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.qmuiteam.qmuidemo.manager;
|
||||
|
||||
public interface UpgradeTask {
|
||||
void upgrade();
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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.qmui.util.QMUIPackageHelper;
|
||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
|
||||
import com.qmuiteam.qmuidemo.R;
|
||||
|
||||
public class UpgradeTipTask implements UpgradeTask {
|
||||
private final int mOldVersion;
|
||||
private final int mNewVersion;
|
||||
|
||||
public UpgradeTipTask(int oldVersion, int newVersion) {
|
||||
mOldVersion = oldVersion;
|
||||
mNewVersion = newVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgrade() {
|
||||
throw new RuntimeException("please call upgrade(Activity activity)");
|
||||
}
|
||||
|
||||
public void upgrade(Activity activity) {
|
||||
String title = String.format(activity.getString(R.string.app_upgrade_tip_title), QMUIPackageHelper.getAppVersion(activity));
|
||||
CharSequence message = getUpgradeWord(activity);
|
||||
new QMUIDialog.MessageDialogBuilder(activity)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.create(R.style.ReleaseDialogTheme)
|
||||
.show();
|
||||
}
|
||||
|
||||
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) {
|
||||
SpannableStringBuilder text = new SpannableStringBuilder();
|
||||
if (mOldVersion == QDUpgradeManager.VERSION_1_1_0) {
|
||||
text.append("1. Bug fixes: can not read /system/build.prop begin from android 8.0.\n");
|
||||
appendBlockSpace(activity, text);
|
||||
text.append("2. Allow custom layout in QMUIPopup.");
|
||||
} else if (mOldVersion < QDUpgradeManager.VERSION_1_1_0) {
|
||||
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(".");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text.append("welcome to QMUI!");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user