this commit fixes #558 and adds open in browser.

This commit is contained in:
Kosh 2017-06-06 23:29:40 +08:00
parent 6e1c2e5489
commit b0cdb7eeaf
6 changed files with 40 additions and 15 deletions

View File

@ -172,7 +172,7 @@ import lombok.NoArgsConstructor;
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());
}
}

View File

@ -78,22 +78,24 @@ public class GistActivity extends BaseActivity<GistMvp.View, GistPresenter>
.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;
}
}

View File

@ -42,7 +42,6 @@ public class NestedWebView extends WebView implements NestedScrollingChild {
@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) {
@ -125,5 +124,7 @@ public class NestedWebView extends WebView implements NestedScrollingChild {
return mChildHelper.dispatchNestedPreFling(velocityX, velocityY);
}
}

View File

@ -32,6 +32,7 @@ import com.prettifier.pretty.helper.PrettifyHelper;
public class PrettifyWebView extends NestedWebView {
private OnContentChangedListener onContentChangedListener;
private boolean interceptTouch;
private boolean enableNestedScrolling;
public interface OnContentChangedListener {
void onContentChanged(int progress);
@ -53,7 +54,7 @@ public class PrettifyWebView extends NestedWebView {
initView(attrs);
}
@Override public boolean onInterceptTouchEvent(MotionEvent p_event) {
@Override public boolean onInterceptTouchEvent(MotionEvent p) {
return true;
}
@ -174,6 +175,14 @@ public class PrettifyWebView extends NestedWebView {
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);

View File

@ -18,12 +18,14 @@ public class MarkDownInterceptorInterface {
@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);
}
}
}

View File

@ -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"