IP-Adresse etc. in der app
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.lfrmobileapp">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
@@ -25,4 +28,6 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
||||
|
||||
</manifest>
|
||||
@@ -1,2 +1,22 @@
|
||||
package com.example.lfrmobileapp;public class Communication {
|
||||
}
|
||||
package com.example.lfrmobileapp;
|
||||
|
||||
import android.accounts.NetworkErrorException;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
public class Communication {
|
||||
public boolean sendData(String data) {
|
||||
try {
|
||||
Socket socket = new Socket("192.168.0.1", 1755);
|
||||
DataOutputStream DOS = new DataOutputStream(socket.getOutputStream());
|
||||
DOS.writeUTF(data);
|
||||
socket.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,4 +34,5 @@ public class MainActivity extends AppCompatActivity {
|
||||
NavigationUI.setupWithNavController(binding.navView, navController);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.lfrmobileapp.Communication;
|
||||
import com.example.lfrmobileapp.databinding.FragmentManuellBinding;
|
||||
|
||||
import io.github.controlwear.virtual.joystick.android.JoystickView;
|
||||
@@ -33,10 +34,12 @@ public class HomeFragment extends Fragment {
|
||||
homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
||||
|
||||
JoystickView joystick = (JoystickView) binding.joystick;
|
||||
Communication com = new Communication();
|
||||
joystick.setOnMoveListener(new JoystickView.OnMoveListener() {
|
||||
@Override
|
||||
public void onMove(int angle, int strength) {
|
||||
homeViewModel.setText(Integer.toString(angle), Integer.toString(strength));
|
||||
com.sendData("Vanessa stinkt, Baran nicht");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
-2
@@ -24,8 +24,6 @@ public class NotificationsFragment extends Fragment {
|
||||
binding = FragmentEinstellungenBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
final TextView textView = binding.textNotifications;
|
||||
notificationsViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="false"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:text="Roboter aktivieren "
|
||||
android:text="Roboter losfahren "
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -6,16 +6,28 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.notifications.NotificationsFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_notifications"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
<EditText
|
||||
android:id="@+id/ipAdress"
|
||||
android:layout_width="269dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:hint="IP-Adresse"
|
||||
android:digits="0123456789."
|
||||
android:textColor="#000000"
|
||||
android:inputType="number|numberDecimal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/port"
|
||||
android:layout_width="269dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginTop="120dp"
|
||||
android:hint="Port"
|
||||
android:digits="0123456789"
|
||||
android:textColor="#000000"
|
||||
android:inputType="number|numberDecimal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -8,16 +8,15 @@
|
||||
|
||||
<io.github.controlwear.virtual.joystick.android.JoystickView
|
||||
android:id="@+id/joystick"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:JV_backgroundColor="@color/THblue"
|
||||
app:JV_borderColor="#000000"
|
||||
app:JV_borderWidth="2dp"
|
||||
android:layout_width="308dp"
|
||||
android:layout_height="317dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@mipmap/kreis"
|
||||
app:JV_buttonColor="#FFFFFF"
|
||||
app:JV_buttonSizeRatio="13%"
|
||||
app:JV_buttonSizeRatio="11%"
|
||||
app:JV_fixedCenter="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintHorizontal_bias="0.481"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -26,7 +25,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="15sp"
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user