terminalfont changed to monospacefont, fixed scroll on commandexecution and fixed visible/invisible-bug on homesite

This commit is contained in:
JG-Cody 2021-08-29 20:43:24 +02:00
parent 20b49adeca
commit fe0da8e7ac
14 changed files with 42 additions and 42 deletions

View File

@ -1,12 +1,10 @@
package de.jg_cody.Teraplex;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
@ -56,8 +54,7 @@ public class AddButtonDialogSingle extends DialogFragment {
String name = editText_name.getText().toString();
String button = editText_button_name.getText().toString();
if(command.isEmpty()||button.isEmpty()||name.isEmpty()){
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))

View File

@ -4,7 +4,6 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -45,8 +44,7 @@ public class AddButtonsDialogDouble extends DialogFragment {
String button1 = editText_button1.getText().toString();
String button2 = editText_button2.getText().toString();
if(command1.isEmpty()||command2.isEmpty()||name.isEmpty()||button1.isEmpty()||button2.isEmpty()){
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))

View File

@ -3,7 +3,6 @@ package de.jg_cody.Teraplex;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -45,8 +44,7 @@ public class AddHeadlineDialog extends DialogFragment {
.setPositiveButton(R.string.add, (dialogInterface, i) -> {
String headline = editText_name.getText().toString();
if(headline.isEmpty()){
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))

View File

@ -15,7 +15,6 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -56,7 +55,6 @@ import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -214,8 +212,7 @@ public class MainActivity extends AppCompatActivity {
}
}
if (tabs.contains(tabname)) {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.tabname))
.setMessage(getString(R.string.tabname_already_exist))
@ -238,8 +235,7 @@ public class MainActivity extends AppCompatActivity {
return;
}
if (tabname.isEmpty()) {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.tabname))
.setMessage(getString(R.string.invalid))

View File

@ -8,7 +8,6 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.method.HideReturnsTransformationMethod;
@ -51,6 +50,7 @@ public class HomeFragment extends Fragment {
Button loginButton;
Button logoutButton;
ImageView togglepassword;
ImageView backgroundoverlay_bottom;
@ -86,12 +86,14 @@ public class HomeFragment extends Fragment {
reboot_Button = (Button) root.findViewById(R.id.reboot);
shutdown_Button = (Button) root.findViewById(R.id.shutdown);
togglepassword = (ImageView) root.findViewById(R.id.togglepassword);
backgroundoverlay_bottom = (ImageView) root.findViewById(R.id.backgroundoverlay_bottom);
SharedPreferences t = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
if (user == null || ip == null) {
loginButton.setVisibility(View.VISIBLE);
togglepassword.setVisibility(View.VISIBLE);
reboot_Button.setVisibility(View.GONE);
shutdown_Button.setVisibility(View.GONE);
backgroundoverlay_bottom.setVisibility(View.INVISIBLE);
} else {
loginButton.setVisibility(View.INVISIBLE);
togglepassword.setVisibility(View.INVISIBLE);
@ -100,6 +102,7 @@ public class HomeFragment extends Fragment {
passwordInput.setVisibility(View.GONE);
reboot_Button.setVisibility(View.VISIBLE);
shutdown_Button.setVisibility(View.VISIBLE);
backgroundoverlay_bottom.setVisibility(View.VISIBLE);
}
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -110,8 +113,7 @@ public class HomeFragment extends Fragment {
vr.vibrate(100);
}
if (userInput.getText().toString().trim().length() == 0 || ipInput.getText().toString().trim().length() == 0 || passwordInput.getText().toString().trim().length() == 0) {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
@ -166,6 +168,7 @@ public class HomeFragment extends Fragment {
login_data.setText("");
reboot_Button.setVisibility(View.GONE);
shutdown_Button.setVisibility(View.GONE);
backgroundoverlay_bottom.setVisibility(View.INVISIBLE);
} else {
login_data.setText(getString(R.string.sie_sind_als_angemeldet).replace("{IP}", ip).replace("{USERNAME}", user));
@ -177,6 +180,7 @@ public class HomeFragment extends Fragment {
passwordInput.setVisibility(View.GONE);
reboot_Button.setVisibility(View.VISIBLE);
shutdown_Button.setVisibility(View.VISIBLE);
backgroundoverlay_bottom.setVisibility(View.VISIBLE);
}
}
});
@ -222,10 +226,12 @@ public class HomeFragment extends Fragment {
passwordInput.setVisibility(View.VISIBLE);
reboot_Button.setVisibility(View.GONE);
shutdown_Button.setVisibility(View.GONE);
backgroundoverlay_bottom.setVisibility(View.INVISIBLE);
} else {
logoutButton.setVisibility(View.VISIBLE);
reboot_Button.setVisibility(View.VISIBLE);
shutdown_Button.setVisibility(View.VISIBLE);
backgroundoverlay_bottom.setVisibility(View.VISIBLE);
}
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -249,8 +255,7 @@ public class HomeFragment extends Fragment {
assert vr != null;
vr.vibrate(100);
}
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.restart_server))
.setMessage(getString(R.string.are_you_sure))
@ -265,8 +270,7 @@ public class HomeFragment extends Fragment {
vr.vibrate(100);
}
try {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_down);
mp.start();
Toast.makeText(getContext(), R.string.rebooting, Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "reboot");
} catch (Exception ignored) {
@ -303,8 +307,7 @@ public class HomeFragment extends Fragment {
assert vr != null;
vr.vibrate(100);
}
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.shutdown_server))
.setMessage(getString(R.string.are_you_sure))
@ -319,8 +322,7 @@ public class HomeFragment extends Fragment {
vr.vibrate(100);
}
try {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_down);
mp.start();
Toast.makeText(getContext(), R.string.shutting_down, Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "shutdown now");
} catch (Exception ignored) {

View File

@ -9,7 +9,6 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Base64;
@ -98,8 +97,7 @@ public class SettingsFragment extends Fragment {
assert vr != null;
vr.vibrate(100);
}
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.alert_error);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle(R.string.reset_app)
.setMessage(R.string.are_you_sure_to_reset)

View File

@ -3,7 +3,6 @@ package de.jg_cody.Teraplex.ui.tabs;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.media.MediaPlayer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -181,8 +180,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
String name = editText_name.getText().toString();
String button = editText_button_name.getText().toString();
if(command.isEmpty()||button.isEmpty()||name.isEmpty()){
MediaPlayer mp = MediaPlayer.create(v.getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(v.getContext())
.setTitle(R.string.invalid)
.setMessage(R.string.inputfields_cant_be_empty)
@ -240,8 +238,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
String button1 = editText_button1.getText().toString();
String button2 = editText_button2.getText().toString();
if (command1.isEmpty() || command2.isEmpty() || name.isEmpty() || button1.isEmpty() || button2.isEmpty()) {
MediaPlayer mp = MediaPlayer.create(v.getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(v.getContext())
.setTitle(R.string.invalid)
.setMessage(R.string.inputfields_cant_be_empty)
@ -306,8 +303,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
.setPositiveButton(R.string.add, (dialogInterface, i) -> {
String headline = editText_name.getText().toString();
if(headline.isEmpty()){
MediaPlayer mp = MediaPlayer.create(v.getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(v.getContext())
.setTitle(R.string.invalid)
.setMessage(R.string.inputfields_cant_be_empty)

View File

@ -5,6 +5,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.view.LayoutInflater;
import android.view.View;
@ -25,6 +27,8 @@ import de.jg_cody.Teraplex.R;
public class TerminalFragment extends Fragment {
public static boolean atBottom = false;
public static String command;
Button send_button;
@ -79,8 +83,17 @@ public class TerminalFragment extends Fragment {
}
if (terminal != null) {
terminal.sendTerminalCommand(terminal_edit_text.getText().toString());
if (atBottom) {
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
}, 500);
}}
}
});
@ -119,13 +132,13 @@ public class TerminalFragment extends Fragment {
@Override
public void run() {
boolean atBottom = scrollView.getChildAt(0).getBottom() <= (scrollView.getHeight() + scrollView.getScrollY());
atBottom = scrollView.getChildAt(0).getBottom() <= (scrollView.getHeight() + scrollView.getScrollY());
terminal_textView.setText(terminal.getTerminalOutput());
System.out.println(atBottom);
terminal_textView.invalidate();
scrollView.invalidate();
scrollView.fullScroll(View.FOCUS_DOWN);
//scrollView.fullScroll(View.FOCUS_DOWN);
}
});

View File

@ -71,7 +71,7 @@
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="@+id/backgroundoverlay"
android:id="@+id/backgroundoverlay_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="-25dp"

View File

@ -32,6 +32,7 @@
android:id="@+id/terminal_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="serif-monospace"
android:text="TextView"
android:textColor="#FFFFFF" />
@ -56,6 +57,7 @@
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:ems="10"
android:fontFamily="serif-monospace"
android:hint="@string/command"
android:imeOptions="actionDone"
android:inputType="text"

Binary file not shown.

Binary file not shown.