Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
this commit fixes #735 and releases 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kosh committed Jul 16, 2017
1 parent 1bf9e12 commit 7b89d1e
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 159 deletions.
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,8 @@
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.DescriptorSubstitutor
-dontwarn kotlin.reflect.jvm.internal.impl.types.TypeConstructor
-keeppackagenames org.jsoup.nodes
-keeppackagenames org.jsoup.nodes
-keep class com.github.b3er.** { *; }
-keep class com.memoizrlabs.** { *; }
-dontwarn com.github.b3er.**
-dontwarn com.memoizrlabs.**
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
private String body;
@SerializedName("in_reply_to") private Long inReplyTo;
private String path;
private int position;
private int line;
private Integer position;
private Integer line;

public CommentRequestModel() {}

Expand All @@ -40,16 +40,16 @@ public CommentRequestModel() {}
dest.writeString(this.body);
dest.writeValue(this.inReplyTo);
dest.writeString(this.path);
dest.writeInt(this.position);
dest.writeInt(this.line);
dest.writeValue(this.position);
dest.writeValue(this.line);
}

protected CommentRequestModel(Parcel in) {
this.body = in.readString();
this.inReplyTo = (Long) in.readValue(Long.class.getClassLoader());
this.path = in.readString();
this.position = in.readInt();
this.line = in.readInt();
this.position = (Integer) in.readValue(Integer.class.getClassLoader());
this.line = (Integer) in.readValue(Integer.class.getClassLoader());
}

