From 2c107c6dd13e5778099bbd88d4463cec7e3e99c1 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 17 Jun 2023 23:45:57 +0200 Subject: Found on an old harddrive --- .gitignore | 10 ++ app/.gitignore | 1 + app/build.gradle | 43 +++++ app/proguard-rules.pro | 21 +++ .../de/marvinborner/pi/ExampleInstrumentedTest.kt | 24 +++ app/src/main/AndroidManifest.xml | 25 +++ .../main/java/de/marvinborner/pi/GameActivity.kt | 108 ++++++++++++ .../main/java/de/marvinborner/pi/MainActivity.kt | 32 ++++ .../res/drawable-v24/ic_launcher_foreground.xml | 30 ++++ .../res/drawable/ic_baseline_arrow_back_ios_24.xml | 5 + .../main/res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++++ app/src/main/res/drawable/round_button.xml | 9 + app/src/main/res/layout/activity_game.xml | 184 ++++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 40 +++++ app/src/main/res/layout/game_over.xml | 60 +++++++ app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../res/mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../main/res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../main/res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes app/src/main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes app/src/main/res/values-v31/themes.xml | 12 ++ app/src/main/res/values/colors.xml | 10 ++ app/src/main/res/values/dimens.xml | 5 + app/src/main/res/values/strings.xml | 4 + app/src/main/res/values/themes.xml | 11 ++ .../java/de/marvinborner/pi/ExampleUnitTest.kt | 17 ++ build.gradle | 10 ++ gradle.properties | 23 +++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 185 +++++++++++++++++++++ gradlew.bat | 89 ++++++++++ settings.gradle | 16 ++ 40 files changed, 1160 insertions(+) create mode 100755 .gitignore create mode 100755 app/.gitignore create mode 100755 app/build.gradle create mode 100755 app/proguard-rules.pro create mode 100755 app/src/androidTest/java/de/marvinborner/pi/ExampleInstrumentedTest.kt create mode 100755 app/src/main/AndroidManifest.xml create mode 100755 app/src/main/java/de/marvinborner/pi/GameActivity.kt create mode 100755 app/src/main/java/de/marvinborner/pi/MainActivity.kt create mode 100755 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100755 app/src/main/res/drawable/ic_baseline_arrow_back_ios_24.xml create mode 100755 app/src/main/res/drawable/ic_launcher_background.xml create mode 100755 app/src/main/res/drawable/round_button.xml create mode 100755 app/src/main/res/layout/activity_game.xml create mode 100755 app/src/main/res/layout/activity_main.xml create mode 100755 app/src/main/res/layout/game_over.xml create mode 100755 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100755 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100755 app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100755 app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100755 app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100755 app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100755 app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100755 app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100755 app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100755 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100755 app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100755 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100755 app/src/main/res/values-v31/themes.xml create mode 100755 app/src/main/res/values/colors.xml create mode 100755 app/src/main/res/values/dimens.xml create mode 100755 app/src/main/res/values/strings.xml create mode 100755 app/src/main/res/values/themes.xml create mode 100755 app/src/test/java/de/marvinborner/pi/ExampleUnitTest.kt create mode 100755 build.gradle create mode 100755 gradle.properties create mode 100755 gradle/wrapper/gradle-wrapper.jar create mode 100755 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100755 gradlew.bat create mode 100755 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..87f66f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +.idea/ +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/.gitignore b/app/.gitignore new file mode 100755 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100755 index 0000000..9e2215d --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + compileSdk 32 + + defaultConfig { + applicationId "de.marvinborner.pi" + minSdk 21 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100755 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/de/marvinborner/pi/ExampleInstrumentedTest.kt b/app/src/androidTest/java/de/marvinborner/pi/ExampleInstrumentedTest.kt new file mode 100755 index 0000000..0deeaf5 --- /dev/null +++ b/app/src/androidTest/java/de/marvinborner/pi/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package de.marvinborner.pi + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("de.marvinborner.pi", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100755 index 0000000..0066eeb --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/de/marvinborner/pi/GameActivity.kt b/app/src/main/java/de/marvinborner/pi/GameActivity.kt new file mode 100755 index 0000000..98fcb0b --- /dev/null +++ b/app/src/main/java/de/marvinborner/pi/GameActivity.kt @@ -0,0 +1,108 @@ +package de.marvinborner.pi + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.media.AudioAttributes +import android.os.* +import androidx.appcompat.app.AppCompatActivity +import android.text.TextUtils.substring +import android.util.TypedValue +import android.view.View +import android.widget.Button +import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import androidx.core.widget.TextViewCompat + +class GameActivity : AppCompatActivity() { + private val e = + "2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668082264800168477411853742345442437107539077744992069551702761838606261331384583000752044933826560297606737113200709328709127443747047230696977209310141692836819025515108657463772111252389784425056953696770785449969967946864454905987931636889230098793127736178215424999229576351482208269895193668033182528869398496465105820939239829488793320362509443117301238197068416140397019837679320683282376464804295311802328782509819455815301756717361332069811250996181881593041690351598888519345807273866738589422879228499892086805825749279610484198444363463244968487560233624827041978623209002160990235304369941849146314093431738143640546253152096183690888707016768396424378140592714563549061303107208510383750510115747704171898610687396965521267154688957035035402123407849819334321068170121005627880235193033224745015853904730419957777093503660416997329725088687696640355570716226844716256079882651787134195124665201030592123667719432527867539855894489697096409754591856956380236370162112047742722836489613422516445078182442352948636372141740238893441247963574370263755294448337998016125492278509257782562092622648326277933386566481627725164019105900491644998289315056604725802778631864155195653244258698294695930801915298721172556347546396447910145904090586298496791287406870504895858671747985466775757320568128845920541334053922000113786300945560688166740016984205580403363795376452030402432256613527836951177883863874439662532249850654995886234281899707733276171783928034946501434558897071942586398772754710962953741521115136835062752602326484728703920764310059584116612054529703023647254929666938115137322753645098889031360205724817658511806303644281231496550704751025446501172721155519486685080036853228183152196003735625279449515828418829478761085263981395599006737648292244375287184624578036192981971399147564488262603903381441823262515097482798777996437308997038886778227138360577297882412561190717663946507063304527954661855096666185664709711344474016070462621568071748187784437143698821855967095910259686200235371858874856965220005031173439207321139080329363447972735595527734907178379342163701205005451326383544000186323991490705479778056697853358048966906295119432473099587655236812859041383241160722602998330535370876138939639177957454016137223618789365260538155841587186925538606164779834025435128439612946035291332594279490433729908573158029095863138268329147711639633709240031689458636060645845925126994655724839186564209752685082307544254599376917041977780085362730941710163434907696423722294352366125572508814779223151974778060569672538017180776360346245927877846585065605078084421152969752189087401966090665180351650179250461950136658543663271254963990854914420001457476081930221206602433009641270489439039717719518069908699860663658323227870937650226014929101151717763594460202324930028040186772391028809786660565118326004368850881715723866984224220102495055188169480322100251542649463981287367765892768816359831247788652014117411091360116499507662907794364600585194199856016264790761532103872755712699251827568798930276176114616254935649590379804583818232336861201624373656984670378585330527583333793990752166069238053369887956513728559388349989470741618155012539706464817194670834819721448889879067650379590366967249499254527903372963616265897603949857674139735944102374432970935547798262961459144293645142861715858733974679189757121195618738578364475844842355558105002561149239151889309946342841393608038309166281881150371528496705974162562823609216807515017772538740256425347087908913729172282861151591568372524163077225440633787593105982676094420326192428531701878177296023541306067213604600038966109364709514141718577701418060644363681546444005331608778314317444081194942297559931401188868331483280270655383300469329011574414756313999722170380461709289457909627166226074071874997535921275608441473782330327033016823719364800217328573493594756433412994302485023573221459784328264142168487872167336701061509424345698440187331281010794512722373788612605816566805371439612788873252737389039289050686532413806279602593038772769778379286840932536588073398845721874602100531148335132385004782716937621800490479559795929059165547050577751430817511269898518840871856402603530558373783242292418562564425502267215598027401261797192804713960068916382866527700975276706977703643926022437284184088325184877047263844037953016690546593746161932384036389313136432713768884102681121989127522305625675625470172508634976536728860596675274086862740791285657699631378975303466061666980421826772456053066077389962421834085988207186468262321508028828635974683965435885668550377313129658797581050121491620765676995065971534476347032085321560367482860837865680307306265763346977429563464371670939719306087696349532884683361303882943104080029687386911706666614680001512114344225602387447432525076938707777519329994213727721125884360871583483562696166198057252661220679754062106208064988291845439530152998209250300549825704339055357016865312052649561485724925738620691740369521353373253166634546658859728665945113644137033139367211856955395210845840724432383558606310680696492485123263269951460359603729725319836842336390463213671011619282171115028280160448805880238203198149309636959673583274202498824568494127386056649135252670604623445054922758115170931492187959271800194096886698683703730220047531433818109270803001720593553052070070607223399946399057131158709963577735902719628506114651483752620956534671329002599439766311454590268589897911583709341937044115512192011716488056694593813118384376562062784631049034629395002945834116482411496975832601180073169943739350696629571241027323913874175492307186245454322203955273529524024590380574450289224688628533654221381572213116328811205214648980518009202471939171055539011394331668151582884368760696110250517100739276238555338627255353883096067164466237092264680967125406186950214317621166814009759528149390722260111268115310838731761732323526360583817315103459573653822353499293582283685100781088463434998351840445170427018938199424341009057537625776757111809008816418331920196262341628816652137471732547772778348877436651882875215668571950637193656539038944936642176400312152787022236646363575550356557694888654950027085392361710550213114741374410613444554419210133617299628569489919336918472947858072915608851039678195942983318648075608367955149663644896559294818785178403877332624705194505041984774201418394773120281588684570729054405751060128525805659470304683634459265255213700806875200959345360731622611872817392807462309468536782310609792159936001994623799343421068781349734695924646975250624695861690917857397659519939299399556754271465491045686070209901260681870498417807917392407194599632306025470790177452751318680998228473086076653686685551646770291133682756310722334672611370549079536583453863719623585631261838715677411873852772292259474337378569553845624680101390572787101651296663676445187246565373040244368414081448873295784734849000301947788802046032466084287535184836495919508288832320652212810419044804724794929134228495197002260131043006241071797150279343326340799596053144605323048852897291765987601666781193793237245385720960758227717848336161358261289622611812945592746276713779448758675365754486140761193112595851265575973457301533364263076798544338576171533346232527057200530398828949903425956623297578248873502925916682589445689465599265845476269452878051650172067478541788798227680653665064191097343452887833862172615626958265447820567298775642632532159429441803994321700009054265076309558846589517170914760743713689331946909098190450129030709956622662030318264936573369841955577696378762491885286568660760056602560544571133728684020557441603083705231224258722343885412317948138855007568938112493538631863528708379984569261998179452336408742959118074745341955142035172618420084550917084568236820089773945584267921427347756087964427920270831215015640634134161716644806981548376449157390012121704154787259199894382536495051477137939914720521952907939613762110723849429061635760459623125350606853765142311534966568371511660422079639446662116325515772907097847315627827759878813649195125748332879377157145909106484164267830994972367442017586226940215940792448054125536043131799269673915754241929660731239376354213923061787675395871143610408940996608947141834069836299367536262154524729846421375289107988438130609555262272083751862983706678722443019579379378607210725427728907173285487437435578196651171661833088112912024520404868220007234403502544820283425418788465360259150644527165770004452109773558589762265548494162171498953238342160011406295071849042778925855274303522139683567901807640604213830730877446017084268827226117718084266433365178000217190344923426426629226145600433738386833555534345300426481847398921562708609565062934040526494324426144566592129122564889356965500915430642613425266847259491431423939884543248632746184284665598533231221046625989014171210344608427161661900125719587079321756969854401339762209674945418540711844643394699016269835160784892451405894094639526780735457970030705116368251948770118976400282764841416058720618418529718915401968825328930914966534575357142731848201638464483249903788606900807270932767312758196656394114896171683298045513972950668760474091542042842999354102582911350224169076943166857424252250902693903481485645130306992519959043638402842926741257342244776558417788617173726546208549829449894678735092958165263207225899236876845701782303809656788311228930580914057261086588484587310165815116753332767488701482916741970151255978257270740643180860142814902414678047232759768426963393577354293018673943971638861176420900406866339885684168100387238921448317607011668450388721236436704331409115573328018297798873659091665961240202177855885487617616198937079438005666336488436508914480557103976521469602766258359905198704230017946553679" + private val golden = + "1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752126633862223536931793180060766726354433389086595939582905638322661319928290267880675208766892501711696207032221043216269548626296313614438149758701220340805887954454749246185695364864449241044320771344947049565846788509874339442212544877066478091588460749988712400765217057517978834166256249407589069704000281210427621771117778053153171410117046665991466979873176135600670874807101317952368942752194843530567830022878569978297783478458782289110976250030269615617002504643382437764861028383126833037242926752631165339247316711121158818638513316203840052221657912866752946549068113171599343235973494985090409476213222981017261070596116456299098162905552085247903524060201727997471753427775927786256194320827505131218156285512224809394712341451702237358057727861600868838295230459264787801788992199027077690389532196819861514378031499741106926088674296226757560523172777520353613936210767389376455606060592165894667595519004005559089502295309423124823552122124154440064703405657347976639723949499465845788730396230903750339938562102423690251386804145779956981224457471780341731264532204163972321340444494873023154176768937521030687378803441700939544096279558986787232095124268935573097045095956844017555198819218020640529055189349475926007348522821010881946445442223188913192946896220023014437702699230078030852611807545192887705021096842493627135925187607778846658361502389134933331223105339232136243192637289106705033992822652635562090297986424727597725655086154875435748264718141451270006023890162077732244994353088999095016803281121943204819643876758633147985719113978153978074761507722117508269458639320456520989698555678141069683728840587461033781054443909436835835813811311689938555769754841491445341509129540700501947754861630754226417293946803673198058618339183285991303960720144559504497792120761247856459161608370594987860069701894098864007644361709334172709191433650137157660114803814306262380514321173481510055901345610118007905063814215270930858809287570345050780814545881990633612982798141174533927312080928972792221329806429468782427487401745055406778757083237310975915117762978443284747908176518097787268416117632503861211291436834376702350371116330725869883258710336322238109809012110198991768414917512331340152733843837234500934786049792945991582201258104598230925528721241370436149102054718554961180876426576511060545881475604431784798584539731286301625448761148520217064404111660766950597757832570395110878230827106478939021115691039276838453863333215658296597731034360323225457436372041244064088826737584339536795931232213437320995749889469956564736007295999839128810319742631251797141432012311279551894778172691415891177991956481255800184550656329528598591000908621802977563789259991649946428193022293552346674759326951654214021091363018194722707890122087287361707348649998156255472811373479871656952748900814438405327483781378246691744422963491470815700735254570708977267546934382261954686153312095335792380146092735102101191902183606750973089575289577468142295433943854931553396303807291691758461014609950550648036793041472365720398600735507609023173125016132048435836481770484818109916024425232716721901893345963786087875287017393593030133590112371023917126590470263494028307668767436386513271062803231740693173344823435645318505813531085497333507599667787124490583636754132890862406324563953572125242611702780286560432349428373017255744058372782679960317393640132876277012436798311446436947670531272492410471670013824783128656506493434180390041017805339505877245866557552293915823970841772983372823115256926092995942240000560626678674357923972454084817651973436265268944888552720274778747335983536727761407591712051326934483752991649980936024617844267572776790019191907038052204612324823913261043271916845123060236278935454324617699757536890417636502547851382463146583363833760235778992672988632161858395903639981838458276449124598093704305555961379734326134830494949686810895356963482817812886253646084203394653819441945714266682371839491832370908574850266568039897440662105360306400260817112665995419936873160945722888109207788227720363668448153256172841176909792666655223846883113718529919216319052015686312228207155998764684235520592853717578076560503677313097519122397388722468258057159744574048429878073522159842667662578077062019430400542550158312503017534094117191019298903844725033298802450143679684416947959545304591031381162187045679978663661746059570003445970113525181346006565535203478881174149941274826415213556776394039071038708818233806803350038046800174808220591096844202644640218770534010031802881664415309139394815640319282278548241451050318882518997007486228794215589574282021665706218809057808805032467699129728721038707369740643566745892025865657397856085956653410703599783204463363464854894976638853510455272982422906998488536968280464597457626514343590509383212437433338705166571490059071056702488798580437181512610044038148804072524406164290224782271527241120850657888387124936351068063651667432223277677557973992703762319147047323955120607055039920884426037087908433342618384135970781648295537143219611895037977146300075559753795703552271449319132172556440128309180504500899218705121186069335731538959350790300736727023314165320423401553741442687154055116479611433230248544040940691145613987302603951828168034482525432673857590056043202453727192912486458133344169852993913574786989579864394980230471169671573622839120181273129165899527599192203183723568272793856373312654799859124632750300605925674549794350881192950568549325935531872914180113641218747075262810686983013576052471944559321955359610452830314883911769301196585834314424894898565584250834109429502771975833522442912573649380754171137392437601435068298784932712997512286881960498357751587717804106971319667534771947922636519016339771284739079336111191408998305603361060987171783055435403560895292908184641437139294378135604820389479125745077075575103002420726629001809042293424942590606661413322872269806901459945119954780163991514126125257282806643312616574693881951064421673871800011004218483025809165433837492364118388856468514315006373190429514814694243146089525470720374055669130692209908048194529751106504642810541775525909518713188835914765996041317960209415308585533238772538023272763297737214312796821671623442118320180288141274744316884721845939278143547409999907223320305926297661123832798331698825393126200650370288447828666940447307947104761255865837529862362509998232335971550723383833244081525778193364262630433026589581708004512788731159355877472172564947000516366725771539209840950327451121536873009121996295227659131637093968607271342692623154753304379933165811073696431421719794340563915512108108136262688856974806806011691894175027229874158699179145349946244419401219785860137366082869072236514771391268742096651378756205918543288883417429209015631332831935756220897137656309785015631549824564458654247929357228287506084814533513521817295879329911710032476222052194645105362450512988430871344439507244267351462861799183233645983696376327225756915972395438305208664747423815110792734948369523964792689936983249179995027895000604596613134633630249499514808053290179029751825158750490074351879835118360327227726017174045355716588555782972910619581935171055482579307091005763586990192972179951687311755631444856481002200142545405542927345883711602099479457208237804368718944805636891825802444996318783420274910153357910727336253289069334741238022220116262771193085448502954191320040099986556665177566409536561978978183804510303565101315894589028718610869058939471368014845700183664956472032943343742989464274125514359058434840919548701523614031739139036164401984550510491211697920012019996050699496640303508636929039410070194505320162348727632327324494396304808905542513797233147518520709102506368598167953048181007394245317002388047598343234504142584314063612721096022824233782280902797659607771084939151748873168777135223900911711735091860065462009902497585277925427816597038349505801062615533369109378465977105297502231730741217783441894118459658610298018778742744563866966127724503845860526415103040898257777544741153320764075881677514975538047116296677710058766461595496776927054962393985709255070274069978140843124965363071866533718060587422425981653070525738345415770542921629981149175086113117657731720956156564786954744892713206080635457794624145310669837421137981689638235333044778831693397287289181036640832698569882544385166758622899306964346848975148408790396476042036102060217173944702634876336543931952290773836167389811781242483655781050341694515636260430036657431084766548777801285779236454185224472361713742292558415931356128663716703280721715533926463257306730639108541088680857428385882806023033414085503909735387261345119629264159952127893113544314601527309025538271043259662267439037455636122861390783194335705900381487008986613153981958574423304419708566967222931427307413848827889755888607997387044702031668348569419909654802982493198176579268298556297230106827772351627407838074318778273182119196952800516087915721288263379682312725628700015001829297577299935790949196407634428615757135444278983830404547027101945800425820212023445806303450336581472185492036799899729353539196812133195165379745399111494244451830338588412904018178188213760066592849413677543174516054093871103687152116404058219344712044827759605416948645398783262695480139150190389959313067031866167066371964025692867138871466311891926856826919952764579977182787594609616172188681094546515788691224106098141972686192554787899263153594729228250805425169068140107817960218853307623055638163164019224545032576567392599765175308014271607143087188628598360374650571342046700834327542302770477933111836669032328853068738799071359007403049074598895136476876086784432382482189306175703195638032308197193635672741964387262587061543307296370381275151704060050575948827238563451563905265771042645947604055695095984088890376207995663880178618559159441117250923132797711380" + private val pi = + "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635342207222582848864815845602850601684273945226746767889525213852254995466672782398645659611635488623057745649803559363456817432411251507606947945109659609402522887971089314566913686722874894056010150330861792868092087476091782493858900971490967598526136554978189312978482168299894872265880485756401427047755513237964145152374623436454285844479526586782105114135473573952311342716610213596953623144295248493718711014576540359027993440374200731057853906219838744780847848968332144571386875194350643021845319104848100537061468067491927819119793995206141966342875444064374512371819217999839101591956181467514269123974894090718649423196156794520809514655022523160388193014209376213785595663893778708303906979207734672218256259966150142150306803844773454920260541466592520149744285073251866600213243408819071048633173464965145390579626856100550810665879699816357473638405257145910289706414011097120628043903975951567715770042033786993600723055876317635942187312514712053292819182618612586732157919841484882916447060957527069572209175671167229109816909152801735067127485832228718352093539657251210835791513698820914442100675103346711031412671113699086585163983150197016515116851714376576183515565088490998985998238734552833163550764791853589322618548963213293308985706420467525907091548141654985946163718027098199430992448895757128289059232332609729971208443357326548938239119325974636673058360414281388303203824903758985243744170291327656180937734440307074692112019130203303801976211011004492932151608424448596376698389522868478312355265821314495768572624334418930396864262434107732269780280731891544110104468232527162010526522721116603966655730925471105578537634668206531098965269186205647693125705863566201855810072936065987648611791045334885034611365768675324944166803962657978771855608455296541266540853061434443185867697514566140680070023787765913440171274947042056223053899456131407112700040785473326993908145466464588079727082668306343285878569830523580893306575740679545716377525420211495576158140025012622859413021647155097925923099079654737612551765675135751782966645477917450112996148903046399471329621073404375189573596145890193897131117904297828564750320319869151402870808599048010941214722131794764777262241425485454033215718530614228813758504306332175182979866223717215916077166925474873898665494945011465406284336639379003976926567214638530673609657120918076383271664162748888007869256029022847210403172118608204190004229661711963779213375751149595015660496318629472654736425230817703675159067350235072835405670403867435136222247715891504953098444893330963408780769325993978054193414473774418426312986080998886874132604721569516239658645730216315981931951673538129741677294786724229246543668009806769282382806899640048243540370141631496589794092432378969070697794223625082216889573837986230015937764716512289357860158816175578297352334460428151262720373431465319777741603199066554187639792933441952154134189948544473456738316249934191318148092777710386387734317720754565453220777092120190516609628049092636019759882816133231666365286193266863360627356763035447762803504507772355471058595487027908143562401451718062464362679456127531813407833033625423278394497538243720583531147711992606381334677687969597030983391307710987040859133746414428227726346594704745878477872019277152807317679077071572134447306057007334924369311383504931631284042512192565179806941135280131470130478164378851852909285452011658393419656213491434159562586586557055269049652098580338507224264829397285847831630577775606888764462482468579260395352773480304802900587607582510474709164396136267604492562742042083208566119062545433721315359584506877246029016187667952406163425225771954291629919306455377991403734043287526288896399587947572917464263574552540790914513571113694109119393251910760208252026187985318877058429725916778131496990090192116971737278476847268608490033770242429165130050051683233643503895170298939223345172201381280696501178440874519601212285993716231301711444846409038906449544400619869075485160263275052983491874078668088183385102283345085048608250393021332197155184306354550076682829493041377655279397517546139539846833936383047461199665385815384205685338621867252334028308711232827892125077126294632295639898989358211674562701021835646220134967151881909730381198004973407239610368540664319395097901906996395524530054505806855019567302292191393391856803449039820595510022635353619204199474553859381023439554495977837790237421617271117236434354394782218185286240851400666044332588856986705431547069657474585503323233421073015459405165537906866273337995851156257843229882737231989875714159578111963583300594087306812160287649628674460477464915995054973742562690104903778198683593814657412680492564879855614537234786733039046883834363465537949864192705638729317487233208376011230299113679386270894387993620162951541337142489283072201269014754668476535761647737946752004907571555278196536213239264061601363581559074220202031872776052772190055614842555187925303435139844253223415762336106425063904975008656271095359194658975141310348227693062474353632569160781547818115284366795706110861533150445212747392454494542368288606134084148637767009612071512491404302725386076482363414334623518975766452164137679690314950191085759844239198629164219399490723623464684411739403265918404437805133389452574239950829659122850855582157250310712570126683024029295252201187267675622041542051618416348475651699981161410100299607838690929160302884002691041407928862150784245167090870006992821206604183718065355672525325675328612910424877618258297651579598470356222629348600341587229805349896502262917487882027342092222453398562647669149055628425039127577102840279980663658254889264880254566101729670266407655904290994568150652653053718294127033693137851786090407086671149655834343476933857817113864558736781230145876871266034891390956200993936103102916161528813843790990423174733639480457593149314052976347574811935670911013775172100803155902485309066920376719220332290943346768514221447737939375170344366199104033751117354719185504644902636551281622882446257591633303910722538374218214088350865739177150968288747826569959957449066175834413752239709683408005355984917541738188399944697486762655165827658483588453142775687900290951702835297163445621296404352311760066510124120065975585127617858382920419748442360800719304576189323492292796501987518721272675079812554709589045563579212210333466974992356302549478024901141952123828153091140790738602515227429958180724716259166854513331239480494707911915326734302824418604142636395480004480026704962482017928964766975831832713142517029692348896276684403232609275249603579964692565049368183609003238092934595889706953653494060340216654437558900456328822505452556405644824651518754711962184439658253375438856909411303150952617937800297412076651479394259029896959469955657612186561967337862362561252163208628692221032748892186543648022967807057656151446320469279068212073883778142335628236089632080682224680122482611771858963814091839036736722208883215137556003727983940041529700287830766709444745601345564172543709069793961225714298946715435784687886144458123145935719849225284716050492212424701412147805734551050080190869960330276347870810817545011930714122339086639383395294257869050764310063835198343893415961318543475464955697810382930971646514384070070736041123735998434522516105070270562352660127648483084076118301305279320542746286540360367453286510570658748822569815793678976697422057505968344086973502014102067235850200724522563265134105592401902742162484391403599895353945909440704691209140938700126456001623742880210927645793106579229552498872758461012648369998922569596881592056001016552563756" + private var seq = "" + + private var score = 0 + private var gameOverDialog: Dialog? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + seq = when (intent.extras!!["type"]) { + R.id.play_e -> e + R.id.play_golden -> golden + R.id.play_pi -> pi + else -> "" + } + + setContentView(R.layout.activity_game) + reset() + } + + fun onClick(view: View) { + if (gameOverDialog != null) + return + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val vib = getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager + vib.defaultVibrator.vibrate( + VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK) + ) + } + + val button = view as Button + append(button.text[0]) + } + + fun onBack(view: View) { + finish() + } + + fun onReset(view: View) { + if (gameOverDialog != null) + gameOverDialog!!.cancel() + + reset() + } + + private fun reset() { + val input = findViewById(R.id.input) + input.text = substring(seq, 0, 2) + score = 0 + gameOverDialog = null; + } + + private fun gameOver(index: Int, entered: Char) { + gameOverDialog = Dialog(this, android.R.style.Theme_Black_NoTitleBar) + gameOverDialog!!.window!!.setBackgroundDrawable(ColorDrawable(Color.argb(100, 0, 0, 0))) + gameOverDialog!!.window!!.attributes.windowAnimations = + androidx.appcompat.R.style.Animation_AppCompat_DropDownUp + gameOverDialog!!.setContentView(R.layout.game_over) + gameOverDialog!!.setCancelable(true) + gameOverDialog!!.show() + + gameOverDialog!!.findViewById(R.id.score).append(score.toString()) + gameOverDialog!!.findViewById(R.id.highscore).visibility = View.GONE // TODO + gameOverDialog!!.findViewById(R.id.correct).append(seq.substring(score + 2, score + 12)) + } + + private fun append(char: Char) { + val input = findViewById(R.id.input) + val current = input.text + + if (seq[score + 2] != char) { + gameOver(score, char) + return + } + + // Normal appending doesn't work with auto-size textview + if (input.textSize.toInt() == TextViewCompat.getAutoSizeMinTextSize(input)) + input.text = current.drop(1).toString() + char + else + input.text = current.toString() + char + + score++ + } +} diff --git a/app/src/main/java/de/marvinborner/pi/MainActivity.kt b/app/src/main/java/de/marvinborner/pi/MainActivity.kt new file mode 100755 index 0000000..2c0f735 --- /dev/null +++ b/app/src/main/java/de/marvinborner/pi/MainActivity.kt @@ -0,0 +1,32 @@ +package de.marvinborner.pi + +import android.app.Dialog +import android.content.Intent +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.util.TypedValue +import android.view.View +import android.widget.Button +import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatDelegate +import androidx.core.widget.TextViewCompat + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) + + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + } + + fun onClick(view: View) { + val button = view as Button + val intent = Intent(this, GameActivity::class.java).apply { + putExtra("type", button.id) + } + startActivity(intent) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100755 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_ios_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_ios_24.xml new file mode 100755 index 0000000..01b2c76 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_arrow_back_ios_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100755 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/round_button.xml b/app/src/main/res/drawable/round_button.xml new file mode 100755 index 0000000..3240f2b --- /dev/null +++ b/app/src/main/res/drawable/round_button.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_game.xml b/app/src/main/res/layout/activity_game.xml new file mode 100755 index 0000000..b39b7b7 --- /dev/null +++ b/app/src/main/res/layout/activity_game.xml @@ -0,0 +1,184 @@ + + +