1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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;
-
-
- 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);
-
- Button 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);
- }
- 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");
- }
- public void Impressum(){
- PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
- }
-
- }
|