Skip to content
Snippets Groups Projects
Commit b4bfbf35 authored by Jean-Marie Place's avatar Jean-Marie Place
Browse files

initial

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 446 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/build
/captures
.externalNativeBuild
.cxx
local.properties
# Default ignored files
/shelf/
/workspace.xml
Tele TP
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
<?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="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "fr.ulille.iutinfo.teletp"
minSdkVersion 23
targetSdkVersion 30
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment:2.3.3'
implementation 'androidx.navigation:navigation-ui:2.3.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
\ No newline at end of file
# 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
\ No newline at end of file
package fr.ulille.iutinfo.teletp;
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("fr.ulille.iutinfo.teletp", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.ulille.iutinfo.teletp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TeleTP">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.TeleTP.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package fr.ulille.iutinfo.teletp;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// TODO Q2.b
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
\ No newline at end of file
# Réponse Question 11 (3 points)
En supposant que les manifest de l'application android est correctemnt rempli, donnez la liste des messages apparaissant sur le logcat suite à l'exécution du code suivant:
```
Log.d("DEBUG", "Hello");
RestQueue restQueue = RestQueue.getInstance(this);
JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET,
"http://10.0.2.2:8080/api/v1/pizza",
null,
jsonArray -> {
Log.d("DEBUG", "A");
},
volleyError -> {
Log.d("DEBUG", "B");
});
Log.d("DEBUG", "C");
restQueue.addToRequestQueue(request);
```
en fonction des cas de figure évoqués.
Vous répondrez en indique les messages affichés précédés de > et éventuellement les délais observés précédés de *
par exemple (ceci n'est pas une bonne réponse):
```
> HELLO
* 10 sec
> A
> B
* 10 sec
> C
```
Quand 2 messages ne sont pas séparé par un délai (comme A et B dans l'exemple), l'ordre des message n'a pas d'importance
## Cas 1: le serveur répond correctement
```
Cas 1: Répondez en remplaçant cette ligne
```
## Cas 2: Le serveur répond immédiatement mais avec un message d'erreur
```
Cas 2: Répondez en remplaçant cette ligne
```
## Cas 3: Le serveur répond en erreur après un time out de 10 secondes
```
Cas 3: Répondez en remplaçant cette ligne
```
package fr.ulille.iutinfo.teletp;
public class SuiviAdapter /* TODO Q6.a */ {
// TODO Q6.a
// TODO Q7
}
package fr.ulille.iutinfo.teletp;
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
public class SuiviViewModel extends AndroidViewModel {
private MutableLiveData<String> liveLocalisation;
private MutableLiveData<String> liveUsername;
// TODO Q2.a
public SuiviViewModel(Application application) {
super(application);
liveLocalisation = new MutableLiveData<>();
liveUsername = new MutableLiveData<>();
}
public LiveData<String> getLiveUsername() {
return liveUsername;
}
public void setUsername(String username) {
liveUsername.setValue(username);
Context context = getApplication().getApplicationContext();
Toast toast = Toast.makeText(context, "Username : " + username, Toast.LENGTH_LONG);
toast.show();
}
public String getUsername() {
return liveUsername.getValue();
}
public LiveData<String> getLiveLocalisation() {
return liveLocalisation;
}
public void setLocalisation(String localisation) {
liveLocalisation.setValue(localisation);
Context context = getApplication().getApplicationContext();
Toast toast = Toast.makeText(context, "Localisation : " + localisation, Toast.LENGTH_LONG);
toast.show();
}
public String getLocalisation() {
return liveLocalisation.getValue();
}
// TODO Q2.a
}
package fr.ulille.iutinfo.teletp;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
public class VueGenerale extends Fragment {
// TODO Q1
// TODO Q2.c
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.vue_generale, container, false);
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// TODO Q1
// TODO Q2.c
// TODO Q4
view.findViewById(R.id.btnToListe).setOnClickListener(view1 -> {
// TODO Q3
NavHostFragment.findNavController(VueGenerale.this).navigate(R.id.generale_to_liste);
});
// TODO Q5.b
// TODO Q9
}
// TODO Q5.a
// TODO Q9
}
\ No newline at end of file
package fr.ulille.iutinfo.teletp;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
public class VueListe extends Fragment /* TODO Q7 */ {
// TODO Q2c
// TODO Q6
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.vue_liste, container, false);
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.btnToGenerale).setOnClickListener(view1 -> NavHostFragment.findNavController(VueListe.this)
.navigate(R.id.liste_to_generale));
// TODO Q2c
// TODO Q6.b
// TODO Q7
// TODO Q8
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment