Merge remote-tracking branch 'origin/master'

# Conflicts:
#	Tetris/app/src/main/AndroidManifest.xml
pull/8/head
Jolys Enzo 2 years ago
commit d27408b1f6

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component> </component>
</project> </project>

@ -11,7 +11,36 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Tetris" android:theme="@style/Theme.Tetris"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name="tetrisGame.activity.Menu"
android:exported="true"/>
<activity
android:name="tetrisGame.activity.Game"
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="activity.Menu" 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="activity.Game" 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="activity.Option" 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="activity.MainActivity" android:exported="true"> <activity android:name="activity.MainActivity" android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>

@ -0,0 +1,31 @@
package but.androidstudio.tetris
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import views.ViewsGame
class GameFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_game, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val view = view.findViewById<ViewsGame>(R.id.tabGame)
//To clean the window
view.invalidate()
}
}

@ -5,12 +5,9 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
class MainFragment : Fragment() { class MainFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
@ -18,4 +15,24 @@ class MainFragment : Fragment() {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_main, container, false) return inflater.inflate(R.layout.fragment_main, container, false)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val buttonStart: Button = view.findViewById(R.id.buttonStart)
buttonStart.setOnClickListener {
val fragmentManager = requireActivity().supportFragmentManager
fragmentManager.beginTransaction()
.replace(R.id.homeLayout, GameFragment())
.commit()
}
val buttonOption: Button = view.findViewById(R.id.buttonOption)
buttonOption.setOnClickListener {
val fragmentManager = requireActivity().supportFragmentManager
fragmentManager.beginTransaction()
.replace(R.id.homeLayout, OptionFragment())
.commit()
}
}
} }

@ -5,28 +5,13 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Spinner
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
* Use the [OptionFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class OptionFragment : Fragment() { class OptionFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
} }
override fun onCreateView( override fun onCreateView(
@ -37,23 +22,24 @@ class OptionFragment : Fragment() {
return inflater.inflate(R.layout.fragment_option, container, false) return inflater.inflate(R.layout.fragment_option, container, false)
} }
companion object { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
/** super.onViewCreated(view, savedInstanceState)
* Use this factory method to create a new instance of
* this fragment using the provided parameters. val spinnerDifficulty: Spinner = view.findViewById(R.id.spinnerDifficulty)
* val difficulty = arrayOf("Easy","Medium","Hard")
* @param param1 Parameter 1.
* @param param2 Parameter 2. /*val adaptateurSpinnerDifficulty = ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,difficulty)
* @return A new instance of fragment OptionFragment. spinnerDifficulty.adapter = adaptateurSpinnerDifficulty
*/
// TODO: Rename and change types and number of parameters spinnerDifficulty.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
@JvmStatic override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
fun newInstance(param1: String, param2: String) = val selectedItem = parent.getItemAtPosition(position).toString()
OptionFragment().apply { // Faites quelque chose avec l'élément sélectionné
arguments = Bundle().apply { }
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2) override fun onNothingSelected(parent: AdapterView<*>) {
} // Ne rien faire si aucun élément n'est sélectionné
} }
})*/
} }
} }

@ -1,34 +0,0 @@
package tetrisGame.activity
import android.graphics.Canvas
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.core.content.ContextCompat
import but.androidstudio.tetris.R
import tetrisGame.views.ViewsGame
import modele.Game
class Game : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_game)
val view = findViewById<ViewsGame>(R.id.tabGame)
//Pour nettoyer la vue
view.invalidate()
}
override fun onResume() {
super.onResume()
val myGame: modele.Game = Game(10,20)
myGame.startGame()
}
}

@ -1,34 +0,0 @@
package tetrisGame.activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import but.androidstudio.tetris.R
class Menu : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_menu)
val appName:TextView = findViewById(R.id.appName)
appName.setText(R.string.app_name)
}
override fun onResume() {
super.onResume()
val buttonStart:Button = findViewById(R.id.buttonStart)
buttonStart.setOnClickListener {
val intentStart = Intent(this,Game::class.java)
startActivity(intentStart)
}
val buttonOption:Button = findViewById(R.id.buttonOption)
buttonOption.setOnClickListener {
val intentOption = Intent(this,Option::class.java)
startActivity(intentOption)
}
}
}

@ -1,39 +0,0 @@
package activity
import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Spinner
import androidx.appcompat.app.AppCompatActivity
import but.androidstudio.tetris.R
class Option : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_option)
}
override fun onResume() {
super.onResume()
val spinnerDifficulty:Spinner = findViewById(R.id.spinnerDifficulty)
val difficulty = arrayOf("Easy","Medium","Hard")
val adaptateurSpinnerDifficulty = ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,difficulty)
spinnerDifficulty.adapter = adaptateurSpinnerDifficulty
spinnerDifficulty.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
val selectedItem = parent.getItemAtPosition(position).toString()
// Faites quelque chose avec l'élément sélectionné
}
override fun onNothingSelected(parent: AdapterView<*>) {
// Ne rien faire si aucun élément n'est sélectionné
}
})
}
}

@ -1,11 +1,9 @@
package tetrisGame.views package views
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
import android.graphics.Paint import android.graphics.Paint
import android.graphics.Rect
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View

@ -1,33 +0,0 @@
<?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="activity.Menu">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Difficulty"/>
<Spinner
android:id="@+id/spinnerDifficulty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1mm"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout 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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="tetrisGame.activity.Game" tools:context=".GameFragment">
android:background="@color/white">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -19,7 +17,7 @@
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="450dp"> android:layout_height="450dp">
<tetrisGame.views.ViewsGame <views.ViewsGame
android:id="@+id/tabGame" android:id="@+id/tabGame"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -71,5 +69,4 @@
</LinearLayout> </LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

Loading…
Cancel
Save