Commit c4d09ce1 authored by mistermad's avatar mistermad

Restructuration total du projet LigAikuma.

Ajout d'un champ "Note" (divers) dans "RecordMetadataLig" et ReaspeakingMetadataLig" en cours.

TODO: Corrigier le problème de chargement des langues faisant planter l'application au lancement.
parent 6f8809a4
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "org.getalp.ligaikuma.lig_aikuma"
minSdkVersion 16
targetSdkVersion 25
multiDexEnabled = true
versionCode 1
versionName "1.0"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-compat'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/aikuma-cloud-storage-0.8.0.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/commons-io-2.4.jar')
compile files('libs/commons-lang3-3.1.jar')
compile files('libs/commons-net-3.1.jar')
compile files('libs/guava-13.0.1.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/musicg-1.4.2.0.jar')
compile files('libs/nanohttpd-2.0.5.jar')
compile files('libs/opencsv-2.3.jar')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'support-v4'
})
compile ('com.android.support:appcompat-v7:25.3.1') {
exclude module: 'support-annotations'
}
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/getalp/baudsong/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 *;
#}
# 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
package org.getalp.ligaikuma.lig_aikuma;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation 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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("org.getalp.ligaikuma.lig_aikuma", appContext.getPackageName());
}
}
This diff is collapsed.
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
package org.getalp.ligaikuma.lig_aikuma;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Settings.Secure;
import android.util.Log;
import org.getalp.ligaikuma.lig_aikuma.model.FileModel;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
//import android.support.annotation.RequiresApi;
/**
* Offers a collection of static methods that require a context independently
* of an Activity.
*
* Sources and caveats:
* http://stackoverflow.com/questions/987072/using-application-context-everywhere
* http://stackoverflow.com/questions/2002288/static-way-to-get-context-on-android
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
public class Aikuma extends android.app.Application {
private static Aikuma instance;
private static List<Language> languages;
private static Map<String, String> languageCodeMap;
private static SharedPreferences preferences;
/**
* The constructor.
*/
public Aikuma() {
instance = this;
}
/**
* Static method that provides a context when needed by code not bound to
* any meaningful context.
*
* @return A Context
*/
public static Context getContext() {
return instance;
}
/**
* Gets the phone model name
*
* @return The device name (manufacturer + model)
*/
public static String getDeviceName() {
return Build.MANUFACTURER + "-" + Build.MODEL;
}
/**
* Gets the android ID of the phone.
*
* @return The android ID as a String.
*/
public static String getAndroidID() {
return Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
}
/**
* A function which return 3 first charactes of ANDROID_ID address
* @return 3 first characters of ANDROID_ID Address
*/
public static String getDeviceId() {
return getAndroidID().substring(0, 3);
}
/**
* Checks whether the device is currently connected to a network
* @return boolean for status
*/
public static boolean isDeviceOnline() {
if(preferences == null) {
preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
AikumaSettings.isOnlyWifi =
preferences.getBoolean(AikumaSettings.WIFI_MODE_KEY, true);
}
ConnectivityManager connMgr = (ConnectivityManager)
getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo;
if(AikumaSettings.isOnlyWifi) {
networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
} else {
networkInfo = connMgr.getActiveNetworkInfo();
}
return networkInfo != null && networkInfo.isConnected();
}
/**
* Check if the file is already archived/in the progress of archiving or not
*
* @param emailAccount Owner account of the file
* @param fm The file's model
* @return boolean of the archive status
*/
//@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public static boolean isArchived(String emailAccount, FileModel fm) {
String itemCloudId = fm.getCloudIdentifier(0);
Set<String> approvedSet;
Set<String> archivedSet;
int archiveProgress = -1;
SharedPreferences privatePreferences =
getContext().getSharedPreferences(emailAccount, MODE_PRIVATE);
String fileType = fm.getFileType();
if(fileType.equals("source") || fileType.equals("respeaking")) {
approvedSet = privatePreferences.getStringSet(
AikumaSettings.APPROVED_RECORDING_KEY, new HashSet<String>());
archivedSet = privatePreferences.getStringSet(
AikumaSettings.ARCHIVED_RECORDING_KEY, new HashSet<String>());
} else if(fileType.equals("speaker")) {
approvedSet = privatePreferences.getStringSet(
AikumaSettings.APPROVED_SPEAKERS_KEY, new HashSet<String>());
archivedSet = privatePreferences.getStringSet(
AikumaSettings.ARCHIVED_SPEAKERS_KEY, new HashSet<String>());
} else {
approvedSet = privatePreferences.getStringSet(
AikumaSettings.APPROVED_OTHERS_KEY, new HashSet<String>());
archivedSet = privatePreferences.getStringSet(
AikumaSettings.ARCHIVED_OTHERS_KEY, new HashSet<String>());
}
if(approvedSet.contains(itemCloudId)) {
String[] requestArchiveState =
privatePreferences.getString(itemCloudId, "").split("\\|");
archiveProgress =
Integer.parseInt(requestArchiveState[1]);
}
return archivedSet.contains(itemCloudId) || (archiveProgress >= 0 && archiveProgress <= 3);
}
/**
* Return an arraylist of available google-accounts in a device
* @return ArrayList of google-accounts
*/
public static ArrayList<String> getGoogleAccounts() {
ArrayList<String> accountList = new ArrayList<>();
Account[] accounts =
AccountManager.get(getContext()).getAccountsByType("com.google");
for(Account ac : accounts) {
accountList.add(ac.name);
}
return accountList;
}
/**
* Show the warning dialog with the message
* @param activity The activity where the message will be shown
* @param message the message shown in the dialog
*/
public static void showAlertDialog(Context activity, String message) {
new AlertDialog.Builder(activity).setMessage(message).show();
}
/**
* Returns the ISO 639-3 languages once they are loaded.
*
* @return the languages
*/
public static List<Language> getLanguages() {
if(languages != null) return languages;
loadLanguages();
while(languages == null);
return languages;
}
/**
* Returns the ISO 639-3 language map (code - name)
*
* @return the languageCodeMap
*/
public static Map<String, String> getLanguageCodeMap() {
if (languageCodeMap != null) return languageCodeMap;
loadLanguages();
while(languageCodeMap == null);//Wait patiently
return languageCodeMap;
}
/**
* Loads the ISO 639-3 languages.
*/
public static void loadLanguages() {
if (languages == null) {
languages = new ArrayList<>();
languageCodeMap = new HashMap<String, String>();
if (loadLangCodesThread == null || !loadLangCodesThread.isAlive()) {
loadLangCodesThread = new Thread(new Runnable() {
public void run() {
/*try {
FileIO.readLangCodes(getContext().getResources(), languages, languageCodeMap); // Méthode non-trouvé.
} catch (IOException e) {
// This should never happen. M: Realy?
throw new RuntimeException("Cannot load languages");
}*/
}
});
loadLangCodesThread.start();