Skip to content
Snippets Groups Projects
Commit 399a2e6a authored by JOSOA Josoa's avatar JOSOA Josoa
Browse files

rendu

parent f8475fd2
No related branches found
No related tags found
No related merge requests found
Showing
with 389 additions and 153 deletions
# Default ignored files
/shelf/
/workspace.xml
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
...@@ -23,6 +33,21 @@ ...@@ -23,6 +33,21 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".CreateModelActivity" android:exported="true"/>
<activity android:name=".LoadModelActivity" android:exported="true"/>
<activity android:name=".AddPhotosActivity" android:exported="true"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package fr.ul.projetdevmob;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import fr.ul.projetdevmob.model.ImageMur;
import fr.ul.projetdevmob.model.Piece;
public class AddPhotosActivity extends AppCompatActivity {
private static final int REQUEST_IMAGE_CAPTURE = 1;
private String currentOrientation;
private String currentPhotoPath;
private HashMap<String, String> photoPaths = new HashMap<>(); // pour stocker N, S, E, O
private String pieceName; // nom de la pièce à récupérer
private Piece currentPiece;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_photos);
// récupérer le nom de la pièce depuis l’activité précédente
pieceName = getIntent().getStringExtra("nom_piece");
currentPiece = new Piece(pieceName);
// lier les boutons
Button btnN = findViewById(R.id.btnPhotoN);
Button btnS = findViewById(R.id.btnPhotoS);
Button btnE = findViewById(R.id.btnPhotoE);
Button btnO = findViewById(R.id.btnPhotoO);
btnN.setOnClickListener(v -> takePhoto("N"));
btnS.setOnClickListener(v -> takePhoto("S"));
btnE.setOnClickListener(v -> takePhoto("E"));
btnO.setOnClickListener(v -> takePhoto("O"));
}
private void takePhoto(String orientation) {
currentOrientation = orientation;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
Toast.makeText(this, "Erreur création image", Toast.LENGTH_SHORT).show();
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this,
getPackageName() + ".provider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
}
private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String fileName = "IMG_" + currentOrientation + "_" + timeStamp;
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(fileName, ".jpg", storageDir);
currentPhotoPath = image.getAbsolutePath();
return image;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
photoPaths.put(currentOrientation, currentPhotoPath);
currentPiece.ajouterImage(currentOrientation, new ImageMur(currentPhotoPath));
Toast.makeText(this, "Photo " + currentOrientation + " enregistrée !", Toast.LENGTH_SHORT).show();
}
}
}
package fr.ul.projetdevmob;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import fr.ul.projetdevmob.model.Modele;
import fr.ul.projetdevmob.model.Piece;
public class CreateModelActivity extends AppCompatActivity {
private EditText editModelName;
private Button btnAddPiece;
private TextView txtPiecesList;
private Modele modele;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_model);
editModelName = findViewById(R.id.editModelName);
btnAddPiece = findViewById(R.id.btnAddPiece);
txtPiecesList = findViewById(R.id.txtPiecesList);
modele = new Modele("Sans nom");
btnAddPiece.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nomModele = editModelName.getText().toString();
if (!nomModele.isEmpty()) {
modele = new Modele(nomModele);
}
showAddPieceDialog();
}
});
}
private void showAddPieceDialog() {
final EditText input = new EditText(this);
input.setHint("Nom de la pièce");
new AlertDialog.Builder(this)
.setTitle("Ajouter une pièce")
.setView(input)
.setPositiveButton("Ajouter", (dialog, which) -> {
String pieceName = input.getText().toString();
if (!pieceName.isEmpty()) {
Piece piece = new Piece(pieceName);
modele.ajouterPiece(piece);
txtPiecesList.setText("Pièces : " + modele.getPieces().size());
Intent intent = new Intent(CreateModelActivity.this, AddPhotosActivity.class);
intent.putExtra("nom_piece", pieceName);
startActivity(intent);
}
})
.setNegativeButton("Annuler", null)
.show();
}
}
package fr.ul.projetdevmob;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class LoadModelActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_load_model);
}
}
\ No newline at end of file
package fr.ul.projetdevmob
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import fr.ul.projetdevmob.ui.theme.ProjetdevmobTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
ProjetdevmobTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Greeting(
name = "Android",
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
ProjetdevmobTheme {
Greeting("Android")
}
}
\ No newline at end of file
package fr.ul.projetdevmob.model;
public class Acces {
private int x, y, width, height; // zone cliquable
private String destination; // nom de la pièce cible
public Acces(int x, int y, int width, int height, String destination) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.destination = destination;
}
public int getX() { return x; }
public int getY() { return y; }
public int getWidth() { return width; }
public int getHeight() { return height; }
public String getDestination() { return destination; }
}
package fr.ul.projetdevmob.model;
import java.util.ArrayList;
import java.util.List;
public class ImageMur {
private String path; // chemin de l'image
private List<Acces> accesList;
public ImageMur(String path) {
this.path = path;
this.accesList = new ArrayList<>();
}
public String getPath() { return path; }
public List<Acces> getAccesList() { return accesList; }
public void ajouterAcces(Acces acces) {
accesList.add(acces);
}
}
package fr.ul.projetdevmob.model;
import java.util.ArrayList;
import java.util.List;
public class Modele {
private String nom;
private List<Piece> pieces;
public Modele(String nom) {
this.nom = nom;
this.pieces = new ArrayList<>();
}
public String getNom() { return nom; }
public List<Piece> getPieces() { return pieces; }
public void ajouterPiece(Piece piece) {
pieces.add(piece);
}
}
package fr.ul.projetdevmob.model;
import java.util.HashMap;
import java.util.Map;
public class Piece {
private String nom;
private Map<String, ImageMur> images; // "N", "S", "E", "O"
public Piece(String nom) {
this.nom = nom;
this.images = new HashMap<>();
}
public String getNom() { return nom; }
public void ajouterImage(String orientation, ImageMur image) {
images.put(orientation, image);
}
public ImageMur getImage(String orientation) {
return images.get(orientation);
}
public Map<String, ImageMur> getImages() {
return images;
}
}
package fr.ul.projetdevmob.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
\ No newline at end of file
package fr.ul.projetdevmob.ui.theme
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
@Composable
fun ProjetdevmobTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
\ No newline at end of file
package fr.ul.projetdevmob.ui.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ajouter les photos (N/S/E/O)"
android:textSize="18sp"
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/btnPhotoN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prendre photo Nord"
android:layout_marginBottom="8dp" />
<Button
android:id="@+id/btnPhotoS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prendre photo Sud"
android:layout_marginBottom="8dp" />
<Button
android:id="@+id/btnPhotoE"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prendre photo Est"
android:layout_marginBottom="8dp" />
<Button
android:id="@+id/btnPhotoO"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prendre photo Ouest"
android:layout_marginBottom="8dp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<EditText
android:id="@+id/editModelName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nom du modèle"
android:layout_marginBottom="16dp" />
<Button
android:id="@+id/btnAddPiece"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ajouter une pièce"
android:layout_marginBottom="16dp" />
<TextView
android:id="@+id/txtPiecesList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pièces : (aucune)"
android:textSize="16sp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chargement_du_mod_le_faire"
android:textSize="18sp" />
</LinearLayout>
<resources> <resources>
<string name="app_name">Projetdevmob</string> <string name="app_name">Projetdevmob</string>
<string name="chargement_du_mod_le_faire">Chargement du modèle (à faire)</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
</paths>
File added
...@@ -8,6 +8,10 @@ espressoCore = "3.6.1" ...@@ -8,6 +8,10 @@ espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.6.1" lifecycleRuntimeKtx = "2.6.1"
activityCompose = "1.10.0" activityCompose = "1.10.0"
composeBom = "2024.04.01" composeBom = "2024.04.01"
appcompat = "1.7.0"
material = "1.12.0"
activity = "1.10.1"
constraintlayout = "2.2.0"
[libraries] [libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
...@@ -24,6 +28,10 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin ...@@ -24,6 +28,10 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
[plugins] [plugins]
android-application = { id = "com.android.application", version.ref = "agp" } android-application = { id = "com.android.application", version.ref = "agp" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment