some more bugfixes, cleanup and translation

added custom dialoganimation
This commit is contained in:
JG-Cody 2021-07-10 18:37:58 +02:00
parent 102dd23aae
commit 18c5e2f0ed
21 changed files with 190 additions and 162 deletions

View File

@ -3,6 +3,7 @@ package de.jg_cody.Teraplex;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -12,12 +13,14 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import de.jg_cody.Teraplex.ui.Flur.FlurFragment; import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
public class AddButtonDialogSingle extends DialogFragment { public class AddButtonDialogSingle extends DialogFragment {
private EditText editText_command, editText_name, editText_button_name; private EditText editText_command, editText_name, editText_button_name;
private AddButtonDialogListenerSingle listener; private AddButtonDialogListenerSingle listener;
private FlurFragment frag; private TabsFragment frag;
/** /**
* *
@ -49,6 +52,22 @@ public class AddButtonDialogSingle extends DialogFragment {
String command = editText_command.getText().toString(); String command = editText_command.getText().toString();
String name = editText_name.getText().toString(); String name = editText_name.getText().toString();
String button = editText_button_name.getText().toString(); String button = editText_button_name.getText().toString();
if(command.isEmpty()||button.isEmpty()||name.isEmpty()){
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")
// 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, null )
.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
}
listener.applyTextsSingle(name,command,button); listener.applyTextsSingle(name,command,button);
} }
}); });
@ -56,14 +75,15 @@ public class AddButtonDialogSingle extends DialogFragment {
AlertDialog mDialog = builder.create(); AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round); mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog; return mDialog;
} }
public void setFragment(FlurFragment frag) public void setFragment(TabsFragment frag)
{ {
this.frag = frag; this.frag = frag;
} }
public FlurFragment getFragment() public TabsFragment getFragment()
{ {
return frag; return frag;
} }

View File

@ -4,6 +4,7 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -11,30 +12,27 @@ import android.widget.EditText;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import de.jg_cody.Teraplex.ui.Flur.FlurFragment; import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
public class AddButtonsDialogDouble extends DialogFragment { public class AddButtonsDialogDouble extends DialogFragment {
private AddButtonsDialogListenerDouble listener; private AddButtonsDialogListenerDouble listener;
private EditText editText_name, editText_command1, editText_button1, editText_command2, editText_button2; private EditText editText_name, editText_command1, editText_button1, editText_command2, editText_button2;
private FlurFragment frag; private TabsFragment frag;
@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 = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.addbuttonsdialog_double, null); View view = inflater.inflate(R.layout.addbuttonsdialog_double, null);
builder.setView(view) builder.setView(view)
.setTitle("ON/OFF BUTTON") .setTitle("ON/OFF BUTTON")
.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { .setNegativeButton("CANCEL", null)
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
})
.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) {
@ -43,7 +41,23 @@ public class AddButtonsDialogDouble extends DialogFragment {
String name = editText_name.getText().toString(); String name = editText_name.getText().toString();
String button1 = editText_button1.getText().toString(); String button1 = editText_button1.getText().toString();
String button2 = editText_button2.getText().toString(); String button2 = editText_button2.getText().toString();
listener.applyTextsDouble(name,command1,button1,command2,button2); if(command1.isEmpty()||command2.isEmpty()||name.isEmpty()||button1.isEmpty()||button2.isEmpty()){
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")
// 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, null )
.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
}
listener.applyTextsDouble(name,command1,command2,button1,button2);
} }
}); });
@ -55,14 +69,15 @@ public class AddButtonsDialogDouble extends DialogFragment {
AlertDialog mDialog = builder.create(); AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round); mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog; return mDialog;
} }
public void setFragment(FlurFragment frag) { public void setFragment(TabsFragment frag) {
this.frag = frag; this.frag = frag;
} }
public FlurFragment getFragment() { public TabsFragment getFragment() {
return frag; return frag;
} }

View File

@ -3,6 +3,7 @@ package de.jg_cody.Teraplex;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -11,13 +12,15 @@ import android.widget.ImageView;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import de.jg_cody.Teraplex.ui.Flur.FlurFragment; import java.util.Objects;
import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
public class AddHeadlineDialog extends DialogFragment { public class AddHeadlineDialog extends DialogFragment {
private AddHeadlineDialogListener listener; private AddHeadlineDialogListener listener;
private EditText editText_name; private EditText editText_name;
private FlurFragment frag; private TabsFragment frag;
ImageView delete; ImageView delete;
/** /**
* *
@ -40,21 +43,37 @@ public class AddHeadlineDialog extends DialogFragment {
}) })
.setPositiveButton("ADD", (dialogInterface, i) -> { .setPositiveButton("ADD", (dialogInterface, i) -> {
String headline = editText_name.getText().toString(); String headline = editText_name.getText().toString();
if(headline.isEmpty()){
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")
// 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, null )
.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
}
listener.applyTextsHeadline(headline); listener.applyTextsHeadline(headline);
}); });
AlertDialog mDialog = builder.create(); AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round); mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
return mDialog; return mDialog;
} }
public void setFragment(FlurFragment frag) public void setFragment(TabsFragment frag)
{ {
this.frag = frag; this.frag = frag;
} }
public FlurFragment getFragment() public TabsFragment getFragment()
{ {
return frag; return frag;
} }

View File

@ -34,7 +34,6 @@ import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Switch; import android.widget.Switch;
import android.widget.Toast;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -65,7 +64,7 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment; import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
import de.jg_cody.Teraplex.ui.Flur.FlurFragment; import de.jg_cody.Teraplex.ui.Tabs.TabsFragment;
import de.jg_cody.Teraplex.ui.rooms.ListAdapter; import de.jg_cody.Teraplex.ui.rooms.ListAdapter;
import de.jg_cody.Teraplex.ui.rooms.ListItem; import de.jg_cody.Teraplex.ui.rooms.ListItem;
@ -139,7 +138,7 @@ public class MainActivity extends AppCompatActivity {
// Passing each menu ID as a set of Ids because each // Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations. // menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder( mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_einstellungen, R.id.nav_kueche, R.id.nav_zeitsteuerung, R.id.nav_schlafzimmer, R.id.nav_flur, R.id.nav_über, R.id.nav_konsole) R.id.nav_home, R.id.nav_einstellungen, R.id.nav_zeitsteuerung, R.id.nav_schlafzimmer, R.id.nav_tabs, R.id.nav_über, R.id.nav_konsole)
.setOpenableLayout(drawer) .setOpenableLayout(drawer)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
@ -148,15 +147,13 @@ public class MainActivity extends AppCompatActivity {
((Switch) navigationView.getMenu().getItem(3).getActionView().findViewById(R.id.switch_editmode)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { ((Switch) navigationView.getMenu().getItem(3).getActionView().findViewById(R.id.switch_editmode)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(MainActivity.this, "Checked", Toast.LENGTH_LONG).show();
editmode = isChecked; editmode = isChecked;
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment; NavHostFragment nhf = (NavHostFragment) currentFragment;
Fragment childfragment = nhf.getChildFragmentManager().getFragments().get(0); Fragment childfragment = nhf.getChildFragmentManager().getFragments().get(0);
Toast.makeText(MainActivity.this, childfragment.toString(), Toast.LENGTH_LONG).show(); if (childfragment instanceof TabsFragment) {
if (childfragment instanceof FlurFragment) {
try { try {
((FlurFragment) childfragment).load(); ((TabsFragment) childfragment).load();
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -228,7 +225,7 @@ public class MainActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setTitle(tabname); Objects.requireNonNull(getSupportActionBar()).setTitle(tabname);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment; NavHostFragment nhf = (NavHostFragment) currentFragment;
nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new FlurFragment(tabname)).commit(); nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new TabsFragment(tabname)).commit();
return true; return true;
} }
}); });
@ -300,6 +297,7 @@ public class MainActivity extends AppCompatActivity {
}); });
AlertDialog mDialog = mBuilder.create(); AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
return true; return true;
} }
@ -316,7 +314,7 @@ public class MainActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setTitle(tab); Objects.requireNonNull(getSupportActionBar()).setTitle(tab);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavHostFragment nhf = (NavHostFragment) currentFragment; NavHostFragment nhf = (NavHostFragment) currentFragment;
nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new FlurFragment(tab)).commit(); nhf.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment, new TabsFragment(tab)).commit();
return true; return true;
} }
}); });

View File

@ -87,6 +87,7 @@ public class EinstellungenFragment extends Fragment {
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.no, null)
.create(); .create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
} }
@ -194,6 +195,7 @@ public class EinstellungenFragment extends Fragment {
}); });
AlertDialog mDialog = mBuilder.create(); AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
} }
@ -219,6 +221,7 @@ public class EinstellungenFragment extends Fragment {
}); });
AlertDialog mDialog = mBuilder.create(); AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
} }

View File

@ -107,6 +107,7 @@ public class KonsoleFragment extends Fragment {
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.no, null)
.create(); .create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
@ -145,6 +146,7 @@ public class KonsoleFragment extends Fragment {
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.no, null)
.create(); .create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
} }

View File

@ -1,4 +1,4 @@
package de.jg_cody.Teraplex.ui.Flur; package de.jg_cody.Teraplex.ui.Tabs;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -47,9 +47,9 @@ import de.jg_cody.Teraplex.ui.rooms.ListItemSpace;
import static android.content.Context.MODE_PRIVATE; import static android.content.Context.MODE_PRIVATE;
public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddButtonDialogListenerSingle, AddButtonsDialogDouble.AddButtonsDialogListenerDouble, AddHeadlineDialog.AddHeadlineDialogListener { public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddButtonDialogListenerSingle, AddButtonsDialogDouble.AddButtonsDialogListenerDouble, AddHeadlineDialog.AddHeadlineDialogListener {
private FlurViewModel flurViewModel; private TabsViewModel tabsViewModel;
String[] commands = {"Hello1", "Hello2", "Hello3", "Hello4", "Hello5"}; String[] commands = {"Hello1", "Hello2", "Hello3", "Hello4", "Hello5"};
int[] type = {0, 1, 0, 0, 1}; int[] type = {0, 1, 0, 0, 1};
@ -65,16 +65,16 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
String tabname; String tabname;
public FlurFragment(String tabname) { public TabsFragment(String tabname) {
this.tabname = tabname; this.tabname = tabname;
} }
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
flurViewModel = tabsViewModel =
new ViewModelProvider(this).get(FlurViewModel.class); new ViewModelProvider(this).get(TabsViewModel.class);
View root = inflater.inflate(R.layout.fragment_flur, container, false); View root = inflater.inflate(R.layout.fragment_tabs, container, false);
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE); SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null); String Background = p.getString("Background", null);
if (Background != null) { if (Background != null) {
@ -106,22 +106,32 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
public boolean onMove(@NonNull @NotNull RecyclerView recyclerView, @NonNull @NotNull RecyclerView.ViewHolder viewHolder, @NonNull @NotNull RecyclerView.ViewHolder target) { public boolean onMove(@NonNull @NotNull RecyclerView recyclerView, @NonNull @NotNull RecyclerView.ViewHolder viewHolder, @NonNull @NotNull RecyclerView.ViewHolder target) {
//listAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); //listAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
listAdapter.swap(viewHolder.getAdapterPosition(), target.getAdapterPosition()); listAdapter.swap(viewHolder.getAdapterPosition(), target.getAdapterPosition());
try {
save();
} catch (JSONException e) {
e.printStackTrace();
}
return true; return true;
} }
@Override @Override
public void onSwiped(@NonNull @NotNull RecyclerView.ViewHolder viewHolder, int direction) { public void onSwiped(@NonNull @NotNull RecyclerView.ViewHolder viewHolder, int direction) {
listAdapter.remove(viewHolder.getAdapterPosition()); listAdapter.remove(viewHolder.getAdapterPosition());
try {
save();
} catch (JSONException e) {
e.printStackTrace();
}
} }
@Override @Override
public boolean isLongPressDragEnabled() { public boolean isLongPressDragEnabled() {
return true; return MainActivity.editmode;
} }
@Override @Override
public boolean isItemViewSwipeEnabled() { public boolean isItemViewSwipeEnabled() {
return true; return MainActivity.editmode;
} }
}); });
@ -177,6 +187,7 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
}); });
AlertDialog mDialog = mBuilder.create(); AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(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
mDialog.show(); mDialog.show();
} }

View File

@ -1,16 +1,16 @@
package de.jg_cody.Teraplex.ui.Flur; package de.jg_cody.Teraplex.ui.Tabs;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
public class FlurViewModel extends ViewModel { public class TabsViewModel extends ViewModel {
private MutableLiveData<String> mText; private MutableLiveData<String> mText;
public FlurViewModel() { public TabsViewModel() {
mText = new MutableLiveData<>(); mText = new MutableLiveData<>();
mText.setValue("FLUR"); mText.setValue("TABS");
} }
public LiveData<String> getText() { public LiveData<String> getText() {

View File

@ -1,10 +1,12 @@
package de.jg_cody.Teraplex.ui.home; package de.jg_cody.Teraplex.ui.home;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
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;
import android.media.MediaPlayer;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -22,6 +24,7 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import java.util.Base64; import java.util.Base64;
import java.util.Objects;
import de.jg_cody.Teraplex.MainActivity; import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
@ -87,7 +90,20 @@ public class HomeFragment extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (userInput.getText().toString().trim().length() == 0 || ipInput.getText().toString().trim().length() == 0 || passwordInput.getText().toString().trim().length() == 0) { if (userInput.getText().toString().trim().length() == 0 || ipInput.getText().toString().trim().length() == 0 || passwordInput.getText().toString().trim().length() == 0) {
Toast.makeText(getContext(), getString(R.string.felder_dürfen_nicht_leer_sein), Toast.LENGTH_SHORT).show(); 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")
// 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, null )
.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
return;
} else { } else {
user = userInput.getText().toString(); user = userInput.getText().toString();
password = passwordInput.getText().toString(); password = passwordInput.getText().toString();

View File

@ -1,54 +0,0 @@
package de.jg_cody.Teraplex.ui.kueche;
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import java.util.Base64;
import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R;
public class KuecheFragment extends Fragment {
private KuecheViewModel kuecheViewModel;
@RequiresApi(api = Build.VERSION_CODES.O)
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
kuecheViewModel =
new ViewModelProvider(this).get(KuecheViewModel.class);
View root = inflater.inflate(R.layout.fragment_kueche, container, false);
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null);
if (Background != null) {
ImageView I = root.findViewById(R.id.Background);
byte[] BA = Base64.getDecoder().decode(Background);
I.setImageDrawable(new BitmapDrawable(getResources(), MainActivity.scaleCenterCrop(BitmapFactory.decodeByteArray(BA, 0, BA.length), MainActivity.getScreenHeight(), MainActivity.getScreenWidth())));
I.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
final TextView textView = root.findViewById(R.id.text_kueche);
kuecheViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
}
});
return root;
}
}

View File

@ -1,19 +0,0 @@
package de.jg_cody.Teraplex.ui.kueche;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class KuecheViewModel extends ViewModel {
private MutableLiveData<String> mText;
public KuecheViewModel() {
mText = new MutableLiveData<>();
mText.setValue("KÜCHE");
}
public LiveData<String> getText() {
return mText;
}
}

View File

@ -1,5 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%" android:toXDelta="100%" android:interpolator="@android:anim/overshoot_interpolator"
android:fromYDelta="0%" android:toYDelta="0%" android:shareInterpolator="true" >
android:duration="600"/> <alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="300"/>
<scale
android:fromXScale="0.8"
android:toXScale="1.0"
android:fromYScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="300"/>
<translate
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="-10%"
android:toYDelta="0%"
android:duration="300"/>
<rotate
android:fromDegrees="10"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="300"/>
</set>

View File

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" android:interpolator="@android:anim/anticipate_interpolator"
android:shareInterpolator="true" > android:shareInterpolator="true" >
<alpha <alpha
android:fromAlpha="0.0" android:fromAlpha="1.0"
android:toAlpha="1.0" android:toAlpha="0.0"
android:duration="1000"/> android:duration="300"/>
<scale <scale
android:fromXScale="0.8" android:fromXScale="1.0"
android:toXScale="1.0" android:toXScale="0.8"
android:fromYScale="1.0" android:fromYScale="1.0"
android:toYScale="1.0" android:toYScale="1.0"
android:pivotX="0.8"
android:pivotY="1.0"
android:duration="1000"/>
<translate
android:fromXDelta="100%"
android:toXDelta="100%"
android:fromYDelta="50%"
android:toYDelta="100%"
android:duration="1000"/>
<rotate
android:fromDegrees="25"
android:toDegrees="0"
android:pivotX="50%" android:pivotX="50%"
android:pivotY="50%" android:pivotY="50%"
android:duration="1000"/> android:duration="300"/>
<translate
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="-10%"
android:duration="300"/>
<rotate
android:fromDegrees="0"
android:toDegrees="-10"
android:pivotX="50%"
android:pivotY="50%"
android:duration="300"/>
</set> </set>

View File

@ -11,6 +11,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:ems="10"
android:inputType="textPersonName" android:inputType="textPersonName"
android:hint="NAME" /> android:hint="HEADLINE" />
</LinearLayout> </LinearLayout>

View File

@ -2,7 +2,7 @@
<FrameLayout 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" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_flur" android:id="@+id/fragment_tabs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">

View File

@ -50,8 +50,5 @@
<item <item
android:id="@+id/nav_schlafzimmer" android:id="@+id/nav_schlafzimmer"
android:title="@string/menu_schlafzimmer" /> android:title="@string/menu_schlafzimmer" />
<item
android:id="@+id/nav_kueche"
android:title="@string/menu_küche" />
</group> </group>
</menu> </menu>

View File

@ -24,12 +24,6 @@
android:label="@string/menu_settings" android:label="@string/menu_settings"
tools:layout="@layout/fragment_einstellungen" /> tools:layout="@layout/fragment_einstellungen" />
<fragment
android:id="@+id/nav_kueche"
android:name="de.jg_cody.Teraplex.ui.kueche.KuecheFragment"
android:label="@string/menu_küche"
tools:layout="@layout/fragment_kueche" />
<fragment <fragment
android:id="@+id/nav_zeitsteuerung" android:id="@+id/nav_zeitsteuerung"
android:name="de.jg_cody.Teraplex.ui.zeitsteuerung.ZeitsteuerungFragment" android:name="de.jg_cody.Teraplex.ui.zeitsteuerung.ZeitsteuerungFragment"
@ -43,10 +37,10 @@
tools:layout="@layout/fragment_schlafzimmer" /> tools:layout="@layout/fragment_schlafzimmer" />
<fragment <fragment
android:id="@+id/nav_flur" android:id="@+id/nav_tabs"
android:name="de.jg_cody.Teraplex.ui.Flur.FlurFragment" android:name="de.jg_cody.Teraplex.ui.Tabs.TabsFragment"
android:label="@string/menu_flur" android:label="@string/menu_tabs"
tools:layout="@layout/fragment_flur" /> tools:layout="@layout/fragment_tabs" />
<fragment <fragment
android:id="@+id/nav_über" android:id="@+id/nav_über"

View File

@ -12,7 +12,7 @@
<string name="menu_kueche">KÜCHE</string> <string name="menu_kueche">KÜCHE</string>
<string name="menu_zeitsteuerung">ZEITSTEUERUNG</string> <string name="menu_zeitsteuerung">ZEITSTEUERUNG</string>
<string name="menu_schlafzimmer">SCHLAFZIMMER</string> <string name="menu_schlafzimmer">SCHLAFZIMMER</string>
<string name="menu_flur">FLUR</string> <string name="menu_tabs">TABS</string>
<string name="menu_küche">KÜCHE</string> <string name="menu_küche">KÜCHE</string>
<string name="menu_settings">EINSTELLUNGEN</string> <string name="menu_settings">EINSTELLUNGEN</string>
<string name="menu_documentation">FRAGE</string> <string name="menu_documentation">FRAGE</string>

View File

@ -18,11 +18,13 @@
<!-- Status bar color. --> <!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorControlActivated">@color/red</item>
<item name="actionOverflowMenuStyle">@style/ActionPopupMenuStyle</item> <item name="actionOverflowMenuStyle">@style/ActionPopupMenuStyle</item>
<item name="android:actionOverflowMenuStyle">@style/ActionPopupMenuStyle</item>
</style>
</style>
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/dialog_in</item>
<item name="android:windowExitAnimation">@anim/dialog_out</item>
</style>
<style name="Theme.red_blue.NoActionBar"> <style name="Theme.red_blue.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>

View File

@ -64,7 +64,7 @@
<string name="menu_kueche">KITCHEN</string> <string name="menu_kueche">KITCHEN</string>
<string name="menu_zeitsteuerung">TIME-CONTROL</string> <string name="menu_zeitsteuerung">TIME-CONTROL</string>
<string name="menu_schlafzimmer">BEDROOM</string> <string name="menu_schlafzimmer">BEDROOM</string>
<string name="menu_flur">HALL</string> <string name="menu_tabs">HALL</string>
<string name="menu_küche">KITCHEN</string> <string name="menu_küche">KITCHEN</string>
<string name="menu_add">ADD TAB</string> <string name="menu_add">ADD TAB</string>
<string name="menu_remove">REMOVE TABS</string> <string name="menu_remove">REMOVE TABS</string>

View File

@ -21,8 +21,8 @@
<item name="actionOverflowMenuStyle">@style/ActionPopupMenuStyle</item> <item name="actionOverflowMenuStyle">@style/ActionPopupMenuStyle</item>
</style> </style>
<style name="DialogAnimation"> <style name="DialogAnimation">
<item name="android:windowEnterAnimation">@android:anim/slide_in_left</item> <item name="android:windowEnterAnimation">@anim/dialog_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item> <item name="android:windowExitAnimation">@anim/dialog_out</item>
</style> </style>
<style name="ActionPopupMenuStyle" parent="Widget.AppCompat.PopupMenu"> <style name="ActionPopupMenuStyle" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@drawable/button_round</item> <item name="android:popupBackground">@drawable/button_round</item>