Java Code Examples for android.widget.TextView#setMovementMethod()

The following examples show how to use android.widget.TextView#setMovementMethod() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FlexibleAdapter   File: MessageDialog.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getActivity())
                                    .inflate(R.layout.dialog_message, null);

    TextView messageView = dialogView.findViewById(R.id.message);
    messageView.setMovementMethod(LinkMovementMethod.getInstance());
    messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
    builder.setTitle(getArguments().getString(ARG_TITLE))
           .setIcon(getArguments().getInt(ARG_ICON))
           .setView(dialogView)
           .setPositiveButton(R.string.OK, new OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   dialog.dismiss();
               }
           });

    return builder.create();
}
 
Example 2
Source Project: mimi-reader   File: RepliesListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public ViewHolderItem(final View v) {
    threadId = (TextView) v.findViewById(R.id.thread_id);
    userName = (TextView) v.findViewById(R.id.user_name);
    postTime = (TextView) v.findViewById(R.id.timestamp);
    userId = (TextView) v.findViewById(R.id.user_id);
    tripCode = (TextView) v.findViewById(R.id.tripcode);
    subject = (TextView) v.findViewById(R.id.subject);
    comment = (TextView) v.findViewById(R.id.comment);
    thumbUrl = (AppCompatImageView) v.findViewById(R.id.thumbnail);
    gotoPost = (TextView) v.findViewById(R.id.goto_post);
    repliesText = (TextView) v.findViewById(R.id.replies_number);
    thumbnailContainer = (ViewGroup) v.findViewById(R.id.thumbnail_container);
    flagIcon = (AppCompatImageView) v.findViewById(R.id.flag_icon);

    comment.setMovementMethod(LongClickLinkMovementMethod.getInstance());
}
 
Example 3
/**
 * Load changelog.
 */
private void loadChangelog() {
    StringBuilder text = new StringBuilder();

    try {
        String line;
        BufferedReader reader = new BufferedReader(new InputStreamReader(requireActivity().getAssets().open("changelog")));
        while ((line = reader.readLine()) != null) {
            text.append(line);
            text.append('\n');
        }
    } catch (IOException ignored) { }

    TextView t = currentView.findViewById(R.id.about_changelog);
    t.setMovementMethod(LinkMovementMethod.getInstance());
    t.setText(Html.fromHtml(text.toString()));
}
 
Example 4
Source Project: weex   File: SupplementalInfoRetriever.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected final void onPostExecute(Object arg) {
  TextView textView = textViewRef.get();
  if (textView != null) {
    for (CharSequence content : newContents) {
      textView.append(content);
    }
    textView.setMovementMethod(LinkMovementMethod.getInstance());
  }
  HistoryManager historyManager = historyManagerRef.get();
  if (historyManager != null) {
    for (String[] text : newHistories) {
      historyManager.addHistoryItemDetails(text[0], text[1]);
    }
  }
}
 
Example 5
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register_activity);

    // Allow a part of the terms and conditions text to be clickable.
    TextView tv = (TextView) findViewById(R.id.terms_text);
    String terms1 = getString(R.string.terms1);
    String terms2 = getString(R.string.terms2);
    SpannableString ss = new SpannableString(terms1 + " " + terms2);
    ss.setSpan(new MyClickableSpan(), terms1.length(), terms1.length() + terms2.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//0 to 7 Android is clickable
    tv.setText(ss);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 6
/**
 * Creates and adds a full-width control with additional text describing what an InfoBar is for.
 */
public View addDescription(CharSequence message) {
    ControlLayoutParams params = new ControlLayoutParams();
    params.mMustBeFullWidth = true;

    TextView descriptionView = (TextView) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_description, this, false);
    addView(descriptionView, params);

    descriptionView.setText(message);
    descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    return descriptionView;
}
 
Example 7
Source Project: walt   File: LogFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    textView = (TextView) activity.findViewById(R.id.txt_log);
    textView.setMovementMethod(new ScrollingMovementMethod());
    textView.setText(logger.getLogText());
    logger.registerReceiver(logReceiver);
}
 
Example 8
/**
 * Do NOT call this method directly from outside {@link InfoBarLayout#InfoBarLayout()}.
 *
 * Adds a full-width control showing the main InfoBar message.  For other text, you should call
 * {@link InfoBarControlLayout#addDescription(CharSequence)} instead.
 */