public static final Creator<CommentRequestModel> CREATOR = new Creator<CommentRequestModel>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
boolean addLeft = false;
boolean addRight = false;
int color = TRANSPARENT;
position++;
if (token.startsWith("@@")) {
color = PATCH;
Matcher matcher = HUNK_TITLE.matcher(token.trim());
Expand All @@ -60,16 +59,19 @@
} catch (NumberFormatException e) {e.printStackTrace();}
}
} else if (firstChar == '+') {
position++;
color = ADDITION;
++rightLineNo;
addRight = true;
addLeft = false;
} else if (firstChar == '-') {
position++;
color = DELETION;
++leftLineNo;
addRight = false;
addLeft = true;
} else {
position++;
addLeft = true;
addRight = true;
++rightLineNo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.support.annotation.NonNull;

import com.fastaccess.App;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.RxHelper;

Expand Down Expand Up @@ -114,7 +113,8 @@ public static void logout() {
public static boolean hasNormalLogin() {
return App.getInstance().getDataStore()
.count(Login.class)
.where(Login.IS_ENTERPRISE.eq(false))
.where(Login.IS_ENTERPRISE.eq(false)
.or(Login.IS_ENTERPRISE.isNull()))
.get()
.value() > 0;
}
Expand Down Expand Up @@ -152,7 +152,6 @@ public static Observable<Boolean> onMultipleLogin(@NonNull Login userModel, bool
PrefGetter.setTokenEnterprise(userModel.token);
PrefGetter.setEnterpriseOtpCode(userModel.otpCode);
PrefGetter.setEnterpriseUrl(userModel.enterpriseUrl);
Logger.e(userModel.enterpriseUrl, PrefGetter.getEnterpriseUrl());
} else {
PrefGetter.resetEnterprise();
PrefGetter.setToken(userModel.token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import io.reactivex.Observable;
import io.reactivex.Single;
import io.reactivex.disposables.Disposable;
import io.requery.BlockingEntityStore;
import io.requery.Column;
import io.requery.Convert;
import io.requery.Entity;
import io.requery.Generated;
import io.requery.Key;
import io.requery.Persistable;
import io.requery.reactivex.ReactiveEntityStore;
import lombok.NoArgsConstructor;

import static com.fastaccess.data.dao.model.PinnedRepos.ENTRY_COUNT;
Expand Down Expand Up @@ -90,7 +90,8 @@ public static boolean isPinned(@NonNull String repoFullName) {

@NonNull public static Single<List<PinnedRepos>> getMyPinnedRepos() {
return App.getInstance().getDataStore().select(PinnedRepos.class)
.where(LOGIN.eq(Login.getUser().getLogin()))
.where(LOGIN.eq(Login.getUser().getLogin())
.or(LOGIN.isNull()))
.orderBy(ENTRY_COUNT.desc(), ID.desc())
.get()
.observable()
Expand All @@ -117,15 +118,15 @@ public static void migrateToVersion4() {
e.onComplete();
return;
}
ReactiveEntityStore<Persistable> reactiveEntityStore = App.getInstance().getDataStore();
List<PinnedRepos> pinnedRepos = reactiveEntityStore.toBlocking().select(PinnedRepos.class)
BlockingEntityStore<Persistable> reactiveEntityStore = App.getInstance().getDataStore().toBlocking();
List<PinnedRepos> pinnedRepos = reactiveEntityStore.select(PinnedRepos.class)
.where(LOGIN.isNull())
.get()
.toList();
if (pinnedRepos != null) {
for (PinnedRepos pinnedRepo : pinnedRepos) {
pinnedRepo.setRepoFullName(login.getLogin());
reactiveEntityStore.toBlocking().update(pinnedRepo);
reactiveEntityStore.update(pinnedRepo);
}
}
Logger.e("Hello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class AuthenticationInterceptor : Interceptor {
}
if (!isScrapping) builder.addHeader("User-Agent", "FastHub")
val request = builder.build()
Logger.e(request.headers())
return chain.proceed(request)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ public class PaginationInterceptor implements Interceptor {
}
json += String.format("\"items\":%s}", response.body().string());
return response.newBuilder().body(ResponseBody.create(response.body().contentType(), json)).build();
} else {
} else if (response.header("link") != null) {
String link = response.header("link");
if (link != null) {
String pagination = "";
String[] links = link.split(",");
for (String link1 : links) {
String[] pageLink = link1.split(";");
String page = Uri.parse(pageLink[0].replaceAll("[<>]", "")).getQueryParameter("page");
String rel = pageLink[1].replaceAll("\"", "").replace("rel=", "");
if (page != null) pagination += String.format("\"%s\":\"%s\",", rel.trim(), page);
}
if (!InputHelper.isEmpty(pagination)) {//hacking for search pagination.
String body = response.body().string();
return response.newBuilder().body(ResponseBody.create(response.body().contentType(),
"{" + pagination + body.substring(1, body.length()))).build();
}
String pagination = "";
String[] links = link.split(",");
for (String link1 : links) {
String[] pageLink = link1.split(";");
String page = Uri.parse(pageLink[0].replaceAll("[<>]", "")).getQueryParameter("page");
String rel = pageLink[1].replaceAll("\"", "").replace("rel=", "");
if (page != null) pagination += String.format("\"%s\":\"%s\",", rel.trim(), page);
}
if (!InputHelper.isEmpty(pagination)) {//hacking for search pagination.
String body = response.body().string();
return response.newBuilder().body(ResponseBody.create(response.body().contentType(),
"{" + pagination + body.substring(1, body.length()))).build();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
Expand Down Expand Up @@ -118,4 +119,20 @@ public static String getEnterpriseGistUrl(@NonNull String url, boolean isEnterpr
}
return url;
}

@Nullable public static String getGistId(@NonNull Uri uri) {
String gistId = null;
if (uri.toString().contains("raw/gist")) {
if (uri.getPathSegments().size() > 5) {
gistId = uri.getPathSegments().get(5);
}
} else if (uri.getPathSegments() != null) {
if (TextUtils.equals(LinkParserHelper.HOST_GISTS_RAW, uri.getAuthority())) {
if (uri.getPathSegments().size() > 1) {
gistId = uri.getPathSegments().get(1);
}
}
}
return gistId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.fastaccess.R;
import com.fastaccess.data.dao.CommitLinesModel;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.ViewHelper;
import com.fastaccess.ui.widgets.SpannableBuilder;
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter;
Expand All @@ -25,7 +24,8 @@
public class CommitLinesViewHolder extends BaseViewHolder<CommitLinesModel> {

@BindView(R.id.textView) AppCompatTextView textView;
@BindView(R.id.lineNo) AppCompatTextView lineNo;
@BindView(R.id.leftLinNo) AppCompatTextView leftLinNo;
@BindView(R.id.rightLinNo) AppCompatTextView rightLinNo;
private final int patchAdditionColor;
private final int patchDeletionColor;
private final int patchRefColor;
Expand All @@ -42,10 +42,8 @@ public static CommitLinesViewHolder newInstance(@NonNull ViewGroup viewGroup, @N
}

@Override public void bind(@NonNull CommitLinesModel item) {
lineNo.setText(SpannableBuilder.builder()
.append(item.getLeftLineNo() >= 0 ? item.getLeftLineNo() + "." : "")
.append(item.getRightLineNo() >= 0 ? item.getRightLineNo() + "." : ""));
lineNo.setVisibility(InputHelper.isEmpty(lineNo) ? View.GONE : View.VISIBLE);
leftLinNo.setText(item.getLeftLineNo() > 0 ? String.valueOf(item.getLeftLineNo()) : " ");
rightLinNo.setText(item.getRightLineNo() > 0 ? String.valueOf(item.getRightLineNo()) : " ");
switch (item.getColor()) {
case CommitLinesModel.ADDITION:
textView.setBackgroundColor(patchAdditionColor);
Expand All @@ -54,6 +52,8 @@ public static CommitLinesViewHolder newInstance(@NonNull ViewGroup viewGroup, @N
textView.setBackgroundColor(patchDeletionColor);
break;
case CommitLinesModel.PATCH:
leftLinNo.setVisibility(View.GONE);
rightLinNo.setVisibility(View.GONE);
textView.setBackgroundColor(patchRefColor);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,9 @@ public static Intent createIntent(@NonNull Context context, @NonNull String url,
finish();
return true;
}
String gistId = null;
if (uri.toString().contains("raw/gist")) {
if (uri.getPathSegments().size() > 5) {
gistId = uri.getPathSegments().get(5);
}
} else if (uri.getPathSegments() != null) {
if (uri.getPathSegments().contains("gist")) {
if (uri.getPathSegments() != null && !uri.getPathSegments().isEmpty() && uri.getPathSegments().size() >= 1) {
gistId = uri.getPathSegments().get(1);
}
}
}
String gistId = LinkParserHelper.getGistId(uri);
if (!InputHelper.isEmpty(gistId)) {
GistActivity.createIntent(this, gistId, isEnterprise());
startActivity(GistActivity.createIntent(this, gistId, isEnterprise()));
} else {
RepoFilesActivity.startActivity(this, url, isEnterprise());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public static void start(@NonNull Activity activity, boolean isBasicAuth, boolea
if (savedInstanceState == null) {
if (getIntent() != null && getIntent().getExtras() != null) {
isBasicAuth = getIntent().getExtras().getBoolean(BundleConstant.YES_NO_EXTRA);
password.setHint(isBasicAuth ? getString(R.string.password) : getString(R.string.access_token));
if (getIntent().getExtras().getBoolean(BundleConstant.EXTRA_TWO)) {
onOpenBrowser();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DonateActivity : BaseActivity<BaseMvp.FAView, BasePresenter<BaseMvp.FAView
.purchase(ProductType.IN_APP, productKey, "inapp:com.fastaccess.github:" + productKey))
.subscribe({ p: Purchase?, throwable: Throwable? ->
if (throwable == null) {
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(productKey))
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(productKey).putSuccess(true))
showMessage(R.string.success, R.string.success_purchase_message)
enableProduct(productKey, applicationContext)
val intent = Intent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import android.widget.EditText
import android.widget.FrameLayout
import butterknife.OnClick
import butterknife.OnEditorAction
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.PurchaseEvent
import com.fastaccess.BuildConfig
import com.fastaccess.R
import com.fastaccess.helper.InputHelper
import com.fastaccess.helper.PrefGetter
import com.fastaccess.helper.ViewHelper
import com.fastaccess.ui.base.BaseActivity
import com.fastaccess.ui.modules.main.donation.DonateActivity
import com.fastaccess.ui.widgets.bindView
Expand Down Expand Up @@ -79,6 +83,7 @@ class PremiumActivity : BaseActivity<PremiumMvp.View, PremiumPresenter>(), Premi
}

override fun onSuccessfullyActivated() {
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(InputHelper.toString(editText)).putSuccess(true))
PrefGetter.setProItems()
PrefGetter.setEnterpriseItem()
showMessage(R.string.success, R.string.success)
Expand All @@ -90,6 +95,7 @@ class PremiumActivity : BaseActivity<PremiumMvp.View, PremiumPresenter>(), Premi
}

override fun showProgress(resId: Int) {
ViewHelper.hideKeyboard(editText)
TransitionManager.beginDelayedTransition(viewGroup)
progressLayout.visibility = View.VISIBLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ class ProfileReposPresenter extends BasePresenter<ProfileReposMvp.View> implemen
sendToView(ProfileReposMvp.View::hideProgress);
return;
}
filterOptions.setIsPersonalProfile(TextUtils.equals(currentLoggedIn, username));
makeRestCall(TextUtils.equals(currentLoggedIn, username)
boolean isProfile = TextUtils.equals(currentLoggedIn, username);
filterOptions.setIsPersonalProfile(isProfile);
makeRestCall(isProfile
? RestProvider.getUserService(isEnterprise()).getRepos(filterOptions.getQueryMap(), page)
: RestProvider.getUserService(isEnterprise()).getRepos(parameter, filterOptions.getQueryMap(), page),
repoModelPageable -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static CommitFilesFragment newInstance(@NonNull String sha, @Nullable Com

@Override public void onToggle(long position, boolean isCollapsed) {
if (adapter.getItem((int) position).getCommitFileModel().getPatch() == null) {
ActivityHelper.openChooser(getContext(), adapter.getItem((int) position).getCommitFileModel().getBlobUrl());
ActivityHelper.startCustomTab(getActivity(), adapter.getItem((int) position).getCommitFileModel().getBlobUrl());
}
toggleMap.put(position, isCollapsed);
}
Expand Down
Loading

0 comments on commit 7b89d1e

Please sign in to comment.