commit b4029d09dd02f1be6722230d25f2d7fadef964cc Author: Stepan Date: Wed May 7 12:14:04 2025 +0200 init 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/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /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..639c779 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ 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..b2c751a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0afe71 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Travelling app + +> This is a school homework project. It is created for educational purposes only and is not intended for commercial use. + +## 📁 Main Files + +### Scripts + +- [MainActivity.java](app/src/main/java/com/example/travelling/MainActivity.java) +- [Splash.java](app/src/main/java/com/example/travelling/Splash.java) +- [ResultActivity.java](app/src/main/java/com/example/travelling/ResultActivity.java) + +### Activities + +- [activity_main.xml](/app/src/main/res/layout/activity_main.xml) +- [activity_result.xml](/app/src/main/res/layout/activity_result.xml) +- [activity_splash.xml](/app/src/main/res/layout/activity_splash.xml) + +## Screenshots + +| activity_splash.xml | activity_main.xml | activity_result.xml | +| --- | --- | --- | +| ![splash](readme_media/split_activity.png) | ![main](readme_media/main_activity.png) | ![result](readme_media/result_activity.png) \ 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..b0651c6 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + alias(libs.plugins.android.application) +} + +android { + namespace = "com.example.travelling" + compileSdk = 35 + + defaultConfig { + applicationId = "com.example.travelling" + minSdk = 26 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + buildFeatures { + viewBinding = true + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + + implementation(libs.appcompat) + implementation(libs.material) + implementation(libs.activity) + implementation(libs.constraintlayout) + 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/com/example/travelling/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/travelling/ExampleInstrumentedTest.java new file mode 100644 index 0000000..116fed0 --- /dev/null +++ b/app/src/androidTest/java/com/example/travelling/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.travelling; + +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("com.example.travelling", 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..d622def --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/travelling/MainActivity.java b/app/src/main/java/com/example/travelling/MainActivity.java new file mode 100644 index 0000000..11ba664 --- /dev/null +++ b/app/src/main/java/com/example/travelling/MainActivity.java @@ -0,0 +1,61 @@ +package com.example.travelling; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.RadioButton; +import android.widget.Toast; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + +import com.example.travelling.databinding.ActivityMainBinding; + +public class MainActivity extends AppCompatActivity { + + private ActivityMainBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + // setContentView(R.layout.activity_main); + + binding = ActivityMainBinding.inflate(getLayoutInflater()); + View view = binding.getRoot(); + setContentView(view); + + binding.btnConfirm.setOnClickListener(this::ConfirmButton); + } + + public void ConfirmButton(View view) { + try { + String name = binding.nameInput.getText().toString(); + String date = binding.dateInput.getText().toString(); + + int citySelectedId = binding.cityRadioGroup.getCheckedRadioButtonId(); + RadioButton selectedRadioButton = binding.getRoot().findViewById(citySelectedId); + String city = selectedRadioButton.getText().toString(); + + boolean isVip = binding.vipSwitch.isChecked(); + boolean hasInsurance = binding.insurance.isChecked(); + + Intent resultIntent = new Intent(this, ResultActivity.class); + + resultIntent.putExtra("NAME", name); + resultIntent.putExtra("DATE", date); + resultIntent.putExtra("CITY", city); + resultIntent.putExtra("IS_VIP", isVip); + resultIntent.putExtra("HAS_INSURANCE", hasInsurance); + + startActivity(resultIntent); + } + catch (NullPointerException ex) { + Toast toast = Toast.makeText(this, "You haven't filled all fields", Toast.LENGTH_LONG); + toast.show(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/travelling/ResultActivity.java b/app/src/main/java/com/example/travelling/ResultActivity.java new file mode 100644 index 0000000..691d7f5 --- /dev/null +++ b/app/src/main/java/com/example/travelling/ResultActivity.java @@ -0,0 +1,41 @@ +package com.example.travelling; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + +import com.example.travelling.databinding.ActivityResultBinding; + +public class ResultActivity extends AppCompatActivity { + + private ActivityResultBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + + binding = ActivityResultBinding.inflate(getLayoutInflater()); + View view = binding.getRoot(); + setContentView(view); + + Intent intent = getIntent(); + String name = intent.getStringExtra("NAME"); + String date = intent.getStringExtra("DATE"); + String city = intent.getStringExtra("CITY"); + boolean hasInsurance = intent.getBooleanExtra("HAS_INSURANCE", false); + boolean isVip = intent.getBooleanExtra("IS_VIP", false); + + binding.nameText.setText(name); + binding.dateText.setText(date); + binding.cityText.setText(city); + binding.insuranceText.setText(hasInsurance ? "Yes" : "No"); + binding.vipText.setText(isVip ? "Yes" : "No"); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/travelling/Splash.java b/app/src/main/java/com/example/travelling/Splash.java new file mode 100644 index 0000000..7c852ba --- /dev/null +++ b/app/src/main/java/com/example/travelling/Splash.java @@ -0,0 +1,36 @@ +package com.example.travelling; + +import android.content.Intent; +import android.os.Bundle; + +import androidx.activity.EdgeToEdge; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + +public class Splash extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + EdgeToEdge.enable(this); + setContentView(R.layout.activity_splash); + + Thread thread = new Thread() { + @Override + public void run() { + try { + sleep(3000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + Intent mainActivityIntent = new Intent(Splash.this, MainActivity.class); + + startActivity(mainActivityIntent); + } + } + }; + thread.start(); + } +} \ 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/travel_logo.png b/app/src/main/res/drawable/travel_logo.png new file mode 100644 index 0000000..bd3dab8 Binary files /dev/null and b/app/src/main/res/drawable/travel_logo.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..a53dbcb --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + +