Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Warwick Stone committed May 9, 2017
2 parents f749c3f + 5d4f473 commit 39a7d4a
Show file tree
Hide file tree
Showing 67 changed files with 1,698 additions and 596 deletions.
5 changes: 4 additions & 1 deletion LanguageRecorder/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ proguard/
# Android Studio
.idea
apks/
EQPay-Android.iml
LanguageRecorder.iml

# API keys
api_keys.*
7 changes: 4 additions & 3 deletions LanguageRecorder/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ android {
}
}

def supportLibVersion = '22.1.10'
def appCompatVersion = '22.2.0'
def supportLibVersion = '22.2.1'

def dropBoxSdkVersion = '1.6'

dependencies {
compile project(':ion')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${appCompatVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"

compile 'com.google.code.gson:gson:2.5'
Expand Down
8 changes: 8 additions & 0 deletions LanguageRecorder/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.common.InterviewerActivity"
android:label="@string/title_activity_interviewer" >
</activity>
<activity
android:name=".activity.common.YesNoActivity"
android:label="@string/app_name" >
Expand Down Expand Up @@ -144,6 +148,10 @@
android:name=".activity.recording.RecordingInstructionsActivity"
android:label="Recording" >
</activity>
<activity
android:name=".activity.recording.InterviewResponseLanguageActivity"
android:label="Recording" >
</activity>
<activity
android:name=".activity.common.AppSettingsActivity"
android:label="@string/title_activity_app_settings" >
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.rhok.linguist.activity.common;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import android.widget.Toast;

import com.androidquery.AQuery;

import org.rhok.linguist.R;
import org.rhok.linguist.api.models.Interviewer;
import org.rhok.linguist.code.PreferencesHelper;

/**
* Create / edit the single interviewer instance
* Created by bramleyt on 11/03/2017.
*/
public class InterviewerActivity extends AppCompatActivity{
private AQuery aq;
private Interviewer interviewer;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_interviewer);
aq = new AQuery(this);

aq.id(R.id.emailEditText).getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId== EditorInfo.IME_ACTION_DONE){
nextButtonClick(v);
return true;
}
return false;
}
});

if(savedInstanceState!=null){
interviewer = (Interviewer) savedInstanceState.getSerializable("interviewer");
}
if(interviewer==null)
interviewer = PreferencesHelper.getInterviewer();
if(interviewer==null)
interviewer = PreferencesHelper.createDefaultInterviewer();
modelToUI();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable("interviewer", interviewer);
}

private void modelToUI(){
aq.id(R.id.nameEditText).text(interviewer.getName());
aq.id(R.id.mobileEditText).text(interviewer.getMobile());
aq.id(R.id.emailEditText).text(interviewer.getEmail());

}
public void nextButtonClick(View v){
interviewer.setName(aq.id(R.id.nameEditText).getText().toString().trim());
interviewer.setMobile(aq.id(R.id.mobileEditText).getText().toString().trim());
interviewer.setEmail(aq.id(R.id.emailEditText).getText().toString().trim());
PreferencesHelper.saveInterviewer(interviewer);
setResult(RESULT_OK);
Toast.makeText(this, "Interviewer Updated", Toast.LENGTH_SHORT).show();
finish();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ public class PersonListActivity extends AppCompatActivity implements AdapterView
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);

boolean hasNext = getIntent().hasExtra(IntentUtil.ARG_NEXT_INTENT);
findViewById(R.id.nextbutton).setVisibility(hasNext?View.VISIBLE:View.GONE);

listView= (ListView) findViewById(R.id.listview);
listView.setOnItemClickListener(this);
DatabaseHelper dbHelper = new DatabaseHelper(this);
Person[] people = dbHelper.getPeople();
PersonAdapter adapter = new PersonAdapter( people);
listView.setAdapter(adapter);

}