TextView addMainMessage(CharSequence mainMessage) {
    ControlLayoutParams params = new ControlLayoutParams();
    params.mMustBeFullWidth = true;

    TextView messageView = (TextView) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_message, this, false);
    addView(messageView, params);

    messageView.setText(mainMessage);
    messageView.setMovementMethod(LinkMovementMethod.getInstance());
    return messageView;
}
 
Example 9
Source Project: RxTools-master   File: RxDialogSure.java    License: Apache License 2.0 5 votes vote down vote up
private void initView() {
    View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_sure, null);
    mTvSure = (TextView) dialogView.findViewById(R.id.tv_sure);
    mTvTitle = (TextView) dialogView.findViewById(R.id.tv_title);
    mTvTitle.setTextIsSelectable(true);
    mTvContent = (TextView) dialogView.findViewById(R.id.tv_content);
    mTvContent.setMovementMethod(ScrollingMovementMethod.getInstance());
    mTvContent.setTextIsSelectable(true);
    mIvLogo = (ImageView) dialogView.findViewById(R.id.iv_logo);
    setContentView(dialogView);
}
 
Example 10
@Override
protected void onPostExecute(String result)
{
    TextView tv = (TextView)findViewById(R.id.tv);
    tv.setText(result);
    tv.setOnClickListener(null);
    tv.setMovementMethod(ScrollingMovementMethod.getInstance());
}
 
Example 11
Source Project: walt   File: AutoRunFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    txtLogAutoRun = (TextView) getActivity().findViewById(R.id.txt_log_auto_run);
    txtLogAutoRun.setMovementMethod(new ScrollingMovementMethod());
    txtLogAutoRun.setText(logger.getLogText());
    logger.registerReceiver(logReceiver);
}
 
Example 12
private static void addLinks(int linkifyMask, BetterLinkMovementExtended movementMethod, TextView textView) {
    textView.setMovementMethod(movementMethod);
    if (linkifyMask != LINKIFY_NONE) {
        Linkify.addLinks(textView, linkifyMask);
    }

}
 
Example 13
@Override
public void enableLoadmore(boolean enable) {
    if (isEnableLoadmore() == enable) {
        return;
    }

    super.enableLoadmore(enable);

    if (!enable) {
        // 显示footer
        if (mFooterView == null) {
            mFooterView = View.inflate(ActivityLifcycleManager.get().current(), LAYOUT_ID_FOOTER, null);
            TextView tvEnd = (TextView) mFooterView.findViewById(R.id.txt_end);
            tvEnd.setMovementMethod(LinkMovementMethod.getInstance());
            String txtEnd = AppUtils.getContext().getString(R.string.to_discover_more_zuthor_and_collection);
            SpannableStringBuilder ssb = new SpannableStringBuilder(txtEnd);
            int startIndex = txtEnd.indexOf("更");
            int endIndex = txtEnd.length();
            if (startIndex > -1) {
                ssb.setSpan(new ClickableSpanNoUnderLine() {
                    public void onClick(View widget) {
                        if (ThrottleUtils.valid(widget)) {
                            AddSubscribeActivity.launch();
                        }
                    }
                }, startIndex, endIndex, 0);
                tvEnd.setText(ssb, BufferType.SPANNABLE);
            }
        }

        if (mFooterView.getParent() == null) {
            addFooterView(mFooterView);
        }
    } else {
        removeFooterView(mFooterView);
    }
}
 
Example 14
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_from_html);

  TextView textView = (TextView) findViewById(R.id.text);
  String html = getString(R.string.from_html_text);
  textView.setText(Html.fromHtml(html, new ResouroceImageGetter(this), null));
  textView.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 15
Source Project: 365browser   File: SadTabViewFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param context Context of the resulting Sad Tab view.
 * @param suggestionAction {@link Runnable} to be executed when user clicks "try these
 *                        suggestions".
 * @param buttonAction {@link Runnable} to be executed when the button is pressed.
 *                     (e.g., refreshing the page or sending feedback)
 * @param showSendFeedbackView Whether to show the "send feedback" version of the Sad Tab view.
 * @return A "Sad Tab" view instance which is used in place of a crashed renderer.
 */
