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 #558 and adds open in browser.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Jun 6, 2017
1 parent 6e1c2e5 commit b0cdb7e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static Observable<Gist> getGist(@NonNull String gistId) {
if (!files.isEmpty()) {
FilesListModel filesListModel = files.get(0);
if (!InputHelper.isEmpty(filesListModel.getFilename()) && filesListModel.getFilename().trim().length() > 2) {
spannableBuilder.append(" ").append("/").append(" ")
spannableBuilder.append(" ")
.append(filesListModel.getFilename());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,24 @@ public static Intent createIntent(@NonNull Context context, @NonNull String gist
.show(getSupportFragmentManager(), MessageDialogView.TAG);
}

@OnClick({R.id.startGist, R.id.forkGist}) public void onGistActions(View view) {
view.setEnabled(false);
@OnClick({R.id.startGist, R.id.forkGist, R.id.browser}) public void onGistActions(View view) {
if (getPresenter().getGist() == null) return;
if (view.getId() != R.id.browser) {
view.setEnabled(false);
}
switch (view.getId()) {
case R.id.startGist:
if (getPresenter().getGist() != null) {
GithubActionService.startForGist(this, getPresenter().getGist().getGistId(),
getPresenter().isStarred() ? GithubActionService.UNSTAR_GIST : GithubActionService.STAR_GIST);
getPresenter().onStarGist();
}
GithubActionService.startForGist(this, getPresenter().getGist().getGistId(),
getPresenter().isStarred() ? GithubActionService.UNSTAR_GIST : GithubActionService.STAR_GIST);
getPresenter().onStarGist();
break;
case R.id.forkGist:
if (getPresenter().getGist() != null) {
GithubActionService.startForGist(this, getPresenter().getGist().getGistId(),
GithubActionService.FORK_GIST);
getPresenter().onForkGist();
}
GithubActionService.startForGist(this, getPresenter().getGist().getGistId(),
GithubActionService.FORK_GIST);
getPresenter().onForkGist();
break;
case R.id.browser:
ActivityHelper.startCustomTab(this, getPresenter().getGist().getHtmlUrl());
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/prettifier/pretty/NestedWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr, int

@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent ev) {
boolean returnValue;

MotionEvent event = MotionEvent.obtain(ev);
final int action = MotionEventCompat.getActionMasked(event);
if (action == MotionEvent.ACTION_DOWN) {
Expand Down Expand Up @@ -125,5 +124,7 @@ public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr, int
return mChildHelper.dispatchNestedPreFling(velocityX, velocityY);
}



}

11 changes: 10 additions & 1 deletion app/src/main/java/com/prettifier/pretty/PrettifyWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class PrettifyWebView extends NestedWebView {
private OnContentChangedListener onContentChangedListener;
private boolean interceptTouch;
private boolean enableNestedScrolling;

public interface OnContentChangedListener {
void onContentChanged(int progress);
Expand All @@ -53,7 +54,7 @@ public PrettifyWebView(Context context, AttributeSet attrs, int defStyleAttr) {
initView(attrs);
}

@Override public boolean onInterceptTouchEvent(MotionEvent p_event) {
@Override public boolean onInterceptTouchEvent(MotionEvent p) {
return true;
}

Expand Down Expand Up @@ -174,6 +175,14 @@ public void setInterceptTouch(boolean interceptTouch) {
this.interceptTouch = interceptTouch;
}

public void setEnableNestedScrolling(boolean enableNestedScrolling) {
if (this.enableNestedScrolling != enableNestedScrolling) {
Logger.e(enableNestedScrolling);
setNestedScrollingEnabled(enableNestedScrolling);
this.enableNestedScrolling = enableNestedScrolling;
}
}

private void startActivity(@Nullable Uri url) {
if (url == null) return;
Logger.e(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ public MarkDownInterceptorInterface(PrettifyWebView prettifyWebView) {
@JavascriptInterface public void startIntercept() {
if (prettifyWebView != null) {
prettifyWebView.setInterceptTouch(true);
prettifyWebView.setEnableNestedScrolling(false);
}
}

@JavascriptInterface public void stopIntercept() {
if (prettifyWebView != null) {
prettifyWebView.setInterceptTouch(false);
prettifyWebView.setEnableNestedScrolling(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
android:layout_height="?actionBarSize"
android:background="?colorPrimary">

<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/browser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/open_in_browser"
android:padding="@dimen/spacing_normal"
android:scaleType="centerCrop"
android:src="@drawable/ic_brower"/>

<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/startGist"
android:layout_width="wrap_content"
Expand Down

0 comments on commit b0cdb7e

Please sign in to comment.