public void nextButtonClick(View view){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import org.rhok.linguist.R;
import org.rhok.linguist.activity.IntentUtil;
import org.rhok.linguist.activity.interview.InterviewNameActivity;
import org.rhok.linguist.activity.old.HomeActivity;
import org.rhok.linguist.activity.old.UploadActivity;
import org.rhok.linguist.activity.recording.InterviewResponseLanguageActivity;
import org.rhok.linguist.activity.recording.RecordingInstructionsActivity;
import org.rhok.linguist.api.models.Interviewer;
import org.rhok.linguist.application.LinguistApplication;
import org.rhok.linguist.code.LocaleHelper;
import org.rhok.linguist.code.PreferencesHelper;
import org.rhok.linguist.util.StringUtils;


public class SplashActivity extends AppCompatActivity {

private Interviewer interviewer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -27,6 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
//ActionBar actionBar = getSupportActionBar();
//actionBar.hide();


}


Expand All @@ -53,10 +61,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_settings:
intent = new Intent(this, AppSettingsActivity.class);
break;
case R.id.action_skip:
intent = new Intent(this, RecordingInstructionsActivity.class);
intent.putExtra(IntentUtil.ARG_PERSON_ID, 1);
break;

case R.id.action_upload:
intent = new Intent(this, UploadInterviewsActivity.class);
break;
Expand All @@ -65,6 +70,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case R.id.menu_person_list:
intent = new Intent(this, PersonListActivity.class);
break;
case R.id.action_edit_interviewer:
editInterviewerClick(null);
break;
}
if(intent!=null){
startActivity(intent);
Expand All @@ -83,6 +92,15 @@ protected void onResume() {
if (LocaleHelper.updateLocale(getBaseContext(), this)) {
this.recreate();
}
interviewer = PreferencesHelper.getInterviewer();
if (interviewer==null){
//create default
interviewer = PreferencesHelper.createDefaultInterviewer();
PreferencesHelper.saveInterviewer(interviewer);
}
getSupportActionBar().setSubtitle(getString(R.string.interviewer_name_format,
interviewer.getName())) ;


}

Expand All @@ -92,4 +110,8 @@ public void nextButtonClick(android.view.View view) {
startActivity(intent);
}

public void editInterviewerClick(View view) {
Intent intent = new Intent(this, InterviewerActivity.class);
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.koushikdutta.ion.Response;

import org.rhok.linguist.R;
import org.rhok.linguist.activity.IntentUtil;
import org.rhok.linguist.activity.interview.InterviewNameActivity;
import org.rhok.linguist.activity.recording.RecordingInstructionsActivity;
import org.rhok.linguist.activity.recording.InterviewResponseLanguageActivity;
import org.rhok.linguist.api.OfflineStorageHelper;
import org.rhok.linguist.api.models.Phrase;
import org.rhok.linguist.api.models.Study;
import org.rhok.linguist.application.LinguistApplication;
import org.rhok.linguist.code.StudyDownloader;
import org.rhok.linguist.network.BaseIonCallback;
import org.rhok.linguist.network.IonHelper;
import org.rhok.linguist.util.UIUtil;
Expand All @@ -37,8 +38,8 @@ public class StudyListActivity extends AppCompatActivity implements AdapterView.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
listView= (ListView) findViewById(R.id.listview);
setContentView(R.layout.activity_study);
listView= (ListView) findViewById(R.id.study_list);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemClickListener(this);
mProgressBar= (ProgressBar) findViewById(R.id.progress);
Expand All @@ -48,35 +49,32 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();
final OfflineStorageHelper helper = new OfflineStorageHelper(this);
// mStudies = helper.getStudyListFromAssets(R.raw.test_study_list);
if(mStudies==null){
OfflineStorageHelper helper = new OfflineStorageHelper(this);
mStudies=helper.getStudyListFromAssets(R.raw.test_study_list);
//STOPSHIP quick hack to grab all /phrases.json from API for demo
IonHelper ionHelper = new IonHelper();
ionHelper.doGet(ionHelper.getIon().build(this), PhraseList.class, "/phrases.json")
ionHelper.doGet(ionHelper.getIon().build(this), StudyList.class, "/studies.json")
.go()
.setCallback(new BaseIonCallback<PhraseList>() {
.setCallback(new BaseIonCallback<StudyList>() {
@Override
public void onSuccess(PhraseList result) {
for(Phrase phrase:result){
//response_type was missing
if(phrase.getResponse_type()==0)phrase.setResponse_type(Phrase.TYPE_TEXT);
phrase.setAudio(null);
}
Study apiStudy = new Study();
apiStudy.setName("API Study");
apiStudy.setId(-1);
apiStudy.setInstructions("Demo from API");
apiStudy.setPhrases(result);
mStudies.add(mStudies.size(), apiStudy);
public void onSuccess(StudyList result) {
mStudies=result;
helper.writeStudyList(result);
updateListView();
}
});

@Override
public void onError(Response<StudyList> response) {
//error loading from network, load from disk if avail
mStudies = helper.getSavedStudyList();
updateListView();
super.onError(response);
}
});
}
updateListView();
}
public static class PhraseList extends ArrayList<Phrase>{
public static class StudyList extends ArrayList<Study>{

}

Expand All @@ -101,11 +99,22 @@ public void nextButtonClick(View view){
}
}

public void downloadAllButtonClick(View view) {
Toast.makeText(getApplicationContext(), "Downloading all studies", Toast.LENGTH_SHORT).show();
StudyDownloader downloader = new StudyDownloader(this);
downloader.downloadAll(mStudies, new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "All studies downloaded", Toast.LENGTH_SHORT).show();
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==REQUEST_YES_NO){
if(requestCode==REQUEST_YES_NO && resultCode!=RESULT_CANCELED){
Intent intent = null;
Intent recordingStartIntent = new Intent(this, RecordingInstructionsActivity.class);
Intent recordingStartIntent = new Intent(this, InterviewResponseLanguageActivity.class);
Study study = (Study) data.getBundleExtra(IntentUtil.ARG_NEXT_ACTIVITY_ARGS).getSerializable(IntentUtil.ARG_STUDY);
recordingStartIntent.putExtra(IntentUtil.ARG_STUDY, study);
if(resultCode==YesNoActivity.RESULT_YES){
Expand Down
Loading

0 comments on commit 39a7d4a

Please sign in to comment.