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 3.1KB

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