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'
......
This diff is collapsed.
package org.getalp.ligaikuma.lig_aikuma.audio;
import android.app.Activity;
import android.widget.TextView;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Recording;
import org.getalp.ligaikuma.lig_aikuma.model.Segments.Segment;
import org.getalp.ligaikuma.lig_aikuma.model.TempTranscript;
......@@ -62,21 +59,10 @@ public class TranscriptPlayer extends MarkedPlayer
// Updates the transcript Ui and prepares the notification marker position.
private void updateTranscriptStatus(long sample) {
Segment segment = transcript.getSegmentOfSample(sample);
updateTranscriptUi(segment);
setNotificationMarkerPosition(segment);
}
// Update the UI such that the transcript reflects the current segment.
private void updateTranscriptUi(Segment segment) {
if (segment != null) {
((TextView) activity.findViewById(R.id.transcriptView)).setText(transcript.getTranscriptPair(segment).transcript);
((TextView) activity.findViewById(R.id.transcriptView2)).setText(transcript.getTranscriptPair(segment).translation);
}
else
((TextView) activity.findViewById(R.id.transcriptView)).setText("");
}
@Override
public void seekToMsec(int msec) {
super.seekToMsec(msec);
......
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
/**
* The audio package offers classes to facilitate playing, recording, and
* respeaking of audio in Aikuma.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
package org.getalp.ligaikuma.lig_aikuma.audio;
......@@ -146,8 +146,9 @@ public class PCMWriter implements Sampler {
*/
public void write(short[] buffer, int len) {
byte[] byteBuffer = new byte[len * 2];
short sample;
for(int i = 0; i < len; i++) {
short sample = buffer[i];
sample = buffer[i];
byteBuffer[i * 2] = (byte) sample;
byteBuffer[i * 2 + 1] = (byte) (sample >>> 8);
}
......@@ -201,7 +202,6 @@ public class PCMWriter implements Sampler {
private void createRandomAccessFile() {
try {
// Random access file.
//
File file = new File(this.fullFilename);
if(BuildConfig.DEBUG)Log.i("mkdirs", " " + file.getParentFile().mkdirs() + ", on " +
file.getParentFile());
......@@ -326,19 +326,16 @@ public class PCMWriter implements Sampler {
try {
// Write size to RIFF header.
//
randomAccessWriter.seek(4);
randomAccessWriter.writeInt(Integer.reverseBytes(36 + payloadSize));
// Write size to Sub-chunk size header.
//
randomAccessWriter.seek(40);
randomAccessWriter.writeInt(Integer.reverseBytes(payloadSize));
randomAccessWriter.close();
} catch (IOException e) {
if(BuildConfig.DEBUG)Log.e(PCMWriter.class.getName(),
"I/O exception occured while closing output file");
if(BuildConfig.DEBUG)Log.e(PCMWriter.class.getName(),"I/O exception occured while closing output file");
}
}
......
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
/**
* This package contains Analyzers take samples and analyze them, calling
* audioTriggered or silenceTriggered on an AudioHandler when appropriate.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
package org.getalp.ligaikuma.lig_aikuma.audio.record.analyzers;
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
/**
* The record package contains classes that facilitate recording and respeaking
* of audio in Aikuma.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
package org.getalp.ligaikuma.lig_aikuma.audio.record;
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
/**
* Recognizers are used to determine whether buffers contain speech or silence.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
package org.getalp.ligaikuma.lig_aikuma.audio.record.recognizers;
package org.getalp.ligaikuma.lig_aikuma.http;
import java.util.ArrayList;
import java.util.List;
import fi.iki.elonen.NanoHTTPD.IHTTPSession;
import fi.iki.elonen.NanoHTTPD.Response;
/**
* Allows to create a chain of HTTP request processors.
*
* @author Haejoong Lee <haejoong@ldc.upenn.edu>
*/
abstract public class Proc {
private List<Proc> procs;
/**
* Add a new processor to the processor chain and returns itself.
*
* @param p Proc object
* @return this object.
*/
public Proc add(Proc p) {
if (procs == null) {
procs = new ArrayList<Proc>();
procs.add(this);
}
procs.add(p);
return this;
}
/**
* The actual behavior of the object should be implemented here.
* @param session An HTTP session object.
* @return a Response object, or null if the HTTP request, described by
* the session object, was not handled.
*/
abstract public Response run(IHTTPSession session);
/**
* Execute the processor chain.
* @param session HTTP session object given to the serve() method of
* NanoHTTPD object.
* @return a Response object, or null if the HTTP request was not
* handled.
*/
public Response exec(IHTTPSession session) {
for(Proc proc : procs) {
Response r = proc.run(session);
if(r != null)
return r;
}
return null;
}
}
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams, Florian Hanke
*/
/**
* This package adds HTTP server feature to the app.
* Embedded NanoHttpd provides an implementation of the HTTP protocol.
*
* @author Haejoong Lee <haejoong@ldc.upenn.edu>
*/
package org.getalp.ligaikuma.lig_aikuma.http;
\ No newline at end of file
......@@ -4,14 +4,14 @@
*/
package org.getalp.ligaikuma.lig_aikuma.model;
import java.io.File;
import android.os.Parcel;
import android.os.Parcelable;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import org.getalp.ligaikuma.lig_aikuma.util.IdUtils;
import java.io.File;
/**
* The file modeled from the viewpoint of GoogleCloud
* (The parent class of Recording and Speaker /
......
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
package org.getalp.ligaikuma.lig_aikuma.model;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import org.json.simple.JSONObject;
/**
* Contains information about the supplied server credentials for connecting to
* an FTP server.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
public class ServerCredentials {
/**
* Constructor
*
* @param ipAddress The IP address of the server.
* @param username The username of a user on the server who will be
* logged in as.
* @param password The password corresponding to the user.
* @param syncActivated A flag indicating whether automatic sync is
* activated or not
* @param lastSyncDate Latest sync success date
*/
public ServerCredentials(String ipAddress, String username,
String password, boolean syncActivated, String lastSyncDate) {
setIPAddress(ipAddress);
setUsername(username);
setPassword(password);
setSyncActivated(syncActivated);
setLastSyncDate(lastSyncDate);
}
/**
* Write the server credentials to file.
*
* @throws IOException If the credentials cannot be written.
*/
public void write() throws IOException {
FileIO.writeJSONObject(
new File(FileIO.getAppRootPath(), "server_credentials.json"),
this.encode());
}
/**
* Reads server credentials from file.
*
* @return A ServerCredentials object representing the stored server
* credentials
* @throws IOException If the credentials cannot be read.
*/
public static ServerCredentials read() throws IOException {
JSONObject encodedServerCredentials = FileIO.readJSONObject(
new File(FileIO.getAppRootPath(), "server_credentials.json"));
return new ServerCredentials(
(String) encodedServerCredentials.get("ipAddress"),
(String) encodedServerCredentials.get("username"),
(String) encodedServerCredentials.get("password"),
(Boolean) encodedServerCredentials.get("syncActivated"),
(String) encodedServerCredentials.get("lastSyncDate"));
}
// Encodes the server credentials as a JSON object.
private JSONObject encode() {
JSONObject encodedServerCredentials = new JSONObject();
encodedServerCredentials.put("ipAddress", getIPAddress());
encodedServerCredentials.put("username", getUsername());
encodedServerCredentials.put("password", getPassword());
encodedServerCredentials.put("syncActivated", getSyncActivated());
encodedServerCredentials.put("lastSyncDate", getLastSyncDate());
return encodedServerCredentials;
}
public String getIPAddress() {
return ipAddress;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public String getLastSyncDate() {
return lastSyncDate;
}
//Sets the IP address but will only accept valid IPv4 addresses.
private void setIPAddress(String ipAddress) {
if(Pattern.compile(IP_ADDRESS_PATTERN).matcher(ipAddress).matches())
this.ipAddress = ipAddress;
else
throw new IllegalArgumentException("Invalid IP Address");
}
// Sets the username, but will not accept empty strings.
private void setUsername(String username) {
if(username.compareTo("") != 0)
this.username = username;
else
throw new IllegalArgumentException("username cannot be an empty string");
}
private void setPassword(String password) {
this.password = password;
}
private void setSyncActivated(boolean syncActivated) {
this.syncActivated = syncActivated;
}
public boolean getSyncActivated() {
return this.syncActivated;
}
/**
* Sets the latest sync-date.
* (Called by SyncUtil)
*
* @param lastSyncDate Lastest success sync date
*/
public void setLastSyncDate(String lastSyncDate) {
this.lastSyncDate = lastSyncDate;
}
private String ipAddress;
private String username;
private String password;
private boolean syncActivated;
private String lastSyncDate;
// Used to ensure the IP address is valid syntactically
private static final String IP_ADDRESS_PATTERN =
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
}
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
package org.getalp.ligaikuma.lig_aikuma.model;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
// TODO: To delete ?
/**
* An "abstract" representation of a WAVE file entity, which offers methods for
* probing information held in the header, as well as calculating the duration.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
public class WaveFile {
/**
* Constructor.
*
* @param file The file to read from.
* @throws IOException In the event that there is an issue reading the
* file.
*/
public WaveFile(File file) throws IOException {
setFile(file);
//readBytes();
readHeader();
readNumChannels();
readSampleRate();
readBitsPerSample();
}
/**
* Gets the sample rate in kHz.
*
* @return the sample rate in kHz.
*/
public int getSampleRate() {
return mSampleRate;
}
/**
* Gets the number of bits per sample.
*
* @return The number of bits per sample.
*/
public short getBitsPerSample() {
return mBitsPerSample;
}
/**
* Gets the number of channels (Mono = 1, Stereo = 2).
*
* @return The number of channels.
*/
public short getNumChannels() {
return mNumChannels;
}
/**
* Gets the duration of the WAVE file in seconds.
*
* @return The duration of the WAVE file in seconds.
*/
public double getDuration() {
// Data length is the total number of bytes minus the header.
long dataLength = mFile.length() - 44;
// Here we assume that bits per sample will always be a multiple of 8.
long numSamples = dataLength / ((getBitsPerSample() / 8) * mNumChannels);
return (double) numSamples / mSampleRate;
}
///////////////////////////////////////////////////////////////////////////
private void setFile(File file) {
mFile = file;
}
// Reads the header from the wave file.
private void readHeader() throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(mFile), 44);
byte[] buff = new byte[44];
if (in.read(buff) == -1)
throw new IOException("End of input stream reached before filling the header.");
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(buff);
out.flush();
mHeader = out.toByteArray();
}
// Reads the sample rate from the wave file
private void readSampleRate() {
byte[] sampleRateBytes = Arrays.copyOfRange(mHeader, 24, 28);
ByteBuffer bb = ByteBuffer.wrap(sampleRateBytes);
bb.order(ByteOrder.LITTLE_ENDIAN);
mSampleRate = bb.getInt();
}
// Reads the bits per sample from the wave file
private void readBitsPerSample() {
byte[] bpsBytes = Arrays.copyOfRange(mHeader, 34, 36);
ByteBuffer bb = ByteBuffer.wrap(bpsBytes);
bb.order(ByteOrder.LITTLE_ENDIAN);
mBitsPerSample = bb.getShort();
}
// Reads the number of channels from the wave file
private void readNumChannels() {
byte[] ncBytes = Arrays.copyOfRange(mHeader, 22, 24);
ByteBuffer bb = ByteBuffer.wrap(ncBytes);
bb.order(ByteOrder.LITTLE_ENDIAN);
mNumChannels = bb.getShort();
}
private File mFile;
private byte[] mHeader;
private int mSampleRate;
private short mBitsPerSample;
private short mNumChannels;
}
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/
/**
* The model package contains classes that model data handled by Aikuma.
*
* @author Oliver Adams <oliver.adams@gmail.com>
* @author Florian Hanke <florian.hanke@gmail.com>
*/
package org.getalp.ligaikuma.lig_aikuma.model;
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Sangyeop Lee
*/
package org.getalp.ligaikuma.lig_aikuma.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import org.getalp.ligaikuma.lig_aikuma.Aikuma;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
/**
* The broadcast-receiver listening to the connectivity-change event
* Re-initialize the alaram-event of cloud-service to be executed peirodically
*
* @author Sangyeop Lee <sangl1@student.unimelb.edu.au>
*/
public class BootReceiver extends BroadcastReceiver {
private final String TAG = "BootReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if(BuildConfig.DEBUG)Log.i(TAG, "BootReceiver started");
if(!intent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE")) return;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if(preferences.getBoolean(AikumaSettings.BACKUP_MODE_KEY, false) &&
preferences.getBoolean(AikumaSettings.AUTO_DOWNLOAD_MODE_KEY, false)) {
Intent serviceIntent = new Intent(context, GoogleCloudService.class);
serviceIntent.putExtra(GoogleCloudService.ACTION_KEY, "sync");
serviceIntent.putStringArrayListExtra(GoogleCloudService.ACCOUNT_KEY, Aikuma.getGoogleAccounts());
context.startService(serviceIntent);
}
}
}
/*
Copyright (C) 2013, The Aikuma Project
AUTHORS: Oliver Adams and Florian Hanke
*/