...
This commit is contained in:
parent
737c2fe722
commit
c5e1b8b986
@ -1,5 +1,7 @@
|
|||||||
package de.jg_cody.Teraplex.ui.Terminal;
|
package de.jg_cody.Teraplex.ui.Terminal;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -8,6 +10,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@ -23,6 +26,7 @@ public class TerminalFragment extends Fragment {
|
|||||||
TextView terminal_textView;
|
TextView terminal_textView;
|
||||||
Terminal terminal;
|
Terminal terminal;
|
||||||
ScrollView scrollView;
|
ScrollView scrollView;
|
||||||
|
public static String user, password, ip;
|
||||||
|
|
||||||
private TerminalViewModel terminalViewModel;
|
private TerminalViewModel terminalViewModel;
|
||||||
|
|
||||||
@ -31,6 +35,16 @@ public class TerminalFragment extends Fragment {
|
|||||||
terminalViewModel =
|
terminalViewModel =
|
||||||
new ViewModelProvider(this).get(TerminalViewModel.class);
|
new ViewModelProvider(this).get(TerminalViewModel.class);
|
||||||
View root = inflater.inflate(R.layout.fragment_terminal, container, false);
|
View root = inflater.inflate(R.layout.fragment_terminal, container, false);
|
||||||
|
SharedPreferences prefs = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||||
|
user = prefs.getString("user", null);
|
||||||
|
password = prefs.getString("password", null);
|
||||||
|
ip = prefs.getString("ip", null);
|
||||||
|
if (user == null || ip == null) {
|
||||||
|
Toast.makeText(getContext(), getString(R.string.login_saved), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(getContext(), ("test"), Toast.LENGTH_SHORT).show();
|
||||||
scrollView = (ScrollView) root.findViewById((R.id.scrollView));
|
scrollView = (ScrollView) root.findViewById((R.id.scrollView));
|
||||||
terminal_edit_text = (EditText) root.findViewById(R.id.terminal_edit_text);
|
terminal_edit_text = (EditText) root.findViewById(R.id.terminal_edit_text);
|
||||||
terminal_edit_text.setOnKeyListener(new View.OnKeyListener() {
|
terminal_edit_text.setOnKeyListener(new View.OnKeyListener() {
|
||||||
@ -40,15 +54,23 @@ public class TerminalFragment extends Fragment {
|
|||||||
terminal.sendTerminalCommand(terminal_edit_text.getText().toString());
|
terminal.sendTerminalCommand(terminal_edit_text.getText().toString());
|
||||||
|
|
||||||
|
|
||||||
}
|
} else {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
terminal_textView = (TextView) root.findViewById(R.id.terminal_textView);
|
terminal_textView = (TextView) root.findViewById(R.id.terminal_textView);
|
||||||
new Thread() {
|
new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
terminal = new Terminal();
|
terminal = new Terminal();
|
||||||
while (true) {
|
boolean isFragmentActive = true;
|
||||||
|
while (isFragmentActive == true) {
|
||||||
|
Fragment myFragment = (Fragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_terminal);
|
||||||
|
if (myFragment == null) {
|
||||||
|
|
||||||
|
isFragmentActive = false;
|
||||||
|
}
|
||||||
|
else if (myFragment.isVisible())
|
||||||
|
{
|
||||||
|
isFragmentActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
requireActivity().runOnUiThread(new Runnable() {
|
requireActivity().runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@ -71,11 +93,18 @@ public class TerminalFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -54,7 +54,7 @@ public class IntroFragment extends Fragment {
|
|||||||
setDimension();
|
setDimension();
|
||||||
mMediaPlayer = mediaPlayer;
|
mMediaPlayer = mediaPlayer;
|
||||||
// We want our video to play over and over so we set looping to true.
|
// We want our video to play over and over so we set looping to true.
|
||||||
mMediaPlayer.setLooping(false);
|
mMediaPlayer.setLooping(true);
|
||||||
// We then seek to the current position if it has been set and play the video.
|
// We then seek to the current position if it has been set and play the video.
|
||||||
if (mCurrentVideoPosition != 0) {
|
if (mCurrentVideoPosition != 0) {
|
||||||
mMediaPlayer.seekTo(mCurrentVideoPosition);
|
mMediaPlayer.seekTo(mCurrentVideoPosition);
|
||||||
|
@ -91,12 +91,13 @@
|
|||||||
android:id="@+id/text_home"
|
android:id="@+id/text_home"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="100dp"
|
android:layout_marginBottom="50dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:text="@string/Welcome_to_your_HOMEAUTOMATION_APP"
|
android:text="@string/Welcome_to_your_HOMEAUTOMATION_APP"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/mtrl_btn_text_color_selector"
|
android:textColor="@color/mtrl_btn_text_color_selector"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/reboot"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/background"
|
android:background="#000000"
|
||||||
tools:context=".ui.intro.IntroFragment">
|
tools:context=".ui.intro.IntroFragment">
|
||||||
|
|
||||||
<VideoView
|
<VideoView
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:id="@+id/fragment_terminal"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.Terminal.TerminalFragment">
|
tools:context=".ui.Terminal.TerminalFragment">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user