Skip to content

Commit

Permalink
release to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cgspine committed Mar 26, 2018
1 parent 25d2808 commit 047b6d0
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 33 deletions.
2 changes: 1 addition & 1 deletion arch/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

group = 'com.qmuiteam'
version = "0.0.2"
version = "0.0.3"

android {

Expand Down
2 changes: 1 addition & 1 deletion qmui/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion qmuidemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 "欢迎体验新版本!";
}
}
2 changes: 1 addition & 1 deletion qmuidemo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- common -->
<string name="app_name">QMUI</string>
<string name="common_example">示例图片</string>
<string name="app_upgrade_tip_title">更新提示(%1$s)</string>
<string name="app_upgrade_tip_title">Release Notes (%1$s)</string>
<string name="ok">确&#160;定</string>
<string name="cancel">取&#160;消</string>

Expand Down
11 changes: 11 additions & 0 deletions qmuidemo/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
<item name="qmui_dialog_menu_item_style">@style/DialogTheme2MenuItemStyle</item>
</style>

<style name="ReleaseDialogTheme" parent="DialogTheme2">
<item name="qmui_dialog_wrapper_style">@style/QMUI.Dialog.Wrapper</item>
<item name="qmui_dialog_message_content_style">@style/ReleaseMessageContentStyle</item>

</style>

<style name="dialog_wrapper_style_63">
<item name="android:paddingLeft">63dp</item>
<item name="android:paddingRight">63dp</item>
Expand Down Expand Up @@ -141,6 +147,11 @@
<item name="qmui_paddingTopWhenNotTitle">27dp</item>
</style>

<style name="ReleaseMessageContentStyle" parent="DialogTheme2MessageContentStyle">
<item name="android:textSize">14sp</item>
<item name="android:gravity">left</item>
</style>

<style name="DialogTheme2MenuItemStyle" parent="@style/QMUI.Dialog_MenuItem">
<item name="android:textSize">16sp</item>
<item name="android:textColor">?attr/qmui_config_color_gray_1</item>
Expand Down

0 comments on commit 047b6d0

Please sign in to comment.