Android + DEV 4.4
61
DEV 3.2/TP08/Authentification/Authentification.java
Normal file
@ -0,0 +1,61 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Authentification {
|
||||
public static void main(String[] args) {
|
||||
Map<String, String> loginMap = new TreeMap<>();
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
try {
|
||||
while (true) {
|
||||
String command = br.readLine();
|
||||
String[] cargs = command.split(" ");
|
||||
|
||||
switch (cargs[0].toLowerCase()) {
|
||||
case "add":
|
||||
if (loginMap.containsKey(cargs[1])) {
|
||||
System.err.println("Utilisateur \"" + cargs[1] + "\" déjà existant.");
|
||||
} else {
|
||||
loginMap.put(cargs[1], cargs[2]);
|
||||
System.out.println("Utilisateur \"" + cargs[1] + "\" ajouté.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "auth":
|
||||
if (loginMap.containsKey(cargs[1])) {
|
||||
if (loginMap.get(cargs[1]).compareTo(cargs[2]) == 0) {
|
||||
System.out.println("Utilisateur \"" + cargs[1] + "\" reconnu.");
|
||||
} else {
|
||||
System.err.println("Utilisateur \"" + cargs[1] + "\" non reconnu.");
|
||||
}
|
||||
} else {
|
||||
System.err.println("Utilisateur \"" + cargs[1] + "\" non reconnu.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "del":
|
||||
if (loginMap.containsKey(cargs[1])) {
|
||||
loginMap.remove(cargs[1]);
|
||||
System.out.println("Utilisateur \"" + cargs[1] + "\" retiré.");
|
||||
} else {
|
||||
System.err.println("Utilisateur \"" + cargs[1] + "\" non reconnu.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "quit":
|
||||
System.out.println("Au revoir");
|
||||
return;
|
||||
|
||||
default:
|
||||
System.out.println("Commande inconnue");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
11
DEV 3.2/TP08/Authentification/StringComparator.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class StringComparator implements TreeComparator<String> {
|
||||
|
||||
@Override
|
||||
public int compare(String a, String b) {
|
||||
int comparing = a.compareTo(b);
|
||||
|
||||
if (comparing == 0) return 0;
|
||||
return comparing /= Math.abs(comparing);
|
||||
}
|
||||
|
||||
}
|
4
DEV 3.2/TP08/Authentification/TreeComparator.java
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
public interface TreeComparator<T> {
|
||||
public int compare(T a, T b);
|
||||
}
|
96
DEV 3.2/TP08/Authentification/TreeMap.java
Normal file
@ -0,0 +1,96 @@
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TreeMap<K,V> implements Map<K,V> {
|
||||
|
||||
private TreeNode<K,V> root;
|
||||
private TreeComparator<K> comparator;
|
||||
|
||||
public TreeMap() {
|
||||
|
||||
}
|
||||
|
||||
public TreeComparator<K> getComparator() {
|
||||
return comparator;
|
||||
}
|
||||
|
||||
public void setComparator(TreeComparator<K> comparator) {
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
root = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (root == null) return false;
|
||||
else return root.containsKey((K)key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
if (root == null) return null;
|
||||
return root.get((K)key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return root == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (root == null) {
|
||||
root = new TreeNode<K,V>(this, key, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
return root.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
if (root == null) return null;
|
||||
else if (comparator.compare(root.getKey(), (K)key) == 0) {
|
||||
V value = root.getValue();
|
||||
root = null;
|
||||
return value;
|
||||
} else {
|
||||
return root.remove((K)key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
105
DEV 3.2/TP08/Authentification/TreeNode.java
Normal file
@ -0,0 +1,105 @@
|
||||
public class TreeNode<K,V> {
|
||||
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
private TreeMap<K, V> tree;
|
||||
private TreeNode<K, V> sub;
|
||||
private TreeNode<K, V> top;
|
||||
|
||||
public TreeNode(TreeMap<K, V> tree, K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public V put(K key, V value) {
|
||||
int comparison = tree.getComparator().compare(this.key, key);
|
||||
|
||||
if (comparison == -1) {
|
||||
if (sub == null) sub = new TreeNode<K,V>(tree, key, value);
|
||||
else sub.put(key, value);
|
||||
return null;
|
||||
} else if (comparison == 0) {
|
||||
V oldValue = this.value;
|
||||
this.value = value;
|
||||
return oldValue;
|
||||
} else {
|
||||
if (top == null) top = new TreeNode<K,V>(tree, key, value);
|
||||
else top.put(key, value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public V get(K key) {
|
||||
int comparison = tree.getComparator().compare(this.key, key);
|
||||
|
||||
if (comparison == -1) {
|
||||
if (sub == null) return null;
|
||||
else return sub.get(key);
|
||||
} else if (comparison == 0) {
|
||||
return value;
|
||||
} else {
|
||||
if (top == null) return null;
|
||||
else return top.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsKey(K key) {
|
||||
int comparison = tree.getComparator().compare(this.key, key);
|
||||
|
||||
if (comparison == -1) {
|
||||
if (sub == null) return false;
|
||||
else return sub.containsKey(key);
|
||||
} else if (comparison == 0) {
|
||||
return true;
|
||||
} else {
|
||||
if (top == null) return false;
|
||||
else return top.containsKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
public TreeNode<K, V> getSub() {
|
||||
return sub;
|
||||
}
|
||||
|
||||
public TreeNode<K, V> getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public V remove(K key) {
|
||||
int comparison = tree.getComparator().compare(this.key, key);
|
||||
|
||||
if (comparison == -1) {
|
||||
if (sub == null) return null;
|
||||
else {
|
||||
if (tree.getComparator().compare(key, sub.getKey()) == 0) {
|
||||
V value = sub.getValue();
|
||||
sub = null;
|
||||
|
||||
return value;
|
||||
} else {
|
||||
return sub.remove(key);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (top == null) return null;
|
||||
else {
|
||||
if (tree.getComparator().compare(key, top.getKey()) == 0) {
|
||||
V value = top.getValue();
|
||||
top = null;
|
||||
return value;
|
||||
} else {
|
||||
return top.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
DEV 3.2/TP08/Tri/RealComparator.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class RealComparator implements TreeComparator<Float> {
|
||||
|
||||
public RealComparator() {}
|
||||
|
||||
@Override
|
||||
public int compare(Float a, Float b) {
|
||||
if (a > b) return 1;
|
||||
else if (a < b) return -1;
|
||||
else return 0;
|
||||
}
|
||||
}
|
23
DEV 3.2/TP08/Tri/SearchTree.java
Normal file
@ -0,0 +1,23 @@
|
||||
public class SearchTree<T> {
|
||||
|
||||
private TreeNode<T> root;
|
||||
private TreeComparator<T> comparator;
|
||||
|
||||
public SearchTree(TreeComparator<T> comparator) {
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
public void add(T object) {
|
||||
if (root != null) root.add(object);
|
||||
else root = new TreeNode<T>(this, object);
|
||||
}
|
||||
|
||||
public TreeComparator<T> getComparator() {
|
||||
return comparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return root.toString();
|
||||
}
|
||||
}
|
3
DEV 3.2/TP08/Tri/TreeComparator.java
Normal file
@ -0,0 +1,3 @@
|
||||
public interface TreeComparator<T> {
|
||||
public int compare(T a, T b);
|
||||
}
|
78
DEV 3.2/TP08/Tri/TreeNode.java
Normal file
@ -0,0 +1,78 @@
|
||||
public class TreeNode<T> {
|
||||
|
||||
private T value;
|
||||
private TreeNode<T> lesser;
|
||||
private TreeNode<T> greater;
|
||||
private SearchTree<T> parentTree;
|
||||
|
||||
public TreeNode(SearchTree<T> parentTree, T object) {
|
||||
this.parentTree = parentTree;
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
public void add(T object) {
|
||||
switch (parentTree.getComparator().compare(value, object)) {
|
||||
case -1:
|
||||
if (lesser != null) lesser.add(object);
|
||||
else lesser = new TreeNode<T>(parentTree, object);
|
||||
break;
|
||||
case 0:
|
||||
throw new IllegalArgumentException("Value already in tree");
|
||||
case 1:
|
||||
if (greater != null) greater.add(object);
|
||||
else greater = new TreeNode<T>(parentTree, object);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(T object) {
|
||||
if (lesser.getValue().equals(object)) {
|
||||
T a = lesser.getLesser().getValue();
|
||||
T b = lesser.getGreater().getValue();
|
||||
parentTree.add(a);
|
||||
parentTree.add(b);
|
||||
lesser = null;
|
||||
} else if (greater.getValue().equals(object)) {
|
||||
T a = greater.getLesser().getValue();
|
||||
T b = greater.getGreater().getValue();
|
||||
parentTree.add(a);
|
||||
parentTree.add(b);
|
||||
greater = null;
|
||||
} else {
|
||||
switch (parentTree.getComparator().compare(value, object)) {
|
||||
case -1:
|
||||
if (lesser != null) lesser.remove(object);
|
||||
else return;
|
||||
break;
|
||||
case 0:
|
||||
throw new IllegalStateException("Something fucked up");
|
||||
case 1:
|
||||
if (greater != null) greater.remove(object);
|
||||
else return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public TreeNode<T> getLesser() {
|
||||
return lesser;
|
||||
}
|
||||
|
||||
public TreeNode<T> getGreater() {
|
||||
return greater;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String str = "";
|
||||
if (greater != null) str += greater.toString();
|
||||
str += value.toString() + " ";
|
||||
if (lesser != null) str += lesser.toString() + " ";
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
16
DEV 3.2/TP08/Tri/Tri.java
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Tri
|
||||
*/
|
||||
public class Tri {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SearchTree<Float> t = new SearchTree<>(new RealComparator());
|
||||
|
||||
for (String arg : args) {
|
||||
Float f = Float.parseFloat(arg);
|
||||
t.add(f);
|
||||
}
|
||||
|
||||
System.out.println(t.toString());
|
||||
}
|
||||
}
|
117
DEV 4.4/TP01/ex1.c
Normal file
@ -0,0 +1,117 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
void encrypt (uint32_t* v, uint32_t* k)
|
||||
{
|
||||
uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
|
||||
uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
||||
uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
|
||||
for (i=0; i < 32; i++) { /* basic cycle start */
|
||||
sum += delta;
|
||||
v0 += ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
|
||||
v1 += ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
|
||||
} /* end cycle */
|
||||
v[0]=v0; v[1]=v1;
|
||||
}
|
||||
|
||||
void decrypt (uint32_t* v, uint32_t* k)
|
||||
{
|
||||
uint32_t delta=0x9e3779b9;
|
||||
uint32_t v0=v[0], v1=v[1], sum=(delta << 5), i;
|
||||
uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3];
|
||||
|
||||
for (i=0; i < 32; i++) {
|
||||
v1 -= ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
|
||||
v0 -= ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
|
||||
sum -= delta;
|
||||
}
|
||||
v[0]=v0; v[1]=v1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int treatFile(FILE* input, FILE* output, uint32_t key[4], char method) {
|
||||
|
||||
int n;
|
||||
uint32_t buffer[2];
|
||||
int m;
|
||||
|
||||
//TODO: Padding management
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case 'd':
|
||||
while ((n = fread(buffer, 4, 2, input)) > 0) {
|
||||
decrypt(buffer, key);
|
||||
|
||||
if (( m = fwrite(buffer, 4, 2, output)) != 2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
while ((n = fread(buffer, 4, 2, input)) > 0) {
|
||||
encrypt(buffer, key);
|
||||
|
||||
if (( m = fwrite(buffer, 4, 2, output)) != 2) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
if (argc < 5) {
|
||||
printf("Usage: %s e/d <key> <input> <output>\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-d") && !strcmp(argv[1], "-e")) {
|
||||
printf("Invalid operation, use either e(ncrypt) or d(ecrypt).");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t key[4];
|
||||
FILE* keyFile = fopen(argv[2], "r");
|
||||
if (!keyFile) {
|
||||
printf("Unable to open key file.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fread(key, 4, 4, keyFile) != 4) {
|
||||
printf("Invalid key length.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(keyFile);
|
||||
|
||||
FILE* input = fopen(argv[3], "r");
|
||||
if (!input) {
|
||||
printf("Unable to open input file.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* output = fopen(argv[4], "w");
|
||||
if (!output) {
|
||||
printf("Unable to open output file.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int failure = treatFile(input, output, key, argv[1][1]);
|
||||
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
|
||||
if (failure) {
|
||||
printf("Error during processing.\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
DEV 4.4/TP01/fichier.crypt
Normal file
1
DEV 4.4/TP01/key1.k
Normal file
@ -0,0 +1 @@
|
||||
÷Nà{q2‘*:¬¨œÇmfU#©`í±Å?&Q3
|
1
DEV 4.4/TP01/test.txt
Normal file
@ -0,0 +1 @@
|
||||
abcdefgh
|
15
DEV-4.5/TP01/Chat-Relative/.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
3
DEV-4.5/TP01/Chat-Relative/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
DEV-4.5/TP01/Chat-Relative/.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
Chat
|
6
DEV-4.5/TP01/Chat-Relative/.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
20
DEV-4.5/TP01/Chat-Relative/.idea/gradle.xml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="/usr/share/java/gradle" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
16
DEV-4.5/TP01/Chat-Relative/.idea/misc.xml
generated
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.33" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
6
DEV-4.5/TP01/Chat-Relative/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
1
DEV-4.5/TP01/Chat-Relative/app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
39
DEV-4.5/TP01/Chat-Relative/app/build.gradle
Normal file
@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.chat"
|
||||
minSdk 21
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildToolsVersion '33.0.0'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
21
DEV-4.5/TP01/Chat-Relative/app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# 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 *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,26 @@
|
||||
package com.example.chat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.chat", appContext.getPackageName());
|
||||
}
|
||||
}
|
27
DEV-4.5/TP01/Chat-Relative/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.chat">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Chat"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
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,14 @@
|
||||
package com.example.chat;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
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=".MainActivity">
|
||||
|
||||
<EditText
|
||||
android:layout_alignParentTop="true"
|
||||
android:gravity="top"
|
||||
android:text="OwO"
|
||||
android:id="@+id/chatBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75sp"
|
||||
/>
|
||||
<EditText
|
||||
android:maxLines="1"
|
||||
android:hint="Message"
|
||||
android:id="@+id/messageBox"
|
||||
android:inputType="text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_below="@+id/chatBox"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
<Button
|
||||
android:id="@+id/submitButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25pt"
|
||||
android:text="OK"
|
||||
android:textAlignment="center"
|
||||
android:layout_below="@+id/chatBox"
|
||||
android:layout_toRightOf="@id/messageBox"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
/>
|
||||
</RelativeLayout>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Chat" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Chat</string>
|
||||
</resources>
|
@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Chat" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
@ -0,0 +1,17 @@
|
||||
package com.example.chat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
9
DEV-4.5/TP01/Chat-Relative/build.gradle
Normal file
@ -0,0 +1,9 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '7.2.1' apply false
|
||||
id 'com.android.library' version '7.2.1' apply false
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|