Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Launcher Screen(Menu) to the App #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CrossFire">
<activity android:name=".MainActivity">
<activity
android:name=".LauncherActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
</application>

</manifest>
27 changes: 27 additions & 0 deletions app/src/main/java/com/krsolutions/crossFire/LauncherActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.krsolutions.crossFire

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import androidx.core.app.ActivityCompat

class LauncherActivity : AppCompatActivity() {
lateinit var btnPlay:Button
lateinit var btnExit:Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_launcher)
btnPlay=findViewById(R.id.btnPlay)
btnExit=findViewById(R.id.btnExit)
btnPlay.setOnClickListener {
val intent=Intent(this@LauncherActivity,MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
startActivity(intent)
}
btnExit.setOnClickListener {
ActivityCompat.finishAffinity(this@LauncherActivity)
}
}
}
42 changes: 42 additions & 0 deletions app/src/main/res/layout/activity_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/txtAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btnPlay"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:padding="6dp"
android:text="@string/crossfire"
android:textSize="50sp" />

<android.widget.Button
android:id="@+id/btnPlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:background="@color/white"
android:padding="6dp"
android:text="@string/play"
android:textSize="22sp"
android:elevation="10dp"/>
<android.widget.Button
android:id="@+id/btnExit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnPlay"
android:layout_margin="10dp"
android:background="@color/white"
android:padding="6dp"
android:text="@string/exit"
android:textSize="22sp"
android:elevation="10dp"/>


</RelativeLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">CrossFire</string>
<string name="crossfire">CrossFire ❌🔥</string>
<string name="play">PLAY</string>
<string name="exit">EXIT</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"

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