123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package com.example.ueberwachungssystem;
-
- import android.view.Gravity;
- import android.view.LayoutInflater;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.Button;
- import android.widget.LinearLayout;
- import android.widget.PopupWindow;
- import android.widget.TextView;
-
- public class PopUpClass {
- private final MainActivity mainActivity;
-
- PermissionRequest permission;
- TextView PopUpText;
-
- Button buttonEdit;
-
-
- public PopUpClass(MainActivity mainActivity) {
- this.mainActivity = mainActivity;
- permission = new PermissionRequest(mainActivity);
- }
-
- //PopupWindow display method
-
- public void showPopupWindow(final View view) {
-
-
- //Create a View object yourself through inflater
- LayoutInflater inflater = (LayoutInflater) view.getContext().getSystemService(view.getContext().LAYOUT_INFLATER_SERVICE);
- View popupView = inflater.inflate(R.layout.popup_window, null);
-
- //Specify the length and width through constants
- int width = LinearLayout.LayoutParams.WRAP_CONTENT;
- int height = LinearLayout.LayoutParams.WRAP_CONTENT;
-
- //Make Inactive Items Outside Of PopupWindow
- boolean focusable = true;
-
- //Create a window with our parameters
- final PopupWindow popupWindow = new PopupWindow(popupView,width*1, height*1, focusable);
-
- //Set the location of the window on the screen
- popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
-
- //Initialize the elements of our window, install the handler
-
- PopUpText = popupView.findViewById(R.id.titleText);
-
- buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
- buttonEdit.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- RechteAnfordern();
- }
- });
-
- //Handler for clicking on the inactive zone of the window
-
- popupView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
-
- //Close the window when clicked
- popupWindow.dismiss();
- return true;
- }
- });
- }
- public void RechtePrüfen(){
- StringBuilder Text = permission.rechtePruefen();
- PopUpText.setText(Text);
- buttonEdit.setVisibility(View.VISIBLE);
-
- }
- public void RechteAnfordern(){
- permission.rechteAnfordern();
- StringBuilder Text = permission.rechtePruefen();
- PopUpText.setText(Text);
-
- }
- public void Sensoren(){
- PopUpText.setText("Es können 3 verschiedene Sensoren verwendet werden \n -1. Beschleunigungssensor\n -2. Mikrofon\n -3. Kamera\n Diese können sowohl einzeln als auch alle zusammen verwendet werden");
- buttonEdit.setVisibility(View.GONE);
- }
- public void Impressum(){
- PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert \n Von: \n -Kohler Bastian\n -Kleinecke Oliver\n -Market Leon\n -Siebenhaar Miguel\n -Wolz Tobias ");
- buttonEdit.setVisibility(View.GONE);
- }
- public void DetectionTotal(int num) {
- PopUpText.setText("Total Detektions:" +num);
- buttonEdit.setVisibility(View.GONE);
- }
- }
|