Commit e100c387 authored by mistermad's avatar mistermad

* Clean projet:

- unnecessary classes remove
- unused resources remove
- permission "camera" and "get-account" remove
- unnecessary dependency remove (aikuma-cloud-storage-0.8.0.jar, nanohttpd-2.0.5.jar, commons-net-3.1.jar et 'com.google.android.gms:play-services:10.2.1')
parent a12f3a38
......@@ -24,14 +24,11 @@ android {
dependencies {
compile files('libs/aikuma-cloud-storage-0.8.0.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', {
......@@ -40,7 +37,6 @@ dependencies {
compile project(path: ':library')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-core-utils:25.3.1'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'javax.annotation:javax.annotation-api:1.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
......
<?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="org.getalp.ligaikuma.lig_aikuma.lig_aikuma"
android:versionCode="3"
android:versionName="3.0">
<uses-sdk android:minSdkVersion="14"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
......@@ -18,13 +15,10 @@
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-feature android:name="android.hardware.camera"/>
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
......@@ -32,179 +26,21 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/MyTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<receiver android:name="org.getalp.ligaikuma.lig_aikuma.service.BootReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.ListenActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.ListenRespeakingActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.CloudSearchActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordVideoActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.SettingsActivity"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataActivity1"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataActivity2"
android:configChanges="orientation"
android:label="@string/app_name"
tools:targetApi="jelly_bean">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataActivity3"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataActivity4"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.LanguageFilterList"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingSpeakersActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.MainSpeakersActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AddSpeakerActivity1"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AddSpeakerActivity2"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AddSpeakerActivity3"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AddSpeakerActivity4"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.ThumbRespeakActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.PhoneRespeakActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AddCustomLanguageActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.DefaultLanguagesActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.CloudSettingsActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.SyncSettingsActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.AboutActivity"
android:configChanges="orientation"
android:label="@string/app_name">
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.HttpServerActivity"
android:label="@string/http_server_activity_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.getalp.ligaikuma.lig_aikuma.MainActivity"/>
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.HowtoActivity"
android:label="@string/http_server_activity_title"
android:parentActivityName="org.getalp.ligaikuma.lig_aikuma.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.getalp.ligaikuma.lig_aikuma.MainActivity"/>
</activity>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.DebugInfo"
android:label="@string/title_activity_debug_info"
android:parentActivityName="org.getalp.ligaikuma.lig_aikuma.ui.AboutActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.getalp.ligaikuma.lig_aikuma.ui.AboutActivity"/>
</activity>
<service android:name="org.getalp.ligaikuma.lig_aikuma.service.GoogleCloudService"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ModeSelection">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
......@@ -212,7 +48,7 @@
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataLig"
android:configChanges="orientation|screenSize">
</activity>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.LanguageFilterListLIG"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.LanguageFilterList"/>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordActivityLig"
android:configChanges="orientation|screenSize"/>
......@@ -230,15 +66,9 @@
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.ElicitationMode"
android:configChanges="orientation|screenSize"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.TranslationSelection"/>
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordElicitation"
android:configChanges="orientation|screenSize"/>
<!--
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.RecordElicitationImage"
android:configChanges="orientation|screenSize" /> Not found in project
-->
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.CheckMode"
android:configChanges="orientation|screenSize"/>
......@@ -248,12 +78,9 @@
<activity
android:name="org.getalp.ligaikuma.lig_aikuma.ui.CheckTranscription"
android:configChanges="orientation|screenSize"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.SpeakerActivity">
</activity>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.ShareFileActivity">
</activity>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.ElicitationFileSearch">
</activity>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.SpeakerActivity"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.ShareFileActivity"/>
<activity android:name="org.getalp.ligaikuma.lig_aikuma.ui.ElicitationFileSearch"/>
</application>
</manifest>
\ No newline at end of file
......@@ -4,70 +4,29 @@
*/
package org.getalp.ligaikuma.lig_aikuma;
import android.accounts.AccountManager;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.GoogleAuthUtil;
import com.google.android.gms.auth.GooglePlayServicesAvailabilityException;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.gms.common.AccountPicker;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.musicg.wave.Wave;
import org.apache.commons.io.FileUtils;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Recording;
import org.getalp.ligaikuma.lig_aikuma.service.GoogleCloudService;
import org.getalp.ligaikuma.lig_aikuma.ui.ListenActivity;
import org.getalp.ligaikuma.lig_aikuma.ui.MenuBehaviour;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordingArrayAdapter;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataActivity1;
import org.getalp.ligaikuma.lig_aikuma.ui.sensors.LocationDetector;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import org.getalp.ligaikuma.lig_aikuma.util.SyncUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
// For audio imports
/**
* The primary activity that lists existing recordings and allows you to select
......@@ -78,6 +37,13 @@ import java.util.UUID;
*/
public class MainActivity extends ListActivity {
private static final String TAG = "MainActivity";
private static final int RECOVER_FROM_AUTH_ERROR_REQUEST_CODE = 1001;
private static final int RECOVER_FROM_GOOGLEPLAY_ERROR_REQUEST_CODE = 1002;
public static LocationDetector locationDetector;
// Helps us store how far down the list we are when MainActivity gets
// stopped.
private Parcelable listViewState;
......@@ -87,8 +53,6 @@ public class MainActivity extends ListActivity {
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
menuBehaviour = new MenuBehaviour(this);
SyncUtil.startSyncLoop(this);
//new Aikuma();
//Aikuma.loadLanguages(this.getApplicationContext());
......@@ -101,55 +65,12 @@ public class MainActivity extends ListActivity {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
// settings.edit().clear().commit();
emailAccount = settings.getString(AikumaSettings.SETTING_OWNER_ID_KEY, null);
googleAuthToken = settings.getString(AikumaSettings.SETTING_AUTH_TOKEN_KEY, null);
googleIdToken = settings.getString(AikumaSettings.SETTING_ID_TOKEN_KEY, null);
googleAPIScope = AikumaSettings.getScope();
if(BuildConfig.DEBUG)Log.i(TAG, "Account: " + emailAccount + ", scope: " + googleAPIScope);
AikumaSettings.setUserId(emailAccount);
showUserAccount(emailAccount, null);
AikumaSettings.isBackupEnabled = settings.getBoolean(AikumaSettings.BACKUP_MODE_KEY, false);
AikumaSettings.isAutoDownloadEnabled = settings.getBoolean(AikumaSettings.AUTO_DOWNLOAD_MODE_KEY, false);
// Automatic validation
if(emailAccount != null) {
// Validate access token
// (And if there are items to be archived, upload them)
if (Aikuma.isDeviceOnline())
new GetTokenTask(emailAccount, googleAPIScope, settings, false).execute();
else
Toast.makeText(this, "Network is disconnected", Toast.LENGTH_SHORT).show();
} else if(AikumaSettings.isBackupEnabled || AikumaSettings.isAutoDownloadEnabled)
// When backup was enabled but the user hasn't ever signed-in google account
getAccountToken();
// Start gathering location data
MainActivity.locationDetector = new LocationDetector(this);
// Create a broadcastReceiver to receive sync-data
syncReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String status = intent.getStringExtra(GoogleCloudService.SYNC_STATUS);
if(status.equals("start"))
showProgressStatus(View.VISIBLE);
else if(status.equals("end"))
showProgressStatus(View.GONE);
else if(status.endsWith("source")) { //source-download
String[] splitName = status.split("-");
try {
updateRecordingView(Recording.read(splitName[0], splitName[2], status.substring(4)));
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, e.getMessage());
}
}
}
};
checkDate();
// Create an index file when app starts
try {
......@@ -157,24 +78,6 @@ public class MainActivity extends ListActivity {
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, e.getMessage());
}
//TODO: Update existing files
/*
String appVersionName = settings.getString(AikumaSettings.SETTING_VERSION_KEY, "");
if(!appVersionName.equals(AikumaSettings.getLatestVersion())) {
// Update the file structure and metadata
new UpdateUtils(this).update();
} */
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return menuBehaviour.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return menuBehaviour.onOptionsItemSelected(item);
}
@Override
......@@ -191,16 +94,6 @@ public class MainActivity extends ListActivity {
List<Recording> recordings = Recording.readAll();
if(BuildConfig.DEBUG)Log.i(TAG, "num: " +recordings.size());
// Filter the recordings for originals
originals = new ArrayList<>();
for(Recording recording : recordings)
if(recording.isOriginal())
originals.add(recording);
if(BuildConfig.DEBUG)Log.i(TAG, "original num: " + originals.size());
adapter = new RecordingArrayAdapter(this, originals);
setListAdapter(adapter);
if(listViewState != null)
getListView().onRestoreInstanceState(listViewState);
......@@ -210,13 +103,12 @@ public class MainActivity extends ListActivity {
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(syncReceiver, new IntentFilter(GoogleCloudService.SYNC_RESULT));
//LocalBroadcastManager.getInstance(this).registerReceiver(syncReceiver, new IntentFilter(GoogleCloudService.SYNC_RESULT));
showProgressStatus(View.GONE);
}
@Override
protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(syncReceiver);
super.onStop();
}
......@@ -226,22 +118,6 @@ public class MainActivity extends ListActivity {
MainActivity.locationDetector.stop();
}
@Override
public void onListItemClick(ListView l, View v, int position, long id){
Recording recording = (Recording) getListAdapter().getItem(position);
if(emailAccount == null) {
Aikuma.showAlertDialog(this, "You need to select your account");
return;
}
Intent intent = new Intent(this, ListenActivity.class);
intent.putExtra("id", recording.getId());
intent.putExtra("ownerId", recording.getOwnerId());
intent.putExtra("versionName", recording.getVersionName());
startActivity(intent);
}
// If current year < 2000, make the user type in the correct date continuously
private void checkDate() {
Calendar calendar = Calendar.getInstance();
......@@ -262,22 +138,6 @@ public class MainActivity extends ListActivity {
}
/**
* Display the progress dialog to the user
*
* @param message String to display
*/
public void showProgressDialog(String message) {
progressDialog = ProgressDialog.show(this, "Update", message);
}
/**
* Dismiss the progress dialog
*/
public void dismissProgressDialog() {
progressDialog.dismiss();
}
/**
* Show the status of cloud-background thread
* @param visibility Visibility of the progress bar View
......@@ -287,123 +147,6 @@ public class MainActivity extends ListActivity {
pStatus.setVisibility(visibility);
}
/**
* Show the current user's ID
* @param userId The user's ID
* @param token The user-account's auth_token
*/
public void showUserAccount(String userId, String token) {
TextView userIdView = (TextView) findViewById(R.id.userIdView);
if(userId != null) {
userIdView.setTextColor((token != null)?Color.BLACK:Color.GRAY);
userIdView.setText(userId);
} else {
userIdView.setText("");
}
}
/**
* Update the list of recordings view
* @param recording New recording to be updated
*/
public void updateRecordingView(Recording recording) {
if(!originals.contains(recording)) {
originals.add(recording);
adapter.notifyDataSetChanged();
}
}
/* *
* Setup the search-menu-item interface (called by MenuBehavior)
* @param menu menu object
*/// Never used
/*public void setUpSearchInterface(Menu menu) {
final MenuItem searchMenuItem = menu.findItem(R.id.search);
searchView = (SearchView) searchMenuItem.getActionView();
// Touch event outside the searchview closes the searchview
searchView.setOnQueryTextFocusChangeListener(
new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus) {
searchMenuItem.collapseActionView();
//searchView.setQuery("", false);
}
}
});
// Execute search
searchView.setOnQueryTextListener(
new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
adapter.getFilter().filter(query);
searchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
return true;
}
});
}*/
/**
* Sync the device with Google-Cloud
*
* @param forceSync Force the cloud-sync
*/
public void syncRefresh(boolean forceSync) {
if(forceSync) {
if(!Aikuma.isDeviceOnline