mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
changed font to roboto, fixed a bug where the url might be null in viewing code, removed the drawer header elevation, removed the alerter lib and used Toasty instead.
This commit is contained in:
parent
20f9087e6b
commit
c81c2bc1ac
@ -43,7 +43,7 @@
|
||||
- BottomNavigationView for `Fragments` navigation.
|
||||
- UIL for image loading.
|
||||
- AndDown for comments markdown highlighting.
|
||||
- Alerter for displaying error/success messages.
|
||||
- Toasty for displaying error/success messages.
|
||||
- CircleImageView for avatar images.
|
||||
- MatrialTapTargetPrompt for displying guides throughout the app.
|
||||
- Firebase analytics, crash reporting, ads & messaging. (analytics & messaging not yet implemented.)
|
||||
|
||||
@ -116,7 +116,7 @@ dependencies {
|
||||
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
|
||||
compile 'com.annimon:stream:1.1.4'
|
||||
compile 'com.commonsware.cwac:anddown:0.3.0'
|
||||
compile 'com.tapadoo.android:alerter:1.0.1'
|
||||
compile 'com.github.GrenderG:Toasty:1.1.3'
|
||||
compile 'uk.co.samuelwall:material-tap-target-prompt:1.9.2'
|
||||
apt 'org.projectlombok:lombok:1.12.6'
|
||||
apt 'frankiesardo:icepick-processor:3.1.0'
|
||||
|
||||
Binary file not shown.
@ -20,11 +20,11 @@ public class InputHelper {
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String text) {
|
||||
return text == null || TextUtils.isEmpty(text) || isWhiteSpaces(text);
|
||||
return text == null || TextUtils.isEmpty(text) || isWhiteSpaces(text) || text.equalsIgnoreCase("null");
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Object text) {
|
||||
return text == null || TextUtils.isEmpty(text.toString()) || isWhiteSpaces(text.toString());
|
||||
return text == null || isEmpty(text.toString());
|
||||
}
|
||||
|
||||
public static boolean isEmpty(EditText text) {
|
||||
|
||||
@ -198,7 +198,7 @@ public class SchemeParser {
|
||||
fullUrl = "https://raw.githubusercontent.com/" + segments.get(0) + "/" + segments.get(1) + "/" +
|
||||
segments.get(segments.size() - 2) + "/" + uri.getLastPathSegment();
|
||||
}
|
||||
return CodeViewerView.createIntent(context, fullUrl);
|
||||
if (fullUrl != null) return CodeViewerView.createIntent(context, fullUrl);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fastaccess.BuildConfig;
|
||||
import com.fastaccess.R;
|
||||
@ -26,12 +27,12 @@ import com.fastaccess.ui.widgets.dialog.ProgressDialogFragment;
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
import com.google.android.gms.ads.MobileAds;
|
||||
import com.tapadoo.alerter.Alerter;
|
||||
|
||||
import net.grandcentrix.thirtyinch.TiActivity;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import icepick.Icepick;
|
||||
import icepick.State;
|
||||
|
||||
@ -46,6 +47,7 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese
|
||||
@Nullable @BindView(R.id.toolbar) Toolbar toolbar;
|
||||
@Nullable @BindView(R.id.toolbarShadow) View shadowView;
|
||||
@Nullable @BindView(R.id.adView) AdView adView;
|
||||
private Toast toast;
|
||||
|
||||
@LayoutRes protected abstract int layout();
|
||||
|
||||
@ -139,11 +141,11 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese
|
||||
|
||||
@Override public void showMessage(@NonNull String titleRes, @NonNull String msgRes) {
|
||||
hideProgress();
|
||||
Alerter.create(this)
|
||||
.setTitle(titleRes)
|
||||
.setText(msgRes)
|
||||
.setBackgroundColor(titleRes.equals(getString(R.string.error)) ? R.color.material_orange_700 : R.color.material_green_700)
|
||||
.show();
|
||||
if (toast != null) toast.cancel();
|
||||
toast = titleRes.equals(getString(R.string.error))
|
||||
? Toasty.warning(getApplicationContext(), msgRes, Toast.LENGTH_LONG)
|
||||
: Toasty.normal(getApplicationContext(), msgRes, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ public class CodeViewerView extends BaseActivity {
|
||||
@State String url;
|
||||
|
||||
public static void startActivity(@NonNull Context context, @NonNull String url) {
|
||||
context.startActivity(createIntent(context, url));
|
||||
if (!InputHelper.isEmpty(url)) context.startActivity(createIntent(context, url));
|
||||
}
|
||||
|
||||
public static Intent createIntent(@NonNull Context context, @NonNull String url) {
|
||||
|
||||
@ -10,8 +10,10 @@ import com.annimon.stream.Stream;
|
||||
import com.fastaccess.data.dao.EventsModel;
|
||||
import com.fastaccess.data.dao.LoginModel;
|
||||
import com.fastaccess.data.dao.NameParser;
|
||||
import com.fastaccess.data.dao.RepoModel;
|
||||
import com.fastaccess.data.dao.SimpleUrlsModel;
|
||||
import com.fastaccess.data.dao.types.EventsType;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.provider.rest.RestProvider;
|
||||
import com.fastaccess.provider.scheme.SchemeParser;
|
||||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
|
||||
@ -47,7 +49,6 @@ class FeedsPresenter extends BasePresenter<FeedsMvp.View> implements FeedsMvp.Pr
|
||||
if (getCurrentPage() == 1) {
|
||||
manageSubscription(EventsModel.save(response.getItems()).subscribe());
|
||||
eventsModels.clear();
|
||||
|
||||
}
|
||||
eventsModels.addAll(response.getItems());
|
||||
sendToView(FeedsMvp.View::onNotifyAdapter);
|
||||
@ -90,8 +91,10 @@ class FeedsPresenter extends BasePresenter<FeedsMvp.View> implements FeedsMvp.Pr
|
||||
@Override public void onWorkOffline() {
|
||||
if (eventsModels.isEmpty()) {
|
||||
manageSubscription(EventsModel.getEvents().subscribe(modelList -> {
|
||||
eventsModels.addAll(modelList);
|
||||
sendToView(FeedsMvp.View::onNotifyAdapter);
|
||||
if (modelList != null) {
|
||||
eventsModels.addAll(modelList);
|
||||
sendToView(FeedsMvp.View::onNotifyAdapter);
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sendToView(FeedsMvp.View::hideProgress);
|
||||
@ -103,10 +106,13 @@ class FeedsPresenter extends BasePresenter<FeedsMvp.View> implements FeedsMvp.Pr
|
||||
NameParser parser = new NameParser(item.getPayload().getForkee().getHtmlUrl());
|
||||
RepoPagerView.startRepoPager(v.getContext(), parser);
|
||||
} else {
|
||||
if (item.getPayload().getIssue() != null) {
|
||||
if (item.getPayload() != null && item.getPayload().getIssue() != null) {
|
||||
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getIssue().getHtmlUrl()));
|
||||
} else {
|
||||
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getRepo().getName()));
|
||||
RepoModel repoModel = item.getRepo();
|
||||
String name = InputHelper.isEmpty(repoModel.getName()) ? repoModel.getFullName() : repoModel.getName();
|
||||
if (name == null) return;
|
||||
if (item.getRepo() != null) SchemeParser.launchUri(v.getContext(), Uri.parse(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,12 +66,16 @@ public class GistFilesListView extends BaseFragment<GistFilesListMvp.View, GistF
|
||||
}
|
||||
|
||||
@Override public void onOpenFile(@NonNull FilesListModel item) {
|
||||
if (item.getSize() > FileHelper.ONE_MB && !MarkDownProvider.isImage(item.getRawUrl())) {
|
||||
MessageDialogView.newInstance(getString(R.string.big_file), getString(R.string.big_file_description),
|
||||
Bundler.start().put(BundleConstant.EXTRA, item.getRawUrl()).end())
|
||||
.show(getChildFragmentManager(), "MessageDialogView");
|
||||
if (item.getRawUrl() != null) {
|
||||
if (item.getSize() > FileHelper.ONE_MB && !MarkDownProvider.isImage(item.getRawUrl())) {
|
||||
MessageDialogView.newInstance(getString(R.string.big_file), getString(R.string.big_file_description),
|
||||
Bundler.start().put(BundleConstant.EXTRA, item.getRawUrl()).end())
|
||||
.show(getChildFragmentManager(), "MessageDialogView");
|
||||
} else {
|
||||
CodeViewerView.startActivity(getContext(), item.getRawUrl());
|
||||
}
|
||||
} else {
|
||||
CodeViewerView.startActivity(getContext(), item.getRawUrl());
|
||||
showErrorMessage(getString(R.string.no_url));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -56,12 +56,13 @@ public class RepoFilesView extends BaseFragment<RepoFilesMvp.View, RepoFilesPres
|
||||
getParent().onAppendPath(model);
|
||||
}
|
||||
} else {
|
||||
if (model.getSize() > FileHelper.ONE_MB && !MarkDownProvider.isImage(model.getDownloadUrl())) {
|
||||
String url = InputHelper.isEmpty(model.getDownloadUrl()) ? model.getUrl() : model.getDownloadUrl();
|
||||
if (model.getSize() > FileHelper.ONE_MB && !MarkDownProvider.isImage(url)) {
|
||||
MessageDialogView.newInstance(getString(R.string.big_file), getString(R.string.big_file_description),
|
||||
Bundler.start().put(BundleConstant.EXTRA, model.getDownloadUrl()).end())
|
||||
.show(getChildFragmentManager(), "MessageDialogView");
|
||||
} else {
|
||||
CodeViewerView.startActivity(getContext(), model.getDownloadUrl());
|
||||
CodeViewerView.startActivity(getContext(), url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,11 @@ public class SearchCodeView extends BaseFragment<SearchCodeMvp.View, SearchCodeP
|
||||
}
|
||||
|
||||
@Override public void onItemClicked(@NonNull SearchCodeModel item) {
|
||||
CodeViewerView.startActivity(getContext(), item.getUrl());
|
||||
if (item.getUrl() != null) {
|
||||
CodeViewerView.startActivity(getContext(), item.getUrl());
|
||||
} else {
|
||||
showErrorMessage(getString(R.string.no_url));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onRefresh() {
|
||||
|
||||
@ -17,7 +17,6 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.Logger;
|
||||
import com.fastaccess.provider.markdown.MarkDownProvider;
|
||||
import com.fastaccess.provider.scheme.SchemeParser;
|
||||
import com.fastaccess.ui.modules.code.CodeViewerView;
|
||||
@ -148,7 +147,7 @@ public class PrettifyWebView extends NestedWebView {
|
||||
}
|
||||
|
||||
private void startActivity(Uri url) {
|
||||
Logger.e(url);
|
||||
if (url == null) return;
|
||||
if (MarkDownProvider.isImage(url.toString())) {
|
||||
CodeViewerView.startActivity(getContext(), url.toString());
|
||||
} else {
|
||||
|
||||
@ -42,9 +42,4 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:background="@drawable/toolbar_shadow"/>
|
||||
|
||||
</LinearLayout>
|
||||
@ -172,4 +172,5 @@
|
||||
<string name="watch">Watch</string>
|
||||
<string name="watch_hint">Click here to watch/unwatch repo.</string>
|
||||
<string name="fork_repo_hint">Click here to fork repo.</string>
|
||||
<string name="no_url">No url found.</string>
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user