ソースコード source code

下記アプリの主要なソースコードを公開しています。アプリ開発の参考になれば幸いです。

画像等が別途必要ですので下記情報のみでアプリが完成するものではありません。 アプリは少しずつ機能拡張していますのでストア公開されているアプリと内容が異なる場合があります。 コードはコピーして自由にお使いいただけます。ただし著作権は放棄しておりませんので全部の再掲載はご遠慮ください。部分的に再掲載したり、改変して再掲載するのは構いません。 自身のアプリ作成の参考として個人使用・商用問わず自由にお使いいただけます。 コード記述のお手本を示すものではありません。ミニアプリですので変数名などさほど気遣いしていない部分も有りますし間違いも有るかと思いますので参考程度にお考え下さい。 他の賢者の皆様が公開されているコードを参考にした箇所も含まれます。Androidアプリ開発の熟練者が書いたコードではありません。 エンジニア向け技術情報共有サービスではありませんので説明は省いています。ご了承ください。 GitHubなどへの公開は予定しておりません。

下記コードの最終ビルド日: 2021-05-09

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.4.32"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "jp.aosystem.roulette"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode 17
        versionName "1.16"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.gms:play-services-ads:20.1.0'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

app/src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="jp.aosystem.roulette">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Roulette">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".VerifyActivity" />
        <activity android:name=".SettingActivity" />

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-0000000000000000~0000000000">
    </application>

</manifest>

app/src/main/java/jp/aosystem/roulette/MainActivity.kt

package jp.aosystem.roulette

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.util.DisplayMetrics
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.MobileAds
import jp.aosystem.roulette.databinding.ActivityMainBinding
import java.util.*

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    private lateinit var viewModel: ConstraintLayout
    private lateinit var customSurfaceView: CustomSurfaceView
    data class ItemState(
            var name: String,
            var rate: Float,
    )
    private var itemStates: Array<ItemState> = arrayOf()
    private var itemSplit: Int = 0  //0 or 1
    private var shortenRotation: Int = 0    //0 or 1
    private var speechResult: Int = 0   //結果を読み上げるか否か 0 or 1
    private var themeNumber: Int = 0  //0 or 1
    private var localeLanguage: String = ""

    //adMob
    private lateinit var adView: AdView     //adMob
    private val adSize: AdSize
        get() {
            val display = windowManager.defaultDisplay
            val outMetrics = DisplayMetrics()
            display.getMetrics(outMetrics)
            val density = outMetrics.density
            var adWidthPixels = this.binding.adContainer.width.toFloat()
            if (adWidthPixels == 0f) {
                adWidthPixels = outMetrics.widthPixels.toFloat()
            }
            val adWidth = (adWidthPixels / density).toInt()
            return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
        }

    companion object {
        //private const val AD_UNIT_ID: String = "ca-app-pub-3940256099942544/6300978111"     //adMob Test
        private const val AD_UNIT_ID: String = "ca-app-pub-0000000000000000/0000000000"     //adMob
        private const val RESULT_VERIFY_ACTIVITY: Int = 1
        private const val RESULT_SETTING_ACTIVITY: Int = 2
        internal const val SETTINGS: String = "settings"
        internal const val ITEM_NAME1: String = "itemName1"
        internal const val ITEM_NAME2: String = "itemName2"
        internal const val ITEM_NAME3: String = "itemName3"
        internal const val ITEM_NAME4: String = "itemName4"
        internal const val ITEM_NAME5: String = "itemName5"
        internal const val ITEM_NAME6: String = "itemName6"
        internal const val ITEM_NAME7: String = "itemName7"
        internal const val ITEM_NAME8: String = "itemName8"
        internal const val ITEM_NAME9: String = "itemName9"
        internal const val ITEM_NAME10: String = "itemName10"
        internal const val ITEM_NAME11: String = "itemName11"
        internal const val ITEM_NAME12: String = "itemName12"
        internal const val ITEM_NAME13: String = "itemName13"
        internal const val ITEM_NAME14: String = "itemName14"
        internal const val ITEM_NAME15: String = "itemName15"
        internal const val ITEM_NAME16: String = "itemName16"
        internal const val ITEM_NAME17: String = "itemName17"
        internal const val ITEM_NAME18: String = "itemName18"
        internal const val ITEM_NAME19: String = "itemName19"
        internal const val ITEM_NAME20: String = "itemName20"
        internal const val ITEM_RATE1: String = "itemRate1"
        internal const val ITEM_RATE2: String = "itemRate2"
        internal const val ITEM_RATE3: String = "itemRate3"
        internal const val ITEM_RATE4: String = "itemRate4"
        internal const val ITEM_RATE5: String = "itemRate5"
        internal const val ITEM_RATE6: String = "itemRate6"
        internal const val ITEM_RATE7: String = "itemRate7"
        internal const val ITEM_RATE8: String = "itemRate8"
        internal const val ITEM_RATE9: String = "itemRate9"
        internal const val ITEM_RATE10: String = "itemRate10"
        internal const val ITEM_RATE11: String = "itemRate11"
        internal const val ITEM_RATE12: String = "itemRate12"
        internal const val ITEM_RATE13: String = "itemRate13"
        internal const val ITEM_RATE14: String = "itemRate14"
        internal const val ITEM_RATE15: String = "itemRate15"
        internal const val ITEM_RATE16: String = "itemRate16"
        internal const val ITEM_RATE17: String = "itemRate17"
        internal const val ITEM_RATE18: String = "itemRate18"
        internal const val ITEM_RATE19: String = "itemRate19"
        internal const val ITEM_RATE20: String = "itemRate20"
        internal const val ITEM_SPLIT: String = "itemSplit"
        internal const val SHORTEN_ROTATION: String = "shortenRotation"
        internal const val SPEECH_RESULT: String = "speechResult"
        internal const val THEME_NUMBER: String = "themeNumber"
        internal const val LOCALE_LANGUAGE: String = "localeLanguage"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        this.binding = ActivityMainBinding.inflate(layoutInflater)
        this.viewModel = this.binding.root
        setContentView(this.viewModel)
        //
        supportActionBar?.hide()    //タイトルバー非表示
        //テーマ読み込みと設定
        this.loadThemeNumber()
        this.setTheme()
        //設定読込
        this.loadItemStates()
        this.loadItemSplit()
        this.loadShortenRotation()
        this.loadSpeechResult()
        //adMob
        MobileAds.initialize(this) {}
        this.adView = AdView(this)
        this.binding.adContainer.addView(this.adView)
        this.loadBanner()
    }

    override fun onResume() {
        super.onResume()
        this.customSurfaceViewStart()
    }

    //adMob
    private fun loadBanner() {
        this.adView.adUnitId = AD_UNIT_ID
        this.adView.adSize = adSize
        val adRequest = AdRequest
            .Builder()
            //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build()
        this.adView.loadAd(adRequest)
    }

    private fun customSurfaceViewStart() {
        this.customSurfaceView = CustomSurfaceView(
            this,
            this.binding.surfaceView1,
            this.itemStates,
            this.itemSplit,
            this.shortenRotation,
            this.speechResult,
            this.localeLanguage
        )
        /*
        this.customSurfaceView.setOnTouchListener { v, event ->
            customSurfaceView.onTouch(event)
        }
        */
    }

    fun onClickStart(v: View) {
        this.customSurfaceView.onClickStart()
    }

    fun onClickVerify(v: View) {
        this.customSurfaceView.setDestroy()
        val intent = Intent(applicationContext, VerifyActivity::class.java)
        intent.putExtra(ITEM_NAME1, this.itemStates[0].name)
        intent.putExtra(ITEM_RATE1, this.itemStates[0].rate)
        intent.putExtra(ITEM_NAME2, this.itemStates[1].name)
        intent.putExtra(ITEM_RATE2, this.itemStates[1].rate)
        intent.putExtra(ITEM_NAME3, this.itemStates[2].name)
        intent.putExtra(ITEM_RATE3, this.itemStates[2].rate)
        intent.putExtra(ITEM_NAME4, this.itemStates[3].name)
        intent.putExtra(ITEM_RATE4, this.itemStates[3].rate)
        intent.putExtra(ITEM_NAME5, this.itemStates[4].name)
        intent.putExtra(ITEM_RATE5, this.itemStates[4].rate)
        intent.putExtra(ITEM_NAME6, this.itemStates[5].name)
        intent.putExtra(ITEM_RATE6, this.itemStates[5].rate)
        intent.putExtra(ITEM_NAME7, this.itemStates[6].name)
        intent.putExtra(ITEM_RATE7, this.itemStates[6].rate)
        intent.putExtra(ITEM_NAME8, this.itemStates[7].name)
        intent.putExtra(ITEM_RATE8, this.itemStates[7].rate)
        intent.putExtra(ITEM_NAME9, this.itemStates[8].name)
        intent.putExtra(ITEM_RATE9, this.itemStates[8].rate)
        intent.putExtra(ITEM_NAME10, this.itemStates[9].name)
        intent.putExtra(ITEM_RATE10, this.itemStates[9].rate)
        intent.putExtra(ITEM_NAME11, this.itemStates[10].name)
        intent.putExtra(ITEM_RATE11, this.itemStates[10].rate)
        intent.putExtra(ITEM_NAME12, this.itemStates[11].name)
        intent.putExtra(ITEM_RATE12, this.itemStates[11].rate)
        intent.putExtra(ITEM_NAME13, this.itemStates[12].name)
        intent.putExtra(ITEM_RATE13, this.itemStates[12].rate)
        intent.putExtra(ITEM_NAME14, this.itemStates[13].name)
        intent.putExtra(ITEM_RATE14, this.itemStates[13].rate)
        intent.putExtra(ITEM_NAME15, this.itemStates[14].name)
        intent.putExtra(ITEM_RATE15, this.itemStates[14].rate)
        intent.putExtra(ITEM_NAME16, this.itemStates[15].name)
        intent.putExtra(ITEM_RATE16, this.itemStates[15].rate)
        intent.putExtra(ITEM_NAME17, this.itemStates[16].name)
        intent.putExtra(ITEM_RATE17, this.itemStates[16].rate)
        intent.putExtra(ITEM_NAME18, this.itemStates[17].name)
        intent.putExtra(ITEM_RATE18, this.itemStates[17].rate)
        intent.putExtra(ITEM_NAME19, this.itemStates[18].name)
        intent.putExtra(ITEM_RATE19, this.itemStates[18].rate)
        intent.putExtra(ITEM_NAME20, this.itemStates[19].name)
        intent.putExtra(ITEM_RATE20, this.itemStates[19].rate)
        startActivityForResult(intent, RESULT_VERIFY_ACTIVITY)
    }

    fun onClickSetting(v: View) {
        this.customSurfaceView.setDestroy()
        val intent = Intent(applicationContext, SettingActivity::class.java)
        intent.putExtra(ITEM_NAME1, this.itemStates[0].name)
        intent.putExtra(ITEM_RATE1, this.itemStates[0].rate)
        intent.putExtra(ITEM_NAME2, this.itemStates[1].name)
        intent.putExtra(ITEM_RATE2, this.itemStates[1].rate)
        intent.putExtra(ITEM_NAME3, this.itemStates[2].name)
        intent.putExtra(ITEM_RATE3, this.itemStates[2].rate)
        intent.putExtra(ITEM_NAME4, this.itemStates[3].name)
        intent.putExtra(ITEM_RATE4, this.itemStates[3].rate)
        intent.putExtra(ITEM_NAME5, this.itemStates[4].name)
        intent.putExtra(ITEM_RATE5, this.itemStates[4].rate)
        intent.putExtra(ITEM_NAME6, this.itemStates[5].name)
        intent.putExtra(ITEM_RATE6, this.itemStates[5].rate)
        intent.putExtra(ITEM_NAME7, this.itemStates[6].name)
        intent.putExtra(ITEM_RATE7, this.itemStates[6].rate)
        intent.putExtra(ITEM_NAME8, this.itemStates[7].name)
        intent.putExtra(ITEM_RATE8, this.itemStates[7].rate)
        intent.putExtra(ITEM_NAME9, this.itemStates[8].name)
        intent.putExtra(ITEM_RATE9, this.itemStates[8].rate)
        intent.putExtra(ITEM_NAME10, this.itemStates[9].name)
        intent.putExtra(ITEM_RATE10, this.itemStates[9].rate)
        intent.putExtra(ITEM_NAME11, this.itemStates[10].name)
        intent.putExtra(ITEM_RATE11, this.itemStates[10].rate)
        intent.putExtra(ITEM_NAME12, this.itemStates[11].name)
        intent.putExtra(ITEM_RATE12, this.itemStates[11].rate)
        intent.putExtra(ITEM_NAME13, this.itemStates[12].name)
        intent.putExtra(ITEM_RATE13, this.itemStates[12].rate)
        intent.putExtra(ITEM_NAME14, this.itemStates[13].name)
        intent.putExtra(ITEM_RATE14, this.itemStates[13].rate)
        intent.putExtra(ITEM_NAME15, this.itemStates[14].name)
        intent.putExtra(ITEM_RATE15, this.itemStates[14].rate)
        intent.putExtra(ITEM_NAME16, this.itemStates[15].name)
        intent.putExtra(ITEM_RATE16, this.itemStates[15].rate)
        intent.putExtra(ITEM_NAME17, this.itemStates[16].name)
        intent.putExtra(ITEM_RATE17, this.itemStates[16].rate)
        intent.putExtra(ITEM_NAME18, this.itemStates[17].name)
        intent.putExtra(ITEM_RATE18, this.itemStates[17].rate)
        intent.putExtra(ITEM_NAME19, this.itemStates[18].name)
        intent.putExtra(ITEM_RATE19, this.itemStates[18].rate)
        intent.putExtra(ITEM_NAME20, this.itemStates[19].name)
        intent.putExtra(ITEM_RATE20, this.itemStates[19].rate)
        intent.putExtra(ITEM_SPLIT, this.itemSplit)
        intent.putExtra(SHORTEN_ROTATION, this.shortenRotation)
        intent.putExtra(SPEECH_RESULT, this.speechResult)
        intent.putExtra(THEME_NUMBER, this.themeNumber)
        intent.putExtra(LOCALE_LANGUAGE, this.localeLanguage)
        startActivityForResult(intent, RESULT_SETTING_ACTIVITY)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
        super.onActivityResult(requestCode, resultCode, intent)
        if (resultCode == Activity.RESULT_OK && requestCode == RESULT_SETTING_ACTIVITY && intent != null) {
            val itemName1: String = intent.getStringExtra(ITEM_NAME1) ?: ""
            val itemRate1: Float = intent.getFloatExtra(ITEM_RATE1, 0F)
            val itemName2: String = intent.getStringExtra(ITEM_NAME2) ?: ""
            val itemRate2: Float = intent.getFloatExtra(ITEM_RATE2, 0F)
            val itemName3: String = intent.getStringExtra(ITEM_NAME3) ?: ""
            val itemRate3: Float = intent.getFloatExtra(ITEM_RATE3, 0F)
            val itemName4: String = intent.getStringExtra(ITEM_NAME4) ?: ""
            val itemRate4: Float = intent.getFloatExtra(ITEM_RATE4, 0F)
            val itemName5: String = intent.getStringExtra(ITEM_NAME5) ?: ""
            val itemRate5: Float = intent.getFloatExtra(ITEM_RATE5, 0F)
            val itemName6: String = intent.getStringExtra(ITEM_NAME6) ?: ""
            val itemRate6: Float = intent.getFloatExtra(ITEM_RATE6, 0F)
            val itemName7: String = intent.getStringExtra(ITEM_NAME7) ?: ""
            val itemRate7: Float = intent.getFloatExtra(ITEM_RATE7, 0F)
            val itemName8: String = intent.getStringExtra(ITEM_NAME8) ?: ""
            val itemRate8: Float = intent.getFloatExtra(ITEM_RATE8, 0F)
            val itemName9: String = intent.getStringExtra(ITEM_NAME9) ?: ""
            val itemRate9: Float = intent.getFloatExtra(ITEM_RATE9, 0F)
            val itemName10: String = intent.getStringExtra(ITEM_NAME10) ?: ""
            val itemRate10: Float = intent.getFloatExtra(ITEM_RATE10, 0F)
            val itemName11: String = intent.getStringExtra(ITEM_NAME11) ?: ""
            val itemRate11: Float = intent.getFloatExtra(ITEM_RATE11, 0F)
            val itemName12: String = intent.getStringExtra(ITEM_NAME12) ?: ""
            val itemRate12: Float = intent.getFloatExtra(ITEM_RATE12, 0F)
            val itemName13: String = intent.getStringExtra(ITEM_NAME13) ?: ""
            val itemRate13: Float = intent.getFloatExtra(ITEM_RATE13, 0F)
            val itemName14: String = intent.getStringExtra(ITEM_NAME14) ?: ""
            val itemRate14: Float = intent.getFloatExtra(ITEM_RATE14, 0F)
            val itemName15: String = intent.getStringExtra(ITEM_NAME15) ?: ""
            val itemRate15: Float = intent.getFloatExtra(ITEM_RATE15, 0F)
            val itemName16: String = intent.getStringExtra(ITEM_NAME16) ?: ""
            val itemRate16: Float = intent.getFloatExtra(ITEM_RATE16, 0F)
            val itemName17: String = intent.getStringExtra(ITEM_NAME17) ?: ""
            val itemRate17: Float = intent.getFloatExtra(ITEM_RATE17, 0F)
            val itemName18: String = intent.getStringExtra(ITEM_NAME18) ?: ""
            val itemRate18: Float = intent.getFloatExtra(ITEM_RATE18, 0F)
            val itemName19: String = intent.getStringExtra(ITEM_NAME19) ?: ""
            val itemRate19: Float = intent.getFloatExtra(ITEM_RATE19, 0F)
            val itemName20: String = intent.getStringExtra(ITEM_NAME20) ?: ""
            val itemRate20: Float = intent.getFloatExtra(ITEM_RATE20, 0F)
            this.itemStates = arrayOf(
                    ItemState(itemName1, itemRate1),
                    ItemState(itemName2, itemRate2),
                    ItemState(itemName3, itemRate3),
                    ItemState(itemName4, itemRate4),
                    ItemState(itemName5, itemRate5),
                    ItemState(itemName6, itemRate6),
                    ItemState(itemName7, itemRate7),
                    ItemState(itemName8, itemRate8),
                    ItemState(itemName9, itemRate9),
                    ItemState(itemName10, itemRate10),
                    ItemState(itemName11, itemRate11),
                    ItemState(itemName12, itemRate12),
                    ItemState(itemName13, itemRate13),
                    ItemState(itemName14, itemRate14),
                    ItemState(itemName15, itemRate15),
                    ItemState(itemName16, itemRate16),
                    ItemState(itemName17, itemRate17),
                    ItemState(itemName18, itemRate18),
                    ItemState(itemName19, itemRate19),
                    ItemState(itemName20, itemRate20),
            )
            this.saveItemStates()
            //
            val lastItemSplit: Int = this.itemSplit
            this.itemSplit = intent.getIntExtra(ITEM_SPLIT, 0)
            if (lastItemSplit != this.itemSplit) {
                this.saveItemSplit()
            }
            //
            val lastShortenRotation: Int = this.shortenRotation
            this.shortenRotation = intent.getIntExtra(SHORTEN_ROTATION, 0)
            if (lastShortenRotation != this.shortenRotation) {
                this.saveShortenRotation()
            }
            //
            val lastSpeechResult: Int = this.speechResult
            this.speechResult = intent.getIntExtra(SPEECH_RESULT, 1)
            if (lastSpeechResult != this.speechResult) {
                this.saveSpeechResult()
            }
            //
            val lastThemeNumber: Int = this.themeNumber
            this.themeNumber = intent.getIntExtra(THEME_NUMBER, 0)
            if (lastThemeNumber != this.themeNumber) {
                this.saveThemeNumber()
            }
            //
            val lastLocaleLanguage = this.localeLanguage
            this.localeLanguage = intent.getStringExtra(LOCALE_LANGUAGE) ?: ""
            if (this.localeLanguage != lastLocaleLanguage) {
                this.saveLocaleLanguage()
            }
        }
        recreate()
    }

    //-------------------------------------------------

    //itemsを保存
    private fun saveItemStates() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putString(ITEM_NAME1, this@MainActivity.itemStates[0].name)
            putFloat(ITEM_RATE1, this@MainActivity.itemStates[0].rate)
            putString(ITEM_NAME2, this@MainActivity.itemStates[1].name)
            putFloat(ITEM_RATE2, this@MainActivity.itemStates[1].rate)
            putString(ITEM_NAME3, this@MainActivity.itemStates[2].name)
            putFloat(ITEM_RATE3, this@MainActivity.itemStates[2].rate)
            putString(ITEM_NAME4, this@MainActivity.itemStates[3].name)
            putFloat(ITEM_RATE4, this@MainActivity.itemStates[3].rate)
            putString(ITEM_NAME5, this@MainActivity.itemStates[4].name)
            putFloat(ITEM_RATE5, this@MainActivity.itemStates[4].rate)
            putString(ITEM_NAME6, this@MainActivity.itemStates[5].name)
            putFloat(ITEM_RATE6, this@MainActivity.itemStates[5].rate)
            putString(ITEM_NAME7, this@MainActivity.itemStates[6].name)
            putFloat(ITEM_RATE7, this@MainActivity.itemStates[6].rate)
            putString(ITEM_NAME8, this@MainActivity.itemStates[7].name)
            putFloat(ITEM_RATE8, this@MainActivity.itemStates[7].rate)
            putString(ITEM_NAME9, this@MainActivity.itemStates[8].name)
            putFloat(ITEM_RATE9, this@MainActivity.itemStates[8].rate)
            putString(ITEM_NAME10, this@MainActivity.itemStates[9].name)
            putFloat(ITEM_RATE10, this@MainActivity.itemStates[9].rate)
            putString(ITEM_NAME11, this@MainActivity.itemStates[10].name)
            putFloat(ITEM_RATE11, this@MainActivity.itemStates[10].rate)
            putString(ITEM_NAME12, this@MainActivity.itemStates[11].name)
            putFloat(ITEM_RATE12, this@MainActivity.itemStates[11].rate)
            putString(ITEM_NAME13, this@MainActivity.itemStates[12].name)
            putFloat(ITEM_RATE13, this@MainActivity.itemStates[12].rate)
            putString(ITEM_NAME14, this@MainActivity.itemStates[13].name)
            putFloat(ITEM_RATE14, this@MainActivity.itemStates[13].rate)
            putString(ITEM_NAME15, this@MainActivity.itemStates[14].name)
            putFloat(ITEM_RATE15, this@MainActivity.itemStates[14].rate)
            putString(ITEM_NAME16, this@MainActivity.itemStates[15].name)
            putFloat(ITEM_RATE16, this@MainActivity.itemStates[15].rate)
            putString(ITEM_NAME17, this@MainActivity.itemStates[16].name)
            putFloat(ITEM_RATE17, this@MainActivity.itemStates[16].rate)
            putString(ITEM_NAME18, this@MainActivity.itemStates[17].name)
            putFloat(ITEM_RATE18, this@MainActivity.itemStates[17].rate)
            putString(ITEM_NAME19, this@MainActivity.itemStates[18].name)
            putFloat(ITEM_RATE19, this@MainActivity.itemStates[18].rate)
            putString(ITEM_NAME20, this@MainActivity.itemStates[19].name)
            putFloat(ITEM_RATE20, this@MainActivity.itemStates[19].rate)
            apply()
        }
    }

    //itemsを読み出し
    private fun loadItemStates() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.itemStates = arrayOf(
                ItemState(pref.getString(ITEM_NAME1, "") ?: "", pref.getFloat(ITEM_RATE1, 1F)),
                ItemState(pref.getString(ITEM_NAME2, "") ?: "", pref.getFloat(ITEM_RATE2, 1F)),
                ItemState(pref.getString(ITEM_NAME3, "") ?: "", pref.getFloat(ITEM_RATE3, 1F)),
                ItemState(pref.getString(ITEM_NAME4, "") ?: "", pref.getFloat(ITEM_RATE4, 1F)),
                ItemState(pref.getString(ITEM_NAME5, "") ?: "", pref.getFloat(ITEM_RATE5, 1F)),
                ItemState(pref.getString(ITEM_NAME6, "") ?: "", pref.getFloat(ITEM_RATE6, 1F)),
                ItemState(pref.getString(ITEM_NAME7, "") ?: "", pref.getFloat(ITEM_RATE7, 1F)),
                ItemState(pref.getString(ITEM_NAME8, "") ?: "", pref.getFloat(ITEM_RATE8, 1F)),
                ItemState(pref.getString(ITEM_NAME9, "") ?: "", pref.getFloat(ITEM_RATE9, 1F)),
                ItemState(pref.getString(ITEM_NAME10, "") ?: "", pref.getFloat(ITEM_RATE10, 1F)),
                ItemState(pref.getString(ITEM_NAME11, "") ?: "", pref.getFloat(ITEM_RATE11, 1F)),
                ItemState(pref.getString(ITEM_NAME12, "") ?: "", pref.getFloat(ITEM_RATE12, 1F)),
                ItemState(pref.getString(ITEM_NAME13, "") ?: "", pref.getFloat(ITEM_RATE13, 1F)),
                ItemState(pref.getString(ITEM_NAME14, "") ?: "", pref.getFloat(ITEM_RATE14, 1F)),
                ItemState(pref.getString(ITEM_NAME15, "") ?: "", pref.getFloat(ITEM_RATE15, 1F)),
                ItemState(pref.getString(ITEM_NAME16, "") ?: "", pref.getFloat(ITEM_RATE16, 1F)),
                ItemState(pref.getString(ITEM_NAME17, "") ?: "", pref.getFloat(ITEM_RATE17, 1F)),
                ItemState(pref.getString(ITEM_NAME18, "") ?: "", pref.getFloat(ITEM_RATE18, 1F)),
                ItemState(pref.getString(ITEM_NAME19, "") ?: "", pref.getFloat(ITEM_RATE19, 1F)),
                ItemState(pref.getString(ITEM_NAME20, "") ?: "", pref.getFloat(ITEM_RATE20, 1F)),
        )
        var nameCount: Int = 0  //項目が2個以上登録されているか
        for (i in this.itemStates.indices) {
            if (this.itemStates[i].name != "") {
                nameCount += 1
                if (nameCount >= 2) {
                    break
                }
            }
        }
        when (nameCount) {
            0 -> {  //初期値設定
                this.itemStates[0].name = resources.getString(R.string.editItem1)
                this.itemStates[0].rate = 1F
                this.itemStates[1].name = resources.getString(R.string.editItem2)
                this.itemStates[1].rate = 1.41F
                this.itemStates[2].name = resources.getString(R.string.editItem3)
                this.itemStates[2].rate = 1.73F
                this.itemStates[3].name = resources.getString(R.string.editItem4)
                this.itemStates[3].rate = 2F
                this.itemStates[4].name = resources.getString(R.string.editItem5)
                this.itemStates[4].rate = 2.23F
            }
            1 -> {  //最低2個は必要
                for (i in this.itemStates.indices) {
                    if (this.itemStates[i].name == "") {
                        this.itemStates[i].name = (i + 1).toString()
                        break
                    }
                }
            }
        }
    }

    //-------------------------------------------------

    //itemSplitを保存
    private fun saveItemSplit() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(ITEM_SPLIT, this@MainActivity.itemSplit)
            apply()
        }
    }

    //ItemSplitを読み出し
    private fun loadItemSplit() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.itemSplit = pref.getInt(ITEM_SPLIT, 0)
    }

    //-------------------------------------------------

    //shortenRotationを保存
    private fun saveShortenRotation() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(SHORTEN_ROTATION, this@MainActivity.shortenRotation)
            apply()
        }
    }

    //shortenRotationを読み出し
    private fun loadShortenRotation() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.shortenRotation = pref.getInt(SHORTEN_ROTATION, 0)
    }

    //-------------------------------------------------

    //結果読み上げを保存
    private fun saveSpeechResult() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(SPEECH_RESULT, this@MainActivity.speechResult)
            apply()
        }
    }

    //結果読み上げを読み出し
    private fun loadSpeechResult() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.speechResult = pref.getInt(SPEECH_RESULT, 1)
    }

    //-------------------------------------------------

    //テーマを保存
    private fun saveThemeNumber() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(THEME_NUMBER, this@MainActivity.themeNumber)
            apply()
        }
    }

    //テーマを読み出し
    private fun loadThemeNumber() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.themeNumber =  pref.getInt(THEME_NUMBER, 0)
    }

    //テーマを設定
    private fun setTheme() {
        when (this.themeNumber) {
            0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
            1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
        }
    }

    //-------------------------------------------------

    //localeLanguageを保存
    private fun saveLocaleLanguage() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putString(LOCALE_LANGUAGE, this@MainActivity.localeLanguage)
            apply()
        }
    }

    //言語設定
    override fun attachBaseContext(base: Context) {
        val pref = base.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.localeLanguage = pref.getString(LOCALE_LANGUAGE, "") ?: ""
        val loc: Locale? = if (this.localeLanguage != "") Locale(this.localeLanguage) else null
        if (loc != null) {
            val res = base.resources
            val config = Configuration(res.configuration)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {    //minSdkVersion 24
                val localeList = LocaleList(loc)
                LocaleList.setDefault(localeList)
                config.setLocales(localeList)
            } else {    //minSdkVersion 17  16はダメ
                config.setLocale(loc)
            }
            super.attachBaseContext(base.createConfigurationContext(config))
        } else {
            super.attachBaseContext(base)
        }
    }

    //----------------------------------------------

}

