mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2026-01-25 14:47:05 +00:00
This commit is contained in:
parent
180c2c9013
commit
0fe7f32f60
@ -9,6 +9,7 @@
|
||||
<uses-permission android:name="com.android.vending.BILLING"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
|
||||
@ -149,7 +149,8 @@ public class SchemeParser {
|
||||
Intent commits = getCommits(context, data, showRepoBtn);
|
||||
Intent blob = getBlob(context, data);
|
||||
Intent label = getLabel(context, data);
|
||||
Optional<Intent> intentOptional = returnNonNull(trending, projects, userIntent, repoIssues, repoPulls,
|
||||
Intent search = getSearchIntent(context, data);
|
||||
Optional<Intent> intentOptional = returnNonNull(trending, projects, search, userIntent, repoIssues, repoPulls,
|
||||
pullRequestIntent, label, commit, commits, createIssueIntent, issueIntent, releasesIntent, repoIntent,
|
||||
repoWikiIntent, blob);
|
||||
Optional<Intent> empty = Optional.empty();
|
||||
@ -267,7 +268,6 @@ public class SchemeParser {
|
||||
return null;
|
||||
}
|
||||
if (issueNumber < 1) return null;
|
||||
Logger.e(commentId);
|
||||
return IssuePagerActivity.createIntent(context, repo, owner, issueNumber, showRepoBtn,
|
||||
LinkParserHelper.isEnterprise(uri.toString()), commentId == null ? 0 : commentId);
|
||||
}
|
||||
@ -463,6 +463,11 @@ public class SchemeParser {
|
||||
if (segments != null && segments.size() == 3 && uri.getLastPathSegment().equalsIgnoreCase("issues")) {
|
||||
String owner = segments.get(0);
|
||||
String repo = segments.get(1);
|
||||
Uri encoded = Uri.parse(uri.toString().replace("utf8=%E2%9C%93&", ""));
|
||||
if (encoded.getQueryParameter("q") != null) {
|
||||
String query = encoded.getQueryParameter("q");
|
||||
return FilterIssuesActivity.getIntent(context, owner, repo, query);
|
||||
}
|
||||
return RepoPagerActivity.createIntent(context, repo, owner, RepoPagerMvp.ISSUES);
|
||||
}
|
||||
return null;
|
||||
@ -473,6 +478,11 @@ public class SchemeParser {
|
||||
if (segments != null && segments.size() == 3 && uri.getLastPathSegment().equalsIgnoreCase("pulls")) {
|
||||
String owner = segments.get(0);
|
||||
String repo = segments.get(1);
|
||||
Uri encoded = Uri.parse(uri.toString().replace("utf8=%E2%9C%93&", ""));
|
||||
if (encoded.getQueryParameter("q") != null) {
|
||||
String query = encoded.getQueryParameter("q");
|
||||
return FilterIssuesActivity.getIntent(context, owner, repo, query);
|
||||
}
|
||||
return RepoPagerActivity.createIntent(context, repo, owner, RepoPagerMvp.PULL_REQUEST);
|
||||
}
|
||||
return null;
|
||||
@ -552,4 +562,17 @@ public class SchemeParser {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable private static Intent getSearchIntent(@NonNull Context context, @NonNull Uri uri) {
|
||||
List<String> segments = uri.getPathSegments();
|
||||
if (segments == null || segments.size() > 1) return null;
|
||||
String search = segments.get(0);
|
||||
if ("search".equalsIgnoreCase(search)) {
|
||||
Uri encoded = Uri.parse(uri.toString().replace("utf8=%E2%9C%93&", ""));
|
||||
String query = encoded.getQueryParameter("q");
|
||||
Logger.e(encoded, query);
|
||||
return SearchActivity.getIntent(context, query);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,15 +38,14 @@ import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
|
||||
if (!PrefGetter.isAutoImageDisabled()) {
|
||||
builder.append("");
|
||||
if (isNull()) return;
|
||||
builder.append("\n");
|
||||
DrawableGetter imageGetter = new DrawableGetter(textView, width);
|
||||
builder.setSpan(new ImageSpan(imageGetter.getDrawable(src)), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(new CenterSpan(), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
appendNewLine(builder);
|
||||
builder.append("\n");
|
||||
} else {
|
||||
builder.append(SpannableBuilder.builder().clickable("Image", v -> {
|
||||
SchemeParser.launchUri(v.getContext(), src);
|
||||
}));
|
||||
appendNewLine(builder);
|
||||
builder.append(SpannableBuilder.builder().clickable("Image", v -> SchemeParser.launchUri(v.getContext(), src)));
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.fastaccess.provider.timeline.handler.drawable;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Html;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -36,8 +37,10 @@ public class DrawableGetter implements Html.ImageGetter, Drawable.Callback {
|
||||
Context context = container.get().getContext();
|
||||
final GenericRequestBuilder load = Glide.with(context)
|
||||
.load(url)
|
||||
.placeholder(ContextCompat.getDrawable(context, R.drawable.ic_image))
|
||||
.dontAnimate();
|
||||
final GlideDrawableTarget target = new GlideDrawableTarget(urlDrawable, container, width);
|
||||
load.override(width, width / 2);
|
||||
load.into(target);
|
||||
cachedTargets.add(target);
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ import com.fastaccess.helper.Bundler
|
||||
import com.fastaccess.helper.InputHelper
|
||||
import com.fastaccess.helper.ViewHelper
|
||||
import com.fastaccess.provider.emoji.Emoji
|
||||
import com.fastaccess.provider.timeline.CommentsHelper
|
||||
import com.fastaccess.ui.base.BaseFragment
|
||||
import com.fastaccess.ui.base.mvp.BaseMvp
|
||||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
|
||||
@ -96,7 +95,7 @@ class CommentEditorFragment : BaseFragment<BaseMvp.FAView, BasePresenter<BaseMvp
|
||||
}
|
||||
markdDownLayout.markdownListener = this
|
||||
if (savedInstanceState == null) {
|
||||
commentText.setText(arguments?.getBundle(BundleConstant.ITEM)?.getString(BundleConstant.EXTRA))
|
||||
arguments?.getBundle(BundleConstant.ITEM)?.getString(BundleConstant.EXTRA)?.let { commentText.setText(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -34,6 +35,8 @@ import butterknife.OnClick;
|
||||
import it.sephiroth.android.library.bottomnavigation.BottomNavigation;
|
||||
import shortbread.Shortcut;
|
||||
|
||||
import static com.fastaccess.helper.AppHelper.getFragmentByTag;
|
||||
|
||||
public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> implements MainMvp.View {
|
||||
|
||||
@State @MainMvp.NavigationType int navType = MainMvp.FEEDS;
|
||||
@ -146,6 +149,29 @@ public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> impl
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override public void onScrollTop(int index) {
|
||||
super.onScrollTop(index);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (index == 0) {
|
||||
FeedsFragment homeView = (FeedsFragment) getFragmentByTag(fragmentManager, FeedsFragment.TAG);
|
||||
if (homeView != null) {
|
||||
homeView.onScrollTop(index);
|
||||
}
|
||||
} else if (index == 1) {
|
||||
MyIssuesPagerFragment issuesView = (MyIssuesPagerFragment) getFragmentByTag
|
||||
(fragmentManager, MyIssuesPagerFragment.TAG);
|
||||
if (issuesView != null) {
|
||||
issuesView.onScrollTop(index);
|
||||
}
|
||||
} else if (index == 2) {
|
||||
MyPullsPagerFragment pullRequestView = (MyPullsPagerFragment) getFragmentByTag
|
||||
(fragmentManager, MyPullsPagerFragment.TAG);
|
||||
if (pullRequestView != null) {
|
||||
pullRequestView.onScrollTop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Shortcut(id = "myIssues", icon = R.drawable.ic_app_shortcut_issues, shortLabelRes = R.string.issues, rank = 2, action = "myIssues")
|
||||
public void myIssues() {}//do nothing
|
||||
|
||||
|
||||
@ -132,5 +132,7 @@ public class MainPresenter extends BasePresenter<MainMvp.View> implements MainMv
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onMenuItemReselect(@IdRes int id, int position, boolean fromUser) {}
|
||||
@Override public void onMenuItemReselect(@IdRes int id, int position, boolean fromUser) {
|
||||
sendToView(view -> view.onScrollTop(position));
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +109,16 @@ public class MyIssuesPagerFragment extends BaseFragment<MyIssuesPagerMvp.View, M
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override public void onScrollTop(int index) {
|
||||
super.onScrollTop(index);
|
||||
if (pager != null && pager.getAdapter() != null) {
|
||||
MyIssuesFragment myIssuesFragment = (MyIssuesFragment) pager.getAdapter().instantiateItem(pager, pager.getCurrentItem());
|
||||
if (myIssuesFragment != null) {
|
||||
myIssuesFragment.onScrollTop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTab(int position, boolean fromViewPager) {
|
||||
if (!fromViewPager) {
|
||||
onShowFilterMenu(getModelAtIndex(position), ViewHelper.getTabTextView(tabs, position));
|
||||
|
||||
@ -109,6 +109,16 @@ public class MyPullsPagerFragment extends BaseFragment<MyPullsPagerMvp.View, MyP
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override public void onScrollTop(int index) {
|
||||
super.onScrollTop(index);
|
||||
if (pager != null && pager.getAdapter() != null) {
|
||||
MyPullRequestFragment myIssuesFragment = (MyPullRequestFragment) pager.getAdapter().instantiateItem(pager, pager.getCurrentItem());
|
||||
if (myIssuesFragment != null) {
|
||||
myIssuesFragment.onScrollTop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTab(int position, boolean fromViewPager) {
|
||||
if (!fromViewPager) {
|
||||
onShowFilterMenu(getModelAtIndex(position), ViewHelper.getTabTextView(tabs, position));
|
||||
|
||||
@ -226,10 +226,10 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
|
||||
String json = new Gson().toJson(preferences);
|
||||
String path = FileHelper.PATH;
|
||||
File folder = new File(path);
|
||||
boolean mkDirs = folder.mkdirs();
|
||||
folder.mkdirs();
|
||||
File backup = new File(folder, "backup.json");
|
||||
try {
|
||||
boolean isCreated = backup.createNewFile();
|
||||
backup.createNewFile();
|
||||
try (FileOutputStream outputStream = new FileOutputStream(backup)) {
|
||||
try (OutputStreamWriter myOutWriter = new OutputStreamWriter(outputStream)) {
|
||||
myOutWriter.append(json);
|
||||
@ -239,6 +239,7 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
|
||||
Log.e(getTag(), "Couldn't backup: " + e.toString());
|
||||
}
|
||||
PrefHelper.set("backed_up", new SimpleDateFormat("MM/dd", Locale.ENGLISH).format(new Date()));
|
||||
Toasty.success(App.getInstance(), getString(R.string.backed_up)).show();
|
||||
} else {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ buildscript {
|
||||
assertjVersion = '2.5.0'
|
||||
espresseVersion = '2.2.2'
|
||||
requery = '1.3.2'
|
||||
kotlin_version = '1.2.0'
|
||||
kotlin_version = '1.2.10'
|
||||
commonmark = '0.10.0'
|
||||
glideVersion = '3.7.0'
|
||||
}
|
||||
@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
|
||||
classpath 'com.android.tools.build:gradle:3.1.0-alpha07'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
classpath 'com.novoda:gradle-build-properties-plugin:0.3'
|
||||
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,7 @@
|
||||
#Thu Dec 28 21:17:34 CET 2017
|
||||
#Sat Jan 06 10:29:07 CET 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-rc-3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
android.enableD8=true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user