Skip to content

Commit

Permalink
Merge pull request #6 from guardianproject/master
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
percy-g2 authored Jan 17, 2018
2 parents 88bf5dd + 16e475f commit 369d6c5
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 234 deletions.
56 changes: 56 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@

/** 0.1.0 beta 8 build 108 / 18 January 2017 / fa3d445584fb29d4fd227c84a58274c48a5339aa **/

fa3d445 update to build 108 (beta 8)
3a438ee for #137 #211 ensure MonitorActivity state is in sync with MonitorService - this allows you to leave and re-exit the monitor activity with bg service still running - this should also improve cases where activity crases but monitoservice is still live
e206c56 show the localized "password" in web interface
ded33f2 for #162, implement pause/resume handling of camera preview
a58f7ed more on #111 to keep screen on, to keep camera active
d3ef157 if running, don't update string with timer message
a8ef1cc work on #111 disable battery opt to allow full background mode
c7d694b update localizations from transifex
2373f2a add camera sensitivity config to onboarding
985f14e update camera sensitivty config UI
e54a6ee for #213 re-implemented time windows for notifications
47395d9 initial work on camera sensitivity config #146 #85 #212
52f9627 require a password for the web server
72b03f4 Merge branch 'mig5-192_use_Save_message_for_remote_number'
0d1fc97 Merge branch '192_use_Save_message_for_remote_number' of https://github.com/mig5/haven into mig5-192_use_Save_message_for_remote_number
ee6aade Merge branch 'christxph-ck/ui-improvements'
e49a3ee Merge branch 'ck/ui-improvements' of https://github.com/christxph/haven into christxph-ck/ui-improvements
69e7fc6 Merge branch 'percy-g2-bug-fix'
ee0f2fe Darken overlay by 5%
7fb8940 Add Toolbar back button in EventActivity
e84ccc6 Add semi-transparent overlay to camera preview to improve text/icon readability
07b8940 Replace png icons with VectorDrawables
6e24045 Force transparent background because API<=16 defaults to a black one
53d0418 Fix camera images can be upside down from rare camera.
1baf43d Merge pull request #4 from guardianproject/master
913b893 Merge branch 'percy-g2-settings-p2'
e7fa68e Merge branch 'settings-p2' of https://github.com/percy-g2/haven into percy-g2-settings-p2
9e1ef72 Merge branch 'percy-g2-settings-p1'
d3ff765 don't require touchscreens (support chromebooks, RPi's, TVs)
0071417 Merge branch 'settings-p1' of https://github.com/percy-g2/haven into percy-g2-settings-p1
f166f34 fix marking of not required features to support tablets
78d6196 Merge branch 'fat-tire-misc_small_fixes'
e21f837 re-enable password masking
81db4fb Merge branch 'misc_small_fixes' of https://github.com/fat-tire/haven into fat-tire-misc_small_fixes
111e9e7 Merge pull request #204 from fat-tire/hide_password
a1b9105 Don't show passwords on screen
54da36d Lint: Misc fixes (see below) Still not a big cleanup but little bits
df07c6d Merge pull request #199 from WangQiru/master
4dd82c3 Minor change
f522de6 Merge pull request #3 from guardianproject/master
ec13b57 Updated Chinese translation
79b5293 adding in code of conduct into the project
968a5e6 Merge pull request #191 from kushaldas/fpf
d9c5281 Merge pull request #196 from FREEWING-JP/japanese-translation
6a1fb24 Merge pull request #197 from FREEWING-JP/fix_hard_coded_string
bd0ef70 Fix Hard coded string
32904c8 Update Japanese translation
4c08a2a Use 'Save Number' dialog for Remote Signal number rather than Register
3d9daaf Fixes the abbreviation of FPF
6e658a8 The summary with string formatting marker.
1fa9dfa Address https://github.com/guardianproject/haven/issues/187
b654559 Merge pull request #2 from guardianproject/master


/** 0.1.0 beta 7 build 107 / 2 January 2017 / 615265bec5d50f8fe8eb829a20f6cadd77a8c869 **/

