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 #552
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed May 28, 2017
1 parent 8a01f94 commit 3be7348
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 87 deletions.
108 changes: 54 additions & 54 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,66 +100,66 @@ repositories {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${supportVersion}"
compile "com.android.support:design:${supportVersion}"
compile "com.android.support:cardview-v7:${supportVersion}"
compile "com.android.support:recyclerview-v7:${supportVersion}"
compile "com.android.support:preference-v14:${supportVersion}"
compile "com.android.support:customtabs:${supportVersion}"
compile "com.android.support:palette-v7:${supportVersion}"
// compile "com.android.support:support-emoji-appcompat:${supportVersion}"
compile "net.grandcentrix.thirtyinch:thirtyinch:${thirtyinchVersion}"
compile "net.grandcentrix.thirtyinch:thirtyinch-rx2:${thirtyinchVersion}"
compile "com.squareup.retrofit2:retrofit:${retrofit}"
compile "com.squareup.retrofit2:converter-gson:${retrofit}"
compile "com.squareup.retrofit2:adapter-rxjava2:${retrofit}"
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'cn.gavinliu.android.lib:ShapedImageView:0.8.3'
compile "frankiesardo:icepick:${icepickVersion}"
compile "com.jakewharton:butterknife:${butterKnifeVersion}"
compile 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1'
compile 'io.reactivex.rxjava2:rxjava:2.0.6'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.annimon:stream:1.1.7'
compile 'com.github.GrenderG:Toasty:1.1.3'
compile 'com.github.JediBurrell:MaterialTapTargetPrompt:-SNAPSHOT'
compile 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
compile 'com.github.daniel-stoneuk:material-about-library:1.8.1'
compile "io.requery:requery:${requery}"
compile "io.requery:requery-android:${requery}"
compile('com.mikepenz:aboutlibraries:5.9.5@aar') { transitive = true }
compile 'com.github.nightwhistler:HtmlSpanner:0.4'
compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.2'
compile 'com.github.matthiasrobbers:shortbread:1.0.1'
compile 'com.atlassian.commonmark:commonmark:0.9.0'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile "com.google.firebase:firebase-ads:${gms}"
compile "com.google.firebase:firebase-messaging:${gms}"
releaseCompile "com.google.firebase:firebase-crash:${gms}"
compile "com.google.android.gms:play-services-auth:${gms}"
compile "com.github.florent37:retrojsoup:${retroJsoup}"
compile "com.github.florent37:rxjsoup:${retroJsoup}"
compile "org.jsoup:jsoup:1.10.2"
// compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlin_version}"
provided "org.projectlombok:lombok:${lombokVersion}"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${supportVersion}"
implementation "com.android.support:design:${supportVersion}"
implementation "com.android.support:cardview-v7:${supportVersion}"
implementation "com.android.support:recyclerview-v7:${supportVersion}"
implementation "com.android.support:preference-v14:${supportVersion}"
implementation "com.android.support:customtabs:${supportVersion}"
implementation "com.android.support:palette-v7:${supportVersion}"
// implementation "com.android.support:support-emoji-appcompat:${supportVersion}"
implementation "net.grandcentrix.thirtyinch:thirtyinch:${thirtyinchVersion}"
implementation "net.grandcentrix.thirtyinch:thirtyinch-rx2:${thirtyinchVersion}"
implementation "com.squareup.retrofit2:retrofit:${retrofit}"
implementation "com.squareup.retrofit2:converter-gson:${retrofit}"
implementation "com.squareup.retrofit2:adapter-rxjava2:${retrofit}"
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'cn.gavinliu.android.lib:ShapedImageView:0.8.3'
implementation "frankiesardo:icepick:${icepickVersion}"
implementation "com.jakewharton:butterknife:${butterKnifeVersion}"
implementation 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:2.0.1-rc1'
implementation 'io.reactivex.rxjava2:rxjava:2.0.7'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.annimon:stream:1.1.7'
implementation 'com.github.GrenderG:Toasty:1.1.3'
implementation 'com.github.JediBurrell:MaterialTapTargetPrompt:-SNAPSHOT'
implementation 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
implementation 'com.github.daniel-stoneuk:material-about-library:1.8.1'
implementation "io.requery:requery:${requery}"
implementation "io.requery:requery-android:${requery}"
implementation('com.mikepenz:aboutlibraries:5.9.5@aar') { transitive = true }
implementation 'com.github.nightwhistler:HtmlSpanner:0.4'
implementation 'net.sourceforge.htmlcleaner:htmlcleaner:2.2'
implementation 'com.github.matthiasrobbers:shortbread:1.0.1'
implementation 'com.atlassian.commonmark:commonmark:0.9.0'
implementation 'com.firebase:firebase-jobdispatcher:0.6.0'
implementation "com.google.firebase:firebase-ads:${gms}"
implementation "com.google.firebase:firebase-messaging:${gms}"
releaseImplementation "com.google.firebase:firebase-crash:${gms}"
implementation "com.google.android.gms:play-services-auth:${gms}"
implementation "com.github.florent37:retrojsoup:${retroJsoup}"
implementation "com.github.florent37:rxjsoup:${retroJsoup}"
implementation "org.jsoup:jsoup:1.10.2"
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlin_version}"
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "com.github.florent37:retrojsoup-compiler:${retroJsoup}"
annotationProcessor "io.requery:requery-processor:${requery}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "frankiesardo:icepick-processor:${icepickVersion}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.0.1'
// testCompile "net.grandcentrix.thirtyinch:thirtyinch-test:$thirtyinchVersion"
testCompile "junit:junit:${junitVersion}"
testCompile "org.mockito:mockito-core:${mockitoVersion}"
testCompile "org.assertj:assertj-core:${assertjVersion}"
androidTestCompile "com.android.support:support-annotations:${supportVersion}"
androidTestCompile "org.mockito:mockito-core:${mockitoVersion}"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile "com.android.support.test.espresso:espresso-intents:${espresseVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-core:${espresseVersion}"
// testImplementation "net.grandcentrix.thirtyinch:thirtyinch-test:$thirtyinchVersion"
testImplementation "junit:junit:${junitVersion}"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.assertj:assertj-core:${assertjVersion}"
androidTestImplementation "com.android.support:support-annotations:${supportVersion}"
androidTestImplementation "org.mockito:mockito-core:${mockitoVersion}"
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test:rules:0.5'
androidTestImplementation "com.android.support.test.espresso:espresso-intents:${espresseVersion}"
androidTestImplementation "com.android.support.test.espresso:espresso-core:${espresseVersion}"
}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static boolean pinUpin(@NonNull Repo repo) {
PinnedRepos pinned = new PinnedRepos();
pinned.setRepoFullName(repo.getFullName());
pinned.setPinnedRepo(repo);
save(pinned).toObservable().blockingFirst(null);
App.getInstance().getDataStore().insert(pinned).blockingGet();
return true;
} else {
delete(pinnedRepos.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fastaccess.helper.Bundler;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.ViewHelper;
import com.fastaccess.provider.timeline.CommentsHelper;
import com.fastaccess.ui.adapter.LabelsAdapter;
import com.fastaccess.ui.adapter.MilestonesAdapter;
import com.fastaccess.ui.adapter.SimpleListAdapter;
Expand All @@ -39,7 +40,8 @@
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
import com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -214,15 +216,22 @@ public static void startActivity(@NonNull Activity context, @NonNull String logi
popupWindow.setElevation(getResources().getDimension(R.dimen.spacing_micro));
popupWindow.setBackgroundDrawable(new ColorDrawable(ViewHelper.getWindowBackground(this)));
popupWindow.setElevation(getResources().getDimension(R.dimen.spacing_normal));
viewHolder.recycler.setAdapter(new SimpleListAdapter<>(Arrays.asList(getResources().getStringArray(R.array.sort_prs_issues)),
new BaseViewHolder.OnItemClickListener<String>() {
@Override public void onItemClick(int position, View v, String item) {
appendSort(item);
}

@Override public void onItemLongClick(int position, View v, String item) {}
}));
AnimHelper.revealPopupWindow(popupWindow, assignee);
ArrayList<String> lists = new ArrayList<>();
Collections.addAll(lists, getResources().getStringArray(R.array.sort_prs_issues));
lists.add(CommentsHelper.getThumbsUp());
lists.add(CommentsHelper.getThumbsDown());
lists.add(CommentsHelper.getLaugh());
lists.add(CommentsHelper.getHooray());
lists.add(CommentsHelper.getSad());
lists.add(CommentsHelper.getHeart());
viewHolder.recycler.setAdapter(new SimpleListAdapter<>(lists, new BaseViewHolder.OnItemClickListener<String>() {
@Override public void onItemClick(int position, View v, String item) {
appendSort(item);
}

@Override public void onItemLongClick(int position, View v, String item) {}
}));
AnimHelper.revealPopupWindow(popupWindow, sort);
}

@Override public void onSetCount(int count, boolean isOpen) {
Expand Down Expand Up @@ -459,6 +468,12 @@ private void appendSort(String item) {
String leastCommentedQuery = "comments-asc";
String recentlyUpdatedQuery = "updated-desc";
String leastRecentUpdatedQuery = "updated-asc";
String sortThumbUp = "reactions-+1-desc";
String sortThumbDown = "reactions--1-desc";
String sortThumbLaugh = "reactions-smile-desc";
String sortThumbHooray = "reactions-tada-desc";
String sortThumbConfused = "reactions-thinking_face-desc";
String sortThumbHeart = "reactions-heart-desc";
String toQuery = "";
String text = InputHelper.toString(searchEditText);
if (item.equalsIgnoreCase(resources.getString(R.string.newest))) {
Expand All @@ -479,6 +494,24 @@ private void appendSort(String item) {
toQuery = recentlyUpdatedQuery;
} else if (item.equalsIgnoreCase(resources.getString(R.string.least_recent_updated))) {
toQuery = leastRecentUpdatedQuery;
} else if (item.equalsIgnoreCase(CommentsHelper.getThumbsUp())) {
toQuery = sortThumbUp;
showMessage(R.string.error, R.string.not_really_working);
} else if (item.equalsIgnoreCase(CommentsHelper.getThumbsDown())) {
toQuery = sortThumbDown;
showMessage(R.string.error, R.string.not_really_working);
} else if (item.equalsIgnoreCase(CommentsHelper.getLaugh())) {
toQuery = sortThumbLaugh;
showMessage(R.string.error, R.string.not_really_working);
} else if (item.equalsIgnoreCase(CommentsHelper.getHooray())) {
toQuery = sortThumbHooray;
showMessage(R.string.error, R.string.not_really_working);
} else if (item.equalsIgnoreCase(CommentsHelper.getSad())) {
toQuery = sortThumbConfused;
showMessage(R.string.error, R.string.not_really_working);
} else if (item.equalsIgnoreCase(CommentsHelper.getHeart())) {
toQuery = sortThumbHeart;
showMessage(R.string.error, R.string.not_really_working);
}
if (!text.replaceAll(regex, "sort:\"" + toQuery + "\"").equalsIgnoreCase(text)) {
String space = text.endsWith(" ") ? "" : " ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fastaccess.data.dao.NameParser;
import com.fastaccess.data.dao.model.AbstractPinnedRepos;
import com.fastaccess.data.dao.model.PinnedRepos;
import com.fastaccess.data.dao.model.Repo;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
import com.fastaccess.ui.modules.repos.RepoPagerActivity;

Expand All @@ -23,10 +22,6 @@ public class PinnedReposPresenter extends BasePresenter<PinnedReposMvp.View> imp
super.onAttachView(view);
if (pinnedRepos.isEmpty()) {
onReload();
if (!AbstractPinnedRepos.isPinned("k0shk0sh/FastHub"))
manageObservable(Repo.getRepo("FastHub", "k0shk0sh")
.map(repo -> repo != null && AbstractPinnedRepos.pinUpin(repo))
.toObservable());
}
}

Expand All @@ -36,7 +31,8 @@ public class PinnedReposPresenter extends BasePresenter<PinnedReposMvp.View> imp

@Override public void onReload() {
manageSubscription(AbstractPinnedRepos.getMyPinnedRepos()
.subscribe(repos -> sendToView(view -> view.onNotifyAdapter(repos))));
.subscribe(repos -> sendToView(view -> view.onNotifyAdapter(repos)), throwable ->
sendToView(view -> view.onNotifyAdapter(null))));
}

@Override public void onItemClick(int position, View v, PinnedRepos item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static Intent createIntent(@NonNull Context context, @NonNull String repo
}
}

@OnLongClick({R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout, R.id.pinLayout}) boolean onLongClick(View view) {
@OnLongClick({R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout}) boolean onLongClick(View view) {
switch (view.getId()) {
case R.id.forkRepoLayout:
RepoMiscDialogFragment.show(getSupportFragmentManager(), getPresenter().login(), getPresenter().repoId(), RepoMiscMVp.FORKS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import butterknife.BindView;
import es.dmoral.toasty.Toasty;
import io.reactivex.disposables.Disposable;

import static android.app.Activity.RESULT_OK;

Expand All @@ -63,6 +64,7 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
private Preference notificationTime;
private Preference notificationRead;
private Preference notificationSound;
private Disposable disposable;

@Override public void onAttach(Context context) {
super.onAttach(context);
Expand Down Expand Up @@ -119,14 +121,14 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
.bold(BuildConfig.VERSION_NAME)
.append(")"));
findPreference("currentVersion").setOnPreferenceClickListener(preference -> {
Release.get("FastHub", "k0shk0sh").subscribe(releases -> {
if (releases.get(0).getTagName().equals(BuildConfig.VERSION_NAME))
Toasty.success(getContext(), getString(R.string.up_to_date)).show();
else
Toasty.warning(getContext(), getString(R.string.new_version)).show();
disposable = Release.get("FastHub", "k0shk0sh").subscribe(releases -> {
if (releases != null) {
if (releases.get(0).getTagName().equals(BuildConfig.VERSION_NAME))
Toasty.success(getContext(), getString(R.string.up_to_date)).show();
else
Toasty.warning(getContext(), getString(R.string.new_version)).show();
}
});


return true;
});
break;
Expand Down Expand Up @@ -249,12 +251,10 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
Map<String, ?> settings = PrefHelper.getAll();
settings.remove("token");
String json = new Gson().toJson(settings);
String path =
Environment.getExternalStorageDirectory() + File.separator + "FastHub";
String path = Environment.getExternalStorageDirectory() + File.separator + "FastHub";
File folder = new File(path);
folder.mkdirs();
File backup = new File(folder, "backup.json");

try {
backup.createNewFile();
FileOutputStream outputStream = new FileOutputStream(backup);
Expand Down Expand Up @@ -323,6 +323,13 @@ else if (entry.getValue().getAsJsonPrimitive().isString())
}
}

@Override public void onDestroyView() {
super.onDestroyView();
if (disposable != null && !disposable.isDisposed()) {
disposable.dispose();
}
}

private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/json");
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_trending.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="?icon_color"
android:pathData="M16,6L18.29,8.29L13.41,13.17L9.41,9.17L2,16.59L3.41,18L9.41,12L13.41,16L19.71,9.71L22,12V6H16Z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:button="@null"
android:drawablePadding="@dimen/spacing_xs_large"
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
android:padding="@dimen/spacing_xs_large"
android:drawablePadding="@dimen/spacing_xs_large"
android:text="@string/last_updated"/>
</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
android:focusableInTouchMode="true"
android:orientation="vertical">

<include layout="@layout/appbar_elevation_dark"/>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/drawer_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
android:id="@+id/pinnedMenu"
android:icon="@drawable/ic_pin_filled"
android:title="@string/pinned"/>

<item
android:id="@+id/trending"
android:icon="@drawable/ic_trending"
android:title="@string/trending"
android:visible="false"/>
<item
android:id="@+id/gists"
android:icon="@drawable/ic_gists"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

<declare-styleable name="ForegroundView">
<attr name="android:foreground"/>
<attr name="android:foregroundInsidePadding"/>
<attr name="android:foregroundGravity"/>
</declare-styleable>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,6 @@
</string>
<string name="edit_banner">CHOOSE BANNER</string>
<string name="image_error">Error loading image, please try again.</string>
<string name="trending">Trending</string>
<string name="not_really_working">Sort by emojies is not really working due to GitHub limitation</string>
</resources>
Loading

0 comments on commit 3be7348

Please sign in to comment.