Tim Zeuner 1 year ago
parent
commit
2af8bfa536
61 changed files with 127 additions and 17 deletions
  1. 2
    2
      MobileApp/.idea/deploymentTargetDropDown.xml
  2. 2
    0
      MobileApp/.idea/misc.xml
  3. BIN
      MobileApp/PicturesCircles/back.png
  4. BIN
      MobileApp/PicturesCircles/blank.png
  5. BIN
      MobileApp/PicturesCircles/forward.png
  6. BIN
      MobileApp/PicturesCircles/left.png
  7. BIN
      MobileApp/PicturesCircles/left_back.png
  8. BIN
      MobileApp/PicturesCircles/left_forward.png
  9. BIN
      MobileApp/PicturesCircles/right.png
  10. BIN
      MobileApp/PicturesCircles/right_back.png
  11. BIN
      MobileApp/PicturesCircles/right_forward.png
  12. 3
    2
      MobileApp/app/src/main/java/com/example/lfrmobileapp/Communication.java
  13. 4
    0
      MobileApp/app/src/main/java/com/example/lfrmobileapp/MainActivity.java
  14. 37
    1
      MobileApp/app/src/main/java/com/example/lfrmobileapp/ui/home/HomeFragment.java
  15. 52
    0
      MobileApp/app/src/main/java/com/example/lfrmobileapp/ui/notifications/NotificationsFragment.java
  16. 17
    3
      MobileApp/app/src/main/res/layout/fragment_einstellungen.xml
  17. 10
    9
      MobileApp/app/src/main/res/layout/fragment_manuell.xml
  18. BIN
      MobileApp/app/src/main/res/layout/fragment_manuell.xml~
  19. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/back.png
  20. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/blank.png
  21. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/forward.png
  22. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/left.png
  23. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/left_forward.png
  24. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/right.png
  25. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/right_back.png
  26. BIN
      MobileApp/app/src/main/res/mipmap-hdpi/right_forward.png
  27. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/back.png
  28. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/blank.png
  29. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/forward.png
  30. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/left.png
  31. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/left_forward.png
  32. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/right.png
  33. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/right_back.png
  34. BIN
      MobileApp/app/src/main/res/mipmap-mdpi/right_forward.png
  35. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/back.png
  36. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/blank.png
  37. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/forward.png
  38. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/left.png
  39. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/left_back.png
  40. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/left_forward.png
  41. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/right.png
  42. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/right_back.png
  43. BIN
      MobileApp/app/src/main/res/mipmap-xhdpi/right_forward.png
  44. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/back.png
  45. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/blank.png
  46. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/forward.png
  47. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/left.png
  48. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/left_back.png
  49. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/left_forward.png
  50. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/right.png
  51. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/right_back.png
  52. BIN
      MobileApp/app/src/main/res/mipmap-xxhdpi/right_forward.png
  53. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/back.png
  54. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/blank.png
  55. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/forward.png
  56. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/left.png
  57. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/left_back.png
  58. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/left_forward.png
  59. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/right.png
  60. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/right_back.png
  61. BIN
      MobileApp/app/src/main/res/mipmap-xxxhdpi/right_forward.png

+ 2
- 2
MobileApp/.idea/deploymentTargetDropDown.xml View File

@@ -7,11 +7,11 @@
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\baran\.android\avd\Nexus_5_API_R.avd" />
<value value="C:\Users\baran\.android\avd\Pixel_2_API_R.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-01-11T18:53:15.217760700Z" />
<timeTargetWasSelectedWithDropDown value="2023-01-12T21:16:30.648959800Z" />
</component>
</project>

+ 2
- 0
MobileApp/.idea/misc.xml View File

@@ -5,11 +5,13 @@
<map>
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable-anydpi/manuell.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_baseline_rotate_left_24.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_dashboard_black_24dp.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_home_black_24dp.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_launcher_background.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/ic_notifications_black_24dp.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/my_btn_toggle.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/drawable/vorwarts.xml" value="0.1" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/activity_main.xml" value="0.16666666666666666" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/fragment_automatik.xml" value="0.3333333333333333" />
<entry key="..\:/Line-Following-Robot/MobileApp/app/src/main/res/layout/fragment_dashboard.xml" value="0.14666666666666667" />

