maj
This commit is contained in:
1
AndroidStudioProjects/TP7/Couleurs/app/.gitignore
vendored
Executable file
1
AndroidStudioProjects/TP7/Couleurs/app/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
/build
|
32
AndroidStudioProjects/TP7/Couleurs/app/build.gradle
Executable file
32
AndroidStudioProjects/TP7/Couleurs/app/build.gradle
Executable file
@@ -0,0 +1,32 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
buildToolsVersion '34.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "fr.iut_fbleau.apl41.couleurs"
|
||||
minSdkVersion 19
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
||||
implementation 'android.arch.lifecycle:livedata:1.1.1'
|
||||
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
17
AndroidStudioProjects/TP7/Couleurs/app/proguard-rules.pro
vendored
Executable file
17
AndroidStudioProjects/TP7/Couleurs/app/proguard-rules.pro
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /opt/android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# 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 *;
|
||||
#}
|
@@ -0,0 +1,13 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
21
AndroidStudioProjects/TP7/Couleurs/app/src/main/AndroidManifest.xml
Executable file
21
AndroidStudioProjects/TP7/Couleurs/app/src/main/AndroidManifest.xml
Executable file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="fr.iut_fbleau.apl41.couleurs">
|
||||
|
||||
<application android:label="@string/app_name">
|
||||
<activity
|
||||
android:theme="@style/Theme.AppCompat"
|
||||
android:name=".Button_activity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Liste"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@@ -0,0 +1,45 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public class AccesBaseDeDonnees extends SQLiteOpenHelper {
|
||||
public final static String NOM_BASE = "base_couleurs";
|
||||
public final static int VERSION_BASE = 3;
|
||||
public final static String NOM_TABLE = "couleurs";
|
||||
public final static String CHAMP_NOM = "couleurs_nom";
|
||||
public final static String CHAMP_VALEUR = "couleurs_valeur";
|
||||
|
||||
public AccesBaseDeDonnees(Context context) {
|
||||
super(context, AccesBaseDeDonnees.NOM_BASE, null, AccesBaseDeDonnees.VERSION_BASE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase baseDeDonnees) {
|
||||
baseDeDonnees.execSQL("create table " + AccesBaseDeDonnees.NOM_TABLE + "(" +
|
||||
BaseColumns._ID + " integer primary key autoincrement, " +
|
||||
AccesBaseDeDonnees.CHAMP_NOM + " text not null, " +
|
||||
AccesBaseDeDonnees.CHAMP_VALEUR + " integer);");
|
||||
|
||||
ContentValues tuple = new ContentValues();
|
||||
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_NOM, "bleu Denim");
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_VALEUR, 0xFF4B0082);
|
||||
baseDeDonnees.insert(AccesBaseDeDonnees.NOM_TABLE, null, tuple);
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_NOM, "bleu électrique");
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_VALEUR, 0xFF1163E3);
|
||||
baseDeDonnees.insert(AccesBaseDeDonnees.NOM_TABLE, null, tuple);
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_NOM, "bleu vert");
|
||||
tuple.put(AccesBaseDeDonnees.CHAMP_VALEUR, 0xFF40E0D0);
|
||||
baseDeDonnees.insert(AccesBaseDeDonnees.NOM_TABLE, null, tuple);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase baseDeDonnees, int vieux, int nouveau) {
|
||||
baseDeDonnees.execSQL("drop table if exists " + AccesBaseDeDonnees.NOM_TABLE);
|
||||
this.onCreate(baseDeDonnees);
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
public class Button_activity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.button_activity);
|
||||
|
||||
Button supprimer = (Button) this.findViewById(R.id.supprimer);
|
||||
Button annuler = (Button) this.findViewById(R.id.annuler);
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by hernand on 3/28/17.
|
||||
*/
|
||||
public class ControleAnnuler implements View.OnClickListener {
|
||||
private Activity parent;
|
||||
public ControleAnnuler(Activity a) {
|
||||
this.parent = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(parent, Liste.class);
|
||||
parent.startActivity(intent);
|
||||
parent.finishAffinity();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by hernand on 3/28/17.
|
||||
*/
|
||||
public class ControleClic implements AdapterView.OnItemClickListener {
|
||||
private Activity parent;
|
||||
public ControleClic(Activity a) {
|
||||
this.parent = a;
|
||||
}
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> liste, View vue, int positionListe, long idBase) {
|
||||
Toast.makeText(this.parent, "Clic sur ligne "+(positionListe+1), Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(parent, Button_activity.class);
|
||||
parent.startActivity(intent);
|
||||
parent.finishAffinity();
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by hernand on 3/28/17.
|
||||
*/
|
||||
public class ControleSupprimer implements View.OnClickListener {
|
||||
private Activity parent;
|
||||
public ControleSupprimer(Activity a) {
|
||||
this.parent = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.view.View;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
|
||||
public class Lieur implements SimpleCursorAdapter.ViewBinder {
|
||||
@Override
|
||||
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
|
||||
if(view.getId() == R.id.couleur) {
|
||||
view.setBackgroundColor(cursor.getInt(columnIndex));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Liste extends Activity {
|
||||
private final static String[] CHAMPS = {AccesBaseDeDonnees.CHAMP_NOM, AccesBaseDeDonnees.CHAMP_VALEUR};
|
||||
private final static int[] VUES = {R.id.nom, R.id.couleur};
|
||||
private SimpleCursorAdapter adaptateur;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.activity_liste);
|
||||
|
||||
this.adaptateur = new SimpleCursorAdapter(this, R.layout.row_element, null, Liste.CHAMPS, Liste.VUES, 0);
|
||||
this.adaptateur.setViewBinder(new Lieur());
|
||||
ListView elements = (ListView) this.findViewById(R.id.elements);
|
||||
elements.setOnItemClickListener(new ControleClic(this));
|
||||
elements.setAdapter(this.adaptateur);
|
||||
this.remplirListe();
|
||||
}
|
||||
|
||||
public void remplirListe() {
|
||||
AccesBaseDeDonnees acces = new AccesBaseDeDonnees(this);
|
||||
SQLiteDatabase baseDeDonnees = acces.getReadableDatabase();
|
||||
|
||||
Cursor curseur = baseDeDonnees.query(AccesBaseDeDonnees.NOM_TABLE, null, null, null, null, null, null);
|
||||
if (curseur != null) {
|
||||
this.adaptateur.swapCursor(curseur);
|
||||
} else {
|
||||
Toast.makeText(this, "Erreur d'accès à la base de données", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
this.getMenuInflater().inflate(R.menu.menu_liste, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_ajouter) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".Liste"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
>
|
||||
<ListView
|
||||
android:id="@+id/elements"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/supprimer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="92dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Supprimer"
|
||||
android:textSize="20dp">
|
||||
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/annuler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="92dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="Annuler"
|
||||
android:textSize="20dp">
|
||||
|
||||
</Button>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
25
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/layout/row_element.xml
Executable file
25
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/layout/row_element.xml
Executable file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/color_size"
|
||||
android:layout_height="@dimen/color_size"
|
||||
android:id="@+id/couleur"
|
||||
android:layout_margin="@dimen/color_margin"
|
||||
android:background="#ff20a080"
|
||||
android:gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Vert"
|
||||
android:id="@+id/nom"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_vertical|start" />
|
||||
</LinearLayout>
|
13
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/menu/menu_liste.xml
Executable file
13
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/menu/menu_liste.xml
Executable file
@@ -0,0 +1,13 @@
|
||||
<menu
|
||||
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"
|
||||
tools:context=".Liste"
|
||||
>
|
||||
<item
|
||||
android:id="@+id/action_ajouter"
|
||||
android:title="@string/action_ajouter"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
/>
|
||||
</menu>
|
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-hdpi/ic_launcher.png
Executable file
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-hdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-mdpi/ic_launcher.png
Executable file
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-mdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Executable file
BIN
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<style name="ThemeOverlay.Couleurs.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A400</item>
|
||||
</style>
|
||||
</resources>
|
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<dimen name="activity_horizontal_margin">
|
||||
64dp
|
||||
</dimen>
|
||||
</resources>
|
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<declare-styleable name="FullscreenAttrs">
|
||||
<attr name="fullscreenBackgroundColor" format="color" />
|
||||
<attr name="fullscreenTextColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<color name="light_blue_600">#FF039BE5</color>
|
||||
<color name="light_blue_900">#FF01579B</color>
|
||||
<color name="light_blue_A200">#FF40C4FF</color>
|
||||
<color name="light_blue_A400">#FF00B0FF</color>
|
||||
<color name="black_overlay">#66000000</color>
|
||||
</resources>
|
14
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/values/dimens.xml
Executable file
14
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/values/dimens.xml
Executable file
@@ -0,0 +1,14 @@
|
||||
<resources>
|
||||
<dimen name="activity_horizontal_margin">
|
||||
16dp
|
||||
</dimen>
|
||||
<dimen name="activity_vertical_margin">
|
||||
16dp
|
||||
</dimen>
|
||||
<dimen name="color_size">
|
||||
32dp
|
||||
</dimen>
|
||||
<dimen name="color_margin">
|
||||
12dp
|
||||
</dimen>
|
||||
</resources>
|
11
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/values/strings.xml
Executable file
11
AndroidStudioProjects/TP7/Couleurs/app/src/main/res/values/strings.xml
Executable file
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
<string name="app_name">
|
||||
Couleurs
|
||||
</string>
|
||||
<string name="action_ajouter">
|
||||
Ajouter
|
||||
</string>
|
||||
<string name="title_activity_button">button_activity</string>
|
||||
<string name="dummy_button">Dummy Button</string>
|
||||
<string name="dummy_content">DUMMY\nCONTENT</string>
|
||||
</resources>
|
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<style name="Widget.Theme.Couleurs.ActionBar.Fullscreen" parent="Widget.AppCompat.ActionBar">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Theme.Couleurs.ButtonBar.Fullscreen" parent="">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item>
|
||||
</style>
|
||||
</resources>
|
@@ -0,0 +1,15 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Couleurs" parent="Theme.AppCompat.Light" />
|
||||
|
||||
<style name="Theme.Couleurs.Fullscreen" parent="Theme.Couleurs">
|
||||
<item name="android:actionBarStyle">@style/Widget.Theme.Couleurs.ActionBar.Fullscreen</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowBackground">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.Couleurs.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A200</item>
|
||||
</style>
|
||||
</resources>
|
@@ -0,0 +1,15 @@
|
||||
package fr.iut_fbleau.apl41.couleurs;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user