...
This commit is contained in:
parent
737c2fe722
commit
c5e1b8b986
@ -1,5 +1,7 @@
|
||||
package de.jg_cody.Teraplex.ui.Terminal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
@ -8,6 +10,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@ -23,6 +26,7 @@ public class TerminalFragment extends Fragment {
|
||||
TextView terminal_textView;
|
||||
Terminal terminal;
|
||||
ScrollView scrollView;
|
||||
public static String user, password, ip;
|
||||
|
||||
private TerminalViewModel terminalViewModel;
|
||||
|
||||
@ -31,6 +35,16 @@ public class TerminalFragment extends Fragment {
|
||||
terminalViewModel =
|
||||
new ViewModelProvider(this).get(TerminalViewModel.class);
|
||||
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));
|
||||
terminal_edit_text = (EditText) root.findViewById(R.id.terminal_edit_text);
|
||||
terminal_edit_text.setOnKeyListener(new View.OnKeyListener() {
|
||||
@ -40,15 +54,23 @@ public class TerminalFragment extends Fragment {
|
||||
terminal.sendTerminalCommand(terminal_edit_text.getText().toString());
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
terminal_textView = (TextView) root.findViewById(R.id.terminal_textView);
|
||||
new Thread() {
|
||||
public void run() {
|
||||
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 {
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@ -71,11 +93,18 @@ public class TerminalFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -54,7 +54,7 @@ public class IntroFragment extends Fragment {
|
||||
setDimension();
|
||||
mMediaPlayer = mediaPlayer;
|
||||
// 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.
|
||||
if (mCurrentVideoPosition != 0) {
|
||||
mMediaPlayer.seekTo(mCurrentVideoPosition);
|
||||
|
@ -91,12 +91,13 @@
|
||||
android:id="@+id/text_home"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/Welcome_to_your_HOMEAUTOMATION_APP"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/mtrl_btn_text_color_selector"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/reboot"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background"
|
||||
android:background="#000000"
|
||||
tools:context=".ui.intro.IntroFragment">
|
||||
|
||||
<VideoView
|
||||
|
@ -5,6 +5,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:clickable="true"
|
||||
android:id="@+id/fragment_terminal"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.Terminal.TerminalFragment">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user