public static View createSadTabView(Context context, final Runnable suggestionAction,
        final Runnable buttonAction, final boolean showSendFeedbackView) {
    // Inflate Sad tab and initialize.
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    View sadTabView = inflater.inflate(R.layout.sad_tab, null);

    TextView titleText = (TextView) sadTabView.findViewById(R.id.sad_tab_title);
    int titleTextId =
            showSendFeedbackView ? R.string.sad_tab_reload_title : R.string.sad_tab_title;
    titleText.setText(titleTextId);

    if (showSendFeedbackView) intializeSuggestionsViews(context, sadTabView);

    TextView messageText = (TextView) sadTabView.findViewById(R.id.sad_tab_message);
    messageText.setText(getHelpMessage(context, suggestionAction, showSendFeedbackView));
    messageText.setMovementMethod(LinkMovementMethod.getInstance());

    Button button = (Button) sadTabView.findViewById(R.id.sad_tab_button);
    int buttonTextId = showSendFeedbackView ? R.string.sad_tab_send_feedback_label
                                            : R.string.sad_tab_reload_label;
    button.setText(buttonTextId);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            SadTabViewFactory.recordEvent(showSendFeedbackView, SadTabEvent.BUTTON_CLICKED);
            buttonAction.run();
        }
    });

    SadTabViewFactory.recordEvent(showSendFeedbackView, SadTabEvent.DISPLAYED);

    return sadTabView;
}
 
