Skip to content

Commit

Permalink
develop releases, released v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirtyDegreesRay committed Sep 17, 2017
1 parent c95accc commit b716ff0
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 10 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ dependencies {
//Android6.0以上权限获取工具
//PermissionsDispatcher provides a simple annotation-based API to handle runtime permissions in Android Marshmallow.
// androidApt: 'com.neenbedankt.gradle.plugins:android-apt:1.8',
compile "com.github.hotchemi:permissionsdispatcher:${PERMISSIONS_DISPATCHER_VERSION}"
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:${PERMISSIONS_DISPATCHER_VERSION}"
// compile "com.github.hotchemi:permissionsdispatcher:${PERMISSIONS_DISPATCHER_VERSION}"
// annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:${PERMISSIONS_DISPATCHER_VERSION}"
compile "com.yanzhenjie:permission:${AND_PERMISSION_VERSION}"

compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.widget.Toast;

import com.thirtydegreesray.openhub.R;
import com.thirtydegreesray.openhub.util.StringUtils;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.Permission;
import com.yanzhenjie.permission.PermissionListener;

import java.util.List;

import es.dmoral.toasty.Toasty;

Expand All @@ -24,6 +31,7 @@ public class Downloader {
private Context mContext;
private long downloadId;

private String url;
private String fileName;

public static Downloader create(Context context){
Expand All @@ -35,13 +43,32 @@ private Downloader(Context context){
}

public void start(String url, String fileName) {
//FIXME write permission
if(StringUtils.isBlank(url) || StringUtils.isBlank(fileName)){
Toasty.error(mContext, mContext.getString(R.string.download_empty_tip)).show();
return;
}
this.url = url;
this.fileName = fileName;

AndPermission.with(mContext)
.permission(Permission.STORAGE)
.callback(new PermissionListener() {
@Override
public void onSucceed(int requestCode, @NonNull List<String> grantPermissions) {
start();
}

@Override
public void onFailed(int requestCode, @NonNull List<String> deniedPermissions) {
Toasty.error(mContext, mContext.getString(R.string.permission_storage_denied),
Toast.LENGTH_LONG).show();
}
})
.start();
}

private void start() {

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
//移动网络情况下是否允许漫游
request.setAllowedOverRoaming(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class EventPayload implements Parcelable {
private String description;
@SerializedName("pusher_type") private String pusherType;

//ReleaseEvent
private Release release;

//ForkEvent,PublicEvent None


Expand Down Expand Up @@ -146,6 +149,14 @@ public void setPusherType(String pusherType) {
this.pusherType = pusherType;
}

public Release getRelease() {
return release;
}

public void setRelease(Release release) {
this.release = release;
}

@Override
public int describeContents() {
return 0;
Expand All @@ -165,6 +176,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.masterBranch);
dest.writeString(this.description);
dest.writeString(this.pusherType);
dest.writeParcelable(this.release, flags);
}

public EventPayload() {
Expand All @@ -183,6 +195,7 @@ protected EventPayload(Parcel in) {
this.masterBranch = in.readString();
this.description = in.readString();
this.pusherType = in.readString();
this.release = in.readParcelable(Release.class.getClassLoader());
}

public static final Parcelable.Creator<EventPayload> CREATOR = new Parcelable.Creator<EventPayload>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ private void correctEvent(ArrayList<Event> events){
}
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onSuccess(HttpResponse<ArrayList<Release>> response) {
public Observable<Response<ArrayList<Release>>> createObservable(boolean forceNetWork) {
return getRepoService().getReleases(forceNetWork, owner, repo, page);
}
}, httpObserver);
}, httpObserver, readCacheFirst);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public static void show(Activity activity, String repoName, Release release){

@Override
public void showReleaseInfo(Release release) {
webView.setMdSource(release.getBodyHtml(), null);
webView.setMdSource(StringUtils.isBlank(release.getBodyHtml()) ?
release.getBody() : release.getBodyHtml(), null);

GlideApp.with(getActivity())
.load(release.getAuthor().getAvatarUrl())
.placeholder(R.mipmap.logo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
action = "Push to " + ref +
" at " + model.getRepo().getFullName();
} else if (Event.EventType.ReleaseEvent.equals(model.getType())) {
//TODO show release name
action = model.getPayload().getAction() + " release at " +
action = model.getPayload().getAction() + " release " +
model.getPayload().getRelease().getTagName() + " at " +
model.getRepo().getFullName();
} else if (Event.EventType.PullRequestEvent.equals(model.getType())) {
action = model.getPayload().getAction() + " pull request " + model.getRepo().getFullName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.time.setText(StringUtils.getNewsTimeStr(context, model.getCreatedAt()));
if(!StringUtils.isBlank(model.getBodyHtml())){
holder.body.setText(Html.fromHtml(model.getBodyHtml()));
holder.body.setVisibility(View.VISIBLE);
} else {
holder.body.setText("");
holder.body.setVisibility(View.GONE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.thirtydegreesray.openhub.mvp.contract.IActivityContract;
import com.thirtydegreesray.openhub.mvp.model.Event;
import com.thirtydegreesray.openhub.mvp.presenter.ActivityPresenter;
import com.thirtydegreesray.openhub.ui.activity.ReleaseInfoActivity;
import com.thirtydegreesray.openhub.ui.activity.RepositoryActivity;
import com.thirtydegreesray.openhub.ui.adapter.ActivitiesAdapter;
import com.thirtydegreesray.openhub.ui.fragment.base.ListFragment;
Expand Down Expand Up @@ -96,6 +97,12 @@ public void onItemClick(int position) {
String actorId = event.getActor().getLogin();
RepositoryActivity.show(getContext(), actorId, event.getRepo().getName());
break;
case ReleaseEvent:
String repoName = event.getRepo().getFullName();
repoName = repoName.substring(repoName.lastIndexOf("/") + 1);
ReleaseInfoActivity.show(getActivity(), repoName,
event.getPayload().getRelease());
break;
default:
RepositoryActivity.show(getContext(), owner, event.getRepo().getName());
break;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/layout_item_release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
android:textColor="?android:textColorPrimary"
android:maxLines="6"
android:paddingStart="@dimen/spacing_micro"
android:paddingEnd="@dimen/spacing_micro"/>
android:paddingEnd="@dimen/spacing_micro"
android:ellipsize="end"/>

</LinearLayout>

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<string name="unwatched">已取消关注</string>
<string name="watch" >关注</string>
<string name="watched">已关注</string>
<string name="watchers" >查看</string>
<string name="watchers" >关注者</string>
<string name="fork" >添加到我的版本库</string>
<string name="fork_warning_msg">添加到我的版本库?</string>
<string name="forked">已添加到我的版本库</string>
Expand Down Expand Up @@ -147,5 +147,6 @@
<string name="released_this">发布此版本</string>
<string name="on">在</string>
<string name="close">关闭</string>
<string name="permission_storage_denied">权限被拒绝,请允许访问存储权限。</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,6 @@
<string name="download_empty_tip">Url or file name is empty!</string>
<string name="download_start">Download start</string>
<string name="download_cancel">Download cancel</string>
<string name="permission_storage_denied">Permission denied, please allow storage permission.</string>

</resources>
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ FILE_DOWNLOADER_VERSION=0.3.1
RXJAVA_VERSION=1.1.0
RETROFIT_VERSION=2.1.0
DAGGER_VERSION=2.11
PERMISSIONS_DISPATCHER_VERSION=2.1.3
#PERMISSIONS_DISPATCHER_VERSION=2.1.3
AND_PERMISSION_VERSION=1.1.0
RETROLAMBDA_VERSION=2.3.0
OKHTTP_VERSION=3.6.0
FASTJSON_VERSION=1.1.46.android
Expand Down

0 comments on commit b716ff0

Please sign in to comment.