use of org.havenapp.main.PreferenceManager in project haven by guardianproject.
the class MonitorService method onCreate.
/**
* Called on service creation, sends a notification
*/
@Override
public void onCreate() {
sInstance = this;
mApp = (HavenApp) getApplication();
manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mPrefs = new PreferenceManager(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mChannel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
mChannel.setDescription(channelDescription);
mChannel.setLightColor(Color.RED);
mChannel.setImportance(NotificationManager.IMPORTANCE_MIN);
manager.createNotificationChannel(mChannel);
}
startSensors();
showNotification();
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");
wakeLock.acquire();
}
use of org.havenapp.main.PreferenceManager in project haven by guardianproject.
the class AccelConfigureActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_accel_configure);
mPrefManager = new PreferenceManager(this.getApplicationContext());
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setTitle("");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mTextLevel = findViewById(R.id.text_display_level);
mNumberTrigger = findViewById(R.id.number_trigger_level);
mWaveform = findViewById(R.id.simplewaveform);
mWaveform.setMaxVal(MAX_SLIDER_VALUE);
mNumberTrigger.setMinValue(0);
mNumberTrigger.setMaxValue(MAX_SLIDER_VALUE);
if (!mPrefManager.getAccelerometerSensitivity().equals(PreferenceManager.HIGH))
mNumberTrigger.setValue(Integer.parseInt(mPrefManager.getAccelerometerSensitivity()));
else
mNumberTrigger.setValue(50);
mNumberTrigger.setListener((oldValue, newValue) -> {
mWaveform.setThreshold(newValue);
mPrefManager.setAccelerometerSensitivity(newValue + "");
});
initWave();
startAccel();
}
use of org.havenapp.main.PreferenceManager in project haven by guardianproject.
the class CameraConfigureActivity method initLayout.
private void initLayout() {
mPrefManager = new PreferenceManager(getApplicationContext());
setContentView(R.layout.activity_camera_configure);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setTitle("");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mFragment = (CameraFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_camera);
findViewById(R.id.btnCameraSwitch).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchCamera();
}
});
mNumberTrigger = findViewById(R.id.number_trigger_level);
mNumberTrigger.setValue(mPrefManager.getCameraSensitivity());
mNumberTrigger.setListener(new OnValueChangeListener() {
@Override
public void onValueChanged(int oldValue, int newValue) {
mFragment.setMotionSensitivity(newValue);
mPrefManager.setCameraSensitivity(newValue);
setResult(RESULT_OK);
}
});
mIsInitializedLayout = true;
}
use of org.havenapp.main.PreferenceManager in project haven by guardianproject.
the class CustomSlideNotify method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(layoutResId, container, false);
mEditNumber = view.findViewById(R.id.editNumber);
mEditNumber.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
askForPermission(Manifest.permission.SEND_SMS, 6);
askForPermission(Manifest.permission.READ_PHONE_STATE, 6);
}
});
PreferenceManager pm = new PreferenceManager(getActivity());
if (!TextUtils.isEmpty(pm.getSmsNumber()))
mEditNumber.setText(pm.getSmsNumber());
Button button = view.findViewById(R.id.btnSaveNumber);
button.setOnClickListener(mListener);
return view;
}
use of org.havenapp.main.PreferenceManager in project haven by guardianproject.
the class CameraFragment method initCamera.
private void initCamera() {
if (preview == null) {
PreferenceManager prefs = new PreferenceManager(getActivity());
if (prefs.getCameraActivation()) {
// Uncomment to see the camera
preview = new Preview(getActivity());
((FrameLayout) getActivity().findViewById(R.id.preview)).addView(preview);
// oldImage = (ImageView) getActivity().findViewById(R.id.old_image);
newImage = getActivity().findViewById(R.id.new_image);
preview.addListener(new MotionAsyncTask.MotionListener() {
public void onProcess(Bitmap oldBitmap, Bitmap newBitmap, Bitmap rawBitmap, boolean motionDetected) {
int rotation = 0;
boolean reflex = false;
if (preview == null)
return;
if (preview.getCameraFacing() == Camera.CameraInfo.CAMERA_FACING_BACK) {
rotation = 90;
} else {
rotation = 270;
reflex = true;
}
// oldImage.setImageBitmap(ImageCodec.rotate(oldBitmap, rotation, reflex));
newImage.setImageBitmap(ImageCodec.rotate(newBitmap, rotation, reflex));
}
});
}
}
}
Aggregations