Skip to content
Snippets Groups Projects
Commit 21609601 authored by John Carlson's avatar John Carlson
Browse files

Anywhere where there might be internal links, keep em internal

parent 299fa07f
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -286,7 +286,7 @@ public class ProjectFragment extends ButterKnifeFragment {
mEventReceiver = new EventReceiver();
App.bus().register(mEventReceiver);
 
mOverviewVew.setMovementMethod(new InternalLinkMovementMethod(getActivity(), App.instance().getAccount().getServerUrl()));
mOverviewVew.setMovementMethod(new InternalLinkMovementMethod(App.instance().getAccount().getServerUrl()));
 
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@ package com.commit451.gitlab.navigation;
 
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
Loading
Loading
@@ -260,4 +261,14 @@ public class Navigator {
IntentUtil.openPage(activity, uri.toString());
}
}
/**
* Like {@link #navigateToUrl(Activity, Uri, Account)} but we already know it is the same server
* @param context context
* @param uri uri
*/
public static void navigateToUrl(Context context, Uri uri) {
Timber.d("navigateToUrl: %s", uri);
context.startActivity(DeepLinker.generateDeeplinkIntentFromUri(context, uri));
}
}
package com.commit451.gitlab.util;
 
 
import android.app.Activity;
import android.net.Uri;
import android.text.Layout;
import android.text.method.LinkMovementMethod;
Loading
Loading
@@ -9,7 +8,6 @@ import android.text.style.URLSpan;
import android.view.MotionEvent;
import android.widget.TextView;
 
import com.commit451.gitlab.App;
import com.commit451.gitlab.navigation.Navigator;
 
import timber.log.Timber;
Loading
Loading
@@ -19,12 +17,9 @@ import timber.log.Timber;
*/
public class InternalLinkMovementMethod extends LinkMovementMethod {
 
//I hate this
private Activity mActivity;
private Uri mServerUrl;
 
public InternalLinkMovementMethod(Activity activity, Uri serverUrl) {
mActivity = activity;
public InternalLinkMovementMethod(Uri serverUrl) {
mServerUrl = serverUrl;
}
 
Loading
Loading
@@ -51,7 +46,7 @@ public class InternalLinkMovementMethod extends LinkMovementMethod {
String url = link[0].getURL();
if (url.startsWith(mServerUrl.toString())) {
Timber.d("Looks like an internal server link: %s", url);
Navigator.navigateToUrl(mActivity, Uri.parse(url), App.instance().getAccount());
Navigator.navigateToUrl(widget.getContext(), Uri.parse(url));
return true;
}
return super.onTouchEvent(widget, buffer, event);
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ package com.commit451.gitlab.viewHolder;
 
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Loading
Loading
@@ -18,6 +17,7 @@ import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.BypassImageGetterFactory;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
import com.commit451.gitlab.util.InternalLinkMovementMethod;
import com.vdurmont.emoji.EmojiParser;
 
import butterknife.BindView;
Loading
Loading
@@ -62,7 +62,7 @@ public class IssueHeaderViewHolder extends RecyclerView.ViewHolder {
String description = issue.getDescription();
description = EmojiParser.parseToUnicode(description);
mDescriptionView.setText(mBypass.markdownToSpannable(description, getter));
mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
mDescriptionView.setMovementMethod(new InternalLinkMovementMethod(App.instance().getAccount().getServerUrl()));
}
 
App.instance().getPicasso()
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ package com.commit451.gitlab.viewHolder;
 
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Loading
Loading
@@ -17,6 +16,7 @@ import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.BypassImageGetterFactory;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
import com.commit451.gitlab.util.InternalLinkMovementMethod;
import com.vdurmont.emoji.EmojiParser;
 
import butterknife.BindView;
Loading
Loading
@@ -58,7 +58,7 @@ public class MergeRequestHeaderViewHolder extends RecyclerView.ViewHolder {
App.instance().getPicasso(),
App.instance().getAccount().getServerUrl().toString(),
project)));
mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
mDescriptionView.setMovementMethod(new InternalLinkMovementMethod(App.instance().getAccount().getServerUrl()));
}
 
App.instance().getPicasso()
Loading
Loading
package com.commit451.gitlab.viewHolder;
 
import android.support.v7.widget.RecyclerView;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Loading
Loading
@@ -17,6 +16,7 @@ import com.commit451.gitlab.transformation.CircleTransformation;
import com.commit451.gitlab.util.BypassImageGetterFactory;
import com.commit451.gitlab.util.DateUtil;
import com.commit451.gitlab.util.ImageUtil;
import com.commit451.gitlab.util.InternalLinkMovementMethod;
import com.vdurmont.emoji.EmojiParser;
 
import butterknife.BindView;
Loading
Loading
@@ -64,7 +64,7 @@ public class NoteViewHolder extends RecyclerView.ViewHolder {
App.instance().getAccount().getServerUrl().toString(),
project);
mSummaryView.setText(bypass.markdownToSpannable(summary, getter));
mSummaryView.setMovementMethod(LinkMovementMethod.getInstance());
mSummaryView.setMovementMethod(new InternalLinkMovementMethod(App.instance().getAccount().getServerUrl()));
 
App.instance().getPicasso()
.load(ImageUtil.getAvatarUrl(note.getAuthor(), itemView.getResources().getDimensionPixelSize(R.dimen.image_size)))
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment