ソースコード 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.luckybox"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode 6
        versionName "1.5"
        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'
    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.luckybox">

    <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.LuckyBox">
        <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=".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/luckybox/MainActivity.kt

package jp.aosystem.luckybox

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Color
import android.os.*
import android.util.DisplayMetrics
import android.view.View
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.TextView
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.luckybox.databinding.ActivityMainBinding
import java.util.*
import kotlin.random.Random


class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    private lateinit var viewModel: ConstraintLayout
    //
    private val resourceImg: List<Int> = listOf(
        R.drawable.box_001,
        R.drawable.box_002,
        R.drawable.box_003,
        R.drawable.box_004,
        R.drawable.box_005,
        R.drawable.box_006,
        R.drawable.box_007,
        R.drawable.box_008,
        R.drawable.box_009,
        R.drawable.box_010,
        R.drawable.box_011,
        R.drawable.box_012,
        R.drawable.box_013,
        R.drawable.box_014,
        R.drawable.box_015,
        R.drawable.box_016,
        R.drawable.box_017,
        R.drawable.box_018,
        R.drawable.box_019,
        R.drawable.box_020,
        R.drawable.box_021,
        R.drawable.box_022,
        R.drawable.box_023,
        R.drawable.box_024,
        R.drawable.box_025,
        R.drawable.box_026,
        R.drawable.box_027,
        R.drawable.box_028,
        R.drawable.box_029,
        R.drawable.box_030,
        R.drawable.box_031,
        R.drawable.box_032,
        R.drawable.box_033,
        R.drawable.box_034,
        R.drawable.box_035,
        R.drawable.box_036,
        R.drawable.box_037,
        R.drawable.box_038,
        R.drawable.box_039,
        R.drawable.box_040,
        R.drawable.box_041,
        R.drawable.box_042,
        R.drawable.box_043,
        R.drawable.box_044,
        R.drawable.box_045,
        R.drawable.box_046,
        R.drawable.box_047,
        R.drawable.box_048,
        R.drawable.box_049,
        R.drawable.box_050,
        R.drawable.box_051,
        R.drawable.box_052,
        R.drawable.box_053,
        R.drawable.box_054,
        R.drawable.box_055,
        R.drawable.box_056,
        R.drawable.box_057,
        R.drawable.box_058,
        R.drawable.box_059,
        R.drawable.box_060,
        R.drawable.box_061,
        R.drawable.box_062,
        R.drawable.box_063,
        R.drawable.box_064,
        R.drawable.box_065,
        R.drawable.box_066,
        R.drawable.box_067,
        R.drawable.box_068,
        R.drawable.box_069,
        R.drawable.box_070,
        R.drawable.box_071,
        R.drawable.box_072,
        R.drawable.box_073,
        R.drawable.box_074,
        R.drawable.box_075,
        R.drawable.box_076,
        R.drawable.box_077,
        R.drawable.box_078,
        R.drawable.box_079,
        R.drawable.box_080,
        R.drawable.box_081,
        R.drawable.box_082,
        R.drawable.box_083,
        R.drawable.box_084,
        R.drawable.box_085,
        R.drawable.box_086,
        R.drawable.box_087,
        R.drawable.box_088,
        R.drawable.box_089,
        R.drawable.box_090,
        R.drawable.box_091,
        R.drawable.box_092,
        R.drawable.box_093,
        R.drawable.box_094,
        R.drawable.box_095,
        R.drawable.box_096,
        R.drawable.box_097,
        R.drawable.box_098,
        R.drawable.box_099,
        R.drawable.box_100,
        R.drawable.box_101,
        R.drawable.box_102,
        R.drawable.box_103,
        R.drawable.box_104,
        R.drawable.box_105,
        R.drawable.box_106,
        R.drawable.box_107,
        R.drawable.box_108,
        R.drawable.box_109,
        R.drawable.box_110,
        R.drawable.box_111,
        R.drawable.box_112,
        R.drawable.box_113,
        R.drawable.box_114,
        R.drawable.box_115,
        R.drawable.box_116,
        R.drawable.box_117,
        R.drawable.box_118,
        R.drawable.box_119,
        R.drawable.box_120,
    )
    data class ItemState(
        var name: String,
        var qty: Int,
    )
    private lateinit var textResult: TextView
    private var baseWidth: Int = 0
    private var baseHeight: Int = 0
    private var boxSize: Int = 0
    private var marginLeft: Int = 0
    private var marginTop: Int = 0
    private var actionCount: Int = 0    //回転の制御
    private var destroyFlag: Boolean = false    //Activity破棄された場合など
    private var busyFlag: Boolean = false       //回転中
    private var itemStates: Array<ItemState> = arrayOf()
    private var speed: Int = 10
    private var themeNumber: Int = 0
    private var localeLanguage: String = ""
    private var choiceLot = 0

    //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_SETTING_ACTIVITY: Int = 1
        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_QTY1: String = "itemQty1"
        internal const val ITEM_QTY2: String = "itemQty2"
        internal const val ITEM_QTY3: String = "itemQty3"
        internal const val ITEM_QTY4: String = "itemQty4"
        internal const val ITEM_QTY5: String = "itemQty5"
        internal const val ITEM_QTY6: String = "itemQty6"
        internal const val ITEM_QTY7: String = "itemQty7"
        internal const val SPEED: String = "speed"
        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.loadSpeed()
        //adMob
        MobileAds.initialize(this) {}
        this.adView = AdView(this)
        this.binding.adContainer.addView(this.adView)
        this.loadBanner()
    }

    override fun onResume() {
        super.onResume()
        //準備が出来たらwidth,heightを取得して次へ進む
        this.binding.layoutBase.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
            override fun onGlobalLayout() {
                this@MainActivity.binding.layoutBase.viewTreeObserver.removeOnGlobalLayoutListener(this)
                this@MainActivity.baseWidth = this@MainActivity.binding.layoutBase.width
                this@MainActivity.baseHeight = this@MainActivity.binding.layoutBase.height
                this@MainActivity.init()
            }
        })
    }

    override fun onDestroy() {
        this.destroyFlag = true
        super.onDestroy()
    }

    //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 init() {
        if (::textResult.isInitialized) {
            this.binding.layoutBase.removeView(this.textResult)
        }
        this.boxSize = minOf(this.baseWidth, this.baseHeight)
        this.marginLeft = (this.baseWidth - this.boxSize).div(2)
        this.marginTop = (this.baseHeight - this.boxSize).div(2)
        //text
        val boxPixel: Float = this.boxSize.div(900F)
        this.textResult = TextView(this)
        this.textResult.text = ""
        this.textResult.textSize = 16F
        this.textResult.setTextColor(Color.rgb(0,0,0))
        this.textResult.alpha = 0F
        this.textResult.x = this.marginLeft + boxPixel.times(400)
        this.textResult.y = this.marginTop + boxPixel.times(600)
        this.binding.layoutBase.addView(this.textResult)
        //
        this.startButtonColor(true)
    }

    fun onClickStart(v: View) {
        if (this.busyFlag) {
            return
        }
        this.busyFlag = true
        this.textResult.alpha = 0F
        this.startButtonColor(false)
        //くじを選ぶ
        var qtySum: Int = 0
        this.itemStates.forEach {
            qtySum += it.qty
        }
        if (qtySum == 0) {    //選ぶものが無くなった
            this.textResult.text = resources.getString(R.string.empty)
            this.textResult.x = 50F
            this.textResult.y = 40F
            this.textResult.textSize = 14F
            this.textResult.alpha = 1F
            this.busyFlag = false
            this.startButtonColor(true)
            return
        }
        var remainNum: Int = Random.nextInt(qtySum)
        var choiceRank: Int = 0
        for (i in this.itemStates.indices) {
            if (this.itemStates[i].qty != 0) {
                remainNum -= this.itemStates[i].qty
                if (remainNum < 0) {
                    choiceRank = i     //このランクに決定
                    this.itemStates[i].qty -= 1     //1個減らす
                    this.saveItemStates()
                    break
                }
            }
        }
        //
        this.choiceLot = choiceRank
        this.destroyFlag = false
        this.actionCount = 0
        this.textResult.text = this.itemStates[this.choiceLot].name
        this.actionTimeline()
    }

    private fun actionTimeline() {
        Handler(Looper.getMainLooper()).postDelayed({
            if (this.destroyFlag) {
                this.startButtonColor(true)
                return@postDelayed
            }
            this.binding.imageKuji.setImageResource(resourceImg[this.actionCount])   //クジ画像切り替え
            this.visibleFortune(this.actionCount) //結果表示
            this.actionCount += 1
            if (this.actionCount > 119) {
                if (this.destroyFlag) {
                    this.startButtonColor(true)
                    return@postDelayed
                }
                this.binding.imageKuji.setImageResource(resourceImg[119])  //クジ最後
                this.busyFlag = false
                this.startButtonColor(true)
                return@postDelayed
            }
            actionTimeline()
        }, this.speed.toLong())
    }

    private fun visibleFortune(num: Int) {
        if (num < 105) {
            return
        }
        this.textResult.alpha = (15F - (120F - num)).div(15F)
    }

    private fun startButtonColor(onOff: Boolean) {
        if (onOff) {
            this.binding.textStart.alpha = 1F
            this.binding.textSetting.alpha = 1F
        } else {
            this.binding.textStart.alpha = 0F
            this.binding.textSetting.alpha = 0F
        }
    }

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

    fun onClickSetting(v: View) {
        if (this.busyFlag) {
            return
        }
        this.destroyFlag = true
        val intent = Intent(applicationContext, SettingActivity::class.java)
        intent.putExtra(ITEM_NAME1, this.itemStates[0].name)
        intent.putExtra(ITEM_QTY1, this.itemStates[0].qty)
        intent.putExtra(ITEM_NAME2, this.itemStates[1].name)
        intent.putExtra(ITEM_QTY2, this.itemStates[1].qty)
        intent.putExtra(ITEM_NAME3, this.itemStates[2].name)
        intent.putExtra(ITEM_QTY3, this.itemStates[2].qty)
        intent.putExtra(ITEM_NAME4, this.itemStates[3].name)
        intent.putExtra(ITEM_QTY4, this.itemStates[3].qty)
        intent.putExtra(ITEM_NAME5, this.itemStates[4].name)
        intent.putExtra(ITEM_QTY5, this.itemStates[4].qty)
        intent.putExtra(ITEM_NAME6, this.itemStates[5].name)
        intent.putExtra(ITEM_QTY6, this.itemStates[5].qty)
        intent.putExtra(ITEM_NAME7, this.itemStates[6].name)
        intent.putExtra(ITEM_QTY7, this.itemStates[6].qty)
        intent.putExtra(SPEED, this.speed)
        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 itemQty1: Int = intent.getIntExtra(ITEM_QTY1, 0)
            val itemName2: String = intent.getStringExtra(ITEM_NAME2) ?: ""
            val itemQty2: Int = intent.getIntExtra(ITEM_QTY2, 0)
            val itemName3: String = intent.getStringExtra(ITEM_NAME3) ?: ""
            val itemQty3: Int = intent.getIntExtra(ITEM_QTY3, 0)
            val itemName4: String = intent.getStringExtra(ITEM_NAME4) ?: ""
            val itemQty4: Int = intent.getIntExtra(ITEM_QTY4, 0)
            val itemName5: String = intent.getStringExtra(ITEM_NAME5) ?: ""
            val itemQty5: Int = intent.getIntExtra(ITEM_QTY5, 0)
            val itemName6: String = intent.getStringExtra(ITEM_NAME6) ?: ""
            val itemQty6: Int = intent.getIntExtra(ITEM_QTY6, 0)
            val itemName7: String = intent.getStringExtra(ITEM_NAME7) ?: ""
            val itemQty7: Int = intent.getIntExtra(ITEM_QTY7, 0)
            this.itemStates = arrayOf(
                ItemState(itemName1, itemQty1),
                ItemState(itemName2, itemQty2),
                ItemState(itemName3, itemQty3),
                ItemState(itemName4, itemQty4),
                ItemState(itemName5, itemQty5),
                ItemState(itemName6, itemQty6),
                ItemState(itemName7, itemQty7),
            )
            this.saveItemStates()
            val lastSpeed = this.speed
            this.speed = intent.getIntExtra(SPEED, 10)
            if (lastSpeed != this.speed) {
                this.saveSpeed()
            }
            val lastThemeNumber = 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)
            putInt(ITEM_QTY1, this@MainActivity.itemStates[0].qty)
            putString(ITEM_NAME2, this@MainActivity.itemStates[1].name)
            putInt(ITEM_QTY2, this@MainActivity.itemStates[1].qty)
            putString(ITEM_NAME3, this@MainActivity.itemStates[2].name)
            putInt(ITEM_QTY3, this@MainActivity.itemStates[2].qty)
            putString(ITEM_NAME4, this@MainActivity.itemStates[3].name)
            putInt(ITEM_QTY4, this@MainActivity.itemStates[3].qty)
            putString(ITEM_NAME5, this@MainActivity.itemStates[4].name)
            putInt(ITEM_QTY5, this@MainActivity.itemStates[4].qty)
            putString(ITEM_NAME6, this@MainActivity.itemStates[5].name)
            putInt(ITEM_QTY6, this@MainActivity.itemStates[5].qty)
            putString(ITEM_NAME7, this@MainActivity.itemStates[6].name)
            putInt(ITEM_QTY7, this@MainActivity.itemStates[6].qty)
            apply()
        }
    }

    //itemsを読み出し
    private fun loadItemStates() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.itemStates = arrayOf(
            ItemState(pref.getString(ITEM_NAME1, "") ?: "", pref.getInt(ITEM_QTY1, 0)),
            ItemState(pref.getString(ITEM_NAME2, "") ?: "", pref.getInt(ITEM_QTY2, 0)),
            ItemState(pref.getString(ITEM_NAME3, "") ?: "", pref.getInt(ITEM_QTY3, 0)),
            ItemState(pref.getString(ITEM_NAME4, "") ?: "", pref.getInt(ITEM_QTY4, 0)),
            ItemState(pref.getString(ITEM_NAME5, "") ?: "", pref.getInt(ITEM_QTY5, 0)),
            ItemState(pref.getString(ITEM_NAME6, "") ?: "", pref.getInt(ITEM_QTY6, 0)),
            ItemState(pref.getString(ITEM_NAME7, "") ?: "", pref.getInt(ITEM_QTY7, 0)),
        )
        var nameFoundFlag: Boolean = false  //項目が1個以上登録されているか
        for (i in this.itemStates.indices) {
            if (this.itemStates[i].name != "") {
                nameFoundFlag = true
                break
            }
        }
        if (nameFoundFlag == false) {
            this.itemStates[0].name = resources.getString(R.string.rank1)
            this.itemStates[0].qty = 1
            this.itemStates[1].name = resources.getString(R.string.rank2)
            this.itemStates[1].qty = 1
            this.itemStates[2].name = resources.getString(R.string.rank3)
            this.itemStates[2].qty = 5
            this.itemStates[3].name = resources.getString(R.string.rank4)
            this.itemStates[3].qty = 5
            this.itemStates[4].name = resources.getString(R.string.rank5)
            this.itemStates[4].qty = 10
            this.itemStates[5].name = resources.getString(R.string.rank6)
            this.itemStates[5].qty = 100
            this.itemStates[6].name = resources.getString(R.string.rank7)
            this.itemStates[6].qty = 300
        }
    }

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

    //speedを保存
    private fun saveSpeed() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(SPEED, this@MainActivity.speed)
            apply()
        }
    }

    //speedを読み出し
    private fun loadSpeed() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.speed = pref.getInt(SPEED, 10)
        if (this.speed <= 0) {
            this.speed = 1
        } else if (this.speed > 1000) {
            this.speed = 1000
        }
    }

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

    //テーマを保存
    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/luckybox/SettingActivity.kt

