this commit fixes #1188 fixes #1182 fixes #1170 fixes #1169 fixes #1096

This commit is contained in:
k0shk0sh 2017-10-27 18:00:48 +02:00
parent 7265c76b39
commit 425776e451
14 changed files with 113 additions and 184 deletions

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,6 @@ import com.fastaccess.BuildConfig;
import com.fastaccess.R;
import com.fastaccess.data.dao.GitHubErrorResponse;
import com.fastaccess.data.dao.GitHubStatusModel;
import com.fastaccess.data.dao.NameParser;
import com.fastaccess.data.service.ContentService;
import com.fastaccess.data.service.GistService;
import com.fastaccess.data.service.IssueService;
@ -108,15 +107,7 @@ public class RestProvider {
return;
}
}
String fileName = "";
NameParser nameParser = new NameParser(url);
if (nameParser.getUsername() != null) {
fileName += nameParser.getUsername() + "_";
}
if (nameParser.getName() != null) {
fileName += nameParser.getName() + "_";
}
fileName += new File(url).getName();
String fileName = new File(url).getName();
request.setDestinationInExternalPublicDir(context.getString(R.string.app_name), fileName);
request.setTitle(fileName);
request.setDescription(context.getString(R.string.downloading_file));

View File

@ -3,14 +3,18 @@ package com.fastaccess.provider.timeline;
import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import com.fastaccess.R;
import com.fastaccess.data.dao.ReactionsModel;
import com.fastaccess.data.dao.TimelineModel;
import com.fastaccess.data.dao.model.Comment;
import com.fastaccess.data.dao.types.ReactionTypes;
import com.fastaccess.provider.tasks.git.ReactionService;
import com.fastaccess.ui.widgets.SpannableBuilder;
import java.util.ArrayList;
import java.util.List;
@ -124,4 +128,64 @@ public class CommentsHelper {
.collect(Collectors.toCollection(ArrayList::new));
}
public static void appendEmojies(@NonNull ReactionsModel reaction, @NonNull TextView thumbsUp,
@NonNull TextView thumbsUpReaction, @NonNull TextView thumbsDown,
@NonNull TextView thumbsDownReaction, @NonNull TextView hurray,
@NonNull TextView hurrayReaction, @NonNull TextView sad,
@NonNull TextView sadReaction, @NonNull TextView laugh,
@NonNull TextView laughReaction, @NonNull TextView heart,
@NonNull TextView heartReaction, @NonNull View reactionsList) {
SpannableBuilder spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsUp()).append(" ")
.append(String.valueOf(reaction.getPlusOne()))
.append(" ");
thumbsUp.setText(spannableBuilder);
thumbsUpReaction.setText(spannableBuilder);
thumbsUpReaction.setVisibility(reaction.getPlusOne() > 0 ? View.VISIBLE : View.GONE);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsDown()).append(" ")
.append(String.valueOf(reaction.getMinusOne()))
.append(" ");
thumbsDown.setText(spannableBuilder);
thumbsDownReaction.setText(spannableBuilder);
thumbsDownReaction.setVisibility(reaction.getMinusOne() > 0 ? View.VISIBLE : View.GONE);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHooray()).append(" ")
.append(String.valueOf(reaction.getHooray()))
.append(" ");
hurray.setText(spannableBuilder);
hurrayReaction.setText(spannableBuilder);
hurrayReaction.setVisibility(reaction.getHooray() > 0 ? View.VISIBLE : View.GONE);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getSad()).append(" ")
.append(String.valueOf(reaction.getConfused()))
.append(" ");
sad.setText(spannableBuilder);
sadReaction.setText(spannableBuilder);
sadReaction.setVisibility(reaction.getConfused() > 0 ? View.VISIBLE : View.GONE);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getLaugh()).append(" ")
.append(String.valueOf(reaction.getLaugh()))
.append(" ");
laugh.setText(spannableBuilder);
laughReaction.setText(spannableBuilder);
laughReaction.setVisibility(reaction.getLaugh() > 0 ? View.VISIBLE : View.GONE);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHeart()).append(" ")
.append(String.valueOf(reaction.getHeart()));
heart.setText(spannableBuilder);
heartReaction.setText(spannableBuilder);
heartReaction.setVisibility(reaction.getHeart() > 0 ? View.VISIBLE : View.GONE);
if (reaction.getPlusOne() > 0 || reaction.getMinusOne() > 0
|| reaction.getLaugh() > 0 || reaction.getHooray() > 0
|| reaction.getConfused() > 0 || reaction.getHeart() > 0) {
reactionsList.setVisibility(View.VISIBLE);
reactionsList.setTag(true);
} else {
reactionsList.setVisibility(View.GONE);
reactionsList.setTag(false);
}
}
}

