Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added informed consent form
  • Loading branch information
cesine committed Aug 26, 2018
commit 3086add088852a981b0d88d16b073fc3304869f3
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;

import com.github.fielddb.Config;
import com.github.fielddb.database.DatumContentProvider;
import com.github.fielddb.KartuliSpeechRecognitionApplication;
import com.github.fielddb.experimentation.ui.ProductionExperimentActivity;
import com.github.fielddb.BugReporter;
import com.github.fielddb.datacollection.DeviceDetails;
Expand All @@ -13,14 +13,19 @@

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.speech.RecognizerIntent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

Expand All @@ -31,6 +36,9 @@ public class WelcomeActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
String language = ((KartuliSpeechRecognitionApplication)getApplication()).forceLocale(Config.DATA_IS_ABOUT_LANGUAGE_ISO);
Log.d(Config.TAG, "Language Lessons Set locale to " + language + " iso " + Config.DATA_IS_ABOUT_LANGUAGE_ISO);

super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_welcome);

Expand Down Expand Up @@ -121,6 +129,36 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
}

private boolean checkAndRequestPermissions() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Boolean informedConsent = prefs.getBoolean("informed_consent", false);
final WelcomeActivity activity = this;

if (!informedConsent) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.informed_consent_dialog, null));
builder.setPositiveButton(R.string.i_agree, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Log.d(Config.TAG, "user said okay");
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("informed_consent", true);
editor.commit();
activity.checkAndRequestPermissions();
}
});
builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
activity.finish();
}
});
builder.create();
builder.show();
return false;
}

List<String> listPermissionsNeeded = new ArrayList<>();

if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
Expand All @@ -137,4 +175,9 @@ public void goToWebSite(View view) {
Intent go = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://batumi.github.io"));
startActivity(go);
}
public void goToPrivacyPolicy(View view) {
Intent go = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://www.lingsync.org/privacy.html"));
startActivity(go);
}

}
31 changes: 31 additions & 0 deletions app/src/main/res/layout/informed_consent_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:layout_marginTop="20dp"
android:scaleType="center"
android:src="@mipmap/ic_launcher" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_explanation"
android:layout_marginBottom="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/privacy_policy" />
</LinearLayout>
</ScrollView>
</LinearLayout>