BIN
MobileApp/PicturesCircles/back.png View File


BIN
MobileApp/PicturesCircles/blank.png View File


BIN
MobileApp/PicturesCircles/forward.png View File


BIN
MobileApp/PicturesCircles/left.png View File


BIN
MobileApp/PicturesCircles/left_back.png View File


BIN
MobileApp/PicturesCircles/left_forward.png View File


BIN
MobileApp/PicturesCircles/right.png View File


BIN
MobileApp/PicturesCircles/right_back.png View File


BIN
MobileApp/PicturesCircles/right_forward.png View File


+ 3
- 2
MobileApp/app/src/main/java/com/example/lfrmobileapp/Communication.java View File

@@ -7,14 +7,15 @@ import java.io.IOException;
import java.net.Socket;

public class Communication {
public boolean sendData(String data) {
public boolean sendData(String data, String ip, int port) {
try {
Socket socket = new Socket("192.168.0.1", 1755);
Socket socket = new Socket(ip, port);
DataOutputStream DOS = new DataOutputStream(socket.getOutputStream());
DOS.writeUTF(data);
socket.close();
} catch (Exception e) {
e.printStackTrace();
return true; //ToDo: change to false to test connection - currently always true is delivered
}
return true;
}

+ 4
- 0
MobileApp/app/src/main/java/com/example/lfrmobileapp/MainActivity.java View File

@@ -1,5 +1,7 @@
package com.example.lfrmobileapp;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

import com.google.android.material.bottomnavigation.BottomNavigationView;
@@ -12,6 +14,8 @@ import androidx.navigation.ui.NavigationUI;

import com.example.lfrmobileapp.databinding.ActivityMainBinding;



public class MainActivity extends AppCompatActivity {

private ActivityMainBinding binding;

+ 37
- 1
MobileApp/app/src/main/java/com/example/lfrmobileapp/ui/home/HomeFragment.java View File

@@ -1,6 +1,7 @@
package com.example.lfrmobileapp.ui.home;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -14,12 +15,20 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.lfrmobileapp.Communication;
import com.example.lfrmobileapp.R;
import com.example.lfrmobileapp.databinding.FragmentManuellBinding;
import com.example.lfrmobileapp.ui.notifications.NotificationsFragment;

import io.github.controlwear.virtual.joystick.android.JoystickView;

public class HomeFragment extends Fragment {

String ipKey = "ipkey";
String portKey = "portkey";

String ipAddress = "192.168.0.1";
int port = 8000;

private FragmentManuellBinding binding;

public View onCreateView(@NonNull LayoutInflater inflater,
@@ -30,6 +39,12 @@ public class HomeFragment extends Fragment {
binding = FragmentManuellBinding.inflate(inflater, container, false);
View root = binding.getRoot();

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();

ipAddress = sharedPref.getString(ipKey, "");
port = sharedPref.getInt(portKey, 0);

final TextView textView = binding.textHome;
homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);

@@ -39,7 +54,28 @@ public class HomeFragment extends Fragment {
@Override
public void onMove(int angle, int strength) {
homeViewModel.setText(Integer.toString(angle), Integer.toString(strength));
com.sendData("Vanessa stinkt, Baran nicht");
if((angle >= 338 || angle < 22) && strength != 0){
joystick.setBackgroundResource(R.mipmap.right);
}else if((angle >= 22 && angle < 67) && strength != 0){
joystick.setBackgroundResource(R.mipmap.right_forward);
}else if((angle >=67 && angle < 112) && strength != 0){
joystick.setBackgroundResource(R.mipmap.forward);
}else if((angle >=112 && angle < 157) && strength != 0){
joystick.setBackgroundResource(R.mipmap.left_forward);
}else if((angle >=157 && angle < 202) && strength != 0){
joystick.setBackgroundResource(R.mipmap.left);
}else if((angle >=202 && angle < 247) && strength != 0){
joystick.setBackgroundResource(R.mipmap.left_back);
}else if((angle >=247 && angle < 292) && strength != 0){
joystick.setBackgroundResource(R.mipmap.back);
}else if((angle >=292 && angle < 337) && strength != 0){
joystick.setBackgroundResource(R.mipmap.right_back);
}
else{
joystick.setBackgroundResource(R.mipmap.blank);
}

com.sendData("Vanessa stinkt, Baran nicht", ipAddress, port);
}
});


+ 52
- 0
MobileApp/app/src/main/java/com/example/lfrmobileapp/ui/notifications/NotificationsFragment.java View File

@@ -1,19 +1,37 @@
package com.example.lfrmobileapp.ui.notifications;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.lfrmobileapp.Communication;
import com.example.lfrmobileapp.R;
import com.example.lfrmobileapp.databinding.FragmentEinstellungenBinding;


public class NotificationsFragment extends Fragment {

String ipKey = "ipkey";
String portKey = "portkey";
String connectionFailed = "Verbindung fehlgeschlagen.";
String connectionSuccessful = "Verbindung erfolgreich.";

String ipAddress = "192.168.0.1";
int port = 8000;

int duration = Toast.LENGTH_LONG;

private FragmentEinstellungenBinding binding;

public View onCreateView(@NonNull LayoutInflater inflater,
@@ -24,6 +42,40 @@ public class NotificationsFragment extends Fragment {
binding = FragmentEinstellungenBinding.inflate(inflater, container, false);
View root = binding.getRoot();

Communication com = new Communication();

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();

ipAddress = sharedPref.getString(ipKey, "");
binding.ipAdress.setText(ipAddress);
port = sharedPref.getInt(portKey, -1);
if(port != -1){
binding.port.setText(Integer.toString(port));
}else{
binding.port.setText("");
}


final Button button = binding.connect;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ipAddress = String.valueOf(binding.ipAdress.getText());
port = Integer.parseInt(String.valueOf(binding.port.getText()));
if(com.sendData("", ipAddress, port)){
editor.putString(ipKey, ipAddress);
editor.putInt(portKey, port);
editor.apply();
Toast toast = Toast.makeText(v.getContext(), connectionSuccessful, duration);
toast.show();
}else{
Toast toast = Toast.makeText(v.getContext(), connectionFailed, duration);
toast.show();
}
}
});


return root;
}


+ 17
- 3
MobileApp/app/src/main/res/layout/fragment_einstellungen.xml View File

@@ -9,8 +9,8 @@
<EditText
android:id="@+id/ipAdress"
android:layout_width="269dp"
android:layout_height="38dp"
android:layout_marginTop="64dp"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:hint="IP-Adresse"
android:digits="0123456789."
android:textColor="#000000"
@@ -22,8 +22,9 @@
<EditText
android:id="@+id/port"
android:layout_width="269dp"
android:layout_height="38dp"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:ems="10"
android:hint="Port"
android:digits="0123456789"
android:textColor="#000000"
@@ -31,4 +32,17 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/connect"
android:layout_width="269dp"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:text="Verbinden"
android:background="@color/THblue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></Button>


</androidx.constraintlayout.widget.ConstraintLayout>

+ 10
- 9
MobileApp/app/src/main/res/layout/fragment_manuell.xml View File

@@ -10,13 +10,13 @@
android:id="@+id/joystick"
android:layout_width="308dp"
android:layout_height="317dp"
android:layout_marginTop="12dp"
android:background="@mipmap/kreis"
android:layout_marginTop="68dp"
android:background="@mipmap/blank"
app:JV_buttonColor="#FFFFFF"
app:JV_buttonSizeRatio="11%"
app:JV_fixedCenter="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.481"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

@@ -25,6 +25,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="15sp"
@@ -37,9 +38,9 @@

<Button
android:id="@+id/rotateLeft"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginTop="325dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="350dp"
android:background="@drawable/ic_baseline_rotate_left_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.150"
@@ -48,9 +49,9 @@

<Button
android:id="@+id/rotateRight"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginTop="325dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="350dp"
android:background="@drawable/ic_baseline_rotate_right_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.85"

BIN
MobileApp/app/src/main/res/layout/fragment_manuell.xml~ View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/back.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/blank.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/left.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/left_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/right.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/right_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-hdpi/right_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/back.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/blank.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/left.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/left_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/right.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/right_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-mdpi/right_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/blank.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/left_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xhdpi/right_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/blank.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/left_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxhdpi/right_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/blank.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/left_forward.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right_back.png View File


BIN
MobileApp/app/src/main/res/mipmap-xxxhdpi/right_forward.png View File


Loading…
Cancel
Save