diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..bf5b1ef --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +STRAW BERRY \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..32522c1 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0ad17cb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..4604c44 --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,252 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..7ddb0f1 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,47 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace = "straw.berry" + compileSdk = 34 + + defaultConfig { + applicationId = "straw.berry" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + buildFeatures { + viewBinding = true + } +} + +dependencies { + + implementation(libs.appcompat) + implementation(libs.material) + implementation(libs.constraintlayout) + implementation(libs.navigation.fragment) + implementation(libs.navigation.ui) + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 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/straw/berry/ExampleInstrumentedTest.java b/app/src/androidTest/java/straw/berry/ExampleInstrumentedTest.java new file mode 100644 index 0000000..7eabdec --- /dev/null +++ b/app/src/androidTest/java/straw/berry/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package straw.berry; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("straw.berry", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..322855b --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/straw/berry/MainActivity.java b/app/src/main/java/straw/berry/MainActivity.java new file mode 100644 index 0000000..9952eae --- /dev/null +++ b/app/src/main/java/straw/berry/MainActivity.java @@ -0,0 +1,178 @@ +package straw.berry; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.media.AudioAttributes; +import android.media.SoundPool; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.animation.AccelerateInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import java.util.Random; + +public class MainActivity extends AppCompatActivity { + + private ViewGroup container; + private TextView counterText; + private int clickCount = 0; + private final int STRAWBERRY_COUNT = 15; + private final int[] strawberryImages = { + R.drawable.strawberry1, + R.drawable.strawberry2, + R.drawable.strawberry3, + R.drawable.strawberry4, + R.drawable.strawberry5, + R.drawable.strawberry6 + }; + private Random random = new Random(); + + // Sound-related variables + private SoundPool soundPool; + private int soundId; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + container = findViewById(R.id.container); + counterText = findViewById(R.id.counter_text); + updateCounter(); + + // Initialize sound + initializeSound(); + + container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + container.getViewTreeObserver().removeOnGlobalLayoutListener(this); + startStrawberryRain(); + } + }); + } + + private void initializeSound() { + AudioAttributes audioAttributes = new AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_GAME) + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .build(); + + soundPool = new SoundPool.Builder() + .setMaxStreams(5) + .setAudioAttributes(audioAttributes) + .build(); + + soundId = soundPool.load(this, R.raw.munch2, 1); + } + + private void startStrawberryRain() { + for (int i = 0; i < 20; i++) { + addStrawberry(); + } + } + + private void addStrawberry() { + ImageView strawberry = new ImageView(this); + int imageResource = strawberryImages[random.nextInt(strawberryImages.length)]; + strawberry.setImageResource(imageResource); + + int size = dpToPx(40 + random.nextInt(40)); // Random size between 40dp and 80dp + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(size, size); + strawberry.setLayoutParams(params); + + container.addView(strawberry); + + strawberry.setRotation(random.nextFloat() * 360); + strawberry.setY(-size); + + strawberry.post(() -> { + int maxX = container.getWidth() - strawberry.getWidth(); + if (maxX > 0) { + strawberry.setX(random.nextInt(maxX)); + } + }); + + strawberry.setOnClickListener(v -> { + clickCount++; + updateCounter(); + container.removeView(v); + playClickSound(); + if (clickCount == STRAWBERRY_COUNT) { + triggerCrazyEvent(); + } else { + addStrawberry(); + } + }); + + ObjectAnimator animator = ObjectAnimator.ofFloat(strawberry, "translationY", container.getHeight() + size); + animator.setDuration(3000 + random.nextInt(3000)); + animator.setInterpolator(new AccelerateInterpolator(1.2f)); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + container.removeView(strawberry); + addStrawberry(); + } + }); + animator.start(); + } + // dGhlIHNlZWQgaGFzIGJlZW4gcGxhbnRlZCA= + private void playClickSound() { + soundPool.play(soundId, 1.0f, 1.0f, 1, 0, 1.0f); + } + + private void updateCounter() { + counterText.setText(clickCount + "/" + STRAWBERRY_COUNT); + } + + private void triggerCrazyEvent() { + ImageView giantStrawberry = new ImageView(this); + giantStrawberry.setImageResource(R.drawable.strawberry_giant); + giantStrawberry.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + container.addView(giantStrawberry); + + giantStrawberry.setScaleX(0); + giantStrawberry.setScaleY(0); + giantStrawberry.animate() + .scaleX(1) + .scaleY(1) + .setDuration(1000) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + resetGame(); + } + }) + .start(); + } + + private void resetGame() { + container.removeAllViews(); + clickCount = 0; + updateCounter(); + startStrawberryRain(); + } + + private int dpToPx(int dp) { + float density = getResources().getDisplayMetrics().density; + return Math.round((float) dp * density); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if (soundPool != null) { + soundPool.release(); + soundPool = null; + } + } +} \ No newline at end of file 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 100644 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/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/strawberry1.png b/app/src/main/res/drawable/strawberry1.png new file mode 100644 index 0000000..1ef9d9b Binary files /dev/null and b/app/src/main/res/drawable/strawberry1.png differ diff --git a/app/src/main/res/drawable/strawberry2.png b/app/src/main/res/drawable/strawberry2.png new file mode 100644 index 0000000..1958705 Binary files /dev/null and b/app/src/main/res/drawable/strawberry2.png differ diff --git a/app/src/main/res/drawable/strawberry3.png b/app/src/main/res/drawable/strawberry3.png new file mode 100644 index 0000000..5ab65e7 Binary files /dev/null and b/app/src/main/res/drawable/strawberry3.png differ diff --git a/app/src/main/res/drawable/strawberry4.png b/app/src/main/res/drawable/strawberry4.png new file mode 100644 index 0000000..55696ca Binary files /dev/null and b/app/src/main/res/drawable/strawberry4.png differ diff --git a/app/src/main/res/drawable/strawberry5.png b/app/src/main/res/drawable/strawberry5.png new file mode 100644 index 0000000..8553411 Binary files /dev/null and b/app/src/main/res/drawable/strawberry5.png differ diff --git a/app/src/main/res/drawable/strawberry6.png b/app/src/main/res/drawable/strawberry6.png new file mode 100644 index 0000000..5017897 Binary files /dev/null and b/app/src/main/res/drawable/strawberry6.png differ diff --git a/app/src/main/res/drawable/strawberry_giant.png b/app/src/main/res/drawable/strawberry_giant.png new file mode 100644 index 0000000..3f5c201 Binary files /dev/null and b/app/src/main/res/drawable/strawberry_giant.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..0a25da6 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/raw/munch.wav b/app/src/main/res/raw/munch.wav new file mode 100644 index 0000000..d78c538 Binary files /dev/null and b/app/src/main/res/raw/munch.wav differ diff --git a/app/src/main/res/raw/munch2.wav b/app/src/main/res/raw/munch2.wav new file mode 100644 index 0000000..7028f1b Binary files /dev/null and b/app/src/main/res/raw/munch2.wav differ diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/app/src/main/res/values-land/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..ed043a2 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values-v23/themes.xml b/app/src/main/res/values-v23/themes.xml new file mode 100644 index 0000000..16d1020 --- /dev/null +++ b/app/src/main/res/values-v23/themes.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values-w1240dp/dimens.xml b/app/src/main/res/values-w1240dp/dimens.xml new file mode 100644 index 0000000..d73f4a3 --- /dev/null +++ b/app/src/main/res/values-w1240dp/dimens.xml @@ -0,0 +1,3 @@ + + 200dp + \ No newline at end of file diff --git a/app/src/main/res/values-w600dp/dimens.xml b/app/src/main/res/values-w600dp/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/app/src/main/res/values-w600dp/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..c8524cd --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..125df87 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,3 @@ + + 16dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..99d8ddd --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + STRAW BERRY + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..1be75f2 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + +