dynamic content update

This commit is contained in:
zwicki 2021-06-12 16:21:13 +02:00
parent 4a9db0ddf1
commit 341b3edc35
23 changed files with 562 additions and 337 deletions

View File

@ -40,6 +40,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'com.jcraft:jsch:0.1.55' implementation 'com.jcraft:jsch:0.1.55'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

View File

@ -13,16 +13,28 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
public class AddButtonDialog extends DialogFragment { public class AddButtonDialogSingle extends DialogFragment {
private EditText editTextUsername; private EditText editTextUsername;
private EditText editTextPassword; private EditText editTextPassword;
private EditText command, name, button_name;
private AddButtonDialogListener listener; private AddButtonDialogListener listener;
/**
*
* @param savedInstanceState
* @return
*/
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.addbuttondialog, null); View view = inflater.inflate(R.layout.addbuttondialog_single, null);
command = getActivity().findViewById(R.id.dialogSingle_editText_command);
name = getActivity().findViewById(R.id.dialogSingle_editText_name);
button_name = getActivity().findViewById(R.id.dialogSingle_editText_buttonName);
builder.setView(view) builder.setView(view)
.setTitle("SINGLE BUTTON") .setTitle("SINGLE BUTTON")
@ -42,8 +54,6 @@ public class AddButtonDialog extends DialogFragment {
}); });
editTextUsername = view.findViewById(R.id.button_name);
editTextPassword = view.findViewById(R.id.button_command);
AlertDialog mDialog = builder.create(); AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round); mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
return mDialog; return mDialog;
@ -61,7 +71,21 @@ public class AddButtonDialog extends DialogFragment {
} }
} }
public interface AddButtonDialogListener { public interface AddButtonDialogListener {
void applyTexts(String username, String password); void applyTexts(String username, String password);
} }
public String getName()
{
return name.getText().toString();
}
public String getButtonName()
{
return button_name.getText().toString();
}
public String getCommand()
{
return command.getText().toString();
}
} }

View File

@ -12,17 +12,17 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
public class AddButtonsDialog extends DialogFragment { public class AddButtonsDialogDouble extends DialogFragment {
private EditText editTextUsername;
private EditText editTextPassword;
private AddButtonsDialogListener listener; private AddButtonsDialogListener listener;
private EditText name, command1, button1, command2, button2;
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.addbuttonsdialog, null); View view = inflater.inflate(R.layout.addbuttonsdialog_double, null);
builder.setView(view) builder.setView(view)
.setTitle("ON/OFF BUTTON") .setTitle("ON/OFF BUTTON")
@ -35,15 +35,15 @@ public class AddButtonsDialog extends DialogFragment {
.setPositiveButton("ADD", new DialogInterface.OnClickListener() { .setPositiveButton("ADD", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
String username = editTextUsername.getText().toString();
String password = editTextPassword.getText().toString();
listener.applyTexts(username, password);
} }
}); });
editTextUsername = view.findViewById(R.id.button_name); name = getActivity().findViewById(R.id.dialogDouble_editText_name);
editTextPassword = view.findViewById(R.id.button_command); command1 = getActivity().findViewById(R.id.dialogDouble_editText_command1);
command2 = getActivity().findViewById(R.id.dialogDouble_editText_command2);
button1 = getActivity().findViewById(R.id.dialogDouble_editText_button1);
button2 = getActivity().findViewById(R.id.dialogDouble_editText_button2);
AlertDialog mDialog = builder.create(); AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round); mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
return mDialog; return mDialog;
@ -63,4 +63,25 @@ public class AddButtonsDialog extends DialogFragment {
public interface AddButtonsDialogListener { public interface AddButtonsDialogListener {
void applyTexts(String username, String password); void applyTexts(String username, String password);
} }
public String getName()
{
return name.getText().toString();
}
public String getCommand1()
{
return command1.getText().toString();
}
public String getButton1()
{
return button1.getText().toString();
}
public String getCommand2()
{
return command2.getText().toString();
}
public String getButton2()
{
return button2.getText().toString();
}
} }

View File

@ -1,9 +1,7 @@
package de.jg_cody.Teraplex; package de.jg_cody.Teraplex;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -48,7 +46,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Base64; import java.util.Base64;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment; import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment; import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
@ -56,7 +53,7 @@ import de.jg_cody.Teraplex.ui.Konsole.KonsoleFragment;
import de.jg_cody.Teraplex.ui.home.HomeFragment; import de.jg_cody.Teraplex.ui.home.HomeFragment;
public class MainActivity extends AppCompatActivity implements AddButtonDialog.AddButtonDialogListener { public class MainActivity extends AppCompatActivity implements AddButtonDialogSingle.AddButtonDialogListener {
public static int RESULT_LOAD_IMAGE = 0; public static int RESULT_LOAD_IMAGE = 0;
private AppBarConfiguration mAppBarConfiguration; private AppBarConfiguration mAppBarConfiguration;
@ -109,13 +106,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setBackgroundResource(R.drawable.toolbartop); toolbar.setBackgroundResource(R.drawable.toolbartop);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
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); FloatingActionButton mfab = findViewById(R.id.fab);
mfab.setOnClickListener(new View.OnClickListener() { mfab.setOnClickListener(new View.OnClickListener() {
@ -143,6 +134,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
} }
/*static public class DemoPreferenceFragment extends PreferenceFragmentCompat { /*static public class DemoPreferenceFragment extends PreferenceFragmentCompat {
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@ -192,15 +184,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
startActivity(startMain); startActivity(startMain);
} }
public void openDialog1() {
AddButtonDialog AddButtonDialog = new AddButtonDialog();
AddButtonDialog.show(getSupportFragmentManager(), "example dialog");
}
public void openDialog2() {
AddButtonsDialog AddButtonsDialog = new AddButtonsDialog();
AddButtonsDialog.show(getSupportFragmentManager(), "example dialog");
}
@Override @Override
public void applyTexts(String username, String password) { public void applyTexts(String username, String password) {
@ -238,30 +222,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
} }
} }
private void showChooseElement() {
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "ÜBERSCHRIFT", "PLATZHALTER"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
mBuilder.setTitle("CHOOSE ELEMENT");
mBuilder.setSingleChoiceItems(listItems, -5, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
openDialog1();
} else if (i == 1) {
openDialog2();
} else if (i == 2) {
} else if (i == 3) {
}
dialogInterface.dismiss();
}
});
AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.show();
}
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
@Override @Override

View File

@ -1,7 +1,8 @@
package de.jg_cody.Teraplex.ui.Flur; package de.jg_cody.Teraplex.ui.Flur;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
@ -10,39 +11,40 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.ListView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import de.jg_cody.Teraplex.ActivityCricketers; import de.jg_cody.Teraplex.AddButtonDialogSingle;
import de.jg_cody.Teraplex.AddButtonsDialogDouble;
import de.jg_cody.Teraplex.Cricketer; import de.jg_cody.Teraplex.Cricketer;
import de.jg_cody.Teraplex.MainActivity; import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
import de.jg_cody.Teraplex.ui.rooms.*;
public class FlurFragment extends Fragment{
public class FlurFragment extends Fragment implements View.OnClickListener {
private FlurViewModel flurViewModel; private FlurViewModel flurViewModel;
LinearLayout layoutList;
Button buttonAdd;
Button buttonSubmitList;
List<String> teamList = new ArrayList<>(); String[] commands = {"Hello1","Hello2","Hello3","Hello4","Hello5"};
int[] type = {0,1,0,0,1};
ListView listView;
ListAdapter listAdapter;
ArrayList<ListItem> items;
ArrayList<Cricketer> cricketersList = new ArrayList<>(); ArrayList<Cricketer> cricketersList = new ArrayList<>();
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
@ -60,119 +62,70 @@ public class FlurFragment extends Fragment implements View.OnClickListener {
I.setScaleType(ImageView.ScaleType.CENTER_CROP); I.setScaleType(ImageView.ScaleType.CENTER_CROP);
} }
layoutList = root.findViewById(R.id.layout_list);
buttonAdd = root.findViewById(R.id.button_add);
buttonSubmitList = root.findViewById(R.id.button_submit_list);
buttonAdd.setOnClickListener(this);
buttonSubmitList.setOnClickListener(this);
teamList.add("Team"); listView = root.findViewById(R.id.listView);
teamList.add("India");
teamList.add("Australia");
teamList.add("England");
return root; items = new ArrayList<ListItem>();
}
listAdapter= new ListAdapter(getContext(), R.id.text, items);
listView.setAdapter(listAdapter);
FloatingActionButton addfab = root.findViewById(R.id.addbutton_fab);
addfab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
showChooseElement();
switch (v.getId()){
case R.id.button_add:
addView();
break;
case R.id.button_submit_list:
if(checkIfValidAndRead()){
Intent intent = new Intent( getContext(), ActivityCricketers.class);
Bundle bundle = new Bundle();
bundle.putSerializable("list",cricketersList);
intent.putExtras(bundle);
startActivity(intent);
}
break;
}
}
private boolean checkIfValidAndRead() {
cricketersList.clear();
boolean result = true;
for(int i=0;i<layoutList.getChildCount();i++){
View cricketerView = layoutList.getChildAt(i);
EditText editTextName = (EditText)cricketerView.findViewById(R.id.edit_cricketer_name);
AppCompatSpinner spinnerTeam = (AppCompatSpinner)cricketerView.findViewById(R.id.spinner_team);
Cricketer cricketer = new Cricketer();
if(!editTextName.getText().toString().equals("")){
cricketer.setCricketerName(editTextName.getText().toString());
}else {
result = false;
break;
}
if(spinnerTeam.getSelectedItemPosition()!=0){
cricketer.setTeamName(teamList.get(spinnerTeam.getSelectedItemPosition()));
}else {
result = false;
break;
}
cricketersList.add(cricketer);
}
if(cricketersList.size()==0){
result = false;
Toast.makeText(getContext(), "Add Cricketers First!", Toast.LENGTH_SHORT).show();
}else if(!result){
Toast.makeText(getContext(), "Enter All Details Correctly!", Toast.LENGTH_SHORT).show();
}
return result;
}
private void addView() {
final View cricketerView = getLayoutInflater().inflate(R.layout.singlebutton,null,false);
EditText editText = (EditText)cricketerView.findViewById(R.id.edit_cricketer_name);
AppCompatSpinner spinnerTeam = (AppCompatSpinner)cricketerView.findViewById(R.id.spinner_team);
ImageView imageClose = (ImageView)cricketerView.findViewById(R.id.image_remove);
ArrayAdapter arrayAdapter = new ArrayAdapter(requireContext(),android.R.layout.simple_spinner_item,teamList);
spinnerTeam.setAdapter(arrayAdapter);
imageClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
removeView(cricketerView);
} }
}); });
layoutList.addView(cricketerView);
return root;
}
private void showChooseElement() {
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "ÜBERSCHRIFT", "PLATZHALTER"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity());
mBuilder.setTitle("CHOOSE ELEMENT");
mBuilder.setSingleChoiceItems(listItems, -5, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
openDialog1();
} else if (i == 1) {
openDialog2();
} else if (i == 2) {
} else if (i == 3) {
} }
private void removeView(View view){ dialogInterface.dismiss();
}
});
AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.show();
}
public void openDialog1() {
AddButtonDialogSingle addButtonDialogSingle = new AddButtonDialogSingle();
addButtonDialogSingle.show(getActivity().getSupportFragmentManager(), "example dialog");
items.add(new ListItemSingle(addButtonDialogSingle.getCommand(),1, addButtonDialogSingle.getName(), addButtonDialogSingle.getButtonName()));
listAdapter.notifyDataSetChanged();
layoutList.removeView(view);
} }
public void openDialog2() {
AddButtonsDialogDouble addButtonsDialogDouble = new AddButtonsDialogDouble();
addButtonsDialogDouble.show(getActivity().getSupportFragmentManager(), "example dialog");
items.add(new ListItemDouble(2,addButtonsDialogDouble.getName(), addButtonsDialogDouble.getCommand1(), addButtonsDialogDouble.getCommand2(), addButtonsDialogDouble.getButton1(), addButtonsDialogDouble.getButton2()));
listAdapter.notifyDataSetChanged();
}
public void addItems(View v) {
listAdapter.notifyDataSetChanged();
}
} }

View File

@ -0,0 +1,8 @@
package de.jg_cody.Teraplex.ui.rooms;
import android.view.View;
public interface IViewHolder {
abstract public String getCommand();
abstract public View[] getViews();
}

View File

@ -0,0 +1,85 @@
package de.jg_cody.Teraplex.ui.rooms;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import java.util.ArrayList;
import de.jg_cody.Teraplex.R;
import de.jg_cody.Teraplex.ui.Flur.FlurFragment;
public class ListAdapter extends ArrayAdapter {
public static int SINGLEBUTTON = 0;
public static int DOUBLEBUTTON = 1;
public static int OPTION3BUTTON = 2;
private ArrayList<ListItem> objects;
@Override
public int getViewTypeCount()
{
return 3;
}
public int getItemViewType(int position){
return objects.get(position).getType();
}
public ListAdapter(Context context, int resource, ArrayList<ListItem> objects)
{
super(context, resource, objects);
this.objects = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
IViewHolder viewHolder= null;
ListItem listViewItem = objects.get(position);
int listViewItemType = getItemViewType(position);
if (convertView == null) {
if (listViewItemType == SINGLEBUTTON) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.singlebutton, null);
Button bRun = convertView.findViewById(R.id.bRun);
Button text = convertView.findViewById(R.id.TEXT);
bRun.setText(listViewItem.getText());
//text.setText(listViewItemType.get)
viewHolder = new ViewHolderSingleButton(bRun , listViewItem.getText());
convertView.setTag(viewHolder);
}
else if (listViewItemType == DOUBLEBUTTON) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.doublebutton, null);
Button bLeft = (Button) convertView.findViewById(R.id.bLeft);
Button bRight = (Button) convertView.findViewById(R.id.bRight);
viewHolder = new ViewHolderDoubleButton(bLeft,bRight,listViewItem.getText());
convertView.setTag(viewHolder);
}
else if(listViewItemType == OPTION3BUTTON)
{
}
}
else{
viewHolder = (IViewHolder) convertView.getTag();
}
return convertView;
}
}

View File

@ -0,0 +1,29 @@
package de.jg_cody.Teraplex.ui.rooms;
public class ListItem {
private String text;
private int type;
public ListItem(int type) {
this.type = type;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}

View File

@ -0,0 +1,55 @@
package de.jg_cody.Teraplex.ui.rooms;
public class ListItemDouble extends ListItem{
private String name, command1, command2,button1, button2;
public ListItemDouble( int type, String name, String command1, String command2, String button1, String button2) {
super( type);
this.name = name;
this.command1 = command1;
this.command2 = command2;
this.button1 = button1;
this.button2 = button2;
}
public void setName(String name)
{
this.name = name;
}
public void setCommand1(String command1)
{
this.command1 = command1;
}
public void setCommand2(String command2)
{
this.command2 = command2;
}
public void setButton1(String button1)
{
this.button1 = button1;
}
public void setButton2(String button2)
{
this.button2 = button2;
}
public String getName()
{
return name;
}
public String getCommand1()
{
return command1;
}
public String getCommand2()
{
return command2;
}
public String getButton1()
{
return button1;
}
public String getButton2()
{
return button2;
}
}

View File

@ -0,0 +1,29 @@
package de.jg_cody.Teraplex.ui.rooms;
public class ListItemSingle extends ListItem{
String buttonName;
String name;
public ListItemSingle(String command, int type, String buttonName, String name) {
super(type);
this.name = name;
this.buttonName = buttonName;
}
public void setButtonName(String buttonName)
{
this.buttonName = buttonName;
}
public void setName(String name)
{
this.name = name;
}
public String getButtonName()
{
return buttonName;
}
public String getName()
{
return name;
}
}

View File

@ -0,0 +1,6 @@
package de.jg_cody.Teraplex.ui.rooms;
import androidx.fragment.app.Fragment;
public class RoomFragment extends Fragment {
}

View File

@ -0,0 +1,47 @@
package de.jg_cody.Teraplex.ui.rooms;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class ViewHolderDoubleButton implements IViewHolder{
String command;
Button bLeft, bRight;
public ViewHolderDoubleButton(Button bLeft, Button bRight, String command) {
this.bLeft = bLeft;
this.bRight = bRight;
this.command = command;
bLeft.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bLeft.getContext(),command + " ON",Toast.LENGTH_SHORT).show();
}
});
bRight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bRight.getContext(),command + " ON",Toast.LENGTH_SHORT).show();
}
});
}
@Override
public String getCommand() {
return command;
}
public Button getbLeft() {
return bLeft;
}
public Button getbRight(){return bRight;}
@Override
public View[] getViews()
{
View[] views = {getbLeft(),getbRight()};
return views;
}
}

View File

@ -0,0 +1,40 @@
package de.jg_cody.Teraplex.ui.rooms;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class ViewHolderSingleButton implements IViewHolder {
String command;
Button bRun;
public ViewHolderSingleButton(Button bRun, String command) {
this.bRun = bRun;
this.command = command;
bRun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bRun.getContext(),command + " ON",Toast.LENGTH_SHORT).show();
}
});
}
@Override
public String getCommand() {
return command;
}
public Button getbRun() {
return bRun;
}
@Override
public View[] getViews()
{
View[] views = {getbRun(),};
return views;
}
}

View File

@ -28,16 +28,7 @@
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
app:srcCompat="?android:attr/fingerprintAuthDrawable" /> app:srcCompat="?android:attr/fingerprintAuthDrawable" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/addbutton_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="70dp"
android:background="@drawable/button_round"
android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp" />
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<EditText
android:id="@+id/button_command2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_command"
android:layout_alignParentLeft="true"
android:hint="COMMAND"
android:inputType="textPassword" />
<EditText
android:id="@+id/button_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="NAME" />
<EditText
android:id="@+id/button_command"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/button_name"
android:layout_alignParentLeft="true"
android:hint="BUTTON"
android:inputType="textPassword" />
</RelativeLayout>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical" >
<EditText
android:id="@+id/dialogSingle_editText_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
<EditText
android:id="@+id/dialogSingle_editText_buttonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Button" />
<EditText
android:id="@+id/dialogSingle_editText_command"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Command" />
</LinearLayout>

View File

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<EditText
android:id="@+id/button_command2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_command"
android:layout_alignParentLeft="true"
android:hint="COMMAND 1"
android:inputType="textPassword" />
<EditText
android:id="@+id/button_command3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_command2"
android:layout_alignParentLeft="true"
android:hint="BUTTON 2"
android:inputType="textPassword" />
<EditText
android:id="@+id/button_command4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_command3"
android:layout_alignParentLeft="true"
android:hint="COMMAND 2"
android:inputType="textPassword" />
<EditText
android:id="@+id/button_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="NAME" />
<EditText
android:id="@+id/button_command"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/button_name"
android:layout_alignParentLeft="true"
android:hint="BUTTON 1 "
android:inputType="textPassword" />
</RelativeLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation = "vertical"
android:padding="16dp">
<EditText
android:id="@+id/dialogDouble_editText_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
<EditText
android:id="@+id/dialogDouble_editText_command1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Command1" />
<EditText
android:id="@+id/dialogDouble_editText_button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Button1" />
<EditText
android:id="@+id/dialogDouble_editText_command2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Command2" />
<EditText
android:id="@+id/dialogDouble_editText_button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Button2" />
</LinearLayout>

View File

@ -2,13 +2,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:id="@+id/line1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<Button <Button
android:id="@+id/button1" android:id="@+id/bLeft"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_margin="5dp" android:layout_margin="5dp"
@ -33,7 +34,7 @@
app:backgroundTint="@null" /> app:backgroundTint="@null" />
<Button <Button
android:id="@+id/button" android:id="@+id/bRight"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_margin="5dp" android:layout_margin="5dp"

View File

@ -1,71 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:clickable="true"
tools:context=".MainActivity"> tools:context=".MainActivity">
<ImageView <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/Background" android:id="@+id/addbutton_fab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="75dp" />
<TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="15dp" android:layout_gravity="top|end"
android:text="Cricketer List" android:layout_marginHorizontal="16dp"
android:textColor="@color/white" android:layout_marginVertical="70dp"
android:textSize="15sp"></TextView> android:background="@drawable/button_round"
android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp" />
<LinearLayout <ListView
android:id="@+id/layout_list" android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout>
<Button
android:id="@+id/button_add"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="40dp" android:layout_height="742dp"
android:layout_marginLeft="15dp" android:visibility="visible"/>
android:layout_marginTop="10dp"
android:background="@drawable/ic_launcher_background"
android:drawableRight="@drawable/add_black_24dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Add"
android:textAllCaps="false"
android:textColor="@color/white"></Button>
<Button
android:id="@+id/button_submit_list"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:background="@drawable/ic_launcher_background"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Submit List"
android:textAllCaps="false"
android:textColor="@color/white"></Button>
</LinearLayout> </FrameLayout>

View File

@ -8,4 +8,22 @@
tools:context=".ui.kueche.KuecheFragment"> tools:context=".ui.kueche.KuecheFragment">
<ImageView
android:id="@+id/background2"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<ListView
android:layout_width="413dp"
android:layout_height="729dp"
tools:layout_editor_absoluteX="-1dp"
tools:layout_editor_absoluteY="2dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<Button <Button
@ -21,7 +21,7 @@ android:layout_height="wrap_content">
app:backgroundTint="@null" /> app:backgroundTint="@null" />
<Button <Button
android:id="@+id/button" android:id="@+id/bRun"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_margin="5dp" android:layout_margin="5dp"

View File

@ -94,5 +94,7 @@
<item>ENGLISH</item> <item>ENGLISH</item>
<item>KLINGONISCH</item> <item>KLINGONISCH</item>
</string-array> </string-array>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>