<commit_before>/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.focus.firstrun;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import org.mozilla.focus.R;

public class FirstrunPagerAdapter extends PagerAdapter {
    private static class FirstrunPage {
        public final String title;
        public final String text;
        public final int imageResource;
        public final String contentDescription;

        private FirstrunPage(String title, String text, int imageResource) {
            this.title = title;
            this.text = text;
            this.imageResource = imageResource;
            this.contentDescription = title + text;
        }
    }

    private final FirstrunPage[] pages;

    private final Context context;
    private final View.OnClickListener listener;

    public FirstrunPagerAdapter(Context context, View.OnClickListener listener) {
        final String appName = context.getString(R.string.app_name);

        this.context = context;
        this.listener = listener;
        this.pages = new FirstrunPage[] {
                new FirstrunPage(
                        context.getString(R.string.firstrun_defaultbrowser_title),
                        context.getString(R.string.firstrun_defaultbrowser_text2),
                        R.drawable.onboarding_img1),
                new FirstrunPage(
                        context.getString(R.string.firstrun_search_title),
                        context.getString(R.string.firstrun_search_text),
                        R.drawable.onboarding_img4),
                new FirstrunPage(
                        context.getString(R.string.firstrun_shortcut_title),
                        context.getString(R.string.firstrun_shortcut_text, appName),
                        R.drawable.onboarding_img3),
                new FirstrunPage(
                        context.getString(R.string.firstrun_privacy_title),
                        context.getString(R.string.firstrun_privacy_text, appName),
                        R.drawable.onboarding_img2)
        };
    }

    private View getView(int position, ViewPager pager) {
        final View view = LayoutInflater.from(context).inflate(
                R.layout.firstrun_page, pager, false);

        final FirstrunPage page = pages[position];

        final TextView titleView = view.findViewById(R.id.title);
        titleView.setText(page.title);

        final TextView textView = view.findViewById(R.id.text);
        textView.setText(page.text);

        final ImageView imageView = view.findViewById(R.id.image);
        imageView.setImageResource(page.imageResource);

        final Button buttonView = view.findViewById(R.id.button);
        buttonView.setOnClickListener(listener);
        if (position == pages.length - 1) {
            buttonView.setText(R.string.firstrun_close_button);
            buttonView.setId(R.id.finish);
        } else {
            buttonView.setText(R.string.firstrun_next_button);
            buttonView.setId(R.id.next);
        }
<commit_msg>Fixes #3286: "Ok, Got it" button read as "Ok, got I.T."<commit_after>/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.focus.firstrun;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import org.mozilla.focus.R;

public class FirstrunPagerAdapter extends PagerAdapter {
    private static class FirstrunPage {
        public final String title;
        public final String text;
        public final int imageResource;
        public final String contentDescription;

        private FirstrunPage(String title, String text, int imageResource) {
            this.title = title;
            this.text = text;
            this.imageResource = imageResource;
            this.contentDescription = title + text;
        }
    }

    private final FirstrunPage[] pages;

    private final Context context;
    private final View.OnClickListener listener;

    public FirstrunPagerAdapter(Context context, View.OnClickListener listener) {
        final String appName = context.getString(R.string.app_name);

        this.context = context;
        this.listener = listener;
        this.pages = new FirstrunPage[] {
                new FirstrunPage(
                        context.getString(R.string.firstrun_defaultbrowser_title),
                        context.getString(R.string.firstrun_defaultbrowser_text2),
                        R.drawable.onboarding_img1),
                new FirstrunPage(
                        context.getString(R.string.firstrun_search_title),
                        context.getString(R.string.firstrun_search_text),
                        R.drawable.onboarding_img4),
                new FirstrunPage(
                        context.getString(R.string.firstrun_shortcut_title),
                        context.getString(R.string.firstrun_shortcut_text, appName),
                        R.drawable.onboarding_img3),
                new FirstrunPage(
                        context.getString(R.string.firstrun_privacy_title),
                        context.getString(R.string.firstrun_privacy_text, appName),
                        R.drawable.onboarding_img2)
        };
    }

    private View getView(int position, ViewPager pager) {
        final View view = LayoutInflater.from(context).inflate(
                R.layout.firstrun_page, pager, false);

        final FirstrunPage page = pages[position];

        final TextView titleView = view.findViewById(R.id.title);
        titleView.setText(page.title);

        final TextView textView = view.findViewById(R.id.text);
        textView.setText(page.text);

        final ImageView imageView = view.findViewById(R.id.image);
        imageView.setImageResource(page.imageResource);

        final Button buttonView = view.findViewById(R.id.button);
        buttonView.setOnClickListener(listener);
        if (position == pages.length - 1) {
            buttonView.setText(R.string.firstrun_close_button);
            buttonView.setId(R.id.finish);
            buttonView.setContentDescription(buttonView.getText().toString().toLowerCase());
        } else {
            buttonView.setText(R.string.firstrun_next_button);
            buttonView.setId(R.id.next);
        }

{'fraction_non_alphanumeric': 0.08902118233421016, 'fraction_numerical': 0.00443029212238682, 'mean_word_length': 2.310724106324473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3873632', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1858, 'n_words': 415}