Example 16
private void setCommentTextClick(TextView mTextView2, JSONArray data,
        View view, int goodSize) {
    if (goodSize > 0 && data.size() > 0) {
        view.setVisibility(View.VISIBLE);
    } else {
        view.setVisibility(View.GONE);
    }
    if (data.size() == 0) {
        mTextView2.setVisibility(View.GONE);
    } else {
        mTextView2.setVisibility(View.VISIBLE);

    }
    SpannableStringBuilder ssb = new SpannableStringBuilder();

    int start = 0;

    for (int i = 0; i < data.size(); i++) {

        JSONObject json = data.getJSONObject(i);
        String content = json.getString("content");
        String scID = json.getString("scID");
        String userID_temp = json.getString("userID");

        String nick = userID_temp;

        if (userID_temp.equals(myuserID)) {
            nick = myNick;

        } else {

            User user = MYApplication.getInstance().getContactList()
                    .get(userID_temp);
            if (user != null) {

                nick = user.getNick();

            }

        }
        String content_0 = "";
        String content_1 = ": " + content;
        String content_2 = ": " + content + "\n";
        if (i == (data.size() - 1) || (data.size() == 1 && i == 0)) {
            ssb.append(nick + content_1);
            content_0 = content_1;
        } else {

            ssb.append(nick + content_2);
            content_0 = content_2;
        }

        ssb.setSpan(new TextViewURLSpan(nick, userID_temp, 1), start, start
                + nick.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (userID_temp.equals(myuserID)) {

            ssb.setSpan(new TextViewURLSpan(nick, userID_temp, i, scID, 2,
                    mTextView2, data, view, goodSize), start,
                    start + nick.length() + content_0.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        start = ssb.length();

    }

    mTextView2.setText(ssb);
    mTextView2.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 17
Source Project: styT   File: WelcomeActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        android.support.design.widget.CollapsingToolbarLayout toolbar0 = (android.support.design.widget.CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
        setSupportActionBar(toolbar);
        toolbar0.setTitle("描述时间:2017-12-02");
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
//		设置导航图标
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View p1) {
                finish();
            }
        });
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_TEXT, "妮哩是一款覆盖功能齐全的工具软件。也可以说是一款集成了许多实用功能的工具箱,例如提取APK、root工具、王者荣耀是也修改、百度云直链提取、网易云音乐启动背景替换、身份证信息查询、快递查询、QQ极速红包等功能\n支付微信支付宝扫码收付款的功能快捷使用\n\n还可以快速领红包现金...\n https://www.coolapk.com/apk/nico.styTool");
                sendIntent.setType("text/plain");
                startActivity(sendIntent);
            }
        });
        final SharedPreferences i = getSharedPreferences("Hello50", 0);
        Boolean o0 = i.getBoolean("FIRST", true);
        if (o0) {//第一次
            i.edit().putBoolean("FIRST", false).apply();
            ViewTooltip
                    .on(fab)
                    .autoHide(false, 100)
                    .position(ViewTooltip.Position.BOTTOM)
                    .corner(30)
                    .align(ViewTooltip.ALIGN.CENTER)
                    .clickToHide(true)
                    .text("这里分享软件")
                    .show();

        } else {

        }
        TextView mTv_html = (TextView) findViewById(R.id.text_mar);
        String s = "<big>软件介绍:</big><br/><HR></HR>";
        s += "<a>源代码 https://github.com/stytooldex/stynico:</a><br/>覆盖功能齐全的工具软件。也可以说是一款集成了许多实用功能的工具箱,例如提取APK、百度云直链提取、网易云音乐启动背景替换、身份证信息查询、快递查询、QQ极速红包等功能。<br/>微信支付宝扫一扫、付款码功能需要手机ROOT之后才能使用。<br/>应用的UI设计以简洁和直观为主<br/>应用有50个基本功能<br/>将从50个功能中挑选出8个进行简单介绍。<br/>•提取APK<br/><small>正如它的字面意思那样,这个功能将列出我们的手机当中安装的所有应用程序,并允许我们将其提取并保存成APK文件(应用的安装包),该功能对系统应用同样有效(比如提取Mokee默认的Lawnchair启动器的APK)</small><br/>•QQ空间蓝色动态<br/><small>这个功能虽然不见得有多大的实用价值,也不见得有多高的技术含量,不过能发表蓝色字体的QQ空间动态,看起来也是非常炫酷的。它的使用方法非常简单,我们只需在妮哩Q空间蓝色动态功能的输入框中输入我们要发表的文字内容,然后点击生成,随后在QQ或者QQ空间客户端里新建一条说说,在输入框内长按,点击粘贴,再点击发送</small><br/>•女闺蜜Ai智障<br/><small>妮哩中内置了一个自动对话机器人,使用了图灵机器人的接口,这个机器人对自然语义的分析和响应还是十分到位的,感兴趣的读者不妨调戏她一番。</small><br/>•Wi-Fi密码查看器<br/><small>有时我们使用合法的WiFi万能钥匙连接到某一加密的公共WiFI后,并无法直接得知它的密码,而妮哩的WiFi密码查看器功能则可以将此WiFi的密码直接展示出来。此外,你可以将你手机中保存的WiFi密码以二维码为媒介分享给你的朋友。</small><br/>•设备信息<br/><small>妮哩的设备信息功能可以列出你设备型号、系统版本、当前用户等,不过这还不够刺激,厉害的是,它可以将你的手机变成FTP服务器</small><br/>•各省今日油价<br/><small>这个功能对有车一族来说应该比较重要,妮哩可以帮助各位老司机查询各省的0号柴油、90号汽油、93号汽油和97号汽油的油价,虽然界面看起来比较简陋,不过油价信息一目了然</small><br/>•天气预报查询<br/><small>天气预报功能依然画风奇特,信息展现以文字为主,你可以在此选择你要查询天气的城市,妮哩给出的天气信息还算全面</small><br/>•历史上的今天查询<br/><small>除了折腾手机之外,如果没什么时间和精力读长篇大论,看看历史上的今天打发打发时间还是不错的。</small>";
        s += "<br/><br/><big>更新历史:</big><br/><HR></HR><small>_支持 直接启动妹纸资源<br/>xposed:去掉部分软件启动广告<br/>_新功能 QQ抢红包<br/>_抢红包支持自动回复信息(免root)<br/><br/>_免费看vip付费电视 匹配(youku|iqiyi|tudou|qq|mgtv|letv|le|sohu|acfun|pptv|yinyuetai|yy|bilibili|wasu|fun|xunyingwang|meitudata|toutiao|tangdou)<br/>_主页 妹子区{支持开关}<br/>_图片 支持下载<br/>{热更新}<br/>_修复 无法下载<br/>新功能 相册处理(禁止再次生成图片到设备<br/><br/>_修复以及调整部分功能<br/>_新功能 嗶哩嗶哩封面<br/>_优化 部分布局细节<br/>_调整 启动界面<br/>{热更新}<br/>优化 服务端部分问题<br/>_提高动态数据速度<br/>动态功能优化<br/>_新模块 妹子图片><br/>_优化 百度云直链提取<br/>_优化 部分布局<br/>_动态 支持显示多少N天<br/>_修复 状态栏颜色问题<br/>_修复 原生状态栏设备无效<br/><br/>_重写 主页ui<br/>恢复 老版本主页动态<br/>优化一些地方<br/><br/>{热更新}<br/>修复滑动Fc<br/><br/>_修复 一些问题<br/>_视频校验修改>文件校验修改<br/>修改默认颜色<br/>_优化 强制清除RAM内存<br/>_优化 抽奖>_调整文字<br/>_新功能 多进制转换<br/><br/>抽奖加入 王者荣耀可选皮肤:<br/>千年之狐 永久<br/>地狱火 永久<br/>微信现金80元<br/>_修复帐号登录问题及异常<br/>_修复抽奖bug<br/>_一个记事本获取数据调整 默认>1000<br/>热更新<br/>_调整金额<br/>_一些优化<br/><br/>_新功能 一个日记<br/>_新功能 主页快捷功能(微信,支付宝)<br/>_修复 一个开关功能无法正常运行<br/>_修复 无法弹出下载窗口<br/>_启动时间调整 1000L>500L<br/>热更新:<br/>_修复无法调用支付宝<br/>_优化辅助功能<br/><br/>_新功能 王者荣耀视野修改<br/>_新功能 三星设备[noroot]修改dpi<br/>_优化 root工具<br/><br/>_新功能 我的日记<br/>_新功能 快递查询<br/>_新功能 root工具<br/>_优化 记事木文字隔离<br/>_优化 部分root功能黑屏<br/>_优化 妮哩Ai智障[布局,代码]</small>";
        Spanned spanned = Html.fromHtml(s);
        mTv_html.setMovementMethod(LinkMovementMethod.getInstance());
        mTv_html.setText(spanned);
    }
 
