mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2026-01-25 14:47:05 +00:00
updated supportLibs, made fabric to be available only on production, fixed readme and other things.
This commit is contained in:
parent
dd86db68af
commit
bb64724959
@ -3,7 +3,7 @@ apply plugin: 'com.apollographql.android'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'com.novoda.build-properties'
|
||||
apply plugin: 'jacoco-android'
|
||||
apply plugin: 'io.fabric'
|
||||
if (isProduction) apply plugin: 'io.fabric'
|
||||
|
||||
buildProperties {
|
||||
notThere {
|
||||
@ -59,7 +59,6 @@ android {
|
||||
}
|
||||
applicationIdSuffix ".debug"
|
||||
versionNameSuffix "-debug"
|
||||
ext.alwaysUpdateBuildId = false
|
||||
}
|
||||
|
||||
}
|
||||
@ -111,7 +110,7 @@ repositories {
|
||||
maven { url "https://clojars.org/repo/" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'https://maven.fabric.io/public' }
|
||||
if (isProduction) maven { url 'https://maven.fabric.io/public' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -157,7 +156,7 @@ dependencies {
|
||||
implementation('com.github.b3er.rxfirebase:firebase-database-kotlin:11.2.0') { transitive = false }
|
||||
implementation('com.github.b3er.rxfirebase:firebase-database:11.2.0') { transitive = false }
|
||||
implementation 'com.firebase:firebase-jobdispatcher:0.7.0'
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true }
|
||||
if (isProduction) implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true }
|
||||
implementation "com.github.miguelbcr:RxBillingService:0.0.3"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||
implementation 'org.jsoup:jsoup:1.10.2'
|
||||
|
||||
@ -5,18 +5,15 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import com.apollographql.apollo.ApolloClient;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.core.CrashlyticsCore;
|
||||
import com.fastaccess.data.dao.model.Models;
|
||||
import com.fastaccess.helper.DeviceNameGetter;
|
||||
import com.fastaccess.helper.TypeFaceHelper;
|
||||
import com.fastaccess.provider.colors.ColorsProvider;
|
||||
import com.fastaccess.provider.emoji.EmojiManager;
|
||||
import com.fastaccess.provider.fabric.FabricProvider;
|
||||
import com.fastaccess.provider.rest.RestProvider;
|
||||
import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask;
|
||||
import com.miguelbcr.io.rx_billing_service.RxBillingService;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.requery.Persistable;
|
||||
import io.requery.android.sqlite.DatabaseSource;
|
||||
import io.requery.meta.EntityModel;
|
||||
@ -48,7 +45,7 @@ public class App extends Application {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
initFabric();
|
||||
FabricProvider.initFabric(this);
|
||||
RxBillingService.register(this);
|
||||
deleteDatabase("database.db");
|
||||
getDataStore();//init requery before anything.
|
||||
@ -61,16 +58,6 @@ public class App extends Application {
|
||||
DeviceNameGetter.getInstance().loadDevice();
|
||||
}
|
||||
|
||||
private void initFabric() {
|
||||
Fabric fabric = new Fabric.Builder(this)
|
||||
.kits(new Crashlytics.Builder()
|
||||
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
|
||||
.build())
|
||||
.debuggable(BuildConfig.DEBUG)
|
||||
.build();
|
||||
Fabric.with(fabric);
|
||||
}
|
||||
|
||||
private void setupPreference() {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.fasthub_settings, false);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.about_settings, false);
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package com.fastaccess.provider.fabric;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Created by kosh on 14/08/2017.
|
||||
*/
|
||||
|
||||
public class FabricProvider {
|
||||
|
||||
public static void initFabric(@NonNull Context context) {}//DO NOTHING IN DEBUG
|
||||
|
||||
public static void logPurchase(@NonNull String productKey) {}//DO NOTHING IN DEBUG
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class MarkDownProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static String stripHtml(String html) {
|
||||
public static String stripHtml(String html) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
} else {
|
||||
@ -315,26 +315,4 @@ public class MarkDownProvider {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class IndentedCodeBlockNodeRenderer implements NodeRenderer {
|
||||
|
||||
private final HtmlWriter html;
|
||||
|
||||
IndentedCodeBlockNodeRenderer(HtmlNodeRendererContext context) {
|
||||
this.html = context.getWriter();
|
||||
}
|
||||
|
||||
@Override public Set<Class<? extends Node>> getNodeTypes() {
|
||||
return Collections.singleton(IndentedCodeBlock.class);
|
||||
}
|
||||
|
||||
@Override public void render(Node node) {
|
||||
IndentedCodeBlock codeBlock = (IndentedCodeBlock) node;
|
||||
html.line();
|
||||
html.tag("pre");
|
||||
html.text(codeBlock.getLiteral());
|
||||
html.tag("/pre");
|
||||
html.line();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +58,7 @@ public class RestProvider {
|
||||
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
||||
.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
|
||||
.setDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
.disableHtmlEscaping()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
|
||||
@ -7,14 +7,24 @@ import com.fastaccess.helper.InputHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class PaginationInterceptor implements Interceptor {
|
||||
|
||||
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Response response = chain.proceed(chain.request());
|
||||
Request request = chain.request();
|
||||
Response response = chain.proceed(request);
|
||||
Headers headers = chain.request().headers();
|
||||
if (headers != null) {
|
||||
if ((headers.values("Accept").contains("application/vnd.github.html") ||
|
||||
headers.values("Accept").contains("application/vnd.github.VERSION.raw"))) {
|
||||
return response;//return them as they are.
|
||||
}
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
if (response.peekBody(1).string().equals("[")) {
|
||||
String json = "{";
|
||||
|
||||
@ -9,7 +9,8 @@ import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder
|
||||
/**
|
||||
* Created by Kosh on 09 Jul 2017, 5:00 PM
|
||||
*/
|
||||
class LoginAdapter constructor(private val small: Boolean = false) : BaseRecyclerAdapter<Login, LoginViewHolder, BaseViewHolder.OnItemClickListener<Login>>() {
|
||||
class LoginAdapter constructor(private val small: Boolean = false)
|
||||
: BaseRecyclerAdapter<Login, LoginViewHolder, BaseViewHolder.OnItemClickListener<Login>>() {
|
||||
|
||||
override fun onBindView(holder: LoginViewHolder, position: Int) {
|
||||
holder.bind(getItem(position))
|
||||
|
||||
@ -5,6 +5,7 @@ import com.fastaccess.ui.adapter.viewholder.ProfilePinnedReposViewHolder
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder
|
||||
import pr.GetPinnedReposQuery
|
||||
import java.text.NumberFormat
|
||||
|
||||
/**
|
||||
* Created by kosh on 09/08/2017.
|
||||
@ -13,12 +14,14 @@ import pr.GetPinnedReposQuery
|
||||
class ProfilePinnedReposAdapter(data: List<GetPinnedReposQuery.Node>) : BaseRecyclerAdapter<GetPinnedReposQuery.Node,
|
||||
ProfilePinnedReposViewHolder, BaseViewHolder.OnItemClickListener<GetPinnedReposQuery.Node>>(data) {
|
||||
|
||||
val numberFormat = NumberFormat.getNumberInstance()
|
||||
|
||||
override fun viewHolder(parent: ViewGroup, viewType: Int): ProfilePinnedReposViewHolder {
|
||||
return ProfilePinnedReposViewHolder.newInstance(parent, this)
|
||||
}
|
||||
|
||||
override fun onBindView(holder: ProfilePinnedReposViewHolder, position: Int) {
|
||||
holder.bind(data[position])
|
||||
holder.bind(data[position], numberFormat)
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,7 +11,6 @@ import com.fastaccess.helper.AppHelper;
|
||||
import com.fastaccess.helper.ViewHelper;
|
||||
import com.fastaccess.ui.adapter.viewholder.SimpleViewHolder;
|
||||
import com.fastaccess.ui.modules.search.SearchActivity;
|
||||
import com.fastaccess.ui.widgets.FontTextView;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
|
||||
|
||||
@ -39,10 +38,10 @@ public class TopicsAdapter extends BaseRecyclerAdapter<String, SimpleViewHolder<
|
||||
if (isLightTheme) {
|
||||
holder.itemView.setBackgroundColor(cardBackground);
|
||||
}
|
||||
String item = getItem(position);
|
||||
holder.itemView.setOnClickListener((view) -> {
|
||||
FontTextView topic = (FontTextView) view;
|
||||
Intent intent = new Intent(new Intent(App.getInstance().getApplicationContext(), SearchActivity.class));
|
||||
intent.putExtra("search", topic.getText().toString());
|
||||
intent.putExtra("search", "topic:\"" + item + "\"");
|
||||
view.getContext().startActivity(intent);
|
||||
});
|
||||
holder.bind(getItem(position));
|
||||
|
||||
@ -19,7 +19,7 @@ import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder
|
||||
class LoginViewHolder private constructor(itemView: View, adapter: BaseRecyclerAdapter<*, *, *>?) :
|
||||
BaseViewHolder<Login>(itemView, adapter) {
|
||||
|
||||
val avatarLayout: AvatarLayout? by lazy { itemView.findViewById<AvatarLayout>(R.id.avatarLayout) as AvatarLayout }
|
||||
val avatarLayout: AvatarLayout? by lazy { itemView.findViewById<AvatarLayout>(R.id.avatarLayout) as AvatarLayout? }
|
||||
@BindView(R.id.title) lateinit var title: FontTextView
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
||||
@ -9,6 +9,7 @@ import com.fastaccess.ui.widgets.FontTextView
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder
|
||||
import pr.GetPinnedReposQuery
|
||||
import java.text.NumberFormat
|
||||
|
||||
/**
|
||||
* Created by kosh on 09/08/2017.
|
||||
@ -23,12 +24,20 @@ class ProfilePinnedReposViewHolder private constructor(view: View, adapter: Base
|
||||
@BindView(R.id.stars) lateinit var stars: FontTextView
|
||||
@BindView(R.id.forks) lateinit var forks: FontTextView
|
||||
|
||||
override fun bind(t: GetPinnedReposQuery.Node) {
|
||||
override fun bind(t: GetPinnedReposQuery.Node) {}
|
||||
|
||||
companion object {
|
||||
fun newInstance(parent: ViewGroup, adapter: BaseRecyclerAdapter<*, *, *>): ProfilePinnedReposViewHolder {
|
||||
return ProfilePinnedReposViewHolder(getView(parent, R.layout.profile_pinned_repo_row_item), adapter)
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(t: GetPinnedReposQuery.Node, numberFormat: NumberFormat) {
|
||||
title.text = t.name()
|
||||
issues.text = "${t.issues().totalCount()}"
|
||||
pullRequest.text = "${t.pullRequests().totalCount()}"
|
||||
forks.text = "${t.forks().totalCount()}"
|
||||
stars.text = "${t.stargazers().totalCount()}"
|
||||
issues.text = numberFormat.format(t.issues().totalCount())
|
||||
pullRequest.text = numberFormat.format(t.pullRequests().totalCount())
|
||||
forks.text = numberFormat.format(t.forks().totalCount())
|
||||
stars.text = numberFormat.format(t.stargazers().totalCount())
|
||||
t.primaryLanguage()?.let {
|
||||
language.text = it.name()
|
||||
it.color()?.let {
|
||||
@ -41,10 +50,4 @@ class ProfilePinnedReposViewHolder private constructor(view: View, adapter: Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(parent: ViewGroup, adapter: BaseRecyclerAdapter<*, *, *>): ProfilePinnedReposViewHolder {
|
||||
return ProfilePinnedReposViewHolder(getView(parent, R.layout.profile_pinned_repo_row_item), adapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ import android.widget.TextView
|
||||
import com.fastaccess.R
|
||||
import com.fastaccess.data.dao.model.Login
|
||||
import com.fastaccess.data.dao.model.PinnedRepos
|
||||
import com.fastaccess.helper.Logger
|
||||
import com.fastaccess.helper.PrefGetter
|
||||
import com.fastaccess.helper.RxHelper
|
||||
import com.fastaccess.provider.scheme.SchemeParser
|
||||
@ -114,13 +115,12 @@ class MainNavDrawer(val view: BaseActivity<*, *>, private val extraNav: Navigati
|
||||
val adapter = LoginAdapter(true)
|
||||
view.getPresenter().manageViewDisposable(Login.getAccounts()
|
||||
.doOnComplete {
|
||||
when (!adapter.isEmpty) {
|
||||
true -> {
|
||||
toggleAccountsLayout.visibility = View.VISIBLE
|
||||
adapter.listener = this
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
else -> toggleAccountsLayout.visibility = View.GONE
|
||||
if (!adapter.isEmpty) {
|
||||
toggleAccountsLayout.visibility = View.VISIBLE
|
||||
adapter.listener = this
|
||||
recyclerView.adapter = adapter
|
||||
} else {
|
||||
toggleAccountsLayout.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
.subscribe({ adapter.addItem(it) }, ::print))
|
||||
|
||||
@ -5,11 +5,10 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import com.crashlytics.android.answers.Answers
|
||||
import com.crashlytics.android.answers.PurchaseEvent
|
||||
import com.fastaccess.BuildConfig
|
||||
import com.fastaccess.R
|
||||
import com.fastaccess.helper.*
|
||||
import com.fastaccess.provider.fabric.FabricProvider
|
||||
import com.fastaccess.ui.base.BaseActivity
|
||||
import com.fastaccess.ui.base.mvp.BaseMvp
|
||||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
|
||||
@ -46,7 +45,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).putSuccess(true))
|
||||
FabricProvider.logPurchase(productKey)
|
||||
showMessage(R.string.success, R.string.success_purchase_message)
|
||||
enableProduct(productKey, applicationContext)
|
||||
val intent = Intent()
|
||||
|
||||
@ -10,14 +10,13 @@ import android.widget.FrameLayout
|
||||
import butterknife.BindView
|
||||
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.AppHelper
|
||||
import com.fastaccess.helper.InputHelper
|
||||
import com.fastaccess.helper.PrefGetter
|
||||
import com.fastaccess.helper.ViewHelper
|
||||
import com.fastaccess.provider.fabric.FabricProvider
|
||||
import com.fastaccess.ui.base.BaseActivity
|
||||
import com.fastaccess.ui.modules.main.donation.DonateActivity
|
||||
|
||||
@ -88,7 +87,7 @@ class PremiumActivity : BaseActivity<PremiumMvp.View, PremiumPresenter>(), Premi
|
||||
}
|
||||
|
||||
override fun onSuccessfullyActivated() {
|
||||
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(InputHelper.toString(editText)).putSuccess(true))
|
||||
FabricProvider.logPurchase(InputHelper.toString(editText))
|
||||
PrefGetter.setProItems()
|
||||
PrefGetter.setEnterpriseItem()
|
||||
showMessage(R.string.success, R.string.success)
|
||||
|
||||
@ -17,7 +17,6 @@ import com.fastaccess.helper.ActivityHelper;
|
||||
import com.fastaccess.helper.BundleConstant;
|
||||
import com.fastaccess.helper.Bundler;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.Logger;
|
||||
import com.fastaccess.helper.PrefGetter;
|
||||
import com.fastaccess.ui.base.BaseFragment;
|
||||
import com.fastaccess.ui.widgets.StateLayout;
|
||||
@ -71,10 +70,10 @@ public class ViewerFragment extends BaseFragment<ViewerMvp.View, ViewerPresenter
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override public void onSetMdText(@NonNull String text, String baseUrl) {
|
||||
@Override public void onSetMdText(@NonNull String text, String baseUrl, boolean replace) {
|
||||
webView.setVisibility(View.VISIBLE);
|
||||
loader.setIndeterminate(false);
|
||||
webView.setGithubContent(text, baseUrl);
|
||||
webView.setGithubContentWithReplace(text, baseUrl, replace);
|
||||
webView.setOnContentChangedListener(this);
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
@ -155,7 +154,7 @@ public class ViewerFragment extends BaseFragment<ViewerMvp.View, ViewerPresenter
|
||||
@Override public void onScrollChanged(boolean reachedTop, int scroll) {
|
||||
if (getPresenter().isRepo()) {
|
||||
if (appBarLayout != null && bottomNavigation != null) {
|
||||
if (scroll <= (appBarLayout.getTotalScrollRange() / 2)) {
|
||||
if (scroll <= (appBarLayout.getTotalScrollRange() / 2) && !scrolledTop) {
|
||||
scrolledTop = true;
|
||||
bottomNavigation.setExpanded(true, true);
|
||||
appBarLayout.setExpanded(true, true);
|
||||
@ -179,7 +178,7 @@ public class ViewerFragment extends BaseFragment<ViewerMvp.View, ViewerPresenter
|
||||
getPresenter().onHandleIntent(getArguments());
|
||||
} else {
|
||||
if (getPresenter().isMarkDown()) {
|
||||
onSetMdText(getPresenter().downloadedStream(), getPresenter().url());
|
||||
onSetMdText(getPresenter().downloadedStream(), getPresenter().url(), false);
|
||||
} else {
|
||||
onSetCode(getPresenter().downloadedStream());
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ interface ViewerMvp {
|
||||
|
||||
void onSetImageUrl(@NonNull String url);
|
||||
|
||||
void onSetMdText(@NonNull String text, String baseUrl);
|
||||
void onSetMdText(@NonNull String text, String baseUrl, boolean replace);
|
||||
|
||||
void onSetCode(@NonNull String text);
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ class ViewerPresenter extends BasePresenter<ViewerMvp.View> implements ViewerMvp
|
||||
isMarkdown = fileModel.isMarkdown();
|
||||
sendToView(view -> {
|
||||
if (isRepo || isMarkdown) {
|
||||
view.onSetMdText(downloadedStream, fileModel.getFullUrl());
|
||||
view.onSetMdText(downloadedStream, fileModel.getFullUrl(), false);
|
||||
} else {
|
||||
view.onSetCode(downloadedStream);
|
||||
}
|
||||
@ -110,8 +110,8 @@ class ViewerPresenter extends BasePresenter<ViewerMvp.View> implements ViewerMvp
|
||||
Observable<String> streamObservable = MarkDownProvider.isMarkdown(url)
|
||||
? RestProvider.getRepoService(isEnterprise()).getFileAsHtmlStream(url)
|
||||
: RestProvider.getRepoService(isEnterprise()).getFileAsStream(url);
|
||||
makeRestCall(isRepo ? RestProvider.getRepoService(isEnterprise()).getReadmeHtml(url)
|
||||
: streamObservable, content -> {
|
||||
Observable<String> observable = isRepo ? RestProvider.getRepoService(isEnterprise()).getReadmeHtml(url) : streamObservable;
|
||||
makeRestCall(observable, content -> {
|
||||
downloadedStream = content;
|
||||
ViewerFile fileModel = new ViewerFile();
|
||||
fileModel.setContent(downloadedStream);
|
||||
@ -121,7 +121,7 @@ class ViewerPresenter extends BasePresenter<ViewerMvp.View> implements ViewerMvp
|
||||
fileModel.setMarkdown(true);
|
||||
isMarkdown = true;
|
||||
isRepo = true;
|
||||
sendToView(view -> view.onSetMdText(downloadedStream, htmlUrl == null ? url : htmlUrl));
|
||||
sendToView(view -> view.onSetMdText(downloadedStream, htmlUrl == null ? url : htmlUrl, false));
|
||||
} else {
|
||||
isMarkdown = MarkDownProvider.isMarkdown(url);
|
||||
if (isMarkdown) {
|
||||
@ -141,7 +141,7 @@ class ViewerPresenter extends BasePresenter<ViewerMvp.View> implements ViewerMvp
|
||||
fileModel.setMarkdown(true);
|
||||
fileModel.setContent(downloadedStream);
|
||||
manageObservable(fileModel.save(fileModel).toObservable());
|
||||
sendToView(view -> view.onSetMdText(downloadedStream, htmlUrl == null ? url : htmlUrl));
|
||||
sendToView(view -> view.onSetMdText(downloadedStream, htmlUrl == null ? url : htmlUrl, true));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ class RepoLicenseBottomSheet : BaseMvpBottomSheetDialogFragment<RepoLicenseMvp.V
|
||||
loader.isIndeterminate = false
|
||||
val licenseText = license.replace("<pre>", "<pre style='overflow: hidden;word-wrap:break-word;word-break:break-all;" +
|
||||
"white-space:pre-line;'>")
|
||||
webView.setGithubContent("<div class='markdown-body'>$licenseText</div>", null)
|
||||
webView.setGithubContent("<div class='markdown-body'>$licenseText</div>", null, false)
|
||||
} else {
|
||||
hideProgress()
|
||||
}
|
||||
|
||||
@ -170,8 +170,11 @@ public class PrettifyWebView extends NestedWebView {
|
||||
return lineNo;
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl) {
|
||||
public void setGithubContentWithReplace(@NonNull String source, @Nullable String baseUrl, boolean replace) {
|
||||
setGithubContent(source, baseUrl, false);
|
||||
addJavascriptInterface(new MarkDownInterceptorInterface(this, false), "Android");
|
||||
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()), false, replace);
|
||||
post(() -> loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null));
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean toggleNestScrolling) {
|
||||
@ -180,13 +183,15 @@ public class PrettifyWebView extends NestedWebView {
|
||||
|
||||
public void setWikiContent(@NonNull String source, @Nullable String baseUrl) {
|
||||
addJavascriptInterface(new MarkDownInterceptorInterface(this, true), "Android");
|
||||
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()), true);
|
||||
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()), AppHelper.isNightMode
|
||||
(getResources()), true);
|
||||
post(() -> loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null));
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean toggleNestScrolling, boolean enableBridge) {
|
||||
if (enableBridge) addJavascriptInterface(new MarkDownInterceptorInterface(this, toggleNestScrolling), "Android");
|
||||
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()), false);
|
||||
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()),
|
||||
AppHelper.isNightMode(getResources()), false);
|
||||
post(() -> loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null));
|
||||
}
|
||||
|
||||
|
||||
@ -23,11 +23,11 @@ import java.util.ArrayList;
|
||||
public class GithubHelper {
|
||||
|
||||
@NonNull public static String generateContent(@NonNull Context context, @NonNull String source,
|
||||
@Nullable String baseUrl, boolean dark, boolean isWiki) {
|
||||
@Nullable String baseUrl, boolean dark, boolean isWiki, boolean replace) {
|
||||
if (baseUrl == null) {
|
||||
return mergeContent(context, source, dark);
|
||||
return mergeContent(context, source, dark, replace);
|
||||
} else {
|
||||
return mergeContent(context, parseReadme(source, baseUrl, isWiki), dark);
|
||||
return mergeContent(context, parseReadme(source, baseUrl, isWiki), dark, replace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,9 +58,7 @@ public class GithubHelper {
|
||||
|
||||
@NonNull private static String getParsedHtml(@NonNull String source, String owner, String repoName,
|
||||
String builder, String baseLinkUrl, boolean isWiki) {
|
||||
Document document = Jsoup.parse(source
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">"), "");
|
||||
Document document = Jsoup.parse(source, "");
|
||||
Elements imageElements = document.getElementsByTag("img");
|
||||
if (imageElements != null && !imageElements.isEmpty()) {
|
||||
for (Element element : imageElements) {
|
||||
@ -112,7 +110,7 @@ public class GithubHelper {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@NonNull private static String mergeContent(@NonNull Context context, @NonNull String source, boolean dark) {
|
||||
@NonNull private static String mergeContent(@NonNull Context context, @NonNull String source, boolean dark, boolean replace) {
|
||||
return "<html>\n" +
|
||||
"\n" +
|
||||
"<head>\n" +
|
||||
@ -123,8 +121,7 @@ public class GithubHelper {
|
||||
" <script src=\"./intercept-hash.js\"></script>\n" +
|
||||
"</head>\n" +
|
||||
"\n" +
|
||||
"<body>\n" +
|
||||
source +
|
||||
"<body>\n" + (replace ? source.replaceAll("<", "<").replaceAll(">", ">") : source) +
|
||||
"\n<script src=\"./intercept-touch.js\"></script>\n" +
|
||||
"</body>\n" +
|
||||
"\n" +
|
||||
|
||||
@ -19,17 +19,15 @@
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/emojiesList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:scrollbarStyle="insideOverlay">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.fastaccess.ui.widgets.FontTextView
|
||||
android:id="@+id/thumbsUp"
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.fastaccess.provider.fabric;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.fastaccess.BuildConfig;
|
||||
|
||||
/**
|
||||
* Created by kosh on 14/08/2017.
|
||||
*/
|
||||
|
||||
public class FabricProvider {
|
||||
|
||||
public static void initFabric(@NonNull Context context) {
|
||||
Fabric fabric = new Fabric.Builder(context)
|
||||
.kits(new Crashlytics.Builder()
|
||||
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
|
||||
.build())
|
||||
.debuggable(BuildConfig.DEBUG)
|
||||
.build();
|
||||
Fabric.with(fabric);
|
||||
}
|
||||
|
||||
public static void logPurchase(@NonNull String productKey) {
|
||||
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(productKey).putSuccess(true));
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext {
|
||||
taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
|
||||
isProduction = taskRequests.toLowerCase().contains("release")
|
||||
butterKnifeVersion = '8.5.1'
|
||||
state_version = '1.1.0'
|
||||
lombokVersion = '1.12.6'
|
||||
supportVersion = "26.0.0"
|
||||
supportVersion = "26.0.1"
|
||||
gms = "11.0.4"
|
||||
thirtyinchVersion = '0.8.0'
|
||||
retrofit = '2.3.0'
|
||||
@ -26,7 +28,7 @@ buildscript {
|
||||
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'
|
||||
classpath 'io.fabric.tools:gradle:1.22.2'
|
||||
if (isProduction) classpath 'io.fabric.tools:gradle:1.22.2'
|
||||
classpath 'com.apollographql.apollo:gradle-plugin:0.4.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user