Search in sources :

Example 1 with PreferenceManager

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();
}
Also used : NotificationChannel(android.app.NotificationChannel) PowerManager(android.os.PowerManager) PreferenceManager(org.havenapp.main.PreferenceManager)

Example 2 with PreferenceManager

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();
}
Also used : PreferenceManager(org.havenapp.main.PreferenceManager) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with PreferenceManager

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;
}
Also used : OnValueChangeListener(me.angrybyte.numberpicker.listener.OnValueChangeListener) PreferenceManager(org.havenapp.main.PreferenceManager) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with PreferenceManager

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;
}
Also used : Button(android.widget.Button) View(android.view.View) PreferenceManager(org.havenapp.main.PreferenceManager) Nullable(android.support.annotation.Nullable)

Example 5 with PreferenceManager

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));
                }
            });
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) Preview(org.havenapp.main.sensors.motion.Preview) PreferenceManager(org.havenapp.main.PreferenceManager) MotionAsyncTask(org.havenapp.main.sensors.media.MotionAsyncTask)

Aggregations

PreferenceManager (org.havenapp.main.PreferenceManager)7 Toolbar (android.support.v7.widget.Toolbar)3 View (android.view.View)3 NotificationChannel (android.app.NotificationChannel)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 PowerManager (android.os.PowerManager)1 Nullable (android.support.annotation.Nullable)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 OnValueChangeListener (me.angrybyte.numberpicker.listener.OnValueChangeListener)1 MotionAsyncTask (org.havenapp.main.sensors.media.MotionAsyncTask)1 Preview (org.havenapp.main.sensors.motion.Preview)1