Skip to content

Commit

Permalink
V1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfusheng committed Jul 10, 2018
1 parent c9a6198 commit f10ea37
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 79 deletions.
2 changes: 0 additions & 2 deletions FirUpdater/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ apply plugin: 'com.novoda.bintray-release'

android {
compileSdkVersion gradle.compileSdkVersion
buildToolsVersion gradle.buildToolsVersion

defaultConfig {
minSdkVersion gradle.minSdkVersion
targetSdkVersion gradle.targetSdkVersion
Expand Down
9 changes: 6 additions & 3 deletions FirUpdater/src/main/java/com/sunfusheng/FirNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class FirNotification {
private NotificationManager manager;
private NotificationCompat.Builder builder;

public void createBuilder(Context context) {
public FirNotification createBuilder(Context context, boolean showProgress) {
this.context = context;
manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(context, CHANNEL_ID);
Expand All @@ -41,7 +41,9 @@ public void createBuilder(Context context) {
}
builder.setAutoCancel(false);
builder.setOngoing(true);
builder.setProgress(100, 0, false);
if (showProgress) {
builder.setProgress(100, 0, false);
}
builder.setWhen(System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setFullScreenIntent(pendingIntent, false);
Expand All @@ -54,6 +56,7 @@ public void createBuilder(Context context) {
if (SDK_INT >= O) {
setupNotificationChannel("FirUpdater", manager, builder);
}
return this;
}

@TargetApi(O)
Expand Down Expand Up @@ -89,7 +92,7 @@ public void setContentIntent(Intent intent) {

public void notifyNotification(int progress) {
builder.setProgress(100, progress, false);
manager.notify(NOTIFICATION_ID, builder.build());
notifyNotification();
}

public void notifyNotification() {
Expand Down
26 changes: 15 additions & 11 deletions FirUpdater/src/main/java/com/sunfusheng/FirUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class FirUpdater {
private String appVersionUrl;
private String apkPath;
private FirAppInfo.AppInfo appInfo;
private boolean isBackgroundDownload = false;
private boolean forceShowDialog = false;

private FirDialog firDialog;
Expand Down Expand Up @@ -94,7 +93,6 @@ private void requestAppInfo() {
apkPath = Environment.getExternalStorageDirectory() + File.separator;
}


appInfo.appId = appId;
appInfo.apkName = apkName;
appInfo.apkPath = apkPath;
Expand All @@ -119,7 +117,8 @@ public void onClickDownload(DialogInterface dialog) {

@Override
public void onClickBackgroundDownload(DialogInterface dialog) {
isBackgroundDownload = true;
firNotification = new FirNotification().createBuilder(context, true);
firNotification.setContentTitle(appInfo.appName);
}

@Override
Expand All @@ -136,33 +135,38 @@ private void downloadApk() {
return;
}

firNotification = new FirNotification();
firNotification.createBuilder(context);
firNotification.setContentTitle("正在下载" + appInfo.appName);

firDialog.showDownloadDialog(context, 0);
firDownloader = new FirDownloader(context.getApplicationContext(), appInfo);
firDownloader.setOnDownLoadListener(new FirDownloader.OnDownLoadListener() {
@Override
public void onProgress(int progress) {
firDialog.showDownloadDialog(context, progress);
if (isBackgroundDownload) {
firNotification.setContentText(progress + "%");
if (firNotification != null) {
firNotification.setContentText("下载更新中..." + progress + "%");
firNotification.notifyNotification(progress);
}
}

@Override
public void onSuccess() {
firDialog.dismissDownloadDialog();
if (isBackgroundDownload) {
if (firNotification != null) {
firNotification.cancel();
}
firNotification = new FirNotification().createBuilder(context, false);
firNotification.setContentIntent(FirUpdaterUtils.getInstallApkIntent(context, appInfo.apkLocalUrl));
firNotification.setContentTitle(appInfo.appName);
firNotification.setContentText("下载完成,点击安装");
firNotification.notifyNotification();
FirUpdaterUtils.installApk(context, appInfo.apkLocalUrl);
}

@Override
public void onError() {

firDialog.dismissDownloadDialog();
if (firNotification != null) {
firNotification.cancel();
}
}
});
firDownloader.downloadApk();
Expand Down
2 changes: 0 additions & 2 deletions Sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ signingProperties.load(new FileInputStream(file("../signings/signing.properties"

android {
compileSdkVersion gradle.compileSdkVersion
buildToolsVersion gradle.buildToolsVersion

defaultConfig {
applicationId "com.sunfusheng.firupdater.sample"
minSdkVersion gradle.minSdkVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.sunfusheng.firupdater.sample;

import android.content.Context;
import android.graphics.drawable.Drawable;

import com.sunfusheng.FirUpdaterUtils;
import com.sunfusheng.GroupViewHolder;
import com.sunfusheng.HeaderGroupRecyclerViewAdapter;

Expand Down Expand Up @@ -43,21 +41,8 @@ public void onBindHeaderViewHolder(GroupViewHolder holder, DataSource.AppConfig

@Override
public void onBindChildViewHolder(GroupViewHolder holder, DataSource.AppConfig item, int groupPosition, int childPosition) {
Context context = holder.itemView.getContext();
Drawable icon = null;

if (FirUpdaterUtils.isAppInstalled(context, context.getString(item.pkgId))) {
icon = FirUpdaterUtils.getIcon(context, context.getString(item.pkgId));
}

if (icon == null) {
icon = context.getResources().getDrawable(R.mipmap.ic_launcher);
}

holder.setImageDrawable(R.id.iv_logo, icon);
holder.setText(R.id.tv_title, item.titleId);
holder.setText(R.id.tv_subtitle, item.subtitleId);

holder.setVisible(R.id.divider, !isGroupLastItem(groupPosition, childPosition));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ public class DataSource {
public static final String FIR_UPDATER_APP_ID = "5a89af10548b7a760110c918";

public static AppConfig[][] apps = {
{AppConfig.NULL, AppConfig.MV, AppConfig.GIV, AppConfig.GRVA},
{AppConfig.NULL, AppConfig.MultiType, AppConfig.MV, AppConfig.GIV, AppConfig.GRVA},
{AppConfig.NULL, AppConfig.GANK, AppConfig.SHLV, AppConfig._360, AppConfig.TULING}
};

public enum AppConfig {
NULL(0, 0, 0, 0, 0),

MultiType(R.attr.key_multitype, R.string.multitype_title, R.string.multitype_subtitle, R.string.multitype_app_id, R.string.multitype_pkg),
MV(R.attr.key_mv, R.string.mv_title, R.string.mv_subtitle, R.string.mv_app_id, R.string.mv_pkg),
GIV(R.attr.key_giv, R.string.giv_title, R.string.giv_subtitle, R.string.giv_app_id, R.string.giv_pkg),
GRVA(R.attr.key_grva, R.string.grva_title, R.string.grva_subtitle, R.string.grva_app_id, R.string.grva_pkg),
Expand Down
63 changes: 24 additions & 39 deletions Sample/src/main/res/layout/item_list_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,36 @@
android:background="@drawable/drawable_list_item_selector"
android:orientation="vertical">

<RelativeLayout
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_item_margin_top_bottom_smaller"
android:layout_marginLeft="@dimen/list_item_margin_left_right"
android:layout_marginRight="@dimen/list_item_margin_left_right"
android:layout_marginTop="@dimen/list_item_margin_top_bottom_smaller">

<ImageView
android:id="@+id/iv_logo"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@mipmap/ic_launcher"/>
android:layout_marginTop="@dimen/list_item_margin_top_bottom_smaller"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/list_item_margin_top_bottom_smaller"
android:layout_toRightOf="@+id/iv_logo"
android:orientation="vertical">

<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="title"
android:textColor="@color/font1"
android:textSize="16sp"/>

<TextView
android:id="@+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:maxLines="1"
android:text="subtitle"
android:textColor="@color/font2"
android:textSize="11sp"/>
</LinearLayout>

</RelativeLayout>
android:ellipsize="end"
android:maxLines="1"
android:text="title"
android:textColor="@color/font1"
android:textSize="16sp"/>

<TextView
android:id="@+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:maxLines="1"
android:text="subtitle"
android:textColor="@color/font2"
android:textSize="11sp"/>
</LinearLayout>

<include
layout="@layout/divider_1px"
Expand Down
1 change: 1 addition & 0 deletions Sample/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<attr name="key_multitype">key_multitype</attr>
<attr name="key_grva">key_grva</attr>
<attr name="key_360">key_360</attr>
<attr name="key_giv">key_giv</attr>
Expand Down
5 changes: 5 additions & 0 deletions Sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@
<string name="tuling_app_id">5704953c00fc74127000000a</string>
<string name="tuling_pkg">com.robot.tuling</string>

<string name="multitype_title">MultiType</string>
<string name="multitype_subtitle">轻松地实现RecyclerView显示多种类型数据,一对多、多对多,可以注册全局类型、局部类型、默认类型</string>
<string name="multitype_app_id">5b3ec988548b7a3d7bd77c8f</string>
<string name="multitype_pkg">com.sunfusheng.multitype.sample</string>

</resources>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.novoda:bintray-release:0.8.0'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.novoda:bintray-release:0.8.1'
}
}

Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
include ':Sample', ':FirUpdater'

gradle.ext.compileSdkVersion = 27
gradle.ext.buildToolsVersion = '27.0.3'
gradle.ext.supportLibraryVersion = '27.0.2'
gradle.ext.buildToolsVersion = '27.1.1'
gradle.ext.supportLibraryVersion = '27.1.1'

gradle.ext.minSdkVersion = 14
gradle.ext.targetSdkVersion = 27
gradle.ext.versionCode = 9
gradle.ext.versionName = '1.0.8'
gradle.ext.versionCode = 10
gradle.ext.versionName = '1.0.9'

0 comments on commit f10ea37

Please sign in to comment.