[Feat] Part 1 - Activation intentionnelle explicite

This commit is contained in:
Kevin Mitressé
2024-11-13 11:50:22 +01:00
parent c84ebb90b1
commit dc81b88b85
21 changed files with 495 additions and 214 deletions
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
@@ -13,7 +13,7 @@
android:theme="@style/Theme.Convertisseur"
tools:targetApi="31">
<activity
android:name=".Convertisseur"
android:name=".TemperatureConverter"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -1,19 +0,0 @@
package fr.univpau.convertisseur;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.widget.Button;
import android.os.Bundle;
public class Convertisseur extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_convertisseur);
Button convertButton = findViewById(R.id.convertButton);
Log.i("TP2-Info", "Button '"+convertButton.getText().toString()+"' found");
convertButton.setOnClickListener(new ButtonListener(findViewById(R.id.srcUnit), findViewById(R.id.destUnit), findViewById(R.id.srcValue), findViewById(R.id.destValue)));
}
}
@@ -17,19 +17,22 @@ public class Temperature {
return srcValue;
else {
if (srcUnit == TemperatureUnits.CELSIUS) {
return destUnit == TemperatureUnits.FAHRENHEIT ?
srcValue * 9 / 5 + 32 :
srcValue + 273.15;
if (destUnit == TemperatureUnits.FAHRENHEIT)
return srcValue * 9 / 5 + 32;
if (destUnit == TemperatureUnits.KELVIN)
return srcValue + 273.15;
}
if (srcUnit == TemperatureUnits.FAHRENHEIT) {
return destUnit == TemperatureUnits.CELSIUS ?
(srcValue - 32) * 5 / 9 :
(srcValue - 32) * 5 / 9 + 273.15;
if (destUnit == TemperatureUnits.CELSIUS)
return (srcValue - 32) * 5 / 9;
if (destUnit == TemperatureUnits.KELVIN)
return (srcValue - 32) * 5 / 9 + 273.15;
}
if (srcUnit == TemperatureUnits.KELVIN) {
return destUnit == TemperatureUnits.CELSIUS ?
srcValue - 273.15 :
(srcValue - 273.15) * 9 / 5 + 32;
if (destUnit == TemperatureUnits.CELSIUS)
return srcValue - 273.15;
if (destUnit == TemperatureUnits.FAHRENHEIT)
return (srcValue - 273.15) * 9 / 5 + 32;
}
}
return 0;
@@ -1,93 +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=".Convertisseur">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="40dp">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:showDividers="middle"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_scr_unite" />
<Spinner
android:id="@+id/srcUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/units"
android:minHeight="48dp" />
<EditText
android:id="@+id/srcValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:minHeight="48dp"
android:hint="@string/enter_value" />
</LinearLayout>
<Space
android:layout_width="40dp"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_dest_unite" />
<Spinner
android:id="@+id/destUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/units"
android:minHeight="48dp" />
<EditText
android:id="@+id/destValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:minHeight="48dp"
android:hint="@string/enter_value" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/convertButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/convert"
android:gravity="center"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,92 +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=".Convertisseur">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="40dp">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:showDividers="middle"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_scr_unite" />
<Spinner
android:id="@+id/srcUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/units"
android:minHeight="48dp" />
<EditText
android:id="@+id/srcValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:minHeight="48dp"
android:hint="@string/enter_value" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_dest_unite" />
<Spinner
android:id="@+id/destUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/units"
android:minHeight="48dp" />
<EditText
android:id="@+id/destValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:minHeight="48dp"
android:hint="@string/enter_value" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/convertButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/convert"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>