minimal changes...

This commit is contained in:
JG-Cody 2021-06-06 19:48:21 +02:00
parent 83cbb00b2e
commit c9a4a7fbdd
9 changed files with 138 additions and 129 deletions

View File

@ -19,11 +19,9 @@ import android.os.Bundle;
import android.provider.MediaStore;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.RequiresApi;
@ -36,7 +34,6 @@ import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
import java.io.ByteArrayOutputStream;
@ -47,8 +44,6 @@ import java.util.Locale;
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
import de.jg_cody.Teraplex.ui.Konsole.KonsoleFragment;
import de.jg_cody.Teraplex.ui.home.HomeFragment;
public class MainActivity extends AppCompatActivity implements AddButtonDialog.AddButtonDialogListener {
@ -77,25 +72,25 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setBackgroundResource(R.drawable.toolbartop);
setSupportActionBar(toolbar);
FloatingActionButton addfab = findViewById(R.id.addbutton_fab);
addfab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showChooseElement();
}
});
// FloatingActionButton addfab = findViewById(R.id.addbutton_fab);
// addfab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// showChooseElement();
// }
// });
FloatingActionButton mfab = findViewById(R.id.fab);
mfab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Log.d("I", "ACTION BUTTON CLICKED");
SSH_connection.executeRemoteCommand(HomeFragment.ip, HomeFragment.user, HomeFragment.password, KonsoleFragment.command);
} catch (Exception e) {
}
}
});
// FloatingActionButton mfab = findViewById(R.id.fab);
// mfab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// try {
// Log.d("I", "ACTION BUTTON CLICKED");
// SSH_connection.executeRemoteCommand(HomeFragment.ip, HomeFragment.user, HomeFragment.password, KonsoleFragment.command);
// } catch (Exception e) {
// }
// }
// });
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each

View File

@ -59,7 +59,7 @@ public class SchlafzimmerFragment extends Fragment {
}
schlafzimmeru1aus = (Button) root.findViewById(R.id.schlafzimmeru1aus);
schlafzimmeru1aus = (Button) root.findViewById(R.id.schlafzimmeru1an);
schlafzimmeru1aus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -72,7 +72,7 @@ public class SchlafzimmerFragment extends Fragment {
}
});
schlafzimmeru1an = (Button) root.findViewById(R.id.schlafzimmeru1an);
schlafzimmeru1an = (Button) root.findViewById(R.id.schlafzimmeru1aus);
schlafzimmeru1an.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -85,7 +85,7 @@ public class SchlafzimmerFragment extends Fragment {
}
});
schlafzimmeru2aus = (Button) root.findViewById(R.id.schlafzimmeru2aus);
schlafzimmeru2aus = (Button) root.findViewById(R.id.schlafzimmeru2an);
schlafzimmeru2aus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -98,7 +98,7 @@ public class SchlafzimmerFragment extends Fragment {
}
});
schlafzimmeru2an = (Button) root.findViewById(R.id.schlafzimmeru2an);
schlafzimmeru2an = (Button) root.findViewById(R.id.schlafzimmeru2aus);
schlafzimmeru2an.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -111,7 +111,7 @@ public class SchlafzimmerFragment extends Fragment {
}
});
schlafzimmeru3aus = (Button) root.findViewById(R.id.schlafzimmeru3aus);
schlafzimmeru3aus = (Button) root.findViewById(R.id.schlafzimmeru3an);
schlafzimmeru3aus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -124,7 +124,7 @@ public class SchlafzimmerFragment extends Fragment {
}
});
schlafzimmeru3an = (Button) root.findViewById(R.id.schlafzimmeru3an);
schlafzimmeru3an = (Button) root.findViewById(R.id.schlafzimmeru3aus);
schlafzimmeru3an.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -78,25 +78,31 @@ public class HomeFragment extends Fragment {
if (user == null || ip == null) {
loginButton.setVisibility(View.VISIBLE);
}
else {loginButton.setVisibility(View.INVISIBLE);}
else {loginButton.setVisibility(View.INVISIBLE);
ipInput.setVisibility(View.GONE);
userInput.setVisibility(View.GONE);
passwordInput.setVisibility(View.GONE);}
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (userInput.getText().toString().trim().length() == 0 || ipInput.getText().toString().trim().length() == 0 || passwordInput.getText().toString().trim().length() == 0) {
Toast.makeText(getContext(), "Felder dürfen nicht leer sein!", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(),getString(R.string.felder_dürfen_nicht_leer_sein), Toast.LENGTH_SHORT).show();
} else {
user = userInput.getText().toString();
password = passwordInput.getText().toString();
ip = ipInput.getText().toString();
SharedPreferences p = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
p.edit().putString("user", user).putString("password", password).putString("ip", ip).apply();
Toast.makeText(getContext(), "Login-Daten gespeichert...", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), getString(R.string.login_saved), Toast.LENGTH_SHORT).show();
if (user == null || ip == null) {
login_data.setText("");
} else {
login_data.setText("Sie sind als " + user + " bei " + ip + " angemeldet!");
login_data.setText(getString(R.string.sie_sind_als_angemeldet).replace("{IP}", ip).replace("{USERNAME}", user));
logoutButton.setVisibility(View.VISIBLE);
loginButton.setVisibility(View.INVISIBLE);
ipInput.setVisibility(View.GONE);
userInput.setVisibility(View.GONE);
passwordInput.setVisibility(View.GONE);
}
}
}
@ -104,6 +110,9 @@ public class HomeFragment extends Fragment {
logoutButton = (Button) root.findViewById(R.id.logoutButton);
if (user == null || ip == null) {
logoutButton.setVisibility(View.INVISIBLE);
ipInput.setVisibility(View.VISIBLE);
userInput.setVisibility(View.VISIBLE);
passwordInput.setVisibility(View.VISIBLE);
}
else {logoutButton.setVisibility(View.VISIBLE);}
logoutButton.setOnClickListener(new View.OnClickListener() {
@ -114,7 +123,7 @@ public class HomeFragment extends Fragment {
getActivity().finish();
}
});
wlan_aus_Button = (Button) root.findViewById(R.id.wlan_aus);
wlan_aus_Button = (Button) root.findViewById(R.id.wlan_an);
wlan_aus_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -126,7 +135,7 @@ public class HomeFragment extends Fragment {
}
}
});
wlan_an_Button = (Button) root.findViewById(R.id.wlan_an);
wlan_an_Button = (Button) root.findViewById(R.id.wlan_aus);
wlan_an_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -138,7 +147,7 @@ public class HomeFragment extends Fragment {
}
}
});
kodiaus = (Button) root.findViewById(R.id.kodiaus);
kodiaus = (Button) root.findViewById(R.id.kodian);
kodiaus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -151,7 +160,7 @@ public class HomeFragment extends Fragment {
}
});
kodian = (Button) root.findViewById(R.id.kodian);
kodian = (Button) root.findViewById(R.id.kodiaus);
kodian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -20,7 +20,7 @@
app:layout_anchor="@+id/include"
app:layout_anchorGravity="center" />
<de.jg_cody.Teraplex.MovableFloatingActionButton
<!-- <de.jg_cody.Teraplex.MovableFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -37,7 +37,7 @@
android:layout_marginVertical="70dp"
android:background="@drawable/button_round"
android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp" />
android:src="@drawable/add_black_24dp" /> -->
<androidx.appcompat.widget.Toolbar

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@ -33,13 +34,15 @@
android:layout_marginTop="-50dp"
android:layout_marginEnd="-25dp"
android:layout_marginRight="-25dp"
android:layout_marginBottom="-50dp"
android:layout_marginBottom="-100dp"
android:scaleType="centerCrop"
android:src="@drawable/backgroundoverlay"
app:layout_constraintBottom_toBottomOf="@+id/Background"
app:layout_constraintEnd_toEndOf="@+id/TERAPLEX_Version"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/TERAPLEX_Version"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="@+id/lizenz"
@ -153,7 +156,7 @@
<TextView
android:id="@+id/TERAPLEX_Version"
android:layout_width="300dp"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:gravity="center_horizontal"

View File

@ -27,15 +27,17 @@
android:id="@drawable/backgroundoverlay"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="-25dp"
android:layout_marginLeft="-25dp"
android:layout_marginTop="-25dp"
android:layout_marginEnd="-25dp"
android:layout_marginRight="-25dp"
android:layout_marginBottom="-25dp"
android:scaleType="centerCrop"
android:src="@drawable/backgroundoverlay"
app:layout_constraintBottom_toBottomOf="@+id/logoutButton"
app:layout_constraintEnd_toEndOf="@+id/ipInput"
app:layout_constraintStart_toStartOf="@+id/ipInput"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toTopOf="@+id/text_home" />
<ImageView
@ -51,23 +53,22 @@
android:scaleType="centerCrop"
android:src="@drawable/backgroundoverlay"
app:layout_constraintBottom_toBottomOf="@+id/textView7"
app:layout_constraintEnd_toEndOf="@+id/wlan_an"
app:layout_constraintStart_toStartOf="@+id/wlan_aus"
app:layout_constraintEnd_toEndOf="@+id/wlan_aus"
app:layout_constraintStart_toStartOf="@+id/wlan_an"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<TextView
android:id="@+id/text_home"
android:layout_width="0dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginTop="100dp"
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/ipInput"
app:layout_constraintEnd_toEndOf="@+id/ipInput"
app:layout_constraintStart_toStartOf="@+id/ipInput"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -78,24 +79,25 @@
android:textAlignment="center"
android:textColor="#00FF00"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="@+id/ipInput"
app:layout_constraintStart_toStartOf="@+id/ipInput"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/text_home" />
<EditText
android:id="@+id/ipInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:backgroundTint="@color/mtrl_btn_text_color_selector"
android:ems="10"
android:hint="@string/login_ipadresse"
android:inputType="text"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textColorHint="@color/mtrl_btn_text_color_selector"
android:backgroundTint="@color/mtrl_btn_text_color_selector"
app:layout_constraintBottom_toTopOf="@+id/loginuserInput"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/login_data" />
<EditText
android:id="@+id/loginuserInput"
@ -108,12 +110,10 @@
android:singleLine="false"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textColorHint="@color/mtrl_btn_text_color_selector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.434" />
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/ipInput" />
<EditText
android:id="@+id/loginpasswordInput"
@ -125,9 +125,9 @@
android:inputType="textPassword"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textColorHint="@color/mtrl_btn_text_color_selector"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/loginuserInput" />
<Button
@ -141,7 +141,7 @@
android:hapticFeedbackEnabled="true"
android:text="@string/login"
app:backgroundTint="@null"
app:layout_constraintStart_toStartOf="@+id/loginpasswordInput"
app:layout_constraintStart_toStartOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/loginpasswordInput" />
<Button
@ -155,68 +155,68 @@
android:hapticFeedbackEnabled="true"
android:text="@string/logout"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="@+id/loginpasswordInput"
app:layout_constraintEnd_toEndOf="@+id/text_home"
app:layout_constraintTop_toBottomOf="@+id/loginpasswordInput" />
<Button
android:id="@+id/wlan_an"
android:id="@+id/wlan_aus"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:background="@drawable/button_right"
android:drawableRight="@drawable/signal_wifi_statusbar_4_bar_24px"
android:drawableRight="@drawable/signal_wifi_off_24px"
android:drawableTint="@color/mtrl_btn_text_color_selector"
android:hapticFeedbackEnabled="true"
android:text="@string/an"
android:text="@string/aus"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintStart_toEndOf="@+id/textView5"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<Button
android:id="@+id/kodian"
android:id="@+id/kodiaus"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:background="@drawable/button_right"
android:drawableRight="@drawable/kodi"
android:drawableRight="@drawable/kodi_aus_1_"
android:drawableTint="@color/mtrl_btn_text_color_selector"
android:hapticFeedbackEnabled="true"
android:text="@string/an"
android:text="@string/aus"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView7"
app:layout_constraintStart_toEndOf="@+id/textView7"
app:layout_constraintTop_toTopOf="@+id/textView7" />
<Button
android:id="@+id/wlan_aus"
android:id="@+id/wlan_an"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_left"
android:drawableLeft="@drawable/signal_wifi_off_24px"
android:drawableLeft="@drawable/signal_wifi_statusbar_4_bar_24px"
android:drawableTint="@color/mtrl_btn_text_color_selector"
android:hapticFeedbackEnabled="true"
android:text="@string/aus"
android:text="@string/an"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintEnd_toStartOf="@+id/textView5"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<Button
android:id="@+id/kodiaus"
android:id="@+id/kodian"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_left"
android:drawableLeft="@drawable/kodi_aus_1_"
android:drawableLeft="@drawable/kodi"
android:drawableTint="@color/mtrl_btn_text_color_selector"
android:hapticFeedbackEnabled="true"
android:text="@string/aus"
android:text="@string/an"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView7"
app:layout_constraintEnd_toStartOf="@+id/textView7"