Example 18
public void initViews(Context context, View dialogContent)
{
    TextView nameView = (TextView) dialogContent.findViewById(R.id.txt_about_name);
    nameView.setText(getString(param_appName));
    nameView.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            openLink(WEBSITE_URL);
        }
    });

    ImageView iconView = (ImageView) dialogContent.findViewById(R.id.txt_about_icon);
    iconView.setImageDrawable(ContextCompat.getDrawable(context, param_iconID));

    TextView versionView = (TextView) dialogContent.findViewById(R.id.txt_about_version);
    versionView.setMovementMethod(LinkMovementMethod.getInstance());
    versionView.setText(SuntimesUtils.fromHtml(htmlVersionString()));

    TextView urlView = (TextView) dialogContent.findViewById(R.id.txt_about_url);
    urlView.setMovementMethod(LinkMovementMethod.getInstance());
    urlView.setText(SuntimesUtils.fromHtml(context.getString(R.string.app_url)));

    TextView supportView = (TextView) dialogContent.findViewById(R.id.txt_about_support);
    supportView.setMovementMethod(LinkMovementMethod.getInstance());
    supportView.setText(SuntimesUtils.fromHtml(context.getString(R.string.app_support_url)));

    TextView legalView1 = (TextView) dialogContent.findViewById(R.id.txt_about_legal1);
    legalView1.setMovementMethod(LinkMovementMethod.getInstance());
    legalView1.setText(SuntimesUtils.fromHtml(context.getString(R.string.app_legal1)));

    TextView legalView2 = (TextView) dialogContent.findViewById(R.id.txt_about_legal2);
    legalView2.setMovementMethod(LinkMovementMethod.getInstance());
    legalView2.setText(SuntimesUtils.fromHtml(initTranslationCredits(getActivity())));

    TextView legalView3 = (TextView) dialogContent.findViewById(R.id.txt_about_legal3);
    legalView3.setMovementMethod(LinkMovementMethod.getInstance());
    legalView3.setText(SuntimesUtils.fromHtml(initLibraryCredits(getActivity())));

    TextView legalView4 = (TextView) dialogContent.findViewById(R.id.txt_about_legal4);
    String permissionsExplained = context.getString(R.string.privacy_permission_location);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        permissionsExplained += "<br/><br/>" + context.getString(R.string.privacy_permission_storage);
    }
    permissionsExplained += "<br/><br/>" + context.getString(R.string.privacy_permission_storage1);
    String privacy = context.getString(R.string.privacy_policy, permissionsExplained);
    legalView4.setText(SuntimesUtils.fromHtml(privacy));

    TextView legalView5 = (TextView) dialogContent.findViewById(R.id.txt_about_legal5);
    legalView5.setMovementMethod(LinkMovementMethod.getInstance());
    legalView5.setText(SuntimesUtils.fromHtml(context.getString(R.string.privacy_url)));
}
 
