SSH is working

SSH is connected to InputFields
This commit is contained in:
JG-Cody 2021-03-06 15:29:50 +01:00
parent 7e15a3d9c1
commit 782cfad891
15 changed files with 104 additions and 32 deletions

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -36,6 +36,7 @@ dependencies {
implementation 'androidx.navigation:navigation-ui:2.3.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0'
implementation 'com.jcraft:jsch:0.1.55'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.jg_cody.Terraplex">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"

View File

@ -1,8 +1,12 @@
package de.jg_cody.Terraplex;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
@ -16,20 +20,33 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import static de.jg_cody.Terraplex.ui.home.HomeFragment.ip;
import static de.jg_cody.Terraplex.ui.home.HomeFragment.password;
import static de.jg_cody.Terraplex.ui.home.HomeFragment.user;
public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) { }
public void onClick(View view) {
try {
Log.d("I","ACTION BUTTON CLICKED");
SSH_connection.executeRemoteCommand(ip, user, password);
} catch (Exception e) {
}}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);

View File

@ -4,7 +4,10 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -16,6 +19,13 @@ import de.jg_cody.Terraplex.R;
public class HomeFragment extends Fragment {
public static String user, password, ip;
public static EditText ipInput;
public static EditText userInput;
public static EditText passwordInput;
Button loginButton;
private HomeViewModel homeViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
@ -30,6 +40,22 @@ public class HomeFragment extends Fragment {
textView.setText(s);
}
});
userInput = (EditText) root.findViewById(R.id.userInput);
passwordInput = (EditText) root.findViewById(R.id.passwordInput);
ipInput = (EditText) root.findViewById(R.id.ipInput);
loginButton = (Button) root.findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
user = userInput.getText().toString();
password = passwordInput.getText().toString();
ip = ipInput.getText().toString();
Toast.makeText(root.getContext(),ip,Toast.LENGTH_SHORT).show();
Toast.makeText(root.getContext(),user,Toast.LENGTH_SHORT).show();
Toast.makeText(root.getContext(),password,Toast.LENGTH_SHORT).show();
}
});
return root;
}
}

View File

@ -10,7 +10,7 @@ public class HomeViewModel extends ViewModel {
public HomeViewModel() {
mText = new MutableLiveData<>();
mText.setValue("Willkommen in Ihrer Homeautomation-App");
mText.setValue("Servus Cody, Willkommen in deiner HOMEAUTOMATIONS-APP");
}
public LiveData<String> getText() {

View File

@ -18,7 +18,8 @@
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView3"
@ -32,7 +33,8 @@
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView4"
@ -45,7 +47,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"

View File

@ -17,6 +17,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -14,10 +14,11 @@
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/editTextNumberSigned"
app:layout_constraintBottom_toTopOf="@+id/ipInput"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView2"
@ -28,25 +29,26 @@
android:textColor="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_home" />
app:layout_constraintTop_toBottomOf="@+id/text_home"
android:gravity="center_horizontal" />
<EditText
android:id="@+id/editTextNumberSigned"
android:id="@+id/ipInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
android:ems="10"
android:hint="IP-Adresse"
android:inputType="numberSigned"
android:inputType="text"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress"
app:layout_constraintBottom_toTopOf="@+id/userInput"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/editTextTextEmailAddress"
android:id="@+id/userInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
@ -62,7 +64,7 @@
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editTextTextPassword"
android:id="@+id/passwordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
@ -74,14 +76,14 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
app:layout_constraintTop_toBottomOf="@+id/userInput" />
<Button
android:id="@+id/login"
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
app:layout_constraintTop_toBottomOf="@+id/passwordInput" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -18,7 +18,8 @@
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView3"
@ -32,7 +33,8 @@
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView4"
@ -45,7 +47,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"

View File

@ -17,7 +17,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView3"
@ -30,7 +31,8 @@
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView4"
@ -43,7 +45,8 @@
app:layout_constraintBottom_toTopOf="@+id/switch1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekBar" />
app:layout_constraintTop_toBottomOf="@+id/seekBar"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"

View File

@ -17,7 +17,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView3"
@ -31,7 +32,8 @@
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView4"
@ -44,7 +46,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"

View File

@ -17,7 +17,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView3"
@ -31,7 +32,8 @@
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/textView4"
@ -44,7 +46,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"

View File

@ -5,6 +5,5 @@
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_logout"
android:titlecolor="#FFFFFF"
app:showAsAction="never" />
</menu>

View File

@ -5,6 +5,10 @@
<string name="nav_header_title">Android Studio</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="SSH_IP">Navigation header</string>
<string name="SSH_User">Navigation header</string>
<string name="SSH_Password">Navigation header</string>
<string name="SSH_Command">Navigation header</string>
<string name="action_logout">logout</string>
<string name="menu_home">Home</string>