View File

@ -34,75 +34,75 @@
android:scaleType="centerCrop"
android:src="@drawable/backgroundoverlay"
app:layout_constraintBottom_toBottomOf="@+id/textView2"
app:layout_constraintEnd_toEndOf="@+id/schlafzimmeru1an"
app:layout_constraintStart_toStartOf="@+id/schlafzimmeru1aus"
app:layout_constraintEnd_toEndOf="@+id/schlafzimmeru1aus"
app:layout_constraintStart_toStartOf="@+id/schlafzimmeru1an"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<Button
android:id="@+id/schlafzimmeru3an"
android:id="@+id/schlafzimmeru3aus"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/button_right"
android:hapticFeedbackEnabled="true"
android:text="AN"
android:text="@string/aus"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView2"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="@+id/textView2" />
<Button
android:id="@+id/schlafzimmeru3aus"
android:id="@+id/schlafzimmeru3an"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/button_left"
android:hapticFeedbackEnabled="true"
android:text="AUS"
android:text="@string/an"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView2"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintTop_toTopOf="@+id/textView2" />
<Button
android:id="@+id/schlafzimmeru2an"
android:id="@+id/schlafzimmeru2aus"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/button_right"
android:hapticFeedbackEnabled="true"
android:text="AN"
android:text="@string/aus"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView3"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintTop_toTopOf="@+id/textView3" />
<Button
android:id="@+id/schlafzimmeru2aus"
android:id="@+id/schlafzimmeru2an"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/button_left"
android:hapticFeedbackEnabled="true"
android:text="AUS"
android:text="@string/an"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView3"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintTop_toTopOf="@+id/textView3" />
<Button
android:id="@+id/schlafzimmeru1aus"
android:id="@+id/schlafzimmeru1an"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/button_left"
android:hapticFeedbackEnabled="true"
android:text="AUS"
android:text="@string/an"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintEnd_toStartOf="@+id/textView5"
@ -157,14 +157,14 @@
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<Button
android:id="@+id/schlafzimmeru1an"
android:id="@+id/schlafzimmeru1aus"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/button_right"
android:hapticFeedbackEnabled="true"
android:text="AN"
android:text="@string/aus"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintStart_toEndOf="@+id/textView5"

View File

@ -25,6 +25,8 @@
<string name="an">ON</string>
<string name="please_login">PLEASE CONNECT TO YOUR SERVER</string>
<string name="sie_sind_als_angemeldet">YOU ARE LOGGED IN ON {IP} AS {USERNAME}</string>
<string name="felder_dürfen_nicht_leer_sein">INPUTFIELDS CANT BE EMPTY!</string>
<string name="login_saved">LOGIN-DATA SAVED!</string>
//konsole
<string name="konsole">CONSOLE</string>