Example 19
Source Project: GDPRDialog   File: GDPRViewManager.java    License: Apache License 2.0 4 votes vote down vote up
private void initGeneralTexts(Activity activity, TextView tvQuestion, TextView tvText1, TextView tvText2, TextView tvText3, CheckBox cbAge) {

        if (mSetup.getCustomTexts().hasQuestion()) {
            tvQuestion.setText(mSetup.getCustomTexts().getQuestion(activity));
        } else {
            String question = activity.getString(R.string.gdpr_dialog_question, (mSetup.containsAdNetwork() && !mSetup.shortQuestion()) ? activity.getString(R.string.gdpr_dialog_question_ads_info) : "");
            tvQuestion.setText(Html.fromHtml(question));
        }

        if (mSetup.getCustomTexts().hasTopText()) {
            tvText1.setText(Html.fromHtml(mSetup.getCustomTexts().getTopText(activity)));
        } else {
            String cheapOrFree = activity.getString(mSetup.hasPaidVersion() ? R.string.gdpr_cheap : R.string.gdpr_free);
            String text1 = activity.getString(R.string.gdpr_dialog_text1_part1);
            if (mSetup.showPaidOrFreeInfoText())
            {
                text1 += " " + activity.getString(R.string.gdpr_dialog_text1_part2, cheapOrFree);
            }
            tvText1.setText(Html.fromHtml(text1));
        }
        tvText1.setMovementMethod(LinkMovementMethod.getInstance());

        if (mSetup.getCustomTexts().hasMainText()) {
            tvText2.setText(mSetup.getCustomTexts().getMainText(activity));
        } else {
            int typesCount = mSetup.getNetworkTypes().size();
            String types = mSetup.getNetworkTypesCommaSeperated(activity);
            String text2 = typesCount == 1 ?
                    activity.getString(R.string.gdpr_dialog_text2_singular, types) :
                    activity.getString(R.string.gdpr_dialog_text2_plural, types);
            CharSequence sequence2 = Html.fromHtml(text2);
            SpannableStringBuilder strBuilder2 = new SpannableStringBuilder(sequence2);
            URLSpan[] urls = strBuilder2.getSpans(0, sequence2.length(), URLSpan.class);
            for (URLSpan span : urls)
            {
                makeLinkClickable(strBuilder2, span, () -> {
                    mCurrentStep = 1;
                    updateSelectedPage();
                });
            }
            tvText2.setText(strBuilder2);
        }
        tvText2.setMovementMethod(LinkMovementMethod.getInstance());

        if (mSetup.getCustomTexts().hasAgeMsg()) {
            tvText3.setText(mSetup.getCustomTexts().getAgeMsg(activity));
        } else {

            String text3 = activity.getString(R.string.gdpr_dialog_text3);
            tvText3.setText(Html.fromHtml(text3));
        }
        tvText3.setMovementMethod(LinkMovementMethod.getInstance());

        if (!mSetup.explicitAgeConfirmation()) {
            cbAge.setVisibility(View.GONE);
        } else {
            tvText3.setVisibility(View.GONE);
            cbAge.setChecked(mAgeConfirmed);
            cbAge.setOnCheckedChangeListener((buttonView, isChecked) -> mAgeConfirmed = isChecked);
        }

        //GDPRUtils.justify(tvText1);
        justifyText(tvText2);
        //GDPRUtils.justify(tvText3);
        //GDPRUtils.justify(tvQuestion);
    }
 
Example 20
Source Project: snowplow-android-tracker   File: Demo.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .penaltyDialog()
            .build());
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
            .penaltyLog()
            .build());
    setContentView(R.layout.activity_demo);

    // Init Tracker
    initAndroidTracker();

    _startButton   = (Button)findViewById(R.id.btn_lite_start);
    _tabButton     = (Button)findViewById(R.id.btn_lite_tab);
    _uriField      = (EditText)findViewById(R.id.emitter_uri_field);
    _type          = (RadioGroup)findViewById(R.id.radio_send_type);
    _security      = (RadioGroup)findViewById(R.id.radio_send_security);
    _collection    = (RadioGroup)findViewById(R.id.radio_data_collection);
    _radioGet      = (RadioButton)findViewById(R.id.radio_get);
    _radioHttp     = (RadioButton)findViewById(R.id.radio_http);
    _logOutput     = (TextView)findViewById(R.id.log_output);
    _eventsCreated = (TextView)findViewById(R.id.created_events);
    _eventsSent    = (TextView)findViewById(R.id.sent_events);
    _emitterOnline = (TextView)findViewById(R.id.online_status);
    _emitterStatus = (TextView)findViewById(R.id.emitter_status);
    _databaseSize  = (TextView)findViewById(R.id.database_size);
    _sessionIndex  = (TextView)findViewById(R.id.session_index);

    _logOutput.setMovementMethod(new ScrollingMovementMethod());
    _logOutput.setText("");

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String uri = sharedPreferences.getString("uri", "");
    _uriField.setText(uri);

    // Setup Listeners
    setupTrackerListener();
    setupTabListener();
}