View File

@ -253,50 +253,8 @@ public class IssueDetailsViewHolder extends BaseViewHolder<TimelineModel> {
}
private void appendEmojies(ReactionsModel reaction) {
SpannableBuilder spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsUp()).append(" ")
.append(String.valueOf(reaction.getPlusOne()))
.append(" ");
thumbsUp.setText(spannableBuilder);
thumbsUpReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsDown()).append(" ")
.append(String.valueOf(reaction.getMinusOne()))
.append(" ");
thumbsDown.setText(spannableBuilder);
thumbsDownReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHooray()).append(" ")
.append(String.valueOf(reaction.getHooray()))
.append(" ");
hooray.setText(spannableBuilder);
hurrayReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getSad()).append(" ")
.append(String.valueOf(reaction.getConfused()))
.append(" ");
sad.setText(spannableBuilder);
sadReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getLaugh()).append(" ")
.append(String.valueOf(reaction.getLaugh()))
.append(" ");
laugh.setText(spannableBuilder);
laughReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHeart()).append(" ")
.append(String.valueOf(reaction.getHeart()));
heart.setText(spannableBuilder);
heartReaction.setText(spannableBuilder);
if (reaction.getPlusOne() > 0 || reaction.getMinusOne() > 0
|| reaction.getLaugh() > 0 || reaction.getHooray() > 0
|| reaction.getConfused() > 0 || reaction.getHeart() > 0) {
reactionsList.setVisibility(View.VISIBLE);
reactionsList.setTag(true);
} else {
reactionsList.setTag(false);
reactionsList.setVisibility(View.GONE);
}
CommentsHelper.appendEmojies(reaction, thumbsUp, thumbsUpReaction, thumbsDown, thumbsDownReaction, hooray, hurrayReaction, sad,
sadReaction, laugh, laughReaction, heart, heartReaction, reactionsList);
}
private void onToggle(boolean expanded, boolean animate) {

View File

@ -27,7 +27,6 @@ import com.fastaccess.ui.adapter.callback.OnToggleView;
import com.fastaccess.ui.adapter.callback.ReactionsCallback;
import com.fastaccess.ui.widgets.AvatarLayout;
import com.fastaccess.ui.widgets.FontTextView;
import com.fastaccess.ui.widgets.SpannableBuilder;
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter;
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
@ -210,50 +209,8 @@ public class ReviewCommentsViewHolder extends BaseViewHolder<ReviewCommentModel>
}
private void appendEmojies(ReactionsModel reaction) {
SpannableBuilder spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsUp()).append(" ")
.append(String.valueOf(reaction.getPlusOne()))
.append(" ");
thumbsUp.setText(spannableBuilder);
thumbsUpReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsDown()).append(" ")
.append(String.valueOf(reaction.getMinusOne()))
.append(" ");
thumbsDown.setText(spannableBuilder);
thumbsDownReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHooray()).append(" ")
.append(String.valueOf(reaction.getHooray()))
.append(" ");
hurray.setText(spannableBuilder);
hurrayReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getSad()).append(" ")
.append(String.valueOf(reaction.getConfused()))
.append(" ");
sad.setText(spannableBuilder);
sadReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getLaugh()).append(" ")
.append(String.valueOf(reaction.getLaugh()))
.append(" ");
laugh.setText(spannableBuilder);
laughReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHeart()).append(" ")
.append(String.valueOf(reaction.getHeart()));
heart.setText(spannableBuilder);
heartReaction.setText(spannableBuilder);
if (reaction.getPlusOne() > 0 || reaction.getMinusOne() > 0
|| reaction.getLaugh() > 0 || reaction.getHooray() > 0
|| reaction.getConfused() > 0 || reaction.getHeart() > 0) {
reactionsList.setVisibility(View.VISIBLE);
reactionsList.setTag(true);
} else {
reactionsList.setVisibility(View.GONE);
reactionsList.setTag(false);
}
CommentsHelper.appendEmojies(reaction, thumbsUp, thumbsUpReaction, thumbsDown, thumbsDownReaction, hurray, hurrayReaction, sad,
sadReaction, laugh, laughReaction, heart, heartReaction, reactionsList);
}
private long getId() {

View File

@ -29,7 +29,6 @@ import com.fastaccess.ui.adapter.callback.ReactionsCallback;
import com.fastaccess.ui.widgets.AvatarLayout;
import com.fastaccess.ui.widgets.FontTextView;
import com.fastaccess.ui.widgets.ForegroundImageView;
import com.fastaccess.ui.widgets.SpannableBuilder;
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
import butterknife.BindView;
@ -247,50 +246,8 @@ public class TimelineCommentsViewHolder extends BaseViewHolder<TimelineModel> {
}
private void appendEmojies(ReactionsModel reaction) {
SpannableBuilder spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsUp()).append(" ")
.append(String.valueOf(reaction.getPlusOne()))
.append(" ");
thumbsUp.setText(spannableBuilder);
thumbsUpReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getThumbsDown()).append(" ")
.append(String.valueOf(reaction.getMinusOne()))
.append(" ");
thumbsDown.setText(spannableBuilder);
thumbsDownReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHooray()).append(" ")
.append(String.valueOf(reaction.getHooray()))
.append(" ");
hurray.setText(spannableBuilder);
hurrayReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getSad()).append(" ")
.append(String.valueOf(reaction.getConfused()))
.append(" ");
sad.setText(spannableBuilder);
sadReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getLaugh()).append(" ")
.append(String.valueOf(reaction.getLaugh()))
.append(" ");
laugh.setText(spannableBuilder);
laughReaction.setText(spannableBuilder);
spannableBuilder = SpannableBuilder.builder()
.append(CommentsHelper.getHeart()).append(" ")
.append(String.valueOf(reaction.getHeart()));
heart.setText(spannableBuilder);
heartReaction.setText(spannableBuilder);
if (reaction.getPlusOne() > 0 || reaction.getMinusOne() > 0
|| reaction.getLaugh() > 0 || reaction.getHooray() > 0
|| reaction.getConfused() > 0 || reaction.getHeart() > 0) {
reactionsList.setVisibility(View.VISIBLE);
reactionsList.setTag(true);
} else {
reactionsList.setVisibility(View.GONE);
reactionsList.setTag(false);
}
CommentsHelper.appendEmojies(reaction, thumbsUp, thumbsUpReaction, thumbsDown, thumbsDownReaction, hurray, hurrayReaction, sad,
sadReaction, laugh, laughReaction, heart, heartReaction, reactionsList);
}
private void onToggle(boolean expanded, boolean animate) {

View File

@ -149,6 +149,7 @@ class MainNavDrawer(val view: BaseActivity<*, *>, private val extraNav: Navigati
}
}
view.findViewById<View>(R.id.donatedIcon).visibility = if (PrefGetter.hasSupported()) View.VISIBLE else View.GONE
view.findViewById<View>(R.id.proTextView).visibility = if (PrefGetter.isProEnabled()) View.VISIBLE else View.GONE
view.findViewById<View>(R.id.navAccHolder).setOnClickListener {
if (extraNav != null && accountsNav != null) {
TransitionManager.beginDelayedTransition(menusHolder ?: extraNav)

View File

@ -3,6 +3,7 @@ package com.fastaccess.ui.modules.main.donation
import android.app.Activity
import android.app.ProgressDialog
import android.os.Bundle
import android.widget.Toast
import com.fastaccess.App
import com.fastaccess.BuildConfig
import com.fastaccess.R
@ -10,6 +11,7 @@ import com.fastaccess.helper.AppHelper
import com.fastaccess.helper.RxHelper
import com.miguelbcr.io.rx_billing_service.RxBillingService
import com.miguelbcr.io.rx_billing_service.entities.ProductType
import es.dmoral.toasty.Toasty
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
@ -26,25 +28,30 @@ class CheckPurchaseActivity : Activity() {
progress = ProgressDialog(this)
.apply {
setMessage(getString(R.string.in_progress))
setOnCancelListener { finishActivity() }
setOnCancelListener { finishActivity(false) }
show()
}
if (AppHelper.isGoogleAvailable(this) && !AppHelper.isEmulator()) {
disposable = RxHelper.getObservable(Observable.fromCallable {
val purchases = RxBillingService.getInstance(this, BuildConfig.DEBUG)
.getPurchases(ProductType.IN_APP)
.toMaybe()
.blockingGet(mutableListOf())
if (!purchases.isEmpty()) {
purchases.filterNotNull()
.map { it.sku() }
.filterNot { !it.isNullOrBlank() }
.onEach { DonateActivity.enableProduct(it, App.getInstance()) }
try {
val purchases = RxBillingService.getInstance(this, BuildConfig.DEBUG)
.getPurchases(ProductType.IN_APP)
.toMaybe()
.blockingGet(mutableListOf())
if (!purchases.isEmpty()) {
purchases.filterNotNull()
.map { it.sku() }
.filterNot { !it.isNullOrBlank() }
.onEach { DonateActivity.enableProduct(it, App.getInstance()) }
return@fromCallable true
}
} catch (e: Exception) {
e.printStackTrace()
}
return@fromCallable true
}).subscribe({ finishActivity() }, { finishActivity() })
return@fromCallable false
}).subscribe({ finishActivity(it) }, { finishActivity(false) })
} else {
finishActivity()
finishActivity(false)
}
}
@ -55,7 +62,8 @@ class CheckPurchaseActivity : Activity() {
override fun onBackPressed() = Unit
private fun finishActivity() {
private fun finishActivity(showMessage: Boolean) {
if (showMessage) Toasty.success(App.getInstance(), getString(R.string.success_purchase_message), Toast.LENGTH_LONG).show()
finish()
}

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/transparent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:rotation="90"
app:lottie_autoPlay="true"
app:lottie_colorFilter="?colorAccent"
app:lottie_fileName="lottie/bounching_ball.json"
app:lottie_loop="true"/>
</LinearLayout>

View File

@ -74,6 +74,17 @@
android:text="@string/app_name"/>
</LinearLayout>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/proTextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:rotation="270"
android:text="PRO"
android:textColor="?colorAccent"
android:visibility="gone"/>
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/navToggle"
android:layout_width="wrap_content"

View File

@ -4,7 +4,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent">
android:layout_gravity="center"
android:background="@color/transparent"
android:gravity="center">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loading"
@ -12,7 +14,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
app:lottie_autoPlay="true"
app:lottie_colorFilter="?colorAccent"
app:lottie_fileName="lottie/bounching_ball.json"
app:lottie_loop="true"/>
</LinearLayout>

View File

@ -131,7 +131,7 @@
android:id="@+id/reactionsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="start"
android:paddingBottom="@dimen/spacing_normal"
android:paddingTop="@dimen/spacing_normal"
android:scrollbarStyle="insideOverlay"

View File

@ -125,12 +125,13 @@
android:id="@+id/reactionsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:layout_marginStart="@dimen/avatar_margin"
android:paddingBottom="@dimen/spacing_normal"
android:paddingTop="@dimen/spacing_normal"
android:scrollbarStyle="insideOverlay"
tools:visibility="visible"
android:visibility="gone">
<LinearLayout

View File

@ -117,7 +117,7 @@
android:id="@+id/reactionsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:layout_marginStart="@dimen/avatar_margin"
android:paddingBottom="@dimen/spacing_normal"