Skip to content

Commit

Permalink
Merge pull request #402 from sladomic/master
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
Jo Grimstad authored Apr 28, 2017
2 parents a23cb02 + be493a2 commit b755282
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 26 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.literacyapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1005009
versionName "1.5.9"
versionCode 1006000
versionName "1.6.0"

// jackOptions {
// enabled true
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/org/literacyapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ protected void onStart() {
return;
}

// Obtain permission to change system settings
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
/*// Obtain permission to change system settings
try {
RootHelper.runAsRoot(new String[] {"pm grant org.literacyapp android.permission.WRITE_SECURE_SETTINGS"});
} catch (IOException | InterruptedException e) {
Log.e(getClass().getName(), null, e);
}
}*/

LiteracyApplication literacyApplication = (LiteracyApplication) getApplication();
letterDao = literacyApplication.getDaoSession().getLetterDao();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authentication);

isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
/*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);
if (isDeviceRooted){
screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
}
}*/

authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);
Expand Down Expand Up @@ -269,7 +270,8 @@ public void run() {
private synchronized void startStudentImageCollectionActivity(boolean authenticationAnimationAlreadyPlayed){
Intent studentImageCollectionIntent = new Intent(getApplicationContext(), StudentImageCollectionActivity.class);
studentImageCollectionIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
studentImageCollectionIntent.putExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, isDeviceRooted);
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
//studentImageCollectionIntent.putExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, isDeviceRooted);
if (authenticationAnimationAlreadyPlayed){
studentImageCollectionIntent.putExtra(AUTHENTICATION_ANIMATION_ALREADY_PLAYED_IDENTIFIER, true);
studentImageCollectionIntent.putExtra(ANIMAL_OVERLAY_IDENTIFIER, animalOverlay.getName());
Expand Down Expand Up @@ -303,8 +305,9 @@ protected void onStop() {
mediaPlayerTabletPlacementOverlay.release();
mediaPlayerAnimalSound.stop();
mediaPlayerAnimalSound.release();
if (isDeviceRooted){
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
/*if (isDeviceRooted){
DetectionHelper.setDefaultScreenBrightnessAndMode(getApplicationContext(), screenBrightnessMode, screenBrightness, displayTemperatureNight);
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authentication_student_image_collection);

isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
/*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);
if (isDeviceRooted){
screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
}
}*/

authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);
Expand Down Expand Up @@ -313,8 +314,9 @@ protected void onStop() {
mediaPlayerAnimalSound.stop();
mediaPlayerAnimalSound.release();

if (isDeviceRooted){
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
/*if (isDeviceRooted){
DetectionHelper.setDefaultScreenBrightnessAndMode(getApplicationContext(), screenBrightnessMode, screenBrightness, displayTemperatureNight);
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public static boolean scheduleAfterBoot(Context context) {
}
}

public static boolean activateAuthentication(){
//UTC Thu May 11 2017 20:59:59
long activationTime = 1494536399000L;
long currentTime = System.currentTimeMillis();
boolean activated = currentTime > activationTime;
Log.i(StartPrefsHelper.class.getName(), "Authentication activated: " + activated + ", activationTime: " + new Date(activationTime) + ", currentTime: " + new Date(currentTime));
return activated;
}

private static long getFirstStartupDate(Context context) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
return sharedPreferences.getLong(PREF_FIRST_STARTUP_DATE, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public void run() {
if (didTheMinimumTimePassSinceLastExecution()){
Intent authenticationIntent = new Intent(context, AuthenticationActivity.class);
authenticationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
authenticationIntent.putExtra(IS_DEVICE_ROOTED_IDENTIFIER, RootHelper.isDeviceRooted());
//Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
//authenticationIntent.putExtra(IS_DEVICE_ROOTED_IDENTIFIER, RootHelper.isDeviceRooted());
context.startActivity(authenticationIntent);
Log.i(getClass().getName(), "The Authentication has been started.");
} else {
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/org/literacyapp/receiver/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ public void onReceive(Context context, Intent intent) {
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(jobInfo);

if (StartPrefsHelper.scheduleAfterBoot(context)){
/*if (StartPrefsHelper.scheduleAfterBoot(context)){
scheduleAuthenticationJobs(context);
} else {
Log.i(getClass().getName(), "Authentication jobs won't be scheduled because the 7 days after first start-up haven't passed yet.");
}
}*/

scheduleAuthenticationJobs(context);
}

private static void scheduleAuthenticationJobs(Context context){
Expand All @@ -52,8 +54,8 @@ private static void scheduleAuthenticationJobs(Context context){
// Initiate background job for face recognition authentication
scheduleAuthentication(context, MINUTES_BETWEEN_AUTHENTICATIONS);

// Initiate background job for merging similar students
scheduleMergeSimilarStudents(context);
/*// Initiate background job for merging similar students
scheduleMergeSimilarStudents(context);*/
}

public static void scheduleFaceRecognitionTranining(Context context){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.job.JobService;
import android.util.Log;

import org.literacyapp.authentication.helper.StartPrefsHelper;
import org.literacyapp.authentication.thread.TrainingThread;

public class FaceRecognitionTrainingJobService extends JobService {
Expand All @@ -14,16 +15,20 @@ public class FaceRecognitionTrainingJobService extends JobService {
@Override
public boolean onStartJob(JobParameters jobParameters) {
Log.i(getClass().getName(), "onStartJob");
this.jobParameters = jobParameters;
trainingThread = new TrainingThread(this);
trainingThread.start();
if (StartPrefsHelper.activateAuthentication()) {
this.jobParameters = jobParameters;
trainingThread = new TrainingThread(this);
trainingThread.start();
}
return false;
}

@Override
public boolean onStopJob(JobParameters jobParameters) {
Log.i(getClass().getName(), "onStopJob");
trainingThread.interrupt();
if ((trainingThread != null) && (trainingThread.isAlive())) {
trainingThread.interrupt();
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.job.JobService;
import android.util.Log;

import org.literacyapp.authentication.helper.StartPrefsHelper;
import org.literacyapp.authentication.thread.AuthenticationThread;

public class AuthenticationJobService extends JobService {
Expand All @@ -14,16 +15,20 @@ public class AuthenticationJobService extends JobService {
@Override
public boolean onStartJob(JobParameters jobParameters) {
Log.i(getClass().getName(), "onStartJob");
this.jobParameters = jobParameters;
authenticationThread = new AuthenticationThread(this);
authenticationThread.start();
if (StartPrefsHelper.activateAuthentication()){
this.jobParameters = jobParameters;
authenticationThread = new AuthenticationThread(this);
authenticationThread.start();
}
return false;
}

@Override
public boolean onStopJob(JobParameters jobParameters) {
Log.i(getClass().getName(), "onStopJob");
authenticationThread.interrupt();
if ((authenticationThread != null) && (authenticationThread.isAlive())){
authenticationThread.interrupt();
}
return false;
}

Expand Down

0 comments on commit b755282

Please sign in to comment.