diff --git a/.travis.yml b/.travis.yml index c9dfe42..2aca0b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ deploy: all_branches: true after_deploy: -- fir p app/outputs/Gank.IO.apk -T $FIR_TOKEN -c "`git cat-file tag $TRAVIS_TAG`" +- fir publish app/outputs/Gank.IO.apk -T $FIR_TOKEN -c "干货集中营Android客户端" notifications: email: diff --git a/README.md b/README.md index bd69d62..776fa7c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ### 预览图 - +
@@ -18,14 +18,22 @@
-### 个人公众号 +### 关注我吧,让我们做朋友^_^ - + + +### 打个赏吧,给作者加点油^_^ + + ### 关于我 [GitHub: sfsheng0322](https://github.com/sfsheng0322) -[个人邮箱: sfsheng0322@126.com]() -[个人博客: sunfusheng.com](http://sunfusheng.com/) -[简书主页](http://www.jianshu.com/users/88509e7e2ed1/latest_articles) + +[个人邮箱: sfsheng0322@126.com](https://mail.126.com/) + +[个人博客: sunfusheng.com](http://sunfusheng.com/) + +[简书主页](http://www.jianshu.com/users/88509e7e2ed1/latest_articles) + [新浪微博](http://weibo.com/u/3852192525) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 71d9511..aa3f314 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -103,6 +103,7 @@ dependencies { implementation 'me.drakeet.multitype:multitype:3.4.2' implementation 'com.afollestad.material-dialogs:core:0.9.4.4' implementation 'com.sunfusheng:glideimageview:1.2.0' + compile 'com.sunfusheng:FirUpdater:1.0.7' implementation 'com.github.chrisbanes:PhotoView:2.1.3' implementation 'jp.wasabeef:recyclerview-animators:2.2.5' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" diff --git a/app/outputs/Gank.IO.apk b/app/outputs/Gank.IO.apk index 81f059a..b4d76e5 100644 Binary files a/app/outputs/Gank.IO.apk and b/app/outputs/Gank.IO.apk differ diff --git a/app/outputs/output.json b/app/outputs/output.json index 7768bb8..5390074 100644 --- a/app/outputs/output.json +++ b/app/outputs/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9},"path":"Gank.IO.apk","properties":{"packageId":"com.sunfusheng.gank","split":"","minSdkVersion":"14"}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11},"path":"Gank.IO.apk","properties":{"packageId":"com.sunfusheng.gank","split":"","minSdkVersion":"14"}}] \ No newline at end of file diff --git a/app/src/main/java/com/sunfusheng/gank/Constants.java b/app/src/main/java/com/sunfusheng/gank/Constants.java index 6ead897..025e04c 100644 --- a/app/src/main/java/com/sunfusheng/gank/Constants.java +++ b/app/src/main/java/com/sunfusheng/gank/Constants.java @@ -8,11 +8,7 @@ public class Constants { // 干货集中营Base Url public static final String BASE_URL = "http://gank.io/api/"; - // fir.im 信息 - public static final String FIR_IM_APP_ID = "58954512ca87a85dc4000135"; public static final String FIR_IM_API_TOKEN = "3c57fb226edf7facf821501e4eba08d2"; - - // fir.im 最新软件版本信息 - public static final String URL_APP_VERSION = "http://api.fir.im/apps/latest/" + FIR_IM_APP_ID + "?api_token=" + FIR_IM_API_TOKEN + "&type=android"; + public static final String FIR_IM_APP_ID = "58954512ca87a85dc4000135"; } diff --git a/app/src/main/java/com/sunfusheng/gank/http/ApiService.java b/app/src/main/java/com/sunfusheng/gank/http/ApiService.java index b40154a..aa7cf56 100644 --- a/app/src/main/java/com/sunfusheng/gank/http/ApiService.java +++ b/app/src/main/java/com/sunfusheng/gank/http/ApiService.java @@ -1,8 +1,6 @@ package com.sunfusheng.gank.http; -import com.sunfusheng.gank.Constants; import com.sunfusheng.gank.model.GankDay; -import com.sunfusheng.gank.util.update.VersionEntity; import io.reactivex.Observable; import retrofit2.http.GET; @@ -18,6 +16,4 @@ public interface ApiService { @GET("day/{year}/{month}/{day}") Observable getGankDay(@Path("year") int year, @Path("month") int month, @Path("day") int day); - @GET(Constants.URL_APP_VERSION) - Observable checkVersion(); } diff --git a/app/src/main/java/com/sunfusheng/gank/ui/KotlinMainActivity.kt b/app/src/main/java/com/sunfusheng/gank/ui/KotlinMainActivity.kt index 1a3d852..c221e7b 100644 --- a/app/src/main/java/com/sunfusheng/gank/ui/KotlinMainActivity.kt +++ b/app/src/main/java/com/sunfusheng/gank/ui/KotlinMainActivity.kt @@ -1,23 +1,19 @@ package com.sunfusheng.gank.ui import android.os.Bundle -import android.text.TextUtils +import com.sunfusheng.FirUpdater +import com.sunfusheng.gank.Constants import com.sunfusheng.gank.R import com.sunfusheng.gank.base.BaseActivity -import com.sunfusheng.gank.http.Api import com.sunfusheng.gank.ui.gank.GankFragment -import com.sunfusheng.gank.util.AppUtil import com.sunfusheng.gank.util.ToastUtil -import com.sunfusheng.gank.util.update.UpdateHelper -import com.sunfusheng.gank.util.update.VersionEntity import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.schedulers.Schedulers import java.util.concurrent.TimeUnit + class KotlinMainActivity : BaseActivity() { private val END_TIME_SECONDS: Long = 2 - private var updateHelper: UpdateHelper = UpdateHelper(this) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -32,13 +28,7 @@ class KotlinMainActivity : BaseActivity() { } private fun checkVersion() { - Api.getInstance().apiService.checkVersion() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .compose(bindToLifecycle()) - .filter { !TextUtils.isEmpty(it.version) } - .filter { Integer.parseInt(it.version) > AppUtil.getVersionCode() } - .subscribe({ updateHelper.dealWithVersion(it) }, { it.printStackTrace() }) + FirUpdater(this, Constants.FIR_IM_API_TOKEN, Constants.FIR_IM_APP_ID).checkVersion() } private fun prepareForExiting() { @@ -53,7 +43,6 @@ class KotlinMainActivity : BaseActivity() { } override fun onDestroy() { - updateHelper.unInit() super.onDestroy() } diff --git a/app/src/main/java/com/sunfusheng/gank/ui/MainActivity.java b/app/src/main/java/com/sunfusheng/gank/ui/MainActivity.java index 3ca360e..506c449 100644 --- a/app/src/main/java/com/sunfusheng/gank/ui/MainActivity.java +++ b/app/src/main/java/com/sunfusheng/gank/ui/MainActivity.java @@ -2,25 +2,21 @@ import android.os.Bundle; import android.support.annotation.Nullable; -import android.text.TextUtils; +import com.sunfusheng.FirUpdater; +import com.sunfusheng.gank.Constants; import com.sunfusheng.gank.R; import com.sunfusheng.gank.base.BaseActivity; -import com.sunfusheng.gank.http.Api; import com.sunfusheng.gank.ui.gank.GankFragment; -import com.sunfusheng.gank.util.AppUtil; import com.sunfusheng.gank.util.ToastUtil; -import com.sunfusheng.gank.util.update.UpdateHelper; import java.util.concurrent.TimeUnit; import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.schedulers.Schedulers; public class MainActivity extends BaseActivity { private static final long END_TIME_SECONDS = 2; - private UpdateHelper updateHelper = new UpdateHelper(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -36,13 +32,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } private void checkVersion() { - Api.getInstance().getApiService().checkVersion() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .compose(bindToLifecycle()) - .filter(it -> it != null && !TextUtils.isEmpty(it.version)) - .filter(it -> Integer.parseInt(it.version) > AppUtil.getVersionCode()) - .subscribe(it -> updateHelper.dealWithVersion(it), Throwable::printStackTrace); + new FirUpdater(this, Constants.FIR_IM_API_TOKEN, Constants.FIR_IM_APP_ID).checkVersion(); } private void prepareForExiting() { @@ -58,9 +48,6 @@ private void prepareForExiting() { @Override protected void onDestroy() { - if (updateHelper != null) { - updateHelper.unInit(); - } super.onDestroy(); } diff --git a/app/src/main/java/com/sunfusheng/gank/util/update/Binary.java b/app/src/main/java/com/sunfusheng/gank/util/update/Binary.java deleted file mode 100644 index 9f884e1..0000000 --- a/app/src/main/java/com/sunfusheng/gank/util/update/Binary.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.sunfusheng.gank.util.update; - -import java.io.Serializable; - -/** - * Created by sunfusheng on 15/8/20. - */ -public class Binary implements Serializable { - - private long fsize; - - public long getFsize() { - return fsize; - } - - public void setFsize(long fsize) { - this.fsize = fsize; - } - -} diff --git a/app/src/main/java/com/sunfusheng/gank/util/update/UpdateHelper.java b/app/src/main/java/com/sunfusheng/gank/util/update/UpdateHelper.java deleted file mode 100644 index 3108657..0000000 --- a/app/src/main/java/com/sunfusheng/gank/util/update/UpdateHelper.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.sunfusheng.gank.util.update; - -import android.app.Activity; - -import com.sunfusheng.gank.R; -import com.sunfusheng.gank.util.AppUtil; -import com.sunfusheng.gank.util.ToastUtil; -import com.sunfusheng.gank.util.dialog.CommonDialog; -import com.sunfusheng.gank.util.dialog.DownloadDialog; -import com.tbruyelle.rxpermissions2.RxPermissions; - -import java.io.File; - -import io.reactivex.Observer; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; -import io.reactivex.schedulers.Schedulers; -import zlc.season.rxdownload2.RxDownload; -import zlc.season.rxdownload2.entity.DownloadStatus; - -import static android.os.Environment.DIRECTORY_DOWNLOADS; -import static android.os.Environment.getExternalStoragePublicDirectory; - -/** - * Created by sunfusheng on 2017/2/4. - */ -public class UpdateHelper { - - private Activity mActivity; - private int lastProgress = 0; - private DownloadDialog mDialog; - private Disposable mDisposable; - - private String fileName; - private String filePath; - private String apkPathName; - - public UpdateHelper(Activity activity) { - this.mActivity = activity; - } - - public void unInit() { - if (mDialog != null && mDialog.isShowing()) { - mDialog.dismiss(); - } - - if (mDisposable != null && !mDisposable.isDisposed()) { - mDisposable.dispose(); - } - } - - public void dealWithVersion(final VersionEntity entity) { - String content = entity.changelog + "\n\n下载(V" + entity.versionShort + ")替换当前版本(" + AppUtil.getVersionName() + ")?"; - new CommonDialog(mActivity).show( - mActivity.getString(R.string.update_app), - content, - mActivity.getString(R.string.update_rightnow), - mActivity.getString(R.string.update_no), - (dialog, which) -> { - fileName = entity.name + "_V" + entity.versionShort + ".apk"; - filePath = getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS).getPath(); - apkPathName = filePath + File.separator + fileName; - download(entity.install_url); - }); - } - - public void download(String url) { - RxPermissions rxPermissions = new RxPermissions(mActivity); - rxPermissions.request(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(granted -> { - if (!granted) { - ToastUtil.toast("您已禁止了写数据权限"); - } else { - RxDownload.getInstance() - .download(url, fileName, filePath) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { - mDisposable = d; - mDialog = new DownloadDialog(mActivity); - mDialog.show(); - } - - @Override - public void onNext(DownloadStatus value) { - float progressF = (float) (value.getDownloadSize() * 1.0 / value.getTotalSize()); - int progressI = (int) (progressF * 100); - if (progressI > lastProgress) { - lastProgress = progressI; - mDialog.setProgress(progressI); - } - } - - @Override - public void onError(Throwable e) { - mDialog.dismiss(); - // 实名认证的fir.im用户,应用每天的下载次数是100次 - ToastUtil.toast("下载次数受限,请明天尝试"); - } - - @Override - public void onComplete() { - mDialog.dismiss(); - AppUtil.installApk(apkPathName); - } - }); - } - }); - } - -} diff --git a/app/src/main/java/com/sunfusheng/gank/util/update/VersionEntity.java b/app/src/main/java/com/sunfusheng/gank/util/update/VersionEntity.java deleted file mode 100644 index 26d0b43..0000000 --- a/app/src/main/java/com/sunfusheng/gank/util/update/VersionEntity.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.sunfusheng.gank.util.update; - -import java.io.Serializable; - -/** - * Created by sunfusheng on 15/8/19. - */ -public class VersionEntity implements Serializable { - - public String name; - public String version; - public String changelog; - public String versionShort; - public String build; - public String installUrl; - public String install_url; - public String update_url; - public Binary binary; - -} diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 7b37251..daa5a2e 100755 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index add6b7c..b9edd48 100755 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 71f8cce..7b0b713 100755 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 7b45498..43e5ef6 100755 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 22993ae..123723f 100755 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 492dd0d..3267628 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,9 +1,9 @@ - #C34A42 - #C34A42 - #C34A42 + #c34a42 + #c34a42 + #c34a42 #212121 #333333 diff --git a/app/src/main/res/values/md_color.xml b/app/src/main/res/values/colors_material.xml similarity index 99% rename from app/src/main/res/values/md_color.xml rename to app/src/main/res/values/colors_material.xml index 1c866c9..33520c0 100755 --- a/app/src/main/res/values/md_color.xml +++ b/app/src/main/res/values/colors_material.xml @@ -280,9 +280,6 @@ #616161 #424242 #212121 - - #000000 - #ffffff #eceff1 diff --git a/build.gradle b/build.gradle index 48e248e..3192ea7 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ buildscript { mavenCentral() google() maven { url "https://jitpack.io" } + maven { url 'https://dl.bintray.com/sfsheng0322/maven' } maven { url 'https://dl.bintray.com/drummer-aidan/maven' } } @@ -22,6 +23,7 @@ allprojects { mavenCentral() google() maven { url "https://jitpack.io" } + maven { url 'https://dl.bintray.com/sfsheng0322/maven' } maven { url 'https://dl.bintray.com/drummer-aidan/maven' } } } diff --git a/resources/res1.gif b/resources/Gank.IO.gif similarity index 100% rename from resources/res1.gif rename to resources/Gank.IO.gif diff --git a/resources/res2.png b/resources/res.png similarity index 100% rename from resources/res2.png rename to resources/res.png diff --git a/settings.gradle b/settings.gradle index 29864d4..1407e20 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,5 +6,5 @@ gradle.ext.supportLibraryVersion = '27.0.2' gradle.ext.minSdkVersion = 14 gradle.ext.targetSdkVersion = 27 -gradle.ext.versionCode = 10 -gradle.ext.versionName = "1.6.4" \ No newline at end of file +gradle.ext.versionCode = 11 +gradle.ext.versionName = "1.6.5" \ No newline at end of file