Gruppe 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PopUpClass.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.example.ueberwachungssystem;
  2. import android.view.Gravity;
  3. import android.view.LayoutInflater;
  4. import android.view.MotionEvent;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.LinearLayout;
  8. import android.widget.PopupWindow;
  9. import android.widget.TextView;
  10. public class PopUpClass {
  11. private final MainActivity mainActivity;
  12. PermissionRequest permission;
  13. TextView PopUpText;
  14. public PopUpClass(MainActivity mainActivity) {
  15. this.mainActivity = mainActivity;
  16. permission = new PermissionRequest(mainActivity);
  17. }
  18. //PopupWindow display method
  19. public void showPopupWindow(final View view) {
  20. //Create a View object yourself through inflater
  21. LayoutInflater inflater = (LayoutInflater) view.getContext().getSystemService(view.getContext().LAYOUT_INFLATER_SERVICE);
  22. View popupView = inflater.inflate(R.layout.popup_window, null);
  23. //Specify the length and width through constants
  24. int width = LinearLayout.LayoutParams.WRAP_CONTENT;
  25. int height = LinearLayout.LayoutParams.WRAP_CONTENT;
  26. //Make Inactive Items Outside Of PopupWindow
  27. boolean focusable = true;
  28. //Create a window with our parameters
  29. final PopupWindow popupWindow = new PopupWindow(popupView,width*1, height*1, focusable);
  30. //Set the location of the window on the screen
  31. popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
  32. //Initialize the elements of our window, install the handler
  33. PopUpText = popupView.findViewById(R.id.titleText);
  34. Button buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
  35. buttonEdit.setOnClickListener(new View.OnClickListener() {
  36. @Override
  37. public void onClick(View v) {
  38. RechteAnfordern();
  39. }
  40. });
  41. //Handler for clicking on the inactive zone of the window
  42. popupView.setOnTouchListener(new View.OnTouchListener() {
  43. @Override
  44. public boolean onTouch(View v, MotionEvent event) {
  45. //Close the window when clicked
  46. popupWindow.dismiss();
  47. return true;
  48. }
  49. });
  50. }
  51. public void RechtePrüfen(){
  52. StringBuilder Text = permission.rechtePruefen();
  53. PopUpText.setText(Text);
  54. }
  55. public void RechteAnfordern(){
  56. permission.rechteAnfordern();
  57. StringBuilder Text = permission.rechtePruefen();
  58. PopUpText.setText(Text);
  59. }
  60. public void Sensoren(){
  61. PopUpText.setText("Es können 3 verschiedene Sensoren verwendet werden \n -1. Beschleunigungssensor\n -2. Mikrofon\n -3. Kamera");
  62. }
  63. public void Impressum(){
  64. PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
  65. }
  66. }