package jp.aosystem.luckybox

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.luckybox.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 itemQty1: Int = intent.getIntExtra(MainActivity.ITEM_QTY1,0)
        val itemName2: String = intent.getStringExtra(MainActivity.ITEM_NAME2) ?: ""
        val itemQty2: Int = intent.getIntExtra(MainActivity.ITEM_QTY2,0)
        val itemName3: String = intent.getStringExtra(MainActivity.ITEM_NAME3) ?: ""
        val itemQty3: Int = intent.getIntExtra(MainActivity.ITEM_QTY3,0)
        val itemName4: String = intent.getStringExtra(MainActivity.ITEM_NAME4) ?: ""
        val itemQty4: Int = intent.getIntExtra(MainActivity.ITEM_QTY4,0)
        val itemName5: String = intent.getStringExtra(MainActivity.ITEM_NAME5) ?: ""
        val itemQty5: Int = intent.getIntExtra(MainActivity.ITEM_QTY5,0)
        val itemName6: String = intent.getStringExtra(MainActivity.ITEM_NAME6) ?: ""
        val itemQty6: Int = intent.getIntExtra(MainActivity.ITEM_QTY6,0)
        val itemName7: String = intent.getStringExtra(MainActivity.ITEM_NAME7) ?: ""
        val itemQty7: Int = intent.getIntExtra(MainActivity.ITEM_QTY7,0)
        if (itemName1 != "") {
            this.binding.editName1.setText(itemName1)
        }
        if (itemQty1 != 0) {
            this.binding.editQty1.setText(itemQty1.toString())
        }
        this.binding.editName2.setText(itemName2)
        if (itemQty2 != 0) {
            this.binding.editQty2.setText(itemQty2.toString())
        }
        this.binding.editName3.setText(itemName3)
        if (itemQty3 != 0) {
            this.binding.editQty3.setText(itemQty3.toString())
        }
        this.binding.editName4.setText(itemName4)
        if (itemQty4 != 0) {
            this.binding.editQty4.setText(itemQty4.toString())
        }
        this.binding.editName5.setText(itemName5)
        if (itemQty5 != 0) {
            this.binding.editQty5.setText(itemQty5.toString())
        }
        this.binding.editName6.setText(itemName6)
        if (itemQty6 != 0) {
            this.binding.editQty6.setText(itemQty6.toString())
        }
        this.binding.editName7.setText(itemName7)
        if (itemQty7 != 0) {
            this.binding.editQty7.setText(itemQty7.toString())
        }
        val speed: Int = intent.getIntExtra(MainActivity.SPEED,10)
        if (speed != 0) {
            this.binding.editSpeed.setText(speed.toString())
        }
        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.editQty1.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty1.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.editQty2.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty2.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.editQty3.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty3.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.editQty4.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty4.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.editQty5.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty5.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.editQty6.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty6.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.editQty7.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editQty7.windowToken,
                    InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editSpeed.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                    this.binding.editSpeed.windowToken,
                    InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
    }

    fun onClickApply(v: View) {
        val itemName1: String = this.binding.editName1.text.toString()
        val itemQty1: Int = ("0" + this.binding.editQty1.text.toString()).toInt()
        val itemName2: String = this.binding.editName2.text.toString()
        val itemQty2: Int = ("0" + this.binding.editQty2.text.toString()).toInt()
        val itemName3: String = this.binding.editName3.text.toString()
        val itemQty3: Int = ("0" + this.binding.editQty3.text.toString()).toInt()
        val itemName4: String = this.binding.editName4.text.toString()
        val itemQty4: Int = ("0" + this.binding.editQty4.text.toString()).toInt()
        val itemName5: String = this.binding.editName5.text.toString()
        val itemQty5: Int = ("0" + this.binding.editQty5.text.toString()).toInt()
        val itemName6: String = this.binding.editName6.text.toString()
        val itemQty6: Int = ("0" + this.binding.editQty6.text.toString()).toInt()
        val itemName7: String = this.binding.editName7.text.toString()
        val itemQty7: Int = ("0" + this.binding.editQty7.text.toString()).toInt()
        val speed: Int = ("0" + this.binding.editSpeed.text.toString()).toInt()
        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_QTY1, itemQty1)
        intent.putExtra(MainActivity.ITEM_NAME2, itemName2)
        intent.putExtra(MainActivity.ITEM_QTY2, itemQty2)
        intent.putExtra(MainActivity.ITEM_NAME3, itemName3)
        intent.putExtra(MainActivity.ITEM_QTY3, itemQty3)
        intent.putExtra(MainActivity.ITEM_NAME4, itemName4)
        intent.putExtra(MainActivity.ITEM_QTY4, itemQty4)
        intent.putExtra(MainActivity.ITEM_NAME5, itemName5)
        intent.putExtra(MainActivity.ITEM_QTY5, itemQty5)
        intent.putExtra(MainActivity.ITEM_NAME6, itemName6)
        intent.putExtra(MainActivity.ITEM_QTY6, itemQty6)
        intent.putExtra(MainActivity.ITEM_NAME7, itemName7)
        intent.putExtra(MainActivity.ITEM_QTY7, itemQty7)
        intent.putExtra(MainActivity.SPEED, speed)
        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/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:id="@+id/layoutBackground"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#FFF176"
        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="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="6"
                android:background="#FFC107"
                android:gravity="center"
                android:minHeight="96dp"
                android:onClick="onClickStart"
                android:text="@string/start" />

            <TextView
                android:id="@+id/textSetting"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="1dp"
                android:layout_weight="1"
                android:background="#FF9800"
                android:gravity="center"
                android:minHeight="96dp"
                android:onClick="onClickSetting"
                android:text="@string/setting" />

        </LinearLayout>

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

        <FrameLayout
            android:id="@+id/layoutBase"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageKuji"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center|center_horizontal|center_vertical"
                android:contentDescription="@string/app_name"
                app:srcCompat="@drawable/box_001" />

        </FrameLayout>

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

    </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="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="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="6"
            android:background="#86C663"
            android:gravity="center"
            android:minHeight="48dp"
            android:onClick="onClickCancel"
            android:text="@string/cancel" />

        <TextView
            android:id="@+id/textApply"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="1dp"
            android:layout_weight="6"
            android:background="#5DC6AF"
            android:gravity="center"
            android:minHeight="48dp"
            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="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:paddingLeft="20dp"
            android:paddingTop="20dp"
            android:paddingRight="20dp"
            android:paddingBottom="50dp">


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

                <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="@string/lot" />

                    <EditText
                        android:id="@+id/editName1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill"/>
                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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="@string/lot" />

                    <EditText
                        android:id="@+id/editName7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

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

                    <EditText
                        android:id="@+id/editQty7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill" />

                </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" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textSpeed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/speed"
                    android:textColor="?android:attr/textColorPrimary" />

                <EditText
                    android:id="@+id/editSpeed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_weight="1"
                    android:ems="6"
                    android:inputType="number" />

            </LinearLayout>

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

            <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/divider5"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="10dp"
                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" />

            <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/divider3"
                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>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>