bugfixes and translation

This commit is contained in:
JG-Cody 2021-07-11 13:28:50 +02:00
parent 169e1a9501
commit e765794fd7
18 changed files with 149 additions and 295 deletions

View File

@ -13,6 +13,8 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
@ -27,10 +29,11 @@ public class AddButtonDialogSingle extends DialogFragment {
* @param savedInstanceState
* @return
*/
@NotNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.addbuttondialog_single, null);
editText_command = view.findViewById(R.id.dialogSingle_editText_command);
@ -40,7 +43,7 @@ public class AddButtonDialogSingle extends DialogFragment {
builder.setView(view)
.setTitle("SINGLE BUTTON")
.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@ -56,8 +59,8 @@ public class AddButtonDialogSingle extends DialogFragment {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle("UNGÜLTIGE EINGABE")
.setMessage("EINGABEFELDER DÜRFEN NICHT LEER SEIN")
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -74,7 +77,7 @@ public class AddButtonDialogSingle extends DialogFragment {
AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog;
}
@ -89,7 +92,7 @@ public class AddButtonDialogSingle extends DialogFragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NotNull Context context) {
super.onAttach(context);
try {

View File

@ -12,6 +12,8 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
@ -23,6 +25,7 @@ public class AddButtonsDialogDouble extends DialogFragment {
private EditText editText_name, editText_command1, editText_button1, editText_command2, editText_button2;
private TabsFragment frag;
@NotNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@ -32,7 +35,7 @@ public class AddButtonsDialogDouble extends DialogFragment {
builder.setView(view)
.setTitle("ON/OFF BUTTON")
.setNegativeButton("CANCEL", null)
.setNegativeButton(getString(R.string.cancel), null)
.setPositiveButton("ADD", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@ -45,8 +48,8 @@ public class AddButtonsDialogDouble extends DialogFragment {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle("UNGÜLTIGE EINGABE")
.setMessage("EINGABEFELDER DÜRFEN NICHT LEER SEIN")
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -68,7 +71,7 @@ public class AddButtonsDialogDouble extends DialogFragment {
editText_button2 = view.findViewById(R.id.dialogDouble_editText_button2);
AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog;
}
@ -82,12 +85,12 @@ public class AddButtonsDialogDouble extends DialogFragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NotNull Context context) {
super.onAttach(context);
try {
listener = (AddButtonsDialogListenerDouble) frag;
} catch (ClassCastException e) {
} catch (ClassCastException ignored) {
}
}

View File

@ -12,6 +12,8 @@ import android.widget.ImageView;
import androidx.fragment.app.DialogFragment;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
@ -27,10 +29,11 @@ public class AddHeadlineDialog extends DialogFragment {
* @param savedInstanceState
* @return
*/
@NotNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.addheadlinedialog, null);
editText_name = view.findViewById(R.id.dialogheadline_editText_name);
@ -38,7 +41,7 @@ public class AddHeadlineDialog extends DialogFragment {
builder.setView(view)
.setTitle("SINGLE BUTTON")
.setNegativeButton("CANCEL", (dialogInterface, i) -> {
.setNegativeButton(getString(R.string.cancel), (dialogInterface, i) -> {
})
.setPositiveButton("ADD", (dialogInterface, i) -> {
@ -47,8 +50,8 @@ public class AddHeadlineDialog extends DialogFragment {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(getContext())
.setTitle("UNGÜLTIGE EINGABE")
.setMessage("EINGABEFELDER DÜRFEN NICHT LEER SEIN")
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -64,7 +67,7 @@ public class AddHeadlineDialog extends DialogFragment {
AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog;
}
@ -79,7 +82,7 @@ public class AddHeadlineDialog extends DialogFragment {
}
@Override
public void onAttach(Context context) {
public void onAttach(@NotNull Context context) {
super.onAttach(context);
try {

View File

@ -42,7 +42,7 @@ public class CricketerAdapter extends RecyclerView.Adapter<CricketerAdapter.Cric
return cricketersList.size();
}
public class CricketerView extends RecyclerView.ViewHolder{
public static class CricketerView extends RecyclerView.ViewHolder{
TextView textCricketerName,textTeamName;
public CricketerView(@NonNull View itemView) {

View File

@ -150,10 +150,12 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
editmode = isChecked;
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment;
assert nhf != null;
Fragment childfragment = nhf.getChildFragmentManager().getFragments().get(0);
if (childfragment instanceof TabsFragment) {
try {
@ -171,6 +173,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onMenuItemClick(MenuItem item) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
@ -182,10 +185,11 @@ public class MainActivity extends AppCompatActivity {
mBuilder.setView(view)
.setTitle(R.string.menu_add);
mBuilder.setPositiveButton(R.string.menu_add, new DialogInterface.OnClickListener() {
mBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
String tabname = editText_name.getText().toString().trim();
@ -195,8 +199,8 @@ public class MainActivity extends AppCompatActivity {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("TABNAME")
.setMessage("DER TABNAME EXISTIERT BEREITS!")
.setTitle(getString(R.string.tabname))
.setMessage(getString(R.string.tabname_already_exist))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -211,8 +215,8 @@ public class MainActivity extends AppCompatActivity {
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.state_change_confirm_up);
mp.start();
AlertDialog mDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("TABNAME")
.setMessage("UNGÜLTIGER TABNAME")
.setTitle(getString(R.string.tabname))
.setMessage(getString(R.string.invalid))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -228,6 +232,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onMenuItemClick(MenuItem item) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
DrawerLayout mDrawerLayout;
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@ -235,6 +240,7 @@ public class MainActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setTitle(tabname);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment;
assert nhf != null;
nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new TabsFragment(tabname)).commit();
return true;
}
@ -249,10 +255,11 @@ public class MainActivity extends AppCompatActivity {
}
});
mBuilder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
mBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
}
@ -268,6 +275,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onMenuItemClick(MenuItem item) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences p = getSharedPreferences("appsettings", MODE_PRIVATE);
Set<String> tabs = new HashSet<>(p.getStringSet("tabs", new HashSet<>()));
@ -288,10 +296,11 @@ public class MainActivity extends AppCompatActivity {
}
}
});
mBuilder.setPositiveButton("REMOVE", new DialogInterface.OnClickListener() {
mBuilder.setPositiveButton(getString(R.string.remove), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
tabs.removeAll(selectedTabs);
SharedPreferences.Editor editor = p.edit();
@ -305,10 +314,11 @@ public class MainActivity extends AppCompatActivity {
}
}
});
mBuilder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
mBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
}
});
@ -326,6 +336,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onMenuItemClick(MenuItem item) {
Vibrator vr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
DrawerLayout mDrawerLayout;
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@ -333,6 +344,7 @@ public class MainActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setTitle(tab);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment;
assert nhf != null;
nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new TabsFragment(tab)).commit();
return true;
}

View File

@ -43,7 +43,7 @@ public class SSH_connection {
}
try {
Thread.sleep(1000);
} catch (Exception ee) {
} catch (Exception ignored) {
}
}
channel.disconnect();

View File

@ -55,7 +55,8 @@ public class EinstellungenFragment extends Fragment {
Language.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
showChangeLanguageDialog();
@ -65,7 +66,8 @@ public class EinstellungenFragment extends Fragment {
Reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.alert_error);
mp.start();
@ -77,7 +79,8 @@ public class EinstellungenFragment extends Fragment {
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
try {
requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().clear().apply();
@ -103,7 +106,8 @@ public class EinstellungenFragment extends Fragment {
choose_background.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
showChangeBackgroundDialog();
@ -114,7 +118,8 @@ public class EinstellungenFragment extends Fragment {
theme1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Theme", "RED_BLUE");
@ -129,7 +134,8 @@ public class EinstellungenFragment extends Fragment {
theme2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Theme", "GREEN_YELLOW");
@ -144,7 +150,8 @@ public class EinstellungenFragment extends Fragment {
theme3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Theme", "ORANGE_TURQUOISE");
@ -159,7 +166,8 @@ public class EinstellungenFragment extends Fragment {
theme4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Theme", "YELLOW_BLUE");
@ -174,7 +182,8 @@ public class EinstellungenFragment extends Fragment {
theme5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Theme", "PINK_GREEN");
@ -192,11 +201,12 @@ public class EinstellungenFragment extends Fragment {
private void showChangeLanguageDialog() {
final String[] listItems = {"GERMAN", "ENGLISCH"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
mBuilder.setTitle("CHOOSE LANGUAGE");
mBuilder.setTitle(getString(R.string.choose_language));
mBuilder.setSingleChoiceItems(listItems, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
if (i == 0) {
setLocale("de");
@ -217,13 +227,14 @@ public class EinstellungenFragment extends Fragment {
}
private void showChangeBackgroundDialog() {
final String[] listItems = {"GRAFIK", "RESET BACKGROUND"};
final String[] listItems = {getString(R.string.image), getString(R.string.reset_background)};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
mBuilder.setTitle("CHOOSE BACKGROUND-TYPE");
mBuilder.setTitle(getString(R.string.choose_backgroundtype));
mBuilder.setSingleChoiceItems(listItems, -5, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
if (i == 0) {
Intent a = new Intent(

View File

@ -66,14 +66,15 @@ public class KonsoleFragment extends Fragment {
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
try {
if (befehlInput.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("UNGÜLTIGE EINGABE")
.setMessage("EINGABEFELDER DÜRFEN NICHT LEER SEIN")
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -82,7 +83,6 @@ public class KonsoleFragment extends Fragment {
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
} else {
command = befehlInput.getText().toString();
Toast.makeText(getContext(), "Kommando gesendet...", Toast.LENGTH_SHORT).show();
@ -99,25 +99,27 @@ public class KonsoleFragment extends Fragment {
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
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("SERVER NEUSTARTEN")
.setMessage("BIST DU SICHER?")
.setTitle(getString(R.string.restart_server))
.setMessage(getString(R.string.are_you_sure))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
try {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_down);
mp.start();
Toast.makeText(getContext(), "Reboot wird ausgeführt...", Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "reboot");
} catch (Exception e) {
} catch (Exception ignored) {
}
// Continue with delete operation
@ -141,18 +143,20 @@ public class KonsoleFragment extends Fragment {
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
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("SERVER HERUNTERFAHREN")
.setMessage("BIST DU SICHER?")
.setTitle(getString(R.string.shutdown_server))
.setMessage(getString(R.string.are_you_sure))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
try {
MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.state_change_confirm_down);

View File

@ -159,9 +159,9 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
}
private void showChooseElement() {
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "ÜBERSCHRIFT", "PLATZHALTER"};
final String[] listItems = {getString(R.string.single_button), getString(R.string.double_button), getString(R.string.heading), getString(R.string.space)};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity());
mBuilder.setTitle("CHOOSE ELEMENT");
mBuilder.setTitle(getString(R.string.choose_element));
mBuilder.setSingleChoiceItems(listItems, -1, new DialogInterface.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
@ -194,20 +194,20 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
public void openDialog1() {
AddButtonDialogSingle addButtonDialogSingle = new AddButtonDialogSingle();
addButtonDialogSingle.setFragment(this);
addButtonDialogSingle.show(getActivity().getSupportFragmentManager(), "example dialog");
addButtonDialogSingle.show(requireActivity().getSupportFragmentManager(), getString(R.string.single_button));
}
public void openDialog2() {
AddButtonsDialogDouble addButtonsDialogDouble = new AddButtonsDialogDouble();
addButtonsDialogDouble.setFragment(this);
addButtonsDialogDouble.show(getActivity().getSupportFragmentManager(), "example dialog");
addButtonsDialogDouble.show(requireActivity().getSupportFragmentManager(), getString(R.string.double_button));
}
public void openDialog3() {
AddHeadlineDialog addHeadlineDialog = new AddHeadlineDialog();
addHeadlineDialog.setFragment(this);
addHeadlineDialog.show(getActivity().getSupportFragmentManager(), "Headline");
addHeadlineDialog.show(requireActivity().getSupportFragmentManager(), getString(R.string.heading));
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)

View File

@ -90,14 +90,15 @@ public class HomeFragment extends Fragment {
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
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("UNGÜLTIGE EINGABE")
.setMessage("EINGABEFELDER DÜRFEN NICHT LEER SEIN")
.setTitle(getString(R.string.invalid))
.setMessage(getString(R.string.inputfields_cant_be_empty))
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
@ -106,7 +107,6 @@ public class HomeFragment extends Fragment {
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
} else {
user = userInput.getText().toString();
password = passwordInput.getText().toString();
@ -139,7 +139,8 @@ public class HomeFragment extends Fragment {
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("ip").remove("user").remove("password").apply();
startActivity(requireActivity().getIntent());
@ -154,7 +155,7 @@ public class HomeFragment extends Fragment {
try {
Toast.makeText(getContext(), "WLAN wird ausgeschaltet...", Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "service hostapd stop");
} catch (Exception e) {
} catch (Exception ignored) {
}
}
});
@ -166,7 +167,7 @@ public class HomeFragment extends Fragment {
try {
Toast.makeText(getContext(), "WLAN wird eingeschaltet...", Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "service hostapd start");
} catch (Exception e) {
} catch (Exception ignored) {
}
}
});
@ -178,7 +179,7 @@ public class HomeFragment extends Fragment {
try {
Toast.makeText(getContext(), "KODI wird ausgeschaltet...", Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 3 0");
} catch (Exception e) {
} catch (Exception ignored) {
}
}
@ -191,7 +192,7 @@ public class HomeFragment extends Fragment {
try {
Toast.makeText(getContext(), "KODI wird angeschaltet...", Toast.LENGTH_SHORT).show();
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 3 1");
} catch (Exception e) {
} catch (Exception ignored) {
}
}

View File

@ -9,13 +9,14 @@ import de.jg_cody.Teraplex.SSH_connection;
public class CommandExecutor implements View.OnClickListener {
private String command;
private final String command;
public CommandExecutor(String command) {
this.command = command;
}
@Override
public void onClick(View v) {
Vibrator vr = (Vibrator) v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
SharedPreferences prefs = v.getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
String user = prefs.getString("user", null);

View File

@ -26,12 +26,10 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
HEADLINE = 2,
SPACE = 3;
private Context context;
private LayoutInflater inflater;
private ArrayList<ListItem> objects;
private final LayoutInflater inflater;
private final ArrayList<ListItem> objects;
public ListAdapter(Context context, ArrayList<ListItem> objects) {
this.context = context;
this.inflater = LayoutInflater.from(context);
this.objects = objects;
}

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="match_parent"
tools:context=".ui.kueche.KuecheFragment">
<ImageView
android:id="@+id/Background"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/fog_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" />
<TextView
android:id="@+id/text_kueche"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center_horizontal"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:layout_width="394dp"
android:layout_height="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/Background"></LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.kueche.KuecheFragment">
tools:context=".MainActivity">
<ImageView

View File

@ -1,173 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="match_parent"
tools:context=".ui.Schlafzimmer.SchlafzimmerFragment">
<ImageView
android:id="@+id/Background"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/fog_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" />
<ImageView
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/textView2"
app:layout_constraintEnd_toEndOf="@+id/schlafzimmeru1aus"
app:layout_constraintStart_toStartOf="@+id/schlafzimmeru1an"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<Button
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="@string/off"
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/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="@string/on"
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/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="@string/off"
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/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="@string/on"
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/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="@string/on"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintEnd_toStartOf="@+id/textView5"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginTop="200dp"
android:background="@drawable/button_middle"
android:gravity="center"
android:text="STECKDOSE 1"
android:textAlignment="center"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/Background" />
<TextView
android:id="@+id/textView2"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginTop="100dp"
android:background="@drawable/button_middle"
android:gravity="center"
android:text="STECKDOSE 3"
android:textAlignment="center"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_marginTop="100dp"
android:background="@drawable/button_middle"
android:gravity="center"
android:text="STECKDOSE 2"
android:textAlignment="center"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<Button
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="@string/off"
app:backgroundTint="@null"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintStart_toEndOf="@+id/textView5"
app:layout_constraintTop_toTopOf="@+id/textView5" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

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

View File

@ -46,7 +46,7 @@
<string name="sie_sind_als_angemeldet">DU BIST ALS {USERNAME} AUF {IP}</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="logout">AUSLOGGEN</string>
<string name="are_you_sure_to_reset">MÖCHTEST DU WIRKLICH DIE APP UND ALLE IHRE EINSTELLUNGEN ZURÜCKSETZEN?</string>
<string name="are_you_sure_to_reset">MÖCHTEST DU WIRKLICH DIE APP UND ALL IHRE EINSTELLUNGEN ZURÜCKSETZEN?</string>
<string name="reset_app">APP ZURÜCKSETZEN</string>
<string name="menu_about">ÜBER</string>
<string name="login_saved">LOGIN_DATEN GESPEICHERT</string>
@ -63,7 +63,25 @@
<string name="appcode">APPCODE</string>
<string name="team">TEAM</string>
<string name="cooperation">IN KOOPERATION MIT</string>
<string name="menu_add">TAB HINZUFÜGEN</string>
<string name="menu_remove">TABS ENTFERNEN</string>
<string name="edit_mode">BEARBEITEN</string>
<string name="menu_add">REGISTERKARTE HINZUFÜGEN</string>
<string name="menu_remove">REGISTERKARTE ENTFERNEN</string>
<string name="edit">BEARBEITEN</string>
<string name="cancel">ABBRECHEN</string>
<string name="invalid">UNGÜLTIGE EINGABE</string>
<string name="tabname">TABNAME</string>
<string name="remove">ENTFERNEN</string>
<string name="tabname_already_exist">DIE REGISTERKARTE EXISTIERT BEREITS!</string>
<string name="choose_language">SPRACHAUSWAHL</string>
<string name="choose_backgroundtype">HINTERGRUND WÄHLEN</string>
<string name="heading">ÜBERSCHRIFT</string>
<string name="double_button">DOPPELTASTE</string>
<string name="single_button">EINZELTASTE</string>
<string name="space">PLATZHALTER</string>
<string name="inputfields_cant_be_empty">EINGABEFELDER DÜRFEN NICHT LEER SEIN</string>
<string name="are_you_sure">SIND SIE SICHER?</string>
<string name="restart_server">SERVER NEUSTARTEN</string>
<string name="shutdown_server">SERVER HERUNTERFAHREN</string>
<string name="choose_element">AUSAHL</string>
<string name="reset_background">HINTERGRUND ZURÜCKSETZEN</string>
<string name="image">BILDHINTERGRUND</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="edit_mode">EDITMODE</string>
<string name="edit">EDIT</string>
//home
<string name="Welcome_to_your_HOMEAUTOMATION_APP">WELCOME TO TERAPLEX</string>
@ -78,5 +78,24 @@
<string name="menu_close">CLOSE</string>
<string name="ok">OK</string>
<string name="cancel">CANCEL</string>
<string name="invalid">INVALID INPUT</string>
<string name="tabname">TABNAME</string>
<string name="remove">REMOVE</string>
<string name="tabname_already_exist">THE TABNAME ALREADY EXISTS!</string>
<string name="choose_language">CHOOSE LANGUAGE</string>
<string name="choose_backgroundtype">CHOOSE BACKGROUND</string>
<string name="single_button">SINGLE BUTTON</string>
<string name="double_button">DOUBLE BUTTON</string>
<string name="heading">HEADING</string>
<string name="space">SPACE</string>
<string name="inputfields_cant_be_empty">INPUTFIELDS CANT BE EMPTY</string>
<string name="are_you_sure">ARE YOU SURE?</string>
<string name="restart_server">RESTART SERVER</string>
<string name="shutdown_server">SHUTDOWN SERVER</string>
<string name="choose_element">CHOOSE ELEMENT</string>
<string name="reset_background">RESET BACKGROUND</string>
<string name="image">IMAGE BACKGROUND</string>
</resources>