use of android.text.method.LinkMovementMethod in project android_packages_apps_Settings by LineageOS.
the class LinkablePreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
TextView textView = (TextView) view.findViewById(android.R.id.title);
if (textView == null) {
return;
}
textView.setSingleLine(false);
if (mContentTitle == null || mClickListener == null) {
return;
}
StringBuilder contentBuilder = new StringBuilder().append(mContentTitle);
if (mContentDescription != null) {
contentBuilder.append("\n\n");
contentBuilder.append(mContentDescription);
}
boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
if (linked && mContentTitle != null) {
// Embolden and enlarge the title.
Spannable boldSpan = (Spannable) textView.getText();
boldSpan.setSpan(new TextAppearanceSpan(getContext(), android.R.style.TextAppearance_Medium), 0, mContentTitle.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(boldSpan);
textView.setMovementMethod(new LinkMovementMethod());
}
}
use of android.text.method.LinkMovementMethod in project twicalico by moko256.
the class ShowTweetActivity method updateView.
private void updateView(Status item) {
TextView tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
long replyTweetId = item.getInReplyToStatusId();
if (replyTweetId != -1) {
tweetIsReply.setVisibility(VISIBLE);
tweetIsReply.setOnClickListener(v -> startActivity(getIntent(this, replyTweetId)));
} else {
tweetIsReply.setVisibility(GONE);
}
StatusView statusView = new StatusView(this);
statusView.setStatus(item);
ViewGroup cview = (ViewGroup) statusView.getChildAt(0);
ViewGroup sview = (ViewGroup) cview.getChildAt(0);
cview.removeView(sview);
FrameLayout statusViewFrame = findViewById(R.id.tweet_show_tweet);
statusViewFrame.removeAllViews();
statusViewFrame.addView(sview);
((TextView) findViewById(R.id.tweet_show_timestamp)).setText(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(item.getCreatedAt()));
TextView viaText = findViewById(R.id.tweet_show_via);
viaText.setText(TwitterStringUtils.convertUrlSpanToCustomTabs(Html.fromHtml("via:" + item.getSource()), this));
viaText.setMovementMethod(new LinkMovementMethod());
AppCompatEditText replyText = findViewById(R.id.tweet_show_tweet_reply_text);
AppCompatButton replyButton = findViewById(R.id.tweet_show_tweet_reply_button);
UserMentionEntity[] users = item.getUserMentionEntities();
replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
replyButton.setOnClickListener(v -> {
replyButton.setEnabled(false);
PostTweetModel model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
model.setTweetText(replyText.getText().toString());
model.setInReplyToStatusId(item.getId());
subscriptions.add(model.postTweet().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
replyButton.setEnabled(true);
Toast.makeText(ShowTweetActivity.this, R.string.succeeded, Toast.LENGTH_SHORT).show();
}, e -> {
e.printStackTrace();
Toast.makeText(ShowTweetActivity.this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
replyButton.setEnabled(true);
}));
});
}
use of android.text.method.LinkMovementMethod in project Camera-Roll-Android-App by kollerlukas.
the class AboutActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setEnterTransition(new Slide(Gravity.BOTTOM));
getWindow().setReturnTransition(new Slide(Gravity.BOTTOM));
}
SwipeBackCoordinatorLayout swipeBackView = findViewById(R.id.swipeBackView);
swipeBackView.setOnSwipeListener(this);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("");
actionBar.setDisplayHomeAsUpEnabled(true);
}
final View header = findViewById(R.id.header);
header.setBackgroundColor(theme.getAccentColor(this));
TextView version = findViewById(R.id.version);
try {
String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
final int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
// noinspection deprecation
version.setText(Html.fromHtml(versionName));
version.setTextColor(theme.getAccentTextColor(this));
version.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Toast.makeText(view.getContext(), "versionCode: " + String.valueOf(versionCode), Toast.LENGTH_SHORT).show();
return false;
}
});
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
final TextView aboutText = findViewById(R.id.about_text);
// noinspection deprecation
aboutText.setText(Html.fromHtml(getString(R.string.about_text)));
aboutText.setMovementMethod(new LinkMovementMethod());
final View rootView = findViewById(R.id.root_view);
final NestedScrollView scrollView = findViewById(R.id.scroll_view);
scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView nestedScrollView, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
int statusBarHeight = toolbar.getPaddingTop();
if (scrollY > header.getHeight() - statusBarHeight / 2) {
if (theme.darkStatusBarIcons()) {
Util.setDarkStatusBarIcons(rootView);
} else {
Util.setLightStatusBarIcons(rootView);
}
} else {
if (theme.darkStatusBarIconsInSelectorMode()) {
Util.setDarkStatusBarIcons(rootView);
} else {
Util.setLightStatusBarIcons(rootView);
}
}
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart(), /*+ insets.getSystemWindowInsetLeft()*/
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd(), /*+ insets.getSystemWindowInsetRight()*/
toolbar.getPaddingBottom());
aboutText.setPadding(aboutText.getPaddingStart(), aboutText.getPaddingTop(), aboutText.getPaddingEnd(), aboutText.getPaddingBottom() + insets.getSystemWindowInsetBottom());
View viewGroup = findViewById(R.id.swipeBackView);
ViewGroup.MarginLayoutParams viewGroupParams = (ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams();
viewGroupParams.leftMargin += insets.getSystemWindowInsetLeft();
viewGroupParams.rightMargin += insets.getSystemWindowInsetRight();
viewGroup.setLayoutParams(viewGroupParams);
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
// set status bar icon color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
} else {
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// hacky way of getting window insets on pre-Lollipop
// somewhat works...
int[] screenSize = Util.getScreenSize(AboutActivity.this);
int[] windowInsets = new int[] { Math.abs(screenSize[0] - rootView.getLeft()), Math.abs(screenSize[1] - rootView.getTop()), Math.abs(screenSize[2] - rootView.getRight()), Math.abs(screenSize[3] - rootView.getBottom()) };
toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd(), toolbar.getPaddingBottom());
View viewGroup = findViewById(R.id.swipeBackView);
ViewGroup.MarginLayoutParams viewGroupParams = (ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams();
viewGroupParams.leftMargin += windowInsets[0];
viewGroupParams.rightMargin += windowInsets[2];
viewGroup.setLayoutParams(viewGroupParams);
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
for (int i = 0; i < toolbar.getChildCount(); i++) {
if (toolbar.getChildAt(i) instanceof ImageView) {
ImageView imageView = ((ImageView) toolbar.getChildAt(i));
int color;
if (!theme.darkStatusBarIconsInSelectorMode()) {
color = ContextCompat.getColor(this, R.color.white_translucent1);
} else {
color = ContextCompat.getColor(this, R.color.black_translucent2);
}
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN);
break;
}
}
// needed for transparent statusBar
setSystemUiFlags();
}
use of android.text.method.LinkMovementMethod in project android_packages_apps_Settings by DirtyUnicorns.
the class LinkablePreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
TextView textView = (TextView) view.findViewById(android.R.id.title);
if (textView == null) {
return;
}
textView.setSingleLine(false);
if (mContentTitle == null || mClickListener == null) {
return;
}
StringBuilder contentBuilder = new StringBuilder().append(mContentTitle);
if (mContentDescription != null) {
contentBuilder.append("\n\n");
contentBuilder.append(mContentDescription);
}
boolean linked = LinkifyUtils.linkify(textView, contentBuilder, mClickListener);
if (linked && mContentTitle != null) {
// Embolden and enlarge the title.
Spannable boldSpan = (Spannable) textView.getText();
boldSpan.setSpan(new TextAppearanceSpan(getContext(), android.R.style.TextAppearance_Medium), 0, mContentTitle.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(boldSpan);
textView.setMovementMethod(new LinkMovementMethod());
}
}
use of android.text.method.LinkMovementMethod in project apps-android-wikipedia by wikimedia.
the class DescriptionEditView method init.
private void init() {
inflate(getContext(), R.layout.view_description_edit, this);
ButterKnife.bind(this);
licenseText.setText(StringUtil.fromHtml(String.format(getContext().getString(R.string.description_edit_license_notice), getContext().getString(R.string.terms_of_use_url), getContext().getString(R.string.cc_0_url))));
licenseText.setMovementMethod(new LinkMovementMethod());
FeedbackUtil.setToolbarButtonLongPressToast(saveButton, cancelButton, helpButton);
setOrientation(VERTICAL);
}
Aggregations