615265b update to build 107
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ android {

defaultConfig {
applicationId "org.havenapp.main"
versionCode 107
versionCode 108
versionName getVersionName()
archivesBaseName = "Haven-$versionName"
minSdkVersion 16
Expand Down
2 changes: 2 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>

<application xmlns:tools="http://schemas.android.com/tools"
android:name="org.havenapp.main.HavenApp"
android:icon="@mipmap/ic_launcher"
Expand Down
68 changes: 42 additions & 26 deletions src/main/java/org/havenapp/main/MonitorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;

import org.havenapp.main.service.MonitorService;
import org.havenapp.main.ui.AccelConfigureActivity;
import org.havenapp.main.ui.CameraFragment;
Expand All @@ -43,7 +45,7 @@
import static org.havenapp.main.Utils.getTimerText;

public class MonitorActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener {

private PreferenceManager preferences = null;

private TextView txtTimer;
Expand All @@ -60,11 +62,32 @@ protected void onCreate(Bundle savedInstanceState) {

boolean permsNeeded = askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 1);

if (!permsNeeded)
initLayout();
if (!permsNeeded) {

initSetupLayout();

if (MonitorService.getInstance() != null)
if (MonitorService.getInstance().isRunning())
initActiveLayout();

}

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

}

private void initLayout() {
private void initActiveLayout() {

((Button) findViewById(R.id.btnStartLater)).setText(R.string.action_cancel);
findViewById(R.id.btnStartNow).setVisibility(View.INVISIBLE);
findViewById(R.id.timer_text_title).setVisibility(View.INVISIBLE);
txtTimer.setText(R.string.status_on);

mOnTimerTicking = false;
mIsMonitoring = true;
}

private void initSetupLayout() {
preferences = new PreferenceManager(getApplicationContext());
setContentView(R.layout.activity_monitor);

Expand Down Expand Up @@ -162,25 +185,24 @@ private void doCancel() {
if (cTimer != null) {
cTimer.cancel();
cTimer = null;
mOnTimerTicking = false;
}

if (mIsMonitoring) {
mIsMonitoring = false;
stopService(new Intent(this, MonitorService.class));
finish();
} else {

findViewById(R.id.btnStartNow).setVisibility(View.VISIBLE);
findViewById(R.id.timer_text_title).setVisibility(View.VISIBLE);
if (mIsMonitoring) {
mIsMonitoring = false;
stopService(new Intent(this, MonitorService.class));
finish();
} else {

((Button) findViewById(R.id.btnStartLater)).setText(R.string.start_later);
findViewById(R.id.btnStartNow).setVisibility(View.VISIBLE);
findViewById(R.id.timer_text_title).setVisibility(View.VISIBLE);

int timeM = preferences.getTimerDelay() * 1000;
txtTimer.setText(getTimerText(timeM));
}
} else {
((Button) findViewById(R.id.btnStartLater)).setText(R.string.start_later);

close();
int timeM = preferences.getTimerDelay() * 1000;
txtTimer.setText(getTimerText(timeM));
}

}

private void showSettings() {
Expand Down Expand Up @@ -253,12 +275,6 @@ private void initMonitor() {
*/
private void close() {

stopService(new Intent(this, MonitorService.class));
if (preferences != null) {
preferences.unsetAccessToken();
preferences.unsetDelegatedAccessToken();
preferences.unsetPhoneId();
}
finish();

}
Expand Down Expand Up @@ -286,7 +302,7 @@ private void showTimeDelayDialog() {
@Override
public void onResume() {
super.onResume();
if (mIsInitializedLayout && !mOnTimerTicking) {
if (mIsInitializedLayout && (!mOnTimerTicking) && (!mIsMonitoring)) {
int totalMilliseconds = preferences.getTimerDelay() * 1000;
txtTimer.setText(getTimerText(totalMilliseconds));
}
Expand All @@ -301,7 +317,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
askForPermission(Manifest.permission.CAMERA, 2);
break;
case 2:
initLayout();
initSetupLayout();
break;
}

Expand Down
65 changes: 14 additions & 51 deletions src/main/java/org/havenapp/main/PreferenceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public class PreferenceManager {

private static final String FIRST_LAUNCH = "first_launch";

public static final String NOTIFICATION_TIME = "notification_time";

public static final String DISABLE_BATTERY_OPT = "config_battery_optimizations";

private Context context;

Expand Down Expand Up @@ -224,55 +227,6 @@ public String getSmsNumber() {
return appSharedPrefs.getString(SMS_NUMBER, "");
}


public void setUnlockCode(String unlockCode) {
prefsEditor.putString(UNLOCK_CODE, unlockCode);
prefsEditor.commit();
}

public String getUnlockCode() {
return appSharedPrefs.getString(UNLOCK_CODE, "");
}

public void setAccessToken(String accessToken) {
prefsEditor.putString(ACCESS_TOKEN, accessToken);
prefsEditor.commit();
}

public String getAccessToken() {
return appSharedPrefs.getString(ACCESS_TOKEN, "");
}

public void unsetAccessToken() {
prefsEditor.remove(ACCESS_TOKEN);
}

public void setDelegatedAccessToken(String deferredAccessToken) {
prefsEditor.putString(DELEGATED_ACCESS_TOKEN, deferredAccessToken);
prefsEditor.commit();
}

public String getDelegatedAccessToken() {
return appSharedPrefs.getString(DELEGATED_ACCESS_TOKEN, "");
}

public void unsetDelegatedAccessToken() {
prefsEditor.remove(DELEGATED_ACCESS_TOKEN);
}

public void setPhoneId(String phoneId) {
prefsEditor.putString(PHONE_ID, phoneId);
prefsEditor.commit();
}

public void unsetPhoneId() {
prefsEditor.remove(PHONE_ID);
}

public String getPhoneId() {
return appSharedPrefs.getString(PHONE_ID, "");
}

public int getTimerDelay ()
{
return appSharedPrefs.getInt(TIMER_DELAY,30);
Expand Down Expand Up @@ -304,12 +258,21 @@ public int getMaxImages ()

public String getAudioPath ()
{
return "/phoneypot";

return "/phoneypot"; //phoneypot is the old code name for Haven
}

public int getAudioLength ()
{
return 15000; //30 seconds
}

public int getNotificationTimeMs () {
return appSharedPrefs.getInt(NOTIFICATION_TIME,-1); //time in minutes times by seconds
}

public void setNotificationTimeMs (int notificationTimeMs) {
prefsEditor.putInt(NOTIFICATION_TIME,notificationTimeMs);
prefsEditor.commit();
}

}
47 changes: 47 additions & 0 deletions src/main/java/org/havenapp/main/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.PowerManager;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
Expand Down Expand Up @@ -109,6 +114,11 @@ public void onCreatePreferencesFix(Bundle bundle, String s) {
findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(R.string.register_signal_desc);
}

if (preferences.getNotificationTimeMs()>0)
{
findPreference(PreferenceManager.NOTIFICATION_TIME).setSummary(preferences.getNotificationTimeMs()/60000 + " " + getString(R.string.minutes));
}

Preference prefCameraSensitivity = findPreference(PreferenceManager.CAMERA_SENSITIVITY);
prefCameraSensitivity.setOnPreferenceClickListener(preference -> {
startActivity(new Intent(mActivity, CameraConfigureActivity.class));
Expand All @@ -133,6 +143,12 @@ public void onCreatePreferencesFix(Bundle bundle, String s) {
return true;
});

Preference prefDisableBatteryOpt = findPreference(PreferenceManager.DISABLE_BATTERY_OPT);
prefDisableBatteryOpt.setOnPreferenceClickListener(preference -> {
requestChangeBatteryOptimizations();
return true;
});

checkSignalUsername();
((EditTextPreference) findPreference(PreferenceManager.VERIFY_SIGNAL)).setText("");
askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 1);
Expand Down Expand Up @@ -286,6 +302,21 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
askForPermission(Manifest.permission.READ_PHONE_STATE, 6);
}
setPhoneNumber();
break;
case PreferenceManager.NOTIFICATION_TIME:
try
{
String text = ((EditTextPreference)findPreference(PreferenceManager.NOTIFICATION_TIME)).getText();
int notificationTimeMs = Integer.parseInt(text)*60000;
preferences.setNotificationTimeMs(notificationTimeMs);
findPreference(PreferenceManager.NOTIFICATION_TIME).setSummary(preferences.getNotificationTimeMs()/60000 + " " + getString(R.string.minutes));

}
catch (NumberFormatException ne)
{
//error parsing user value
}

break;
case PreferenceManager.REMOTE_ACCESS_ONION: {
String text = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ONION)).getText();
Expand Down Expand Up @@ -411,4 +442,20 @@ public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int seco
int delaySeconds = second + minute * 60 + hourOfDay * 60 * 60;
preferences.setTimerDelay(delaySeconds);
}

private void requestChangeBatteryOptimizations ()
{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
String packageName = getActivity().getPackageName();
PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
if (pm.isIgnoringBatteryOptimizations(packageName))
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
else {
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
}
getActivity().startActivity(intent);
}
}
}
Loading

0 comments on commit 369d6c5

Please sign in to comment.