app/src/main/java/jp/aosystem/roulette/SettingActivity.kt

package jp.aosystem.roulette

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import jp.aosystem.roulette.databinding.ActivitySettingBinding
import java.util.*

class SettingActivity : AppCompatActivity() {
    private lateinit var binding: ActivitySettingBinding
    private lateinit var viewModel: ConstraintLayout
    private var inputMethodManager: InputMethodManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        this.binding = ActivitySettingBinding.inflate(layoutInflater)
        this.viewModel = this.binding.root
        setContentView(this.viewModel)
        //データ受け取り
        val intent = this.intent
        val itemName1: String = intent.getStringExtra(MainActivity.ITEM_NAME1) ?: ""
        val itemRate1: Float = intent.getFloatExtra(MainActivity.ITEM_RATE1,0F)
        val itemName2: String = intent.getStringExtra(MainActivity.ITEM_NAME2) ?: ""
        val itemRate2: Float = intent.getFloatExtra(MainActivity.ITEM_RATE2,0F)
        val itemName3: String = intent.getStringExtra(MainActivity.ITEM_NAME3) ?: ""
        val itemRate3: Float = intent.getFloatExtra(MainActivity.ITEM_RATE3,0F)
        val itemName4: String = intent.getStringExtra(MainActivity.ITEM_NAME4) ?: ""
        val itemRate4: Float = intent.getFloatExtra(MainActivity.ITEM_RATE4,0F)
        val itemName5: String = intent.getStringExtra(MainActivity.ITEM_NAME5) ?: ""
        val itemRate5: Float = intent.getFloatExtra(MainActivity.ITEM_RATE5,0F)
        val itemName6: String = intent.getStringExtra(MainActivity.ITEM_NAME6) ?: ""
        val itemRate6: Float = intent.getFloatExtra(MainActivity.ITEM_RATE6,0F)
        val itemName7: String = intent.getStringExtra(MainActivity.ITEM_NAME7) ?: ""
        val itemRate7: Float = intent.getFloatExtra(MainActivity.ITEM_RATE7,0F)
        val itemName8: String = intent.getStringExtra(MainActivity.ITEM_NAME8) ?: ""
        val itemRate8: Float = intent.getFloatExtra(MainActivity.ITEM_RATE8,0F)
        val itemName9: String = intent.getStringExtra(MainActivity.ITEM_NAME9) ?: ""
        val itemRate9: Float = intent.getFloatExtra(MainActivity.ITEM_RATE9,0F)
        val itemName10: String = intent.getStringExtra(MainActivity.ITEM_NAME10) ?: ""
        val itemRate10: Float = intent.getFloatExtra(MainActivity.ITEM_RATE10,0F)
        val itemName11: String = intent.getStringExtra(MainActivity.ITEM_NAME11) ?: ""
        val itemRate11: Float = intent.getFloatExtra(MainActivity.ITEM_RATE11,0F)
        val itemName12: String = intent.getStringExtra(MainActivity.ITEM_NAME12) ?: ""
        val itemRate12: Float = intent.getFloatExtra(MainActivity.ITEM_RATE12,0F)
        val itemName13: String = intent.getStringExtra(MainActivity.ITEM_NAME13) ?: ""
        val itemRate13: Float = intent.getFloatExtra(MainActivity.ITEM_RATE13,0F)
        val itemName14: String = intent.getStringExtra(MainActivity.ITEM_NAME14) ?: ""
        val itemRate14: Float = intent.getFloatExtra(MainActivity.ITEM_RATE14,0F)
        val itemName15: String = intent.getStringExtra(MainActivity.ITEM_NAME15) ?: ""
        val itemRate15: Float = intent.getFloatExtra(MainActivity.ITEM_RATE15,0F)
        val itemName16: String = intent.getStringExtra(MainActivity.ITEM_NAME16) ?: ""
        val itemRate16: Float = intent.getFloatExtra(MainActivity.ITEM_RATE16,0F)
        val itemName17: String = intent.getStringExtra(MainActivity.ITEM_NAME17) ?: ""
        val itemRate17: Float = intent.getFloatExtra(MainActivity.ITEM_RATE17,0F)
        val itemName18: String = intent.getStringExtra(MainActivity.ITEM_NAME18) ?: ""
        val itemRate18: Float = intent.getFloatExtra(MainActivity.ITEM_RATE18,0F)
        val itemName19: String = intent.getStringExtra(MainActivity.ITEM_NAME19) ?: ""
        val itemRate19: Float = intent.getFloatExtra(MainActivity.ITEM_RATE19,0F)
        val itemName20: String = intent.getStringExtra(MainActivity.ITEM_NAME20) ?: ""
        val itemRate20: Float = intent.getFloatExtra(MainActivity.ITEM_RATE20,0F)
        if (itemName1 != "") {
            this.binding.editName1.setText(itemName1)
        }
        if (itemRate1 != 0F) {
            var ir: String = itemRate1.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate1.setText(ir)
        }
        this.binding.editName2.setText(itemName2)
        if (itemRate2 != 0F) {
            var ir: String = itemRate2.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate2.setText(ir)
        }
        this.binding.editName3.setText(itemName3)
        if (itemRate3 != 0F) {
            var ir: String = itemRate3.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate3.setText(ir)
        }
        this.binding.editName4.setText(itemName4)
        if (itemRate4 != 0F) {
            var ir: String = itemRate4.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate4.setText(ir)
        }
        this.binding.editName5.setText(itemName5)
        if (itemRate5 != 0F) {
            var ir: String = itemRate5.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate5.setText(ir)
        }
        this.binding.editName6.setText(itemName6)
        if (itemRate6 != 0F) {
            var ir: String = itemRate6.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate6.setText(ir)
        }
        this.binding.editName7.setText(itemName7)
        if (itemRate7 != 0F) {
            var ir: String = itemRate7.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate7.setText(ir)
        }
        this.binding.editName8.setText(itemName8)
        if (itemRate8 != 0F) {
            var ir: String = itemRate8.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate8.setText(ir)
        }
        this.binding.editName9.setText(itemName9)
        if (itemRate9 != 0F) {
            var ir: String = itemRate9.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate9.setText(ir)
        }
        this.binding.editName10.setText(itemName10)
        if (itemRate10 != 0F) {
            var ir: String = itemRate10.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate10.setText(ir)
        }
        this.binding.editName11.setText(itemName11)
        if (itemRate11 != 0F) {
            var ir: String = itemRate11.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate11.setText(ir)
        }
        this.binding.editName12.setText(itemName12)
        if (itemRate12 != 0F) {
            var ir: String = itemRate12.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate12.setText(ir)
        }
        this.binding.editName13.setText(itemName13)
        if (itemRate13 != 0F) {
            var ir: String = itemRate13.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate13.setText(ir)
        }
        this.binding.editName14.setText(itemName14)
        if (itemRate14 != 0F) {
            var ir: String = itemRate14.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate14.setText(ir)
        }
        this.binding.editName15.setText(itemName15)
        if (itemRate15 != 0F) {
            var ir: String = itemRate15.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate15.setText(ir)
        }
        this.binding.editName16.setText(itemName16)
        if (itemRate16 != 0F) {
            var ir: String = itemRate16.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate16.setText(ir)
        }
        this.binding.editName17.setText(itemName17)
        if (itemRate17 != 0F) {
            var ir: String = itemRate17.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate17.setText(ir)
        }
        this.binding.editName18.setText(itemName18)
        if (itemRate18 != 0F) {
            var ir: String = itemRate18.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate18.setText(ir)
        }
        this.binding.editName19.setText(itemName19)
        if (itemRate19 != 0F) {
            var ir: String = itemRate19.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate19.setText(ir)
        }
        this.binding.editName20.setText(itemName20)
        if (itemRate20 != 0F) {
            var ir: String = itemRate20.toString()
            if (ir.takeLast(2) == ".0") {
                ir = ir.substring(0, ir.length - 2)
            }
            this.binding.editRate20.setText(ir)
        }
        val itemSplit: Int = intent.getIntExtra(MainActivity.ITEM_SPLIT,0)
        this.binding.switchSplit.isChecked = itemSplit != 0
        val shortenRotation: Int = intent.getIntExtra(MainActivity.SHORTEN_ROTATION,0)
        this.binding.switchShortenRotation.isChecked = shortenRotation != 0
        val speechResult: Int = intent.getIntExtra(MainActivity.SPEECH_RESULT,0)
        this.binding.switchSpeechResult.isChecked = speechResult != 0
        val themeNumber: Int = intent.getIntExtra(MainActivity.THEME_NUMBER,0)
        this.binding.switchTheme.isChecked = themeNumber != 0
        val localeLanguage: String = intent.getStringExtra(MainActivity.LOCALE_LANGUAGE) ?: ""
        when (localeLanguage) {
            "en" -> this.binding.radioLanguageEn.isChecked = true
            "bg" -> this.binding.radioLanguageBg.isChecked = true
            "cs" -> this.binding.radioLanguageCs.isChecked = true
            "da" -> this.binding.radioLanguageDa.isChecked = true
            "de" -> this.binding.radioLanguageDe.isChecked = true
            "el" -> this.binding.radioLanguageEl.isChecked = true
            "es" -> this.binding.radioLanguageEs.isChecked = true
            "et" -> this.binding.radioLanguageEt.isChecked = true
            "fi" -> this.binding.radioLanguageFi.isChecked = true
            "fr" -> this.binding.radioLanguageFr.isChecked = true
            "hu" -> this.binding.radioLanguageHu.isChecked = true
            "it" -> this.binding.radioLanguageIt.isChecked = true
            "ja" -> this.binding.radioLanguageJa.isChecked = true
            "lt" -> this.binding.radioLanguageLt.isChecked = true
            "lv" -> this.binding.radioLanguageLv.isChecked = true
            "nl" -> this.binding.radioLanguageNl.isChecked = true
            "pl" -> this.binding.radioLanguagePl.isChecked = true
            "pt" -> this.binding.radioLanguagePt.isChecked = true
            "ro" -> this.binding.radioLanguageRo.isChecked = true
            "ru" -> this.binding.radioLanguageRu.isChecked = true
            "sk" -> this.binding.radioLanguageSk.isChecked = true
            "sv" -> this.binding.radioLanguageSv.isChecked = true
            "zh" -> this.binding.radioLanguageZh.isChecked = true
            else -> this.binding.radioLanguageSystem.isChecked = true
        }
        //
        supportActionBar?.hide()    //タイトルバー非表示
        //
        this.setTouchListener()
    }

    //背景タッチでテキストエリアからフォーカスを外してキーボードを隠す
    private fun setTouchListener() {
        this.inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
        this.binding.editName1.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName1.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate1.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate1.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName2.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName2.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate2.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate2.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName3.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName3.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate3.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate3.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName4.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName4.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate4.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate4.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName5.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName5.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate5.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate5.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName6.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName6.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate6.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate6.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName7.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName7.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate7.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate7.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName8.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName8.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate8.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate8.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName9.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName9.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate9.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate9.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName10.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName10.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate10.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate10.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName11.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName11.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate11.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate11.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName12.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName12.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate12.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate12.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName13.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName13.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate13.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate13.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName14.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName14.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate14.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate14.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName15.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName15.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate15.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate15.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName16.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName16.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate16.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate16.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName17.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName17.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate17.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate17.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName18.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName18.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate18.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate18.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName19.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName19.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate19.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate19.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName20.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName20.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRate20.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRate20.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
    }

    fun onClickApply(v: View) {
        val itemName1: String = this.binding.editName1.text.toString()
        val itemRate1: Float = ("0" + this.binding.editRate1.text.toString()).toFloat()
        val itemName2: String = this.binding.editName2.text.toString()
        val itemRate2: Float = ("0" + this.binding.editRate2.text.toString()).toFloat()
        val itemName3: String = this.binding.editName3.text.toString()
        val itemRate3: Float = ("0" + this.binding.editRate3.text.toString()).toFloat()
        val itemName4: String = this.binding.editName4.text.toString()
        val itemRate4: Float = ("0" + this.binding.editRate4.text.toString()).toFloat()
        val itemName5: String = this.binding.editName5.text.toString()
        val itemRate5: Float = ("0" + this.binding.editRate5.text.toString()).toFloat()
        val itemName6: String = this.binding.editName6.text.toString()
        val itemRate6: Float = ("0" + this.binding.editRate6.text.toString()).toFloat()
        val itemName7: String = this.binding.editName7.text.toString()
        val itemRate7: Float = ("0" + this.binding.editRate7.text.toString()).toFloat()
        val itemName8: String = this.binding.editName8.text.toString()
        val itemRate8: Float = ("0" + this.binding.editRate8.text.toString()).toFloat()
        val itemName9: String = this.binding.editName9.text.toString()
        val itemRate9: Float = ("0" + this.binding.editRate9.text.toString()).toFloat()
        val itemName10: String = this.binding.editName10.text.toString()
        val itemRate10: Float = ("0" + this.binding.editRate10.text.toString()).toFloat()
        val itemName11: String = this.binding.editName11.text.toString()
        val itemRate11: Float = ("0" + this.binding.editRate11.text.toString()).toFloat()
        val itemName12: String = this.binding.editName12.text.toString()
        val itemRate12: Float = ("0" + this.binding.editRate12.text.toString()).toFloat()
        val itemName13: String = this.binding.editName13.text.toString()
        val itemRate13: Float = ("0" + this.binding.editRate13.text.toString()).toFloat()
        val itemName14: String = this.binding.editName14.text.toString()
        val itemRate14: Float = ("0" + this.binding.editRate14.text.toString()).toFloat()
        val itemName15: String = this.binding.editName15.text.toString()
        val itemRate15: Float = ("0" + this.binding.editRate15.text.toString()).toFloat()
        val itemName16: String = this.binding.editName16.text.toString()
        val itemRate16: Float = ("0" + this.binding.editRate16.text.toString()).toFloat()
        val itemName17: String = this.binding.editName17.text.toString()
        val itemRate17: Float = ("0" + this.binding.editRate17.text.toString()).toFloat()
        val itemName18: String = this.binding.editName18.text.toString()
        val itemRate18: Float = ("0" + this.binding.editRate18.text.toString()).toFloat()
        val itemName19: String = this.binding.editName19.text.toString()
        val itemRate19: Float = ("0" + this.binding.editRate19.text.toString()).toFloat()
        val itemName20: String = this.binding.editName20.text.toString()
        val itemRate20: Float = ("0" + this.binding.editRate20.text.toString()).toFloat()
        val itemSplit = if (this.binding.switchSplit.isChecked) 1 else 0
        val shortenRotation = if (this.binding.switchShortenRotation.isChecked) 1 else 0
        val speechResult: Int = if (this.binding.switchSpeechResult.isChecked) 1 else 0
        val themeNumber = if (this.binding.switchTheme.isChecked) 1 else 0
        var localeLanguage: String = ""
        if (this.binding.radioLanguageEn.isChecked) {
            localeLanguage = "en"
        } else if (this.binding.radioLanguageBg.isChecked) {
            localeLanguage = "bg"
        } else if (this.binding.radioLanguageCs.isChecked) {
            localeLanguage = "cs"
        } else if (this.binding.radioLanguageDa.isChecked) {
            localeLanguage = "da"
        } else if (this.binding.radioLanguageDe.isChecked) {
            localeLanguage = "de"
        } else if (this.binding.radioLanguageEl.isChecked) {
            localeLanguage = "el"
        } else if (this.binding.radioLanguageEs.isChecked) {
            localeLanguage = "es"
        } else if (this.binding.radioLanguageEt.isChecked) {
            localeLanguage = "et"
        } else if (this.binding.radioLanguageFi.isChecked) {
            localeLanguage = "fi"
        } else if (this.binding.radioLanguageFr.isChecked) {
            localeLanguage = "fr"
        } else if (this.binding.radioLanguageHu.isChecked) {
            localeLanguage = "hu"
        } else if (this.binding.radioLanguageIt.isChecked) {
            localeLanguage = "it"
        } else if (this.binding.radioLanguageJa.isChecked) {
            localeLanguage = "ja"
        } else if (this.binding.radioLanguageLt.isChecked) {
            localeLanguage = "lt"
        } else if (this.binding.radioLanguageLv.isChecked) {
            localeLanguage = "lv"
        } else if (this.binding.radioLanguageNl.isChecked) {
            localeLanguage = "nl"
        } else if (this.binding.radioLanguagePl.isChecked) {
            localeLanguage = "pl"
        } else if (this.binding.radioLanguagePt.isChecked) {
            localeLanguage = "pt"
        } else if (this.binding.radioLanguageRo.isChecked) {
            localeLanguage = "ro"
        } else if (this.binding.radioLanguageRu.isChecked) {
            localeLanguage = "ru"
        } else if (this.binding.radioLanguageSk.isChecked) {
            localeLanguage = "sk"
        } else if (this.binding.radioLanguageSv.isChecked) {
            localeLanguage = "sv"
        } else if (this.binding.radioLanguageZh.isChecked) {
            localeLanguage = "zh"
        }
        val intent = Intent()
        intent.putExtra(MainActivity.ITEM_NAME1, itemName1)
        intent.putExtra(MainActivity.ITEM_RATE1, itemRate1)
        intent.putExtra(MainActivity.ITEM_NAME2, itemName2)
        intent.putExtra(MainActivity.ITEM_RATE2, itemRate2)
        intent.putExtra(MainActivity.ITEM_NAME3, itemName3)
        intent.putExtra(MainActivity.ITEM_RATE3, itemRate3)
        intent.putExtra(MainActivity.ITEM_NAME4, itemName4)
        intent.putExtra(MainActivity.ITEM_RATE4, itemRate4)
        intent.putExtra(MainActivity.ITEM_NAME5, itemName5)
        intent.putExtra(MainActivity.ITEM_RATE5, itemRate5)
        intent.putExtra(MainActivity.ITEM_NAME6, itemName6)
        intent.putExtra(MainActivity.ITEM_RATE6, itemRate6)
        intent.putExtra(MainActivity.ITEM_NAME7, itemName7)
        intent.putExtra(MainActivity.ITEM_RATE7, itemRate7)
        intent.putExtra(MainActivity.ITEM_NAME8, itemName8)
        intent.putExtra(MainActivity.ITEM_RATE8, itemRate8)
        intent.putExtra(MainActivity.ITEM_NAME9, itemName9)
        intent.putExtra(MainActivity.ITEM_RATE9, itemRate9)
        intent.putExtra(MainActivity.ITEM_NAME10, itemName10)
        intent.putExtra(MainActivity.ITEM_RATE10, itemRate10)
        intent.putExtra(MainActivity.ITEM_NAME11, itemName11)
        intent.putExtra(MainActivity.ITEM_RATE11, itemRate11)
        intent.putExtra(MainActivity.ITEM_NAME12, itemName12)
        intent.putExtra(MainActivity.ITEM_RATE12, itemRate12)
        intent.putExtra(MainActivity.ITEM_NAME13, itemName13)
        intent.putExtra(MainActivity.ITEM_RATE13, itemRate13)
        intent.putExtra(MainActivity.ITEM_NAME14, itemName14)
        intent.putExtra(MainActivity.ITEM_RATE14, itemRate14)
        intent.putExtra(MainActivity.ITEM_NAME15, itemName15)
        intent.putExtra(MainActivity.ITEM_RATE15, itemRate15)
        intent.putExtra(MainActivity.ITEM_NAME16, itemName16)
        intent.putExtra(MainActivity.ITEM_RATE16, itemRate16)
        intent.putExtra(MainActivity.ITEM_NAME17, itemName17)
        intent.putExtra(MainActivity.ITEM_RATE17, itemRate17)
        intent.putExtra(MainActivity.ITEM_NAME18, itemName18)
        intent.putExtra(MainActivity.ITEM_RATE18, itemRate18)
        intent.putExtra(MainActivity.ITEM_NAME19, itemName19)
        intent.putExtra(MainActivity.ITEM_RATE19, itemRate19)
        intent.putExtra(MainActivity.ITEM_NAME20, itemName20)
        intent.putExtra(MainActivity.ITEM_RATE20, itemRate20)
        intent.putExtra(MainActivity.ITEM_SPLIT, itemSplit)
        intent.putExtra(MainActivity.SHORTEN_ROTATION, shortenRotation)
        intent.putExtra(MainActivity.SPEECH_RESULT, speechResult)
        intent.putExtra(MainActivity.THEME_NUMBER, themeNumber)
        intent.putExtra(MainActivity.LOCALE_LANGUAGE, localeLanguage)
        setResult(Activity.RESULT_OK, intent)
        finish()
    }

    fun onClickCancel(v: View) {
        val intent = Intent()
        setResult(Activity.RESULT_CANCELED, intent)
        finish()
    }

    //-----------------------------------------------

    //言語設定
    override fun attachBaseContext(base: Context) {
        val pref = base.getSharedPreferences(MainActivity.SETTINGS, Context.MODE_PRIVATE)
        val localeLanguage: String = pref.getString(MainActivity.LOCALE_LANGUAGE, "") ?: ""
        val loc: Locale? = if (localeLanguage != "") Locale(localeLanguage) else null
        if (loc != null) {
            val res = base.resources
            val config = Configuration(res.configuration)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {    //minSdkVersion 24
                val localeList = LocaleList(loc)
                LocaleList.setDefault(localeList)
                config.setLocales(localeList)
            } else {    //minSdkVersion 17  16はダメ
                config.setLocale(loc)
            }
            super.attachBaseContext(base.createConfigurationContext(config))
        } else {
            super.attachBaseContext(base)
        }
    }

    //-----------------------------------------------

}

app/src/main/java/jp/aosystem/roulette/VerifyActivity.kt

package jp.aosystem.roulette

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import jp.aosystem.roulette.databinding.ActivityVerifyBinding
import java.util.*
import kotlin.random.Random

class VerifyActivity : AppCompatActivity() {
    private lateinit var binding: ActivityVerifyBinding
    private lateinit var viewModel: ConstraintLayout
    private var itemStates: Array<MainActivity.ItemState> = arrayOf()   //全てのアイテム
    private var items: Array<MainActivity.ItemState> = arrayOf()    //有効なアイテムのみ
    private var itemRateSum: Float = 0F //レートの合計
    private var actionState: Int = 0    //回転状態
    private var actionAngle: Float = Random.nextInt(360).toFloat() + Random.nextFloat()    //回転の制御
    private var actionCount: Int = 0    //回転の制御

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        this.binding = ActivityVerifyBinding.inflate(layoutInflater)
        this.viewModel = this.binding.root
        setContentView(this.viewModel)
        //タイトルバー非表示
        supportActionBar?.hide()
        //データ受け取り
        val intent = this.intent
        val itemName1: String = intent.getStringExtra(MainActivity.ITEM_NAME1) ?: ""
        val itemRate1: Float = intent.getFloatExtra(MainActivity.ITEM_RATE1, 0F)
        val itemName2: String = intent.getStringExtra(MainActivity.ITEM_NAME2) ?: ""
        val itemRate2: Float = intent.getFloatExtra(MainActivity.ITEM_RATE2, 0F)
        val itemName3: String = intent.getStringExtra(MainActivity.ITEM_NAME3) ?: ""
        val itemRate3: Float = intent.getFloatExtra(MainActivity.ITEM_RATE3, 0F)
        val itemName4: String = intent.getStringExtra(MainActivity.ITEM_NAME4) ?: ""
        val itemRate4: Float = intent.getFloatExtra(MainActivity.ITEM_RATE4, 0F)
        val itemName5: String = intent.getStringExtra(MainActivity.ITEM_NAME5) ?: ""
        val itemRate5: Float = intent.getFloatExtra(MainActivity.ITEM_RATE5, 0F)
        val itemName6: String = intent.getStringExtra(MainActivity.ITEM_NAME6) ?: ""
        val itemRate6: Float = intent.getFloatExtra(MainActivity.ITEM_RATE6, 0F)
        val itemName7: String = intent.getStringExtra(MainActivity.ITEM_NAME7) ?: ""
        val itemRate7: Float = intent.getFloatExtra(MainActivity.ITEM_RATE7, 0F)
        val itemName8: String = intent.getStringExtra(MainActivity.ITEM_NAME8) ?: ""
        val itemRate8: Float = intent.getFloatExtra(MainActivity.ITEM_RATE8, 0F)
        val itemName9: String = intent.getStringExtra(MainActivity.ITEM_NAME9) ?: ""
        val itemRate9: Float = intent.getFloatExtra(MainActivity.ITEM_RATE9, 0F)
        val itemName10: String = intent.getStringExtra(MainActivity.ITEM_NAME10) ?: ""
        val itemRate10: Float = intent.getFloatExtra(MainActivity.ITEM_RATE10, 0F)
        val itemName11: String = intent.getStringExtra(MainActivity.ITEM_NAME11) ?: ""
        val itemRate11: Float = intent.getFloatExtra(MainActivity.ITEM_RATE11, 0F)
        val itemName12: String = intent.getStringExtra(MainActivity.ITEM_NAME12) ?: ""
        val itemRate12: Float = intent.getFloatExtra(MainActivity.ITEM_RATE12, 0F)
        val itemName13: String = intent.getStringExtra(MainActivity.ITEM_NAME13) ?: ""
        val itemRate13: Float = intent.getFloatExtra(MainActivity.ITEM_RATE13, 0F)
        val itemName14: String = intent.getStringExtra(MainActivity.ITEM_NAME14) ?: ""
        val itemRate14: Float = intent.getFloatExtra(MainActivity.ITEM_RATE14, 0F)
        val itemName15: String = intent.getStringExtra(MainActivity.ITEM_NAME15) ?: ""
        val itemRate15: Float = intent.getFloatExtra(MainActivity.ITEM_RATE15, 0F)
        val itemName16: String = intent.getStringExtra(MainActivity.ITEM_NAME16) ?: ""
        val itemRate16: Float = intent.getFloatExtra(MainActivity.ITEM_RATE16, 0F)
        val itemName17: String = intent.getStringExtra(MainActivity.ITEM_NAME17) ?: ""
        val itemRate17: Float = intent.getFloatExtra(MainActivity.ITEM_RATE17, 0F)
        val itemName18: String = intent.getStringExtra(MainActivity.ITEM_NAME18) ?: ""
        val itemRate18: Float = intent.getFloatExtra(MainActivity.ITEM_RATE18, 0F)
        val itemName19: String = intent.getStringExtra(MainActivity.ITEM_NAME19) ?: ""
        val itemRate19: Float = intent.getFloatExtra(MainActivity.ITEM_RATE19, 0F)
        val itemName20: String = intent.getStringExtra(MainActivity.ITEM_NAME20) ?: ""
        val itemRate20: Float = intent.getFloatExtra(MainActivity.ITEM_RATE20, 0F)
        this.itemStates = arrayOf(
                MainActivity.ItemState(itemName1, itemRate1),
                MainActivity.ItemState(itemName2, itemRate2),
                MainActivity.ItemState(itemName3, itemRate3),
                MainActivity.ItemState(itemName4, itemRate4),
                MainActivity.ItemState(itemName5, itemRate5),
                MainActivity.ItemState(itemName6, itemRate6),
                MainActivity.ItemState(itemName7, itemRate7),
                MainActivity.ItemState(itemName8, itemRate8),
                MainActivity.ItemState(itemName9, itemRate9),
                MainActivity.ItemState(itemName10, itemRate10),
                MainActivity.ItemState(itemName11, itemRate11),
                MainActivity.ItemState(itemName12, itemRate12),
                MainActivity.ItemState(itemName13, itemRate13),
                MainActivity.ItemState(itemName14, itemRate14),
                MainActivity.ItemState(itemName15, itemRate15),
                MainActivity.ItemState(itemName16, itemRate16),
                MainActivity.ItemState(itemName17, itemRate17),
                MainActivity.ItemState(itemName18, itemRate18),
                MainActivity.ItemState(itemName19, itemRate19),
                MainActivity.ItemState(itemName20, itemRate20),
        )
        //
        this.initItemData()     //itemsとitemRateSum
        for (i in items.indices) {
            this.setTextName(i, items[i].name)
            this.setTextRate(i, items[i].rate)
            this.setTextPercent(i, items[i].rate, this.itemRateSum)
        }
    }

    fun onClickVerification(v: View) {
        for (i in 0..19) {
            this.setTextChosen(i,0)
            this.setTextChosenPercent(i,0, 0)
        }
        //
        val limitMax: Int = 10000
        var limitCount: Int = 0
        val chosen: Array<Int> = arrayOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        while (true) {
            when (this.actionState) {
                0 -> {  //回転徐々に早く
                    this.actionAngle += this.actionCount
                    this.actionCount += 1
                    if (this.actionCount > 50) {
                        this.actionAngle %= 360
                        this.actionCount = 0
                        this.actionState = 1
                    }
                }
                1 -> {  //回転中
                    this.actionAngle += 89.7F + this.actionCount.div(10)
                    this.actionCount += 1
                    if (this.actionCount > 50) {
                        this.actionAngle += Random.nextInt(360).toFloat() + Random.nextFloat()
                        this.actionAngle %= 360
                        this.actionCount = 0
                        this.actionState = 2
                    }
                }
                2 -> {  //回転徐々に停止
                    this.actionAngle += 100 - this.actionCount.div(2)
                    this.actionCount += 1
                    if (this.actionCount > 200) {
                        this.actionAngle %= 360
                        this.actionCount = 0
                        this.actionState = 3
                    }
                }
                3 -> {  //終了
                    this.actionAngle %= 360
                    this.actionCount = 0
                    this.actionState = 0
                    var startAngle: Float = this.actionAngle
                    //判定結果を表示する
                    var i: Int = 0
                    var nowSelectItem: Int = -1
                    items.forEach {
                        val currentAngle: Float = it.rate.div(itemRateSum).times(360)   //書こうとする扇形の確度
                        val startAngleTmp: Float = startAngle % 360
                        if (((startAngleTmp <= 270F) && (startAngleTmp + currentAngle > 270F)) || ((startAngleTmp >= 270F) && (startAngleTmp + currentAngle >= 630F))) {
                            nowSelectItem = i
                        }
                        startAngle += currentAngle
                        i += 1
                    }
                    if (nowSelectItem != -1) {
                        chosen[nowSelectItem] += 1
                        this.setTextChosen(nowSelectItem, chosen[nowSelectItem])
                        this.setTextChosenPercent(nowSelectItem, chosen[nowSelectItem], chosen.sum())
                    }
                    limitCount += 1
                    if (limitCount >= limitMax) {
                        break
                    }
                }
            }
        }
    }

    fun onClickCancel(v: View) {
        val intent = Intent()
        setResult(Activity.RESULT_CANCELED, intent)
        finish()
    }

    //itemStatesを参照して使用するデータの用意
    private fun initItemData() {
        this.itemRateSum = 0F //レートの合計
        this.items = arrayOf()    //有効なアイテムのみにする
        itemStates.forEach {
            if (it.name != "") {
                itemRateSum += it.rate
                items += MainActivity.ItemState(it.name, it.rate)
            }
        }
    }

    private fun setTextName(num: Int, name: String) {
        when (num + 1) {
            1 -> this.binding.textName1.text = name
            2 -> this.binding.textName2.text = name
            3 -> this.binding.textName3.text = name
            4 -> this.binding.textName4.text = name
            5 -> this.binding.textName5.text = name
            6 -> this.binding.textName6.text = name
            7 -> this.binding.textName7.text = name
            8 -> this.binding.textName8.text = name
            9 -> this.binding.textName9.text = name
            10 -> this.binding.textName10.text = name
            11 -> this.binding.textName11.text = name
            12 -> this.binding.textName12.text = name
            13 -> this.binding.textName13.text = name
            14 -> this.binding.textName14.text = name
            15 -> this.binding.textName15.text = name
            16 -> this.binding.textName16.text = name
            17 -> this.binding.textName17.text = name
            18 -> this.binding.textName18.text = name
            19 -> this.binding.textName19.text = name
            20 -> this.binding.textName20.text = name
        }
    }

    private fun setTextRate(num: Int, rate: Float) {
        val rateStr: String = rate.toString()
        when (num + 1) {
            1 -> this.binding.textRate1.text = rateStr
            2 -> this.binding.textRate2.text = rateStr
            3 -> this.binding.textRate3.text = rateStr
            4 -> this.binding.textRate4.text = rateStr
            5 -> this.binding.textRate5.text = rateStr
            6 -> this.binding.textRate6.text = rateStr
            7 -> this.binding.textRate7.text = rateStr
            8 -> this.binding.textRate8.text = rateStr
            9 -> this.binding.textRate9.text = rateStr
            10 -> this.binding.textRate10.text = rateStr
            11 -> this.binding.textRate11.text = rateStr
            12 -> this.binding.textRate12.text = rateStr
            13 -> this.binding.textRate13.text = rateStr
            14 -> this.binding.textRate14.text = rateStr
            15 -> this.binding.textRate15.text = rateStr
            16 -> this.binding.textRate16.text = rateStr
            17 -> this.binding.textRate17.text = rateStr
            18 -> this.binding.textRate18.text = rateStr
            19 -> this.binding.textRate19.text = rateStr
            20 -> this.binding.textRate20.text = rateStr
        }
    }

    private fun setTextPercent(num: Int, rate: Float, rateSum: Float) {
        val percentStr: String = String.format("%.2f%%", rate.div(rateSum).times(100))
        when (num + 1) {
            1 -> this.binding.textPercent1.text = percentStr
            2 -> this.binding.textPercent2.text = percentStr
            3 -> this.binding.textPercent3.text = percentStr
            4 -> this.binding.textPercent4.text = percentStr
            5 -> this.binding.textPercent5.text = percentStr
            6 -> this.binding.textPercent6.text = percentStr
            7 -> this.binding.textPercent7.text = percentStr
            8 -> this.binding.textPercent8.text = percentStr
            9 -> this.binding.textPercent9.text = percentStr
            10 -> this.binding.textPercent10.text = percentStr
            11 -> this.binding.textPercent11.text = percentStr
            12 -> this.binding.textPercent12.text = percentStr
            13 -> this.binding.textPercent13.text = percentStr
            14 -> this.binding.textPercent14.text = percentStr
            15 -> this.binding.textPercent15.text = percentStr
            16 -> this.binding.textPercent16.text = percentStr
            17 -> this.binding.textPercent17.text = percentStr
            18 -> this.binding.textPercent18.text = percentStr
            19 -> this.binding.textPercent19.text = percentStr
            20 -> this.binding.textPercent20.text = percentStr
        }
    }

    private fun setTextChosen(num: Int, count: Int) {
        val countStr: String = count.toString()
        runOnUiThread {
            when (num + 1) {
                1 -> this.binding.textChosen1.text = countStr
                2 -> this.binding.textChosen2.text = countStr
                3 -> this.binding.textChosen3.text = countStr
                4 -> this.binding.textChosen4.text = countStr
                5 -> this.binding.textChosen5.text = countStr
                6 -> this.binding.textChosen6.text = countStr
                7 -> this.binding.textChosen7.text = countStr
                8 -> this.binding.textChosen8.text = countStr
                9 -> this.binding.textChosen9.text = countStr
                10 -> this.binding.textChosen10.text = countStr
                11 -> this.binding.textChosen11.text = countStr
                12 -> this.binding.textChosen12.text = countStr
                13 -> this.binding.textChosen13.text = countStr
                14 -> this.binding.textChosen14.text = countStr
                15 -> this.binding.textChosen15.text = countStr
                16 -> this.binding.textChosen16.text = countStr
                17 -> this.binding.textChosen17.text = countStr
                18 -> this.binding.textChosen18.text = countStr
                19 -> this.binding.textChosen19.text = countStr
                20 -> this.binding.textChosen20.text = countStr
            }
        }
    }

    private fun setTextChosenPercent(num: Int, count: Int, countSum: Int) {
        val countF: Float = count.toFloat()
        val countSumF: Float = countSum.toFloat()
        runOnUiThread {
            val percentStr: String = if (countSum == 0) "0.00%" else String.format("%.2f%%", countF.div(countSumF).times(100))
            when (num + 1) {
                1 -> this.binding.textChosenPercent1.text = percentStr
                2 -> this.binding.textChosenPercent2.text = percentStr
                3 -> this.binding.textChosenPercent3.text = percentStr
                4 -> this.binding.textChosenPercent4.text = percentStr
                5 -> this.binding.textChosenPercent5.text = percentStr
                6 -> this.binding.textChosenPercent6.text = percentStr
                7 -> this.binding.textChosenPercent7.text = percentStr
                8 -> this.binding.textChosenPercent8.text = percentStr
                9 -> this.binding.textChosenPercent9.text = percentStr
                10 -> this.binding.textChosenPercent10.text = percentStr
                11 -> this.binding.textChosenPercent11.text = percentStr
                12 -> this.binding.textChosenPercent12.text = percentStr
                13 -> this.binding.textChosenPercent13.text = percentStr
                14 -> this.binding.textChosenPercent14.text = percentStr
                15 -> this.binding.textChosenPercent15.text = percentStr
                16 -> this.binding.textChosenPercent16.text = percentStr
                17 -> this.binding.textChosenPercent17.text = percentStr
                18 -> this.binding.textChosenPercent18.text = percentStr
                19 -> this.binding.textChosenPercent19.text = percentStr
                20 -> this.binding.textChosenPercent20.text = percentStr
            }
        }
    }

    //-----------------------------------------------

    //言語設定
    override fun attachBaseContext(base: Context) {
        val pref = base.getSharedPreferences(MainActivity.SETTINGS, Context.MODE_PRIVATE)
        val localeLanguage: String = pref.getString(MainActivity.LOCALE_LANGUAGE, "") ?: ""
        val loc: Locale? = if (localeLanguage != "") Locale(localeLanguage) else null
        if (loc != null) {
            val res = base.resources
            val config = Configuration(res.configuration)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {    //minSdkVersion 24
                val localeList = LocaleList(loc)
                LocaleList.setDefault(localeList)
                config.setLocales(localeList)
            } else {    //minSdkVersion 17  16はダメ
                config.setLocale(loc)
            }
            super.attachBaseContext(base.createConfigurationContext(config))
        } else {
            super.attachBaseContext(base)
        }
    }

    //-----------------------------------------------

}

app/src/main/java/jp/aosystem/roulette/CustomSurfaceView.kt

package jp.aosystem.roulette

import android.content.Context
import android.graphics.*
import android.graphics.Path.FillType
import android.os.Handler
import android.os.Looper
import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener
import android.view.SurfaceHolder
import android.view.SurfaceView
import java.util.*
import kotlin.math.*
import kotlin.random.Random


class CustomSurfaceView(
        context: Context,
        surfaceView: SurfaceView,
        paramItemStates: Array<MainActivity.ItemState>,
        paramItemSplit: Int,
        paramShortenRotation: Int,
        paramSpeechResult: Int,
        paramLocaleLanguage: String
    ) : SurfaceView(context), SurfaceHolder.Callback, TextToSpeech.OnInitListener {
    private var textToSpeech: TextToSpeech
    private var surfaceHolder: SurfaceHolder? = null
    //private var thread: Thread? = null
    //private var prevBitmap: Bitmap? = null
    //private var prevCanvas: Canvas? = null
    private val adHeight: Int = 185
    private val itemStates: Array<MainActivity.ItemState> = paramItemStates
    private val itemSplit: Int = paramItemSplit
    private val shortenRotation: Int = paramShortenRotation
    private val speechResult: Int = paramSpeechResult
    private val localeLanguage: String = paramLocaleLanguage
    //
    private var canvas: Canvas? = null
    private var items: Array<MainActivity.ItemState> = arrayOf()    //有効なアイテムのみ
    private var itemRateSum: Float = 0F //レートの合計
    private var canvasW: Float = 0F
    private var canvasH: Float = 0F
    private var boxSize: Float = 0F     //描画できる正方形範囲の辺の長さ
    private var boxPadding: Float = 0F  //描画できる正方形範囲のpadding(上下左右)
    private var centerX: Float = 0F     //円の中心
    private var centerY: Float = 0F     //円の中心
    private var half: Float = 0F        //半径
    private var whitePaint: Paint? = null        //白のPaint
    private var textPaint: Paint? = null            //文字のPaint
    private var textLargePaint: Paint? = null            //文字のPaint
    private var paints: Array<Paint> = arrayOf()    //円グラフのpaint
    private var paintsDark: Array<Paint> = arrayOf()    //円グラフのpaint
    private var actionState: Int = 0    //回転状態
    private var actionAngle: Float = Random.nextInt(360).toFloat() + Random.nextFloat()    //回転の制御
    private var actionCount: Int = 0    //回転の制御
    private var destroyFlag: Boolean = false    //Activity破棄された場合など
    //
    init {
        this.surfaceHolder = surfaceView.holder
        this.surfaceHolder!!.setFormat(PixelFormat.TRANSPARENT)
        surfaceView.setZOrderOnTop(true)
        this.surfaceHolder!!.addCallback(this)
        //読み上げ
        this.textToSpeech = TextToSpeech(context, this)
        this.textToSpeech.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
            override fun onDone(utteranceId: String) {
            }
            override fun onError(utteranceId: String) {
            }
            override fun onStart(utteranceId: String) {
            }
        })
        this.setSpeechLocale()
    }

    override fun onInit(status: Int) {
        if (status == TextToSpeech.SUCCESS) {
            this.setSpeechLocale()
        }
    }

    override fun surfaceCreated(p0: SurfaceHolder) {
        //initializeBitmap()
        //this.thread = Thread()
        //this.thread!!.start()
        this.drawCanvas()
    }

    override fun surfaceChanged(p0: SurfaceHolder, format: Int, width: Int, height: Int) {
    }

    override fun surfaceDestroyed(p0: SurfaceHolder) {
        this.destroyFlag = true
        //this.prevBitmap!!.recycle()
        //this.thread = null
    }

    private fun initializeBitmap() {
        //if (this.prevBitmap == null) {
        //   this.prevBitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888)
        //}
        //if (this.prevCanvas == null) {
        //    this.prevCanvas = Canvas(this.prevBitmap!!)
        //}
        //this.prevCanvas!!.drawColor(0, PorterDuff.Mode.CLEAR)
    }

    fun setDestroy() {
        this.textToSpeech.shutdown()
        this.destroyFlag = true
    }

    //最初の描画と初期データ用意
    private fun drawCanvas() {
        this.initItemData()     //有効なアイテム、レートの合計
        this.initWhitePaint()    //白Paint
        this.initTextPaint()    //文字Paint
        this.initTextLargePaint()    //文字Paint
        this.initPaints()       //円グラフPaint
        this.initPaintsDark()   //円グラフPaint
        this.canvas = Canvas()
        this.canvas = this.surfaceHolder!!.lockCanvas()     //ロックしてキャンバスを取得
        this.canvas!!.drawColor(0, PorterDuff.Mode.CLEAR)   //キャンバスのクリア
        //this.canvas!!.drawBitmap(this.prevBitmap!!, 0F, 0F, null) //前回のビットマップをキャンバスに描画
        //this.canvas!!.drawCircle(centerX, centerY - 300F, 300F, this.paint!!)
        this.canvasW = this.canvas?.width!!.toFloat()
        this.canvasH = (this.canvas?.height!!.minus(this.adHeight)).toFloat()
        this.centerX = this.canvasW.div(2)
        this.centerY = this.canvasH.div(2)
        this.boxSize = if (canvasW <= canvasH) canvasW else canvasH
        val clientSize: Float = this.boxSize.times(0.9).toFloat()
        this.boxPadding = (this.boxSize - clientSize).div(2)
        this.half = clientSize.div(2)
        this.actionStartDraw(this.actionAngle)
        this.surfaceHolder!!.unlockCanvasAndPost(this.canvas)   //ロックを解除
    }

    fun onClickStart() {
        this.actionState = 0
        this.actionCount = 0
        actionTimeline()
    }

    private fun actionTimeline() {
        Handler(Looper.getMainLooper()).postDelayed({
            if (this.destroyFlag) {
                return@postDelayed
            }
            actionStart(this.actionAngle)
            when (this.actionState) {
                0 -> {  //回転徐々に早く
                    this.actionAngle += this.actionCount
                    this.actionCount += 1
                    if (this.actionCount > 50) {
                        this.actionAngle %= 360
                        this.actionCount = 0
                        if (this.shortenRotation == 1) {
                            this.actionCount = 51
                        }
                        this.actionState = 1
                    }
                }
                1 -> {  //回転中
                    this.actionAngle += 89.7F + this.actionCount.div(10)
                    this.actionCount += 1
                    if (this.actionCount > 50) {
                        this.actionAngle += Random.nextInt(360).toFloat() + Random.nextFloat()
                        this.actionAngle %= 360
                        this.actionCount = 0
                        if (this.shortenRotation == 1) {
                            this.actionCount = 100
                        }
                        this.actionState = 2
                    }
                }
                2 -> {  //回転徐々に停止
                    this.actionAngle += 100 - this.actionCount.div(2)
                    this.actionCount += 1
                    if (this.actionCount > 200) {
                        this.actionAngle %= 360
                        this.actionCount = 0
                        this.actionState = 3
                    }
                }
                3 -> {  //終了
                    return@postDelayed
                }
            }
            actionTimeline()
        }, 1)
    }

    private fun actionStart(startAngle: Float) {
        this.canvas = Canvas()
        this.canvas = this.surfaceHolder!!.lockCanvas()     //ロックしてキャンバスを取得
        this.canvas!!.drawColor(0, PorterDuff.Mode.CLEAR)   //キャンバスのクリア
        this.actionStartDraw(startAngle)
        this.surfaceHolder!!.unlockCanvasAndPost(this.canvas)   //ロックを解除
    }

    private fun actionStartDraw(paramStartAngle: Float) {
        var startAngle: Float = paramStartAngle
        var i: Int = 0
        val path = Path()
        //判定結果計算
        i = 0
        var nowSelectItem: Int = -1
        items.forEach {
            val currentAngle: Float = it.rate.div(itemRateSum).times(360)   //書こうとする扇形の確度
            val startAngleTmp: Float = startAngle % 360
            if (((startAngleTmp <= 270F) && (startAngleTmp + currentAngle > 270F)) || ((startAngleTmp >= 270F) && (startAngleTmp + currentAngle >= 630F))) {
                nowSelectItem = i
            }
            startAngle += currentAngle
            i += 1
        }
        //判定結果表示 back color
        if (nowSelectItem != -1) {  //念のため
            path.fillType = FillType.EVEN_ODD
            path.moveTo(0F, 0F)
            path.lineTo(this.canvasW, 0F)
            path.lineTo(this.canvasW, this.centerY + this.canvasH.div(2))
            path.lineTo(0F, this.centerY + this.canvasH.div(2))
            path.close()
            this.canvas!!.drawPath(path, this.paints[nowSelectItem % 10])
        }
        //白丸
        this.canvas!!.drawArc(this.centerX - this.half - this.boxPadding.div(2), this.centerY - this.half - this.boxPadding.div(2), this.centerX + this.half + this.boxPadding.div(2), this.centerY + this.half + this.boxPadding.div(2),-89.5F, 359F, true, this.whitePaint!!)
        //円グラフ
        startAngle = paramStartAngle
        i = 0
        items.forEach {
            val currentAngle: Float = it.rate.div(itemRateSum).times(360)   //書こうとする扇形の確度
            //circle
            this.canvas!!.drawArc(this.centerX - this.half, this.centerY - this.half, this.centerX + this.half, this.centerY + this.half, startAngle, currentAngle, true, this.paints[i % 10])
            //circle dark
            this.canvas!!.drawArc(this.centerX - this.half.div(2), this.centerY - this.half.div(2), this.centerX + this.half.div(2), this.centerY + this.half.div(2), startAngle, currentAngle, true, this.paintsDark[i % 10])
            startAngle += currentAngle
            i += 1
        }
        //円グラフの文字
        startAngle = paramStartAngle
        i = 0
        items.forEach {
            val currentAngle: Float = it.rate.div(itemRateSum).times(360)   //書こうとする扇形の確度
            //text
            val textAngle: Float = (currentAngle.div(2) + startAngle) + 90
            val textX: Float = sin(textAngle.times(PI.div(180))).times(this.half.div(1.3)).toFloat() - this.textPaint!!.textSize.div(2)
            val textY: Float = cos(textAngle.times(PI.div(180))).times(this.half.div(1.3)).toFloat().times(-1) + this.textPaint!!.textSize.div(2)
            this.canvas!!.drawText("◆" + it.name, textX + this.centerX, textY + this.centerY, this.textPaint!!)
            startAngle += currentAngle
            i += 1
        }
        //判定結果表示 text
        if (nowSelectItem != -1) {  //念のため
            this.canvas!!.drawText(items[nowSelectItem].name, this.textLargePaint!!.textSize, this.textLargePaint!!.textSize.times(1.5F), this.textLargePaint!!)
            if (this.speechResult == 1) {
                this.speakText(items[nowSelectItem].name)
            }
        }
    }

    //itemStatesを参照して使用するデータの用意
    private fun initItemData() {
        this.itemRateSum = 0F //レートの合計
        this.items = arrayOf()    //有効なアイテムのみにする
        itemStates.forEach {
            if (it.name != "") {
                itemRateSum += it.rate
                items += MainActivity.ItemState(it.name, it.rate)
            }
        }
        if (itemSplit == 1) {   //全て4倍にする
            this.itemRateSum = this.itemRateSum.times(4)
            val copyItems: Array<MainActivity.ItemState> = this.items
            copyItems.forEach {
                items += MainActivity.ItemState(it.name, it.rate)
            }
            copyItems.forEach {
                items += MainActivity.ItemState(it.name, it.rate)
            }
            copyItems.forEach {
                items += MainActivity.ItemState(it.name, it.rate)
            }
        }
    }

    private fun speakText(text: String) {
        textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null, "utteranceId")
    }

    //白Paintの用意
    private fun initWhitePaint() {
        this.whitePaint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(255,255,255)
        }
    }

    //文字Paintの用意
    private fun initTextPaint() {
        this.textPaint = Paint().apply {
            isAntiAlias = true
            color = Color.BLACK
            textSize = 30F
        }
    }

    //文字大Paintの用意
    private fun initTextLargePaint() {
        this.textLargePaint = Paint().apply {
            isAntiAlias = true
            color = Color.BLACK
            textSize = 60F
        }
    }

    //円グラフPaintの用意
    private fun initPaints() {
        val paint0: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(234, 123, 132)
            Paint.Style.FILL
        }
        val paint1: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(240, 196, 123)
            Paint.Style.FILL
        }
        val paint2: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(247, 239, 123)
            Paint.Style.FILL
        }
        val paint3: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(192, 217, 139)
            Paint.Style.FILL
        }
        val paint4: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(123, 197, 156)
            Paint.Style.FILL
        }
        val paint5: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(123, 201, 235)
            Paint.Style.FILL
        }
        val paint6: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(123, 173, 211)
            Paint.Style.FILL
        }
        val paint7: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(138, 139, 189)
            Paint.Style.FILL
        }
        val paint8: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(194, 127, 186)
            Paint.Style.FILL
        }
        val paint9: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(233, 123, 185)
            Paint.Style.FILL
        }
        this.paints = arrayOf(paint0, paint2, paint4, paint6, paint8, paint1, paint3, paint5, paint7, paint9, paint0, paint2, paint4, paint6, paint8, paint1, paint3, paint5, paint7, paint9)
    }

    //円グラフPaintの用意
    private fun initPaintsDark() {
        val paint0: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(222,0,17)
            Paint.Style.FILL
        }
        val paint1: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(234,145,0)
            Paint.Style.FILL
        }
        val paint2: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(247,232,0)
            Paint.Style.FILL
        }
        val paint3: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(137,188,30)
            Paint.Style.FILL
        }
        val paint4: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(0,147,66)
            Paint.Style.FILL
        }
        val paint5: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(0,154,225)
            Paint.Style.FILL
        }
        val paint6: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(0,101,176)
            Paint.Style.FILL
        }
        val paint7: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(28,31,131)
            Paint.Style.FILL
        }
        val paint8: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(140,7,126)
            Paint.Style.FILL
        }
        val paint9: Paint = Paint().apply {
            isAntiAlias = true
            color = Color.rgb(220,0,123)
            Paint.Style.FILL
        }
        this.paintsDark = arrayOf(paint0, paint2, paint4, paint6, paint8, paint1, paint3, paint5, paint7, paint9, paint0, paint2, paint4, paint6, paint8, paint1, paint3, paint5, paint7, paint9)
    }

    //-------------------------------------------------

    //音声の言語設定
    private fun setSpeechLocale() {
        val loc: Locale? = if (this.localeLanguage != "") Locale(this.localeLanguage) else null
        if (loc != null) {
            this.textToSpeech.let { tts ->
                if (tts.isLanguageAvailable(loc) > TextToSpeech.LANG_AVAILABLE) {
                    tts.language = loc
                } else {
                    // 言語の設定に失敗
                }
            }
        }
    }

    //-------------------------------------------------


    /*
    /// 画面をタッチしたときにアクションごとに関数を呼び出す
    fun onTouch(e: MotionEvent): Boolean {
        when (e.action) {
            MotionEvent.ACTION_DOWN -> touchDown(e.x, e.y)
            //MotionEvent.ACTION_MOVE -> touchMove(e.x, e.y)
            MotionEvent.ACTION_UP -> touchUp(e.x, e.y)
        }
        return true
    }

    private fun touchDown(x: Float, y: Float) {
    }

    private fun touchUp(x: Float, y: Float) {
    }
    */
}

app/src/main/res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/layoutHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="1dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textStart"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="6"
                android:background="#5DC6AF"
                android:gravity="center"
                android:minHeight="96dp"
                android:onClick="onClickStart"
                android:text="@string/rouletteStart" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="1dp"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textSetting"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#6093C5"
                    android:gravity="center"
                    android:minHeight="48dp"
                    android:onClick="onClickSetting"
                    android:text="@string/setting" />

                <TextView
                    android:id="@+id/textVerify"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="1dp"
                    android:background="#5FB1C6"
                    android:gravity="center"
                    android:minHeight="47dp"
                    android:onClick="onClickVerify"
                    android:text="@string/verify" />

            </LinearLayout>

        </LinearLayout>

        <SurfaceView
            android:id="@+id/surfaceView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="1dp" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ad_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent" />



</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/activity_setting.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SettingActivity">

    <LinearLayout
        android:id="@+id/layoutButtons"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        android:layout_marginTop="1dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/textCancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#86C663"
            android:gravity="center"
            android:minHeight="48dip"
            android:onClick="onClickCancel"
            android:text="@string/cancel" />

        <TextView
            android:id="@+id/textApply"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="1dp"
            android:layout_weight="1"
            android:background="#5DC6AF"
            android:gravity="center"
            android:minHeight="48dip"
            android:onClick="onClickApply"
            android:text="@string/apply" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/layoutButtons">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="auto"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:paddingBottom="50dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:layout_marginBottom="20dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textName0"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:text="@string/item_ratio"
                    android:textColor="?android:attr/textColorPrimary" />

                <TableLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp">

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="1" />

                        <EditText
                            android:id="@+id/editName1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="2" />

                        <EditText
                            android:id="@+id/editName2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="3" />

                        <EditText
                            android:id="@+id/editName3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="4" />

                        <EditText
                            android:id="@+id/editName4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName5"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="5" />

                        <EditText
                            android:id="@+id/editName5"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate5"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName6"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="6" />

                        <EditText
                            android:id="@+id/editName6"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate6"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName7"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="7" />

                        <EditText
                            android:id="@+id/editName7"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate7"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName8"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="8" />

                        <EditText
                            android:id="@+id/editName8"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate8"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName9"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="9" />

                        <EditText
                            android:id="@+id/editName9"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate9"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName10"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="10" />

                        <EditText
                            android:id="@+id/editName10"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate10"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName11"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="11" />

                        <EditText
                            android:id="@+id/editName11"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate11"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName12"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="12" />

                        <EditText
                            android:id="@+id/editName12"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate12"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName13"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="13" />

                        <EditText
                            android:id="@+id/editName13"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate13"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName14"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="14" />

                        <EditText
                            android:id="@+id/editName14"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate14"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName15"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="15" />

                        <EditText
                            android:id="@+id/editName15"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate15"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName16"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="16" />

                        <EditText
                            android:id="@+id/editName16"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate16"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName17"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="17" />

                        <EditText
                            android:id="@+id/editName17"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate17"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName18"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="18" />

                        <EditText
                            android:id="@+id/editName18"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate18"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName19"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="19" />

                        <EditText
                            android:id="@+id/editName19"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate19"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:id="@+id/textName20"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="20" />

                        <EditText
                            android:id="@+id/editName20"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_weight="1"
                            android:ems="9"
                            android:inputType="text" />

                        <EditText
                            android:id="@+id/editRate20"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:ems="4"
                            android:inputType="numberDecimal" />
                    </TableRow>

                </TableLayout>

                <View
                    android:id="@+id/divider1"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />


                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/switchSplit"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:text="@string/splitItem" />

                <TextView
                    android:id="@+id/textSplit"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/split" />

                <View
                    android:id="@+id/divider5"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/switchShortenRotation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="@string/shortenRotation" />

                <TextView
                    android:id="@+id/textShortenRotation1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/shortenRotation1" />

                <View
                    android:id="@+id/divider8"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/switchSpeechResult"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="15dp"
                    android:text="@string/speechResult" />

                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/speechResult1" />

                <View
                    android:id="@+id/divider3"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />

                <TextView
                    android:id="@+id/textLanguage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:text="@string/language"
                    android:textColor="?android:attr/textColorPrimary" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:text="@string/languageNote" />

                <RadioGroup
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                    <RadioButton
                        android:id="@+id/radioLanguageSystem"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageSystem" />
                    <RadioButton
                        android:id="@+id/radioLanguageEn"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageEn" />
                    <RadioButton
                        android:id="@+id/radioLanguageBg"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageBg" />
                    <RadioButton
                        android:id="@+id/radioLanguageCs"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageCs" />
                    <RadioButton
                        android:id="@+id/radioLanguageDa"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageDa" />
                    <RadioButton
                        android:id="@+id/radioLanguageDe"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageDe" />
                    <RadioButton
                        android:id="@+id/radioLanguageEl"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageEl" />
                    <RadioButton
                        android:id="@+id/radioLanguageEs"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageEs" />
                    <RadioButton
                        android:id="@+id/radioLanguageEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageEt" />
                    <RadioButton
                        android:id="@+id/radioLanguageFi"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageFi" />
                    <RadioButton
                        android:id="@+id/radioLanguageFr"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageFr" />
                    <RadioButton
                        android:id="@+id/radioLanguageHu"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageHu" />
                    <RadioButton
                        android:id="@+id/radioLanguageIt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageIt" />
                    <RadioButton
                        android:id="@+id/radioLanguageJa"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageJa" />
                    <RadioButton
                        android:id="@+id/radioLanguageLt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageLt" />
                    <RadioButton
                        android:id="@+id/radioLanguageLv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageLv" />
                    <RadioButton
                        android:id="@+id/radioLanguageNl"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageNl" />
                    <RadioButton
                        android:id="@+id/radioLanguagePl"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languagePl" />
                    <RadioButton
                        android:id="@+id/radioLanguagePt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languagePt" />
                    <RadioButton
                        android:id="@+id/radioLanguageRo"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageRo" />
                    <RadioButton
                        android:id="@+id/radioLanguageRu"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageRu" />
                    <RadioButton
                        android:id="@+id/radioLanguageSk"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageSk" />
                    <RadioButton
                        android:id="@+id/radioLanguageSv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageSv" />
                    <RadioButton
                        android:id="@+id/radioLanguageZh"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/languageZh" />

                </RadioGroup>

                <View
                    android:id="@+id/divider2"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/switchTheme"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="@string/darkTheme" />

                <View
                    android:id="@+id/divider6"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="10dp"
                    android:background="?android:attr/listDivider" />

                <TextView
                    android:id="@+id/textUsage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="20dp"
                    android:text="@string/usage" />

                <TextView
                    android:id="@+id/textUsage1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/usage1" />

                <View
                    android:id="@+id/divider4"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="20dp"
                    android:background="?android:attr/listDivider" />

                <Space
                    android:layout_width="match_parent"
                    android:layout_height="120dp" />

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/custom_toast_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".VerifyActivity">

    <LinearLayout
        android:id="@+id/layoutButtons"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_marginTop="1dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/textCancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#BFC663"
            android:gravity="center"
            android:minHeight="48dp"
            android:onClick="onClickCancel"
            android:text="@string/cancel" />

        <TextView
            android:id="@+id/textApply"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="1dp"
            android:layout_weight="1"
            android:background="#86C663"
            android:gravity="center"
            android:minHeight="48dp"
            android:onClick="onClickVerification"
            android:text="@string/verification" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/layoutButtons">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="20dp"
            android:paddingTop="20dp"
            android:paddingRight="20dp"
            android:paddingBottom="150dp">

            <TextView
                android:id="@+id/textVerifyNote2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="@string/verifyNote2"
                android:textSize="12sp" />

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:shrinkColumns="0"
                android:stretchColumns="0">

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName0"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/item" />

                    <TextView
                        android:id="@+id/textRate0"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="center"
                        android:text="@string/ratio" />

                    <TextView
                        android:id="@+id/textPercent0"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="center"
                        android:text="@string/percent" />

                    <TextView
                        android:id="@+id/textChosen0"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="center"
                        android:text="@string/chosen" />

                    <TextView
                        android:id="@+id/textChosenPercent0"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="center"
                        android:text="@string/chosenPercent" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName8"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate8"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent8"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen8"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent8"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="" />

                    <TextView
                        android:id="@+id/textRate20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="" />

                    <TextView
                        android:id="@+id/textPercent20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosen20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                    <TextView
                        android:id="@+id/textChosenPercent20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:gravity="end"
                        android:text="" />

                </TableRow>

            </TableLayout>

            <TextView
                android:id="@+id/textVerifyNote"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dp"
                android:text="@string/verifyNote"
                android:textSize="12sp" />

        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>