<uses-permission android:name="android.permission.INTERNET" /> | <uses-permission android:name="android.permission.INTERNET" /> | ||||
<uses-permission android:name="android.permission.CAMERA"/> | <uses-permission android:name="android.permission.CAMERA"/> | ||||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |||||
<uses-feature android:name="android.hardware.camera"/> | <uses-feature android:name="android.hardware.camera"/> | ||||
private TextView accelerometerWarningTV; | private TextView accelerometerWarningTV; | ||||
private Button backToMainActivityButton; | private Button backToMainActivityButton; | ||||
private AccelerometerViewModel mAccelerometerViewModel; | private AccelerometerViewModel mAccelerometerViewModel; | ||||
private Permission permission = new Permission(); | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(AccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(AccelerometerActivity.this, AccelerometerActivity.this)){ | |||||
Toast.makeText(AccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(AccelerometerActivity.this); | |||||
if(permission.alarmRechtePruefen(AccelerometerActivity.this, AccelerometerActivity.this)){ | |||||
Toast.makeText(AccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(AccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(AccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(AccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); |
public class AudiodetectionActivity extends AppCompatActivity { | public class AudiodetectionActivity extends AppCompatActivity { | ||||
private TextView microfonStatusMessage; | private TextView microfonStatusMessage; | ||||
private Button backToMainActivityButton; | private Button backToMainActivityButton; | ||||
private Permission permission = new Permission(); | |||||
private MicrofonViewModel mMicrofonViewModel; | private MicrofonViewModel mMicrofonViewModel; | ||||
@Override | @Override | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(AudiodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(AudiodetectionActivity.this, AudiodetectionActivity.this)){ | |||||
Toast.makeText(AudiodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(AudiodetectionActivity.this); | |||||
if(permission.alarmRechtePruefen(AudiodetectionActivity.this, AudiodetectionActivity.this)){ | |||||
Toast.makeText(AudiodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(AudiodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(AudiodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(AudiodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); |
private AudiodetectionAndAccelerometerViewModel mAudiodetectionAndAccelerometerViewModel; | private AudiodetectionAndAccelerometerViewModel mAudiodetectionAndAccelerometerViewModel; | ||||
private Button backToMainActivity; | private Button backToMainActivity; | ||||
private Permission permission = new Permission(); | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(AudiodetectionAndAccelerometerActivity.this, AudiodetectionAndAccelerometerActivity.this)){ | |||||
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(AudiodetectionAndAccelerometerActivity.this); | |||||
if(permission.alarmRechtePruefen(AudiodetectionAndAccelerometerActivity.this, AudiodetectionAndAccelerometerActivity.this)){ | |||||
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); |
import androidx.recyclerview.widget.LinearLayoutManager; | import androidx.recyclerview.widget.LinearLayoutManager; | ||||
import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
import android.app.Activity; | |||||
import android.content.Context; | |||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.hardware.SensorManager; | import android.hardware.SensorManager; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import com.example.greenwatch.models.Device; | import com.example.greenwatch.models.Device; | ||||
import com.example.greenwatch.viewmodels.MainActivityViewModel; | import com.example.greenwatch.viewmodels.MainActivityViewModel; | ||||
import java.util.List; | import java.util.List; | ||||
public class MainActivity extends AppCompatActivity { | public class MainActivity extends AppCompatActivity { | ||||
private Button videodetectionAndAccelerometerButton; | private Button videodetectionAndAccelerometerButton; | ||||
private Button connectionButton; | private Button connectionButton; | ||||
private MainActivityViewModel mMainActivityViewModel; | private MainActivityViewModel mMainActivityViewModel; | ||||
private Permission permission = new Permission(); | |||||
private Activity activity = new Activity(); | |||||
private Context context; | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setContentView(R.layout.activity_main); | setContentView(R.layout.activity_main); | ||||
activity = MainActivity.this; | |||||
context = MainActivity.this; | |||||
audiodetectionButton = (Button) findViewById(R.id.audiodetectionButton); | audiodetectionButton = (Button) findViewById(R.id.audiodetectionButton); | ||||
videodetectionButton = (Button) findViewById(R.id.videodetectionButton); | videodetectionButton = (Button) findViewById(R.id.videodetectionButton); | ||||
accelerometerButton = (Button) findViewById(R.id.accelerometerButton); | accelerometerButton = (Button) findViewById(R.id.accelerometerButton); | ||||
final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter(); | final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter(); | ||||
alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter); | alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter); | ||||
permission.startRechtePruefen(this, this); | |||||
mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class); | mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class); | ||||
mMainActivityViewModel.init(); | mMainActivityViewModel.init(); | ||||
mMainActivityViewModel.accessRequestCamera(this); | |||||
mMainActivityViewModel.accessRequestMicrofon(this); | |||||
mMainActivityViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() { | mMainActivityViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() { | ||||
@Override | @Override | ||||
public void onChanged(List<Device> devices) { | public void onChanged(List<Device> devices) { | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(MainActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(context, activity)){ | |||||
Toast.makeText(MainActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(activity); | |||||
if(permission.alarmRechtePruefen(context, activity)){ | |||||
Toast.makeText(MainActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(MainActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(MainActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(MainActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | ||||
audiodetectionButton.setOnClickListener(new View.OnClickListener() { | audiodetectionButton.setOnClickListener(new View.OnClickListener() { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
if (mMainActivityViewModel.isMicrofonAccessAllowed(MainActivity.this)) { | |||||
if (permission.microRechtePruefen(context, activity)) { | |||||
openAudiodetectionActivity(); | openAudiodetectionActivity(); | ||||
} | } | ||||
else { | else { | ||||
mMainActivityViewModel.accessRequestMicrofon(MainActivity.this); | |||||
permission.microRechteAnfordern(activity); | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
videodetectionButton.setOnClickListener(new View.OnClickListener() { | videodetectionButton.setOnClickListener(new View.OnClickListener() { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
if (mMainActivityViewModel.isCameraAccessAllowed(MainActivity.this)) { | |||||
if (permission.kameraRechtePruefen(context, activity)) { | |||||
openVideodetectionActivity(); | openVideodetectionActivity(); | ||||
} | } | ||||
else { | else { | ||||
mMainActivityViewModel.accessRequestCamera(MainActivity.this); | |||||
permission.kameraRechteAnfordern(activity); | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
audiodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() { | audiodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
if (mMainActivityViewModel.isMicrofonAccessAllowed(MainActivity.this)) { | |||||
if (permission.microRechtePruefen(context, activity)) { | |||||
openAudiodetectionAndAccelerometerActivity(); | openAudiodetectionAndAccelerometerActivity(); | ||||
} | } | ||||
else { | else { | ||||
mMainActivityViewModel.accessRequestMicrofon(MainActivity.this); | |||||
permission.microRechteAnfordern(activity); | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
videodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() { | videodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
openVideodetectionAndAccelerometerActivity(); | |||||
if (permission.kameraRechtePruefen(context, activity)) { | |||||
openVideodetectionAndAccelerometerActivity(); | |||||
} | |||||
else { | |||||
permission.kameraRechteAnfordern(activity); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
connectionButton.setOnClickListener(new View.OnClickListener() { | connectionButton.setOnClickListener(new View.OnClickListener() { |
package com.example.greenwatch; | |||||
import static android.Manifest.permission.CAMERA; | |||||
import static android.Manifest.permission.RECORD_AUDIO; | |||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; | |||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE; | |||||
import static androidx.core.app.ActivityCompat.requestPermissions; | |||||
import static androidx.core.content.ContextCompat.checkSelfPermission; | |||||
import android.Manifest; | |||||
import android.app.Activity; | |||||
import android.content.Context; | |||||
import android.content.DialogInterface; | |||||
import android.content.pm.PackageManager; | |||||
import android.os.Bundle; | |||||
import android.util.Log; | |||||
import android.view.View; | |||||
import androidx.appcompat.app.AlertDialog; | |||||
import androidx.appcompat.app.AppCompatActivity; | |||||
import androidx.core.app.ActivityCompat; | |||||
import androidx.core.content.ContextCompat; | |||||
public class Permission { | |||||
private static final int PERMISSION_REQUEST_MICRO = 1; | |||||
private static final int PERMISSION_REQUEST_CAMERA = 2; | |||||
private static final int PERMISSION_REQUEST_ALARM = 1234; | |||||
private static final int PERMISSION_REQUEST_START = 1235; | |||||
public void startRechtePruefen(Context context, Activity activity){ | |||||
boolean rechtKamera = checkSelfPermission(context, CAMERA) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtAudio = checkSelfPermission(context, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtSchreiben = checkSelfPermission(context, WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtLesen = checkSelfPermission(context, READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; | |||||
Log.d("Kamera Rechte", String.valueOf(rechtKamera)); | |||||
Log.d("Audio Rechte", String.valueOf(rechtAudio)); | |||||
Log.d("Schreib Rechte", String.valueOf(rechtSchreiben)); | |||||
Log.d("Lese Rechte", String.valueOf(rechtLesen)); | |||||
if(rechtKamera && rechtAudio && rechtSchreiben && rechtLesen){ | |||||
Log.d("Rechte", "erteilt"); | |||||
} else { | |||||
startRechteAnfordern(activity); | |||||
} | |||||
} | |||||
public boolean kameraRechtePruefen(Context context, Activity activity){ | |||||
boolean rechtKamera = checkSelfPermission(context, CAMERA) == PackageManager.PERMISSION_GRANTED; | |||||
Log.d("Kamera Rechte", String.valueOf(rechtKamera)); | |||||
if(rechtKamera){ | |||||
Log.d("Kamerarechte", "erteilt"); | |||||
return true; | |||||
} else { | |||||
kameraRechteAnfordern(activity); | |||||
if(checkSelfPermission(context, CAMERA) == PackageManager.PERMISSION_GRANTED){ | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
} | |||||
public boolean microRechtePruefen(Context context, Activity activity){ | |||||
boolean rechtAudio = checkSelfPermission(context, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; | |||||
Log.d("Audio Rechte", String.valueOf(rechtAudio)); | |||||
if(rechtAudio){ | |||||
Log.d("Rechte", "erteilt"); | |||||
return true; | |||||
} else { | |||||
microRechteAnfordern(activity); | |||||
if(checkSelfPermission(context, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED){ | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
} | |||||
public boolean alarmRechtePruefen(Context context, Activity activity){ | |||||
boolean rechtKamera = checkSelfPermission(context, CAMERA) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtAudio = checkSelfPermission(context, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtSchreiben = checkSelfPermission(context, WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; | |||||
boolean rechtLesen = checkSelfPermission(context, READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; | |||||
Log.d("Kamera Rechte", String.valueOf(rechtKamera)); | |||||
Log.d("Audio Rechte", String.valueOf(rechtAudio)); | |||||
Log.d("Schreib Rechte", String.valueOf(rechtSchreiben)); | |||||
Log.d("Lese Rechte", String.valueOf(rechtLesen)); | |||||
if(rechtKamera && rechtAudio && rechtSchreiben && rechtLesen){ | |||||
Log.d("Rechte", "erteilt"); | |||||
return true; | |||||
} else { | |||||
alarmRechteAnfordern(activity); | |||||
if(checkSelfPermission(context, CAMERA) == PackageManager.PERMISSION_GRANTED | |||||
&& checkSelfPermission(context, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED | |||||
&& checkSelfPermission(context, WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED | |||||
&& checkSelfPermission(context, READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED){ | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
} | |||||
public void startRechteAnfordern(Activity activity){ | |||||
ActivityCompat.requestPermissions(activity, new String[]{CAMERA, RECORD_AUDIO, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_START); | |||||
} | |||||
public void kameraRechteAnfordern(Activity activity){ | |||||
ActivityCompat.requestPermissions(activity, new String[]{CAMERA}, PERMISSION_REQUEST_CAMERA); | |||||
} | |||||
public void microRechteAnfordern(Activity activity){ | |||||
ActivityCompat.requestPermissions(activity, new String[]{RECORD_AUDIO}, PERMISSION_REQUEST_MICRO); | |||||
} | |||||
public void alarmRechteAnfordern(Activity activity){ | |||||
ActivityCompat.requestPermissions(activity, new String[]{CAMERA, RECORD_AUDIO, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_ALARM); | |||||
} | |||||
} |
private Button backToMainActivity; | private Button backToMainActivity; | ||||
private VideodetectionViewModel mVideoDetectionViewModel; | private VideodetectionViewModel mVideoDetectionViewModel; | ||||
private Permission permission = new Permission(); | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(VideodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(VideodetectionActivity.this, VideodetectionActivity.this)){ | |||||
Toast.makeText(VideodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(VideodetectionActivity.this); | |||||
if(permission.alarmRechtePruefen(VideodetectionActivity.this, VideodetectionActivity.this)){ | |||||
Toast.makeText(VideodetectionActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(VideodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(VideodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(VideodetectionActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); |
private TextView videodetectionAndAccelerometerWarningTV; | private TextView videodetectionAndAccelerometerWarningTV; | ||||
private Button backToMainActivity; | private Button backToMainActivity; | ||||
private VideodetectionAndAccelerometerViewModel mVideodetectionAndAccelerometerViewModel; | private VideodetectionAndAccelerometerViewModel mVideodetectionAndAccelerometerViewModel; | ||||
private Permission permission = new Permission(); | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
@Override | @Override | ||||
public void onChanged(Boolean aBoolean) { | public void onChanged(Boolean aBoolean) { | ||||
if (aBoolean) { | if (aBoolean) { | ||||
Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
if(permission.alarmRechtePruefen(VideodetectionAndAccelerometerActivity.this, VideodetectionAndAccelerometerActivity.this)){ | |||||
Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo AlarmHandling einfügen | |||||
} else { | |||||
permission.alarmRechteAnfordern(VideodetectionAndAccelerometerActivity.this); | |||||
if(permission.alarmRechtePruefen(VideodetectionAndAccelerometerActivity.this, VideodetectionAndAccelerometerActivity.this)){ | |||||
Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Start Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
//todo Alarmhandling einfügen | |||||
} else { | |||||
Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | |||||
} | |||||
} | |||||
} | } | ||||
else { | else { | ||||
Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); | Toast.makeText(VideodetectionAndAccelerometerActivity.this, "Stop Alarm Recording", Toast.LENGTH_LONG).show(); |
private MutableLiveData<List<Device>> mAlarmHistoryList; | private MutableLiveData<List<Device>> mAlarmHistoryList; | ||||
private MutableLiveData<Boolean> mStartAlarmRecording; | private MutableLiveData<Boolean> mStartAlarmRecording; | ||||
private DeviceRepository mDeviceRepository; | private DeviceRepository mDeviceRepository; | ||||
private static final int RIGHTS_REQUEST_CAMERA = 10; | |||||
private static final int RIGHTS_REQUEST_CAMERA_MICROFON = 1; | |||||
@Override | @Override | ||||
public void init() { | public void init() { | ||||
mStartAlarmRecording = mDeviceRepository.getStartAlarmRecording(); | mStartAlarmRecording = mDeviceRepository.getStartAlarmRecording(); | ||||
} | } | ||||
public boolean isMicrofonAccessAllowed(Context context) { | |||||
return ContextCompat.checkSelfPermission(context, android.Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; | |||||
} | |||||
public void accessRequestMicrofon(Activity activity) { | |||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.RECORD_AUDIO}, RIGHTS_REQUEST_CAMERA_MICROFON); | |||||
} | |||||
public boolean isCameraAccessAllowed(Context context) { | |||||
return ContextCompat.checkSelfPermission(context, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED; | |||||
} | |||||
public void accessRequestCamera(Activity activity) { | |||||
ActivityCompat.requestPermissions(activity, new String[]{android.Manifest.permission.CAMERA}, RIGHTS_REQUEST_CAMERA); | |||||
} | |||||
@Override | @Override | ||||
public LiveData<List<Device>> getConnectedDeviceList() { | public LiveData<List<Device>> getConnectedDeviceList() { | ||||
return mDeviceList; | return mDeviceList; |