Commit 5b357fc7 authored by CallisteHanriat's avatar CallisteHanriat

Adding pastilles and background color for good files + icons

pastille ok

Adding identification for trsl and rspk files + delete unused boolean
parent f4482779
......@@ -3,10 +3,35 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="75dp"
android:layout_height="50dp"
android:src="@drawable/folder_close_icon"
android:id="@+id/image_file_type"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize = "16dp"
android:layout_toRightOf="@+id/image_file_type"
android:gravity="center_vertical"
android:id="@+id/textFileName"/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/image_pastille_trsl"
android:src="@drawable/pastille_trsl"
android:layout_alignParentRight="true"
android:visibility="invisible"
/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/image_pastille_rspk"
android:layout_toLeftOf="@+id/image_pastille_trsl"
android:src="@drawable/pastille_rspk"
android:visibility="invisible"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:id="@+id/layoutListView">
<ImageView
android:layout_width="75dp"
android:layout_height="50dp"
android:src="@drawable/folder_close_icon"
android:id="@+id/image_file_type"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize = "16dp"
android:layout_height="33dp"
android:layout_centerVertical="true"
android:textSize = "14dp"
android:layout_toRightOf="@+id/image_file_type"
android:gravity="center_vertical"
android:id="@+id/textFileName"/>
android:id="@+id/textFileName"
/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/image_pastille_trsl"
android:src="@drawable/pastille_trsl"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_below="@+id/textFileName"
/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="@+id/image_pastille_rspk"
android:layout_toLeftOf="@+id/image_pastille_trsl"
android:src="@drawable/pastille_rspk"
android:visibility="invisible"
android:layout_below="@+id/textFileName"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_rspk">#CC123E7C</color>
<color name="color_trsl">#CC127C1F</color>
</resources>
......@@ -202,7 +202,6 @@ public class CheckTranscription extends AikumaActivity {
*/
public int countNumberOfLines() throws IOException {
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(transcripTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
......
......@@ -263,7 +263,6 @@ public class CheckWordVariant extends AikumaActivity {
*/
public int countNumberOfLines() throws IOException {
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(variantTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
......
package org.lp20.aikuma.ui;
import java.io.File;
import org.lp20.aikuma2.R;
import android.R.color;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Color;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class ListFileAdapter extends ArrayAdapter {
private LayoutInflater layoutInflater;
private ContentResolver contentResolver;
private File parentFile;
static class ViewHolder {
public TextView textFileName;
public ImageView imageType;
public ImageView imagePastilleRspk;
public ImageView imagePastilleTrsl;
}
public ListFileAdapter(Context context, String[] files) {
public ListFileAdapter(Context context, String[] files, File parentFile) {
super(context, R.layout.content_dialog_select_file_frag, files);
this.layoutInflater = LayoutInflater.from(context);
this.contentResolver = context.getContentResolver();
this.parentFile = parentFile;
}
@Override
......@@ -35,21 +41,71 @@ public class ListFileAdapter extends ArrayAdapter {
rowView = this.layoutInflater.inflate(R.layout.content_dialog_select_file_frag, null);
holder = new ViewHolder();
holder.textFileName = (TextView) rowView.findViewById(R.id.textFileName);
holder.imageType = (ImageView) rowView.findViewById(R.id.image_file_type);
holder.imagePastilleRspk = (ImageView) rowView.findViewById(R.id.image_pastille_rspk);
holder.imagePastilleTrsl = (ImageView) rowView.findViewById(R.id.image_pastille_trsl);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
String fileName = (String) getItem(position);
File file = new File(parentFile.getAbsolutePath()+"/"+fileName);
holder.textFileName.setText(fileName);
if (fileName.contains("rspk") && fileName.contains(".wav"))
holder.textFileName.setBackgroundColor(Color.GREEN);
else if (fileName.contains("trsl") && fileName.contains(".wav")){
holder.textFileName.setBackgroundColor(Color.CYAN);
} else {
holder.textFileName.setBackgroundColor(Color.TRANSPARENT);
RelativeLayout relativeListFile = (RelativeLayout) rowView.findViewById(R.id.layoutListView);
if (!file.isDirectory()) {
if (fileName.contains("rspk") && fileName.contains(".wav")) {
relativeListFile.setBackgroundColor(Color.parseColor("#80673AB7"));
}
else if (fileName.contains("trsl") && fileName.contains(".wav")){
relativeListFile.setBackgroundColor(Color.parseColor("#80FF9800"));
}else {
relativeListFile.setBackgroundColor(Color.TRANSPARENT);
}
holder.imageType.setImageResource(R.drawable.file_icon);
} else {
ListFileTask task = new ListFileTask();
task.setHolder(holder);
task.execute(file);
}
return rowView;
}
private class ListFileTask extends AsyncTask<File, Integer, File[]> {
ViewHolder holder;
protected void setHolder (ViewHolder viewHolder) {
holder = viewHolder;
}
@Override
protected File[] doInBackground(File... f) {
return f[0].listFiles();
}
@Override
protected void onPostExecute(File[] files) {
boolean rspk = false;
boolean trsl = false;
int i = 0;
while (i<files.length && (!rspk || !trsl)) {
if (files[i].getName().contains("trsl")) {
holder.imagePastilleTrsl.setVisibility(ImageView.VISIBLE);
trsl = true;
}
else if (files[i].getName().contains("rspk")) {
holder.imagePastilleRspk.setVisibility(ImageView.VISIBLE);
rspk= true;
}
else {
holder.imagePastilleRspk.setVisibility(ImageView.INVISIBLE);
holder.imagePastilleTrsl.setVisibility(ImageView.INVISIBLE);
}
i++;
}
}
}
}
......@@ -364,7 +364,6 @@ public class RecordElicitation extends AikumaActivity {
*/
public int countNumberOfLines() throws IOException {
int nbLine = 0;
boolean finFichier = false;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(eliciTextFile)));
String phrase;
while ((phrase = bufferedReader.readLine()) != null) {
......
......@@ -5,9 +5,11 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.parser.MLSxEntryParser;
import org.lp20.aikuma.ModeSelection;
import org.lp20.aikuma.MainActivity.FilebrowserDialogFragment;
import org.lp20.aikuma.model.Recording;
......@@ -49,6 +51,7 @@ public class RespeakingSelection extends AikumaActivity {
private File mPath;
private String[] mFileList;
private String mChosenFile;
/** Called when the activity is first created. */
@Override
......@@ -59,6 +62,7 @@ public class RespeakingSelection extends AikumaActivity {
if (translateMode) {
((TextView) findViewById(R.id.respeaking_title)).setText(R.string.translatemode);
}
//initializeAdapter();
}
public void onImportAudioClick(View _view) {
......@@ -123,12 +127,11 @@ public class RespeakingSelection extends AikumaActivity {
View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_select_file_frag, null);
listElement = (ListView) view.findViewById(R.id.listItemFile);
ListFileAdapter adapter = new ListFileAdapter(getActivity(), mFileList);
ListFileAdapter adapter = new ListFileAdapter(getActivity(), mFileList, mPath);
listElement.setAdapter(adapter);
//listElement.setOnItemClickListener(this);
listElement.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
dismiss();
......
......@@ -120,7 +120,7 @@ public class ThumbRespeakFragment extends Fragment {
}
String filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+count+".rspk.wav";
"/recordings/" + "temp.rspk.wav";
if (listenFragment.getPlayer() != null) {
listenFragment.getPlayer().release();
}
......@@ -130,7 +130,7 @@ public class ThumbRespeakFragment extends Fragment {
Log.i(TAG, "Deleting " + filename);
count--;
filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+count+".rspk.wav";
"/recordings/" + "temp.rspk.wav";
}
} catch (IOException e) {
Log.e(TAG, "failed to delete " + filename + " - maybe the file didn't exist");
......@@ -205,7 +205,7 @@ public class ThumbRespeakFragment extends Fragment {
count++;
String filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+count+".rspk.wav";
"/recordings/" + "temp.rspk.wav";
if (listenFragment.getPlayer() != null) {
listenFragment.getPlayer().release();
}
......@@ -242,7 +242,7 @@ public class ThumbRespeakFragment extends Fragment {
// save the latest segment in a temporary file
String filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+count+".rspk.wav";
"/recordings/" + "temp.rspk.wav";
int rate = respeaker.getRecorder().getMicrophone().getSampleRate();
PCMWriter file = PCMWriter.getInstance(rate,
respeaker.getRecorder().getMicrophone().getChannelConfiguration(),
......@@ -317,29 +317,11 @@ public class ThumbRespeakFragment extends Fragment {
* called when we need to set the previous
* recorded segment to the graphical listen fragment
*/
private void setPreviousPlayerToListenFragment() {
int rate = respeaker.getRecorder().getMicrophone().getSampleRate();
String filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+(count-1)+".rspk.wav";
if (count-1 == 0){
FragmentTransaction ft = getFragmentManager().beginTransaction();
listenFragment = new ListenFragment();
ft.replace(R.id.respeak_latest_segment_player, listenFragment);
ft.commit();
}else {
try {
SimplePlayer player = new SimplePlayer(new File(filename),
rate, true);
Log.i(TAG, "New SimplePlater of" + filename + " (rate: " + rate + ")");
listenFragment.setPlayer(player);
Log.d("passage", "fin setPreviousPLayer");
} catch (IOException e) {
Log.e(TAG, e.toString());
} catch (NoSuchElementException e) {
Log.e(TAG, e.toString());
}
}
private void resetPlayer() {
FragmentTransaction ft = getFragmentManager().beginTransaction();
listenFragment = new ListenFragment();
ft.replace(R.id.respeak_latest_segment_player, listenFragment);
ft.commit();
}
/**
......@@ -348,8 +330,7 @@ public class ThumbRespeakFragment extends Fragment {
*/
private void deleteLastTempFile() {
String filename = FileIO.getOwnerPath().getAbsolutePath() +
"/recordings/" + "temp"+count+".rspk.wav";
count--;
"/recordings/" + "temp.rspk.wav";
try {
FileIO.delete(new File(filename));
Log.i(TAG, "Deleting " + filename);
......@@ -381,8 +362,9 @@ public class ThumbRespeakFragment extends Fragment {
undo.setEnabled(false);
}
setPreviousPlayerToListenFragment();
resetPlayer();
deleteLastTempFile();
count--;
respeaker.goToPreviousSample();
int currentPosition =
respeaker.getSimplePlayer().getCurrentMsec();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment