Commit 00cc5c41 authored by mistermad's avatar mistermad

- Add waveform visualization of the original audio file in the Elicitation and Traslating mode

parent 6e7e27b7
......@@ -53,4 +53,5 @@ dependencies {
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
compile 'javax.annotation:javax.annotation-api:1.2'
compile project(path: ':library')
}
......@@ -53,6 +53,7 @@ public class ModeSelection extends Activity implements OnClickListener{
/** Called when the activity is first created. */
@Override
@SuppressLint("CommitPrefEdits")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mode_selection);
......@@ -94,9 +95,9 @@ public class ModeSelection extends Activity implements OnClickListener{
MainActivity.locationDetector = new LocationDetector(this);
// check the existing session and show popup to propose retrieving it
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
ed = prefsUserSession.edit();
if(prefsUserSession.getBoolean(getString(R.string.sessionActive), false))
if(prefsUserSession.getBoolean("active", false))
showSessionDialog();
}
......@@ -189,10 +190,9 @@ public class ModeSelection extends Activity implements OnClickListener{
@Override
public void onClick(DialogInterface dialog, int which) {
if(BuildConfig.DEBUG)Log.i(TAG,"no don't retrieve the session but keep files");
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//clear sharedPrefs
ed.clear();
ed.commit();
ed.clear().commit();
}
})
.setNeutralButton(R.string.no_and_erase_files, new DialogInterface.OnClickListener() {
......@@ -203,31 +203,27 @@ public class ModeSelection extends Activity implements OnClickListener{
//remove files
eraseFiles();
//clear sharedPrefs
ed.clear();
// ed.putBoolean(getString(R.string.sessionActive), false);
ed.commit();
ed.clear().commit();
}
});
return builder.create();
}
public void retrieveSession() {
String mode = prefsUserSession.getString(getString(R.string.sessionMode), null);
String mode = prefsUserSession.getString("mode", null);
if(BuildConfig.DEBUG)Log.d(TAG, "mode retrieval: "+mode);
Intent intent;
if (mode.compareToIgnoreCase(CheckTranscription.TAG) == 0) {
intent = new Intent(getActivity(), CheckTranscription.class);
} else if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) {
intent = new Intent(getActivity(), CheckWordVariant.class);
} else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) {
intent = new Intent(getActivity(), ThumbRespeakActivityLig.class);
} else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
intent = new Intent(getActivity(), RecordElicitation.class);
} else {
if(((mode != null)?mode.compareToIgnoreCase(CheckTranscription.TAG):0) == 0)
startActivity(new Intent(getActivity(), CheckTranscription.class));
else if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0)
startActivity(new Intent(getActivity(), CheckWordVariant.class));
else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0)
startActivity(new Intent(getActivity(), ThumbRespeakActivityLig.class));
else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0)
startActivity(new Intent(getActivity(), RecordElicitation.class));
else
Toast.makeText(getActivity(), "An error ocurred. The session could not be retrieved", Toast.LENGTH_LONG).show();
return;
}
startActivity(intent);
}
public void setDialogDetails(LinearLayout ll) {
......@@ -244,20 +240,20 @@ public class ModeSelection extends Activity implements OnClickListener{
* ThumbRespeakActivityLig / respeaking ----------> Respeaking / null
* "" / translation ----------> Translation / null
*/
String mode = prefsUserSession.getString(getString(R.string.sessionMode), getString(R.string.undefined));
String submode = prefsUserSession.getString(getString(R.string.session_submode), getString(R.string.undefined));
String mode = prefsUserSession.getString("mode", "undefined");
String submode = prefsUserSession.getString("submode", "undefined");
String modeDialog = null, submodeDialog = null;
if (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || mode.compareTo(CheckTranscription.TAG) == 0) {
modeDialog = getString(R.string.check_mode);
submodeDialog = (mode.compareToIgnoreCase(CheckWordVariant.TAG) == 0) ? CheckWordVariant.TAG : CheckTranscription.TAG;
} else if (mode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
modeDialog = getString(R.string.elicitation);
if (submode.compareToIgnoreCase("text") == 0) { submodeDialog = "text"; }
else if (submode.compareToIgnoreCase("image") == 0) { submodeDialog = "image"; }
else if (submode.compareToIgnoreCase("video") == 0) { submodeDialog = "video"; }
if (submode.compareToIgnoreCase("text") == 0) submodeDialog = "text";
else if (submode.compareToIgnoreCase("image") == 0) submodeDialog = "image";
else if (submode.compareToIgnoreCase("video") == 0) submodeDialog = "video";
} else if (mode.compareToIgnoreCase(ThumbRespeakActivityLig.TAG) == 0) {
if (submode.compareToIgnoreCase(getString(R.string.respeak)) == 0) { modeDialog = "Respeaking"; }
else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) { modeDialog = "Translation"; }
if (submode.compareToIgnoreCase(getString(R.string.respeak)) == 0) modeDialog = "Respeaking";
else if (submode.compareToIgnoreCase(getString(R.string.translation)) == 0) modeDialog = "Translation";
submodeDialog = "None";
}
((TextView) ll.findViewById(R.id.session_mode)).setText(modeDialog);
......@@ -265,32 +261,32 @@ public class ModeSelection extends Activity implements OnClickListener{
// display date in a more convenient way
try {
Date date = new SimpleDateFormat().parse(prefsUserSession.getString(getString(R.string.sessionDate), "undefined"));
Date date = new SimpleDateFormat().parse(prefsUserSession.getString("date", "undefined"));
// TODO parsing fails...
((TextView) ll.findViewById(R.id.session_date)).setText(new SimpleDateFormat("dd/MM/yyyy at HH:mm",Locale.FRANCE).format(date));
} catch (ParseException e) {
if(BuildConfig.DEBUG)Log.e(TAG, ""+e);
((TextView) ll.findViewById(R.id.session_date)).setText(prefsUserSession.getString(getString(R.string.sessionDate), "undefined"));
((TextView) ll.findViewById(R.id.session_date)).setText(prefsUserSession.getString("date", "undefined"));
}
((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getString(getString(R.string.sessionProgress), "0"));
((TextView) ll.findViewById(R.id.session_progress)).setText("" + prefsUserSession.getString("progress", "0"));
// display only filename
String file = new File(prefsUserSession.getString(getString(R.string.sessionInputFile), "undefined")).getName();
String file = new File(prefsUserSession.getString("inputFile", "undefined")).getName();
((TextView) ll.findViewById(R.id.session_input_file)).setText(file);
}
}
public void eraseFiles() {
File savedFile;
String savedMode = prefsUserSession.getString(getString(R.string.sessionMode), null);
String savedSubmode = prefsUserSession.getString(getString(R.string.session_submode), "undefined");
String savedMode = prefsUserSession.getString("mode", null);
String savedSubmode = prefsUserSession.getString("submode", "undefined");
if(BuildConfig.DEBUG)Log.d(TAG, "saved mode: "+savedMode);
if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode);
/*Check Mode*/
if (savedMode.compareToIgnoreCase(CheckWordVariant.TAG) == 0 || savedMode.compareTo(CheckTranscription.TAG) == 0) {
savedFile = new File(prefsUserSession.getString(getString(R.string.sessionCheckExportFile),"undefined"));
savedFile = new File(prefsUserSession.getString("checkExportFile","undefined"));
if(BuildConfig.DEBUG)Log.d(TAG, "saved file: "+savedFile);
savedFile.delete();
if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedFile);
......@@ -299,9 +295,9 @@ public class ModeSelection extends Activity implements OnClickListener{
} else if (savedMode.compareToIgnoreCase(RecordElicitation.TAG) == 0) {
if(BuildConfig.DEBUG)Log.d(TAG, "saved submode: "+savedSubmode);
String idDevice = Aikuma.getDeviceId();
String savedDate = prefsUserSession.getString(getString(R.string.sessionDate), "");
Language savedRecordLang = new Language(prefsUserSession.getString(getString(R.string.language_name), ""),
prefsUserSession.getString(getString(R.string.languageCode), ""));
String savedDate = prefsUserSession.getString("date", "");
Language savedRecordLang = new Language(prefsUserSession.getString("Language name", ""),
prefsUserSession.getString("LanguageCode", ""));
String name = savedDate + "_" +
savedRecordLang.getCode() + "_" + idDevice;
//erase linker
......@@ -310,7 +306,7 @@ public class ModeSelection extends Activity implements OnClickListener{
savedTextFile.delete();
if(BuildConfig.DEBUG)Log.i(TAG, "saved file erased: "+savedTextFile);
//erase metadata and audio files
int savedProgress = prefsUserSession.getInt(getString(R.string.currentLine), 0);
int savedProgress = prefsUserSession.getInt("currentLine", 0);
if(BuildConfig.DEBUG)Log.d(TAG, "saved progress: "+savedProgress);
for (int i=savedProgress; i>=0; i--) {
File savedMetadataFile = new File(FileIO.getOwnerPath()+"/recordings/"+name + "/" + name + "_" + i + RecordingLig.METADATA_SUFFIX);
......@@ -347,7 +343,7 @@ public class ModeSelection extends Activity implements OnClickListener{
// }
//}
Toast.makeText(this, "Session and files erased.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.session_and_files_erased, Toast.LENGTH_LONG).show();
}
}
......@@ -8,6 +8,8 @@ import android.media.AudioManager;
import android.media.MediaPlayer;
import android.util.Log;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.model.Recording;
......@@ -39,7 +41,7 @@ public class SimplePlayer extends Player implements Sampler
*/
public SimplePlayer(Recording recording, boolean playThroughSpeaker) throws IOException {
setRecording(recording);
mediaPlayer = new MediaPlayer();
mediaPlayer = MediaPlayerFactory.getNewMediaPlayer();
mediaPlayer.setAudioStreamType((playThroughSpeaker)?AudioManager.STREAM_MUSIC:AudioManager.STREAM_VOICE_CALL);
if(BuildConfig.DEBUG)Log.i("SimplePlayer", "Media Player - data source: " + recording.getFile().getCanonicalPath());
mediaPlayer.setDataSource(recording.getFile().getCanonicalPath());
......@@ -190,7 +192,7 @@ public class SimplePlayer extends Player implements Sampler
//Never use
//protected void setFinishedPlaying(boolean finished) {this.finishedPlaying = finished;}
protected Recording getRecording() {
public Recording getRecording() {
return recording;
}
......
......@@ -151,17 +151,15 @@ public class Microphone {
private static AudioRecord getListener(
int sampleRate, int audioFormat, int channelConfig) {
// Sample size.
int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8;
// Channels.
int numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2;
// Sample size and Channels.
int sampleSize = (audioFormat == AudioFormat.ENCODING_PCM_16BIT)? 16: 8,
numberOfChannels = (channelConfig == AudioFormat.CHANNEL_IN_MONO)? 1: 2,
// Calculate buffer size.
/** The period used for callbacks to onBufferFull. */
int framePeriod = sampleRate * 120 / 1000;
framePeriod = sampleRate * 120 / 1000,
/** The buffer needed for the above period */
int bufferSize = framePeriod * 2 * sampleSize * numberOfChannels / 8;
bufferSize = framePeriod * 2 * sampleSize * numberOfChannels / 8;
return new AudioRecord(MediaRecorder.AudioSource.MIC,
sampleRate, AudioFormat.CHANNEL_IN_MONO,
......
......@@ -274,8 +274,7 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
// Append all audio-values in srcBuffer to audioBuffer
private void storeBuffer(short[] srcBuffer) {
if(audioBuffer.length < audioBufLength + srcBuffer.length) {
int newBufLength = 2 * audioBuffer.length;
short[] newBuffer = new short[newBufLength];
short[] newBuffer = new short[(2 * audioBuffer.length)];
System.arraycopy(audioBuffer, 0, newBuffer, 0, audioBufLength);
audioBuffer = newBuffer;
}
......@@ -303,10 +302,8 @@ public class Recorder implements AudioHandler, MicrophoneListener, Sampler {
totalAudioLength += buffer.length;
if (this.type == 0 &&
Math.round((double) totalAudioLength / sampleRate) < Recording.SAMPLE_SEC) // 15sec sample
{
sampleFile.write(buffer);
}
}
public long getTotalAudioLength() {
......
......@@ -41,8 +41,7 @@ public class ThumbRespeaker {
public ThumbRespeaker(Recording original, UUID respeakingUUID,
int rewindAmount) throws Microphone.MicException, IOException {
if(BuildConfig.DEBUG)Log.d("Rte-ThumbRespeaker", "smp : " + original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(),
respeakingUUID + ".wav"), original.getSampleRate());
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false);
......@@ -60,10 +59,9 @@ public class ThumbRespeaker {
* @throws MicException If the microphone couldn't be used.
* @throws IOException If there is an I/O issue.
*/
public ThumbRespeaker(RecordingLig original, UUID respeakingUUID,
int rewindAmount) throws MicException, IOException {
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(),
respeakingUUID + ".wav"), original.getSampleRate());
public ThumbRespeaker(RecordingLig original, UUID respeakingUUID, int rewindAmount)
throws MicException, IOException {
recorder = new Recorder(1, new File(Recording.getNoSyncRecordingsPath(), respeakingUUID + ".wav"), original.getSampleRate());
player = new SimplePlayer(original, true);
mapper = new Mapper(respeakingUUID);
setFinishedPlaying(false);
......
......@@ -1410,8 +1410,8 @@ public class Recording extends FileModel {
*/
/*
public static void enableSync(String id) throws IOException {
File wavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav");
FileUtils.moveFileToDirectory(wavFile, getRecordingsPath(), false);
File WavFile = new File(getNoSyncRecordingsPath(), uuid + ".wav");
FileUtils.moveFileToDirectory(WavFile, getRecordingsPath(), false);
}
*/
......
......@@ -66,33 +66,31 @@ public class CheckTranscription extends AikumaActivity {
initProgressBars();
if(BuildConfig.DEBUG)Log.d("dataPath", dataPath);
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
//case: session already exists
boolean append;
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) {
if (prefsUserSession.getBoolean("active", false)) {
//retrieve selected file handled in the last session
transcripTextFile = prefsUserSession.getString(getString(R.string.sessionInputFile),null);
transcripTextFile = prefsUserSession.getString("inputFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected import file: " + transcripTextFile);
//retrieve result file handled in the last session
transcriptChecked = prefsUserSession.getString(getString(R.string.sessionCheckExportFile),null);
transcriptChecked = prefsUserSession.getString("checkExportFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected export file: " + transcriptChecked);
//retrieve number of lines already handled in the last session
//nbReadLines = Integer.parseInt(prefsUserSession.getString(getString(R.string.sessionProgress),"0"));
nbReadLines = prefsUserSession.getInt(getString(R.string.currentLine), 0);
nbReadLines = prefsUserSession.getInt("currentLine", 0);
if(BuildConfig.DEBUG)Log.i(TAG, "onCreate - #sentences treated: " + nbReadLines);
append = true;
// clear the current stored session
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.clear();
ed.commit();
prefsUserSession.edit().clear().apply();
isNewSession = false;
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+isNewSession);
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+ false);
//case: no session
} else {
transcripTextFile = getIntent().getStringExtra(CheckMode.importFileName);
if(BuildConfig.DEBUG)Log.i(TAG, "Is it a new session ? "+isNewSession);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected file: " + transcripTextFile);
if(BuildConfig.DEBUG){Log.i(TAG, "Is it a new session ? "+isNewSession);
Log.i(TAG, "Selected file: " + transcripTextFile);}
append = false;
//output filename
transcriptChecked = transcripTextFile.replace(".txt", "_"+date+"_CHECKED.txt");
......@@ -307,13 +305,13 @@ public class CheckTranscription extends AikumaActivity {
*/
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.putBoolean(getString(R.string.sessionActive), true); //session activated
ed.putInt(getString(R.string.currentLine), nbReadLines); //nb lines
ed.putString(getString(R.string.sessionProgress), nbReadLines + " / " + nb_total_lines);
ed.putString(getString(R.string.sessionInputFile), transcripTextFile); //handled file
ed.putString(getString(R.string.sessionCheckExportFile), transcriptChecked); //resulting file
ed.putString(getString(R.string.sessionDate), date); //set date
ed.putString(getString(R.string.sessionMode),TAG); //set mode
ed.putBoolean("active", true); //session activated
ed.putInt("currentLine", nbReadLines); //nb lines
ed.putString("progress", nbReadLines + " / " + nb_total_lines);
ed.putString("inputFile", transcripTextFile); //handled file
ed.putString("checkExportFile", transcriptChecked); //resulting file
ed.putString("date", date); //set date
ed.putString("mode",TAG); //set mode
// ed.putBoolean(getString(R.string.checkTranscript), true); //set submode
//save infos
ed.commit();
......@@ -354,9 +352,8 @@ public class CheckTranscription extends AikumaActivity {
try {
if(BuildConfig.DEBUG)Log.i("saveFile", "Writing on file");
//if checked
if (transcriptOK.isChecked()) {
if(transcriptOK.isChecked())
outputFile.write(transcriptID.getText()+" : "+transcriptOK.getText()+"\n");
}
} catch (IOException e1) {e1.printStackTrace();}
return true;
}
......
......@@ -53,9 +53,9 @@ public class CheckWordVariant extends AikumaActivity {
setContentView(R.layout.check_word_variant);
initProgressBars();
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
prefsUserSession = getSharedPreferences(getString(R.string.userSession), MODE_PRIVATE);
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
//case: session already exists
if (prefsUserSession.getBoolean(getString(R.string.sessionActive), false)) {
if (prefsUserSession.getBoolean("active", false)) {
/*
* TODO rajouter une condition en &&
* soustraire date.now à date session :
......@@ -63,18 +63,17 @@ public class CheckWordVariant extends AikumaActivity {
* sinon continue;
*/
//retrieve selected file handled in the last session
variantTextFile = prefsUserSession.getString(getString(R.string.sessionInputFile),null);
variantTextFile = prefsUserSession.getString("inputFile", null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected import file: " + variantTextFile);
//retrieve result file handled in the last session
variantchecked = prefsUserSession.getString(getString(R.string.sessionCheckExportFile),null);
variantchecked = prefsUserSession.getString("checkExportFile",null);
if(BuildConfig.DEBUG)Log.i(TAG, "Selected export file: " + variantchecked);
//retrieve number of lines already handled in the last session
nbReadLines = prefsUserSession.getInt(getString(R.string.nbReadLines),0);
nbReadLines = prefsUserSession.getInt("nbReadLine",0);
append = true;
// clear the current stored session
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.clear(); ed.commit();
prefsUserSession.edit().clear().apply();
//case: no session
} else {
variantTextFile = getIntent().getStringExtra(CheckMode.importFileName);
......@@ -304,16 +303,16 @@ public class CheckWordVariant extends AikumaActivity {
Toast.makeText(this, R.string.the_session_has_been_saved, Toast.LENGTH_SHORT).show();
date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.FRANCE).format(new Date());
SharedPreferences.Editor ed = prefsUserSession.edit();
ed.putBoolean(getString(R.string.sessionActive), true); //session activated
ed.putInt(getString(R.string.nbReadLines), nbReadLines); //nb lines
ed.putString(getString(R.string.sessionProgress), nbReadLines + "/" + totalNumberOfExpressions);
ed.putString(getString(R.string.sessionInputFile), variantTextFile); //handled file
ed.putString(getString(R.string.sessionCheckExportFile), variantchecked); //resulting file
ed.putString(getString(R.string.sessionDate), date); //set date
ed.putString(getString(R.string.sessionMode),TAG); //set mode
ed.putBoolean("active", true); //session activated
ed.putInt("nbReadLine", nbReadLines); //nb lines
ed.putString("progress", nbReadLines + "/" + totalNumberOfExpressions);
ed.putString("inputFile", variantTextFile); //handled file
ed.putString("checkExportFile", variantchecked); //resulting file
ed.putString("date", date); //set date
ed.putString("mode",TAG); //set mode
// ed.putBoolean(getString(R.string.checkVariant), true); //set submode
//save infos
ed.commit();
ed.apply();
}
} catch (IOException e) {
e.printStackTrace();
......
......@@ -91,8 +91,8 @@ public class CloudSearchActivity extends AikumaListActivity {
isMediaPlayerPrepared = false;
setUpQuickMenu();
recordings = new ArrayList<Recording>();
itemIdsToDownload = new ArrayList<String>();
recordings = new ArrayList<>();
itemIdsToDownload = new ArrayList<>();
adapter = new RecordingArrayAdapter(this, recordings, quickMenu);
setListAdapter(adapter);
......@@ -176,7 +176,7 @@ public class CloudSearchActivity extends AikumaListActivity {
// Creates the quickMenu for the original recording
//(quickMenu: download)
private void setUpQuickMenu() {
quickMenu = new QuickActionMenu<Recording>(this);
quickMenu = new QuickActionMenu<>(this);
if(AikumaSettings.getCurrentUserToken() != null) {
QuickActionItem sampleDownloadAct = new QuickActionItem("Sample", R.drawable.download_32);
......@@ -224,7 +224,7 @@ public class CloudSearchActivity extends AikumaListActivity {
String sampleCloudId = new FileModel(recording.getVersionName(),
recording.getOwnerId(), recording.getPreviewId(), "preview", "wav").
getCloudIdentifier(0);
List<String> cloudId = new ArrayList<String>();
List<String> cloudId = new ArrayList<>();
cloudId.add(sampleCloudId);
new RequestShareFileTask(cloudId, googleEmailAccount, googleAuthToken).execute();
......@@ -290,10 +290,10 @@ public class CloudSearchActivity extends AikumaListActivity {
this.mAccessToken = accessToken;
this.mQuery = query;
constraints = new TreeMap<String, String>();
cloudIdsToDownload = new ArrayList<String>();
metadataToWrite = new HashMap<String, String>();
speakerIdsToDownload = new ArrayList<String>();
constraints = new TreeMap<>();
cloudIdsToDownload = new ArrayList<>();
metadataToWrite = new HashMap<>();
speakerIdsToDownload = new ArrayList<>();
}
@Override
......@@ -390,7 +390,7 @@ public class CloudSearchActivity extends AikumaListActivity {
// String metadataJSONStr = result.get("metadata");
// metadataToWrite.put(identifier, metadataJSONStr);
FileModel fm = FileModel.fromCloudId(identifier);
String metadataCloudId = fm.getCloudIdentifier(1);
String metadataCloudId = (fm != null)?fm.getCloudIdentifier(1):null;
cloudIdsToDownload.add(metadataCloudId);
}
......@@ -419,7 +419,7 @@ public class CloudSearchActivity extends AikumaListActivity {
File dir = new File(FileIO.getAppRootPath(), relPath);
dir.mkdirs();
if(BuildConfig.DEBUG)Log.i(TAG, dir.getAbsolutePath() + ", " + fileModel.getMetadataIdExt());
if(BuildConfig.DEBUG)Log.i(TAG, dir.getAbsolutePath() + ", " + ((fileModel != null)?fileModel.getMetadataIdExt():""));
FileIO.writeJSONObject(new File(dir, fileModel.getMetadataIdExt()), jsonObj);
} catch (ParseException | IOException e) {
if(BuildConfig.DEBUG)Log.e(TAG, e.getMessage());
......@@ -507,10 +507,8 @@ public class CloudSearchActivity extends AikumaListActivity {
if(BuildConfig.DEBUG)Log.i(TAG, "autodownload start");
Intent syncIntent = new Intent(CloudSearchActivity.this, GoogleCloudService.class);
syncIntent.putExtra(GoogleCloudService.ACTION_KEY, "autoDownload");
syncIntent.putExtra(GoogleCloudService.ACCOUNT_KEY,
AikumaSettings.getCurrentUserId());
syncIntent.putExtra(GoogleCloudService.TOKEN_KEY,
AikumaSettings.getCurrentUserToken());
syncIntent.putExtra(GoogleCloudService.ACCOUNT_KEY, AikumaSettings.getCurrentUserId());
syncIntent.putExtra(GoogleCloudService.TOKEN_KEY, AikumaSettings.getCurrentUserToken());
syncIntent.putStringArrayListExtra("downloadItems", mSharedFileCloudIds);
startService(syncIntent);
......@@ -543,8 +541,7 @@ public class CloudSearchActivity extends AikumaListActivity {
protected Boolean doInBackground(Void... params) {
DataStore gd;
try {
gd = new GoogleDriveStorage(mAccessToken,
AikumaSettings.ROOT_FOLDER_ID, AikumaSettings.CENTRAL_USER_ID);
gd = new GoogleDriveStorage(mAccessToken, AikumaSettings.ROOT_FOLDER_ID, AikumaSettings.CENTRAL_USER_ID);
} catch (DataStore.StorageException e) {
if(BuildConfig.DEBUG)Log.e(TAG, "Failed to initialize GoogleDriveStorage");
return false;
......@@ -578,15 +575,13 @@ public class CloudSearchActivity extends AikumaListActivity {
@Override
protected void onPostExecute(final Boolean result) {
if (result) {
Toast.makeText(CloudSearchActivity.this,
R.string.sample_is_downloaded,
Toast.LENGTH_LONG).show();
Toast.makeText(CloudSearchActivity.this, R.string.sample_is_downloaded, Toast.LENGTH_LONG).show();
/*
if(!isMediaPlayerReleased) {
setUpPlayer(mFile);
mediaPlayer.start();
}*/
} else {
//} else {
//Aikuma.showAlertDialog(getApplicationContext(), "Error in downloading a file");
}
......
......@@ -94,7 +94,7 @@ public class DebugInfo extends Activity {
mPref.edit()
.putString(AikumaSettings.SETTING_AUTH_TOKEN_KEY, toks[0])
.putString("id_token", toks[1])
.commit();
.apply();
displayTokens();
break;
default:
......@@ -158,11 +158,11 @@ public class DebugInfo extends Activity {
if (tokens == null)
if(BuildConfig.DEBUG)Log.i(TAG, "failed");
else {
final String[] toks = tokens;
final String[] toks = null;
mPref.edit()
.putString(AikumaSettings.SETTING_AUTH_TOKEN_KEY, tokens[0])
.putString("id_token", tokens[1])
.commit();
.apply();
new AsyncTask<Void,Void,Void>() {
@Override
......@@ -388,14 +388,13 @@ public class DebugInfo extends Activity {
StringBuffer hexString = new StringBuffer();
String prefix = "";
for (int i = 0; i < publicKey.length; i++) {
String appendString = Integer.toHexString(0xFF & publicKey[i]);
for(byte aPublicKey : publicKey) {
String appendString = Integer.toHexString(0xFF & aPublicKey);
if (appendString.length() == 1) hexString.append("0");
hexString.append(prefix);
hexString.append(appendString.toUpperCase());
prefix = ":";
}
return hexString.toString();
} catch (CertificateEncodingException e) {
e.printStackTrace();
......
......@@ -195,7 +195,7 @@ public class ElicitationMode extends AikumaActivity{
intent.putExtra(importFileName, mPath.getAbsolutePath());
if(BuildConfig.DEBUG)Log.i(TAG, "selected file: " + mPath.getAbsolutePath());
intent.putExtra(ELICITATION, true);
intent.putExtra(getString(R.string.selectedFileType), selectedFileType);
intent.putExtra("selectedFileType", selectedFileType);
startActivity(intent);