commands executing wasn't working jet... ooops :P

now commandexecuting is implemented and should work
This commit is contained in:
JG-Cody 2021-07-10 19:37:19 +02:00
parent f2af9e8ab4
commit d9504a4f9c
5 changed files with 36 additions and 3 deletions

View File

@ -0,0 +1,30 @@
package de.jg_cody.Teraplex.ui.rooms;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import de.jg_cody.Teraplex.SSH_connection;
public class CommandExecutor implements View.OnClickListener {
private String command;
public CommandExecutor(String command) {
this.command = command;
}
@Override
public void onClick(View v) {
SharedPreferences prefs = v.getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
String user = prefs.getString("user", null);
String password = prefs.getString("password", null);
String ip = prefs.getString("ip", null);
if (user == null||ip == null||password == null){
return;
}
try {
SSH_connection.executeRemoteCommand(ip, user, password, command);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -135,6 +135,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
Button text = view.findViewById(R.id.singleButton_text);
bRun.setText(strings[2]);
bRun.setOnClickListener(new CommandExecutor(strings[1]));
text.setText(strings[0]);
break;
}
@ -146,6 +147,8 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
bLeft.setText(strings[3]);
bRight.setText(strings[4]);
bLeft.setOnClickListener(new CommandExecutor(strings[1]));
bRight.setOnClickListener(new CommandExecutor(strings[2]));
text.setText(strings[0]);
break;
}

View File

@ -30,7 +30,7 @@
<item
android:id="@+id/app_bar_switch"
android:icon="@drawable/mode_edit_black_24dp"
android:title="@strings/edit_mode"
android:title="@string/edit_mode"
app:actionLayout="@layout/switch_item"
app:showAsAction="always" />
<item

View File

@ -65,5 +65,5 @@
<string name="cooperation">IN KOOPERATION MIT</string>
<string name="menu_add">TAB HINZUFÜGEN</string>
<string name="menu_remove">TABS ENTFERNEN</string>
<string name="editmode">BEARBEITEN</string>
<string name="edit_mode">BEARBEITEN</string>
</resources>

View File

@ -6,7 +6,7 @@
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="action_logout">LOGOUT</string>
<string name="ssh_remote">SSH-REMOTE</string>
<string name="editmode">EDITMODE</string>
<string name="edit_mode">EDITMODE</string>
//home
<string name="Welcome_to_your_HOMEAUTOMATION_APP">WELCOME TO TERAPLEX</string>