code bereinigt und nach vorschlag von android studio angepasst
This commit is contained in:
parent
fa70aad80e
commit
b33ad3df96
@ -48,6 +48,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
|
||||
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
|
||||
@ -238,7 +239,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
}
|
||||
|
||||
private void showChooseElement() {
|
||||
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "OPTION3"};
|
||||
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() {
|
||||
@ -250,12 +251,15 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
openDialog2();
|
||||
} else if (i == 2) {
|
||||
|
||||
} else if (i == 3) {
|
||||
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog mDialog = mBuilder.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class CreditsFragment extends Fragment {
|
||||
creditsViewModel =
|
||||
new ViewModelProvider(this).get(CreditsViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_credits, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
|
@ -28,6 +28,7 @@ import com.rarepebble.colorpicker.ColorPickerView;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
@ -44,7 +45,7 @@ public class EinstellungenFragment extends Fragment {
|
||||
einstellungenViewModel =
|
||||
new ViewModelProvider(this).get(EinstellungenViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_einstellungen, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
@ -75,10 +76,10 @@ public class EinstellungenFragment extends Fragment {
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().clear().commit();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
} catch (Exception e) {
|
||||
requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().clear().apply();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// Continue with delete operation
|
||||
@ -88,7 +89,7 @@ public class EinstellungenFragment extends Fragment {
|
||||
// A null listener allows the button to dismiss the dialog and take no further action.
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@ -107,11 +108,11 @@ public class EinstellungenFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Theme1", Toast.LENGTH_SHORT).show();
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Theme", "RED_BLUE");
|
||||
editor.apply();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
|
||||
}
|
||||
@ -121,11 +122,11 @@ public class EinstellungenFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Theme2", Toast.LENGTH_SHORT).show();
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Theme", "GREEN_YELLOW");
|
||||
editor.apply();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
|
||||
}
|
||||
@ -135,11 +136,11 @@ public class EinstellungenFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Theme3", Toast.LENGTH_SHORT).show();
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Theme", "ORANGE_TURQUOISE");
|
||||
editor.apply();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
|
||||
}
|
||||
@ -149,11 +150,11 @@ public class EinstellungenFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Theme4", Toast.LENGTH_SHORT).show();
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Theme", "YELLOW_BLUE");
|
||||
editor.apply();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
|
||||
}
|
||||
@ -163,11 +164,11 @@ public class EinstellungenFragment extends Fragment {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(), "Theme5", Toast.LENGTH_SHORT).show();
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Theme", "PINK_GREEN");
|
||||
editor.apply();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
|
||||
}
|
||||
@ -185,22 +186,22 @@ public class EinstellungenFragment extends Fragment {
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
setLocale("de");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
} else if (i == 1) {
|
||||
setLocale("en");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
} else if (i == 2) {
|
||||
setLocale("tlh");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog mDialog = mBuilder.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ public class EinstellungenFragment extends Fragment {
|
||||
|
||||
}
|
||||
}).create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@ -238,25 +239,25 @@ public class EinstellungenFragment extends Fragment {
|
||||
|
||||
}
|
||||
}).create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else if (i == 2) {
|
||||
Intent a = new Intent(
|
||||
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
getActivity().startActivityForResult(a, MainActivity.RESULT_LOAD_IMAGE);
|
||||
requireActivity().startActivityForResult(a, MainActivity.RESULT_LOAD_IMAGE);
|
||||
} else if (i == 3) {
|
||||
getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("Background").commit();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("Background").apply();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog mDialog = mBuilder.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@ -265,8 +266,8 @@ public class EinstellungenFragment extends Fragment {
|
||||
Locale.setDefault(locale);
|
||||
Configuration config = new Configuration();
|
||||
config.locale = locale;
|
||||
getContext().getResources().updateConfiguration(config, getContext().getResources().getDisplayMetrics());
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
requireContext().getResources().updateConfiguration(config, requireContext().getResources().getDisplayMetrics());
|
||||
SharedPreferences.Editor editor = requireContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
|
||||
editor.putString("Language", lang);
|
||||
editor.apply();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jg_cody.Teraplex.ActivityCricketers;
|
||||
import de.jg_cody.Teraplex.Cricketer;
|
||||
@ -50,7 +51,7 @@ public class FlurFragment extends Fragment implements View.OnClickListener {
|
||||
flurViewModel =
|
||||
new ViewModelProvider(this).get(FlurViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_flur, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
@ -154,7 +155,7 @@ public class FlurFragment extends Fragment implements View.OnClickListener {
|
||||
AppCompatSpinner spinnerTeam = (AppCompatSpinner)cricketerView.findViewById(R.id.spinner_team);
|
||||
ImageView imageClose = (ImageView)cricketerView.findViewById(R.id.image_remove);
|
||||
|
||||
ArrayAdapter arrayAdapter = new ArrayAdapter(getContext(),android.R.layout.simple_spinner_item,teamList);
|
||||
ArrayAdapter arrayAdapter = new ArrayAdapter(requireContext(),android.R.layout.simple_spinner_item,teamList);
|
||||
spinnerTeam.setAdapter(arrayAdapter);
|
||||
|
||||
imageClose.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -23,6 +23,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
@ -49,7 +50,7 @@ public class KonsoleFragment extends Fragment {
|
||||
konsoleViewModel =
|
||||
new ViewModelProvider(this).get(KonsoleViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_konsole, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
@ -71,7 +72,7 @@ public class KonsoleFragment extends Fragment {
|
||||
Toast.makeText(root.getContext(), command, Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ public class KonsoleFragment extends Fragment {
|
||||
// A null listener allows the button to dismiss the dialog and take no further action.
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
|
||||
|
||||
@ -133,7 +134,7 @@ public class KonsoleFragment extends Fragment {
|
||||
mp.start();
|
||||
Toast.makeText(getContext(), "Server wird heruntergefahren...", Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, "shutdown now");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// Continue with delete operation
|
||||
@ -143,7 +144,7 @@ public class KonsoleFragment extends Fragment {
|
||||
// A null listener allows the button to dismiss the dialog and take no further action.
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create();
|
||||
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
|
||||
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
|
||||
mDialog.show();
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
user = prefs.getString("user", null);
|
||||
password = prefs.getString("password", null);
|
||||
ip = prefs.getString("ip", null);
|
||||
@ -49,7 +49,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
schlafzimmerViewModel =
|
||||
new ViewModelProvider(this).get(SchlafzimmerViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_schlafzimmer, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
@ -67,7 +67,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe wird ausgeschaltet...", Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 4 0");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe wird angeschaltet...", Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 4 1");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe wird ausgeschaltet...", Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 2 0");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe wird angeschaltet...", Toast.LENGTH_SHORT).show();
|
||||
SSH_connection.executeRemoteCommand(ip, user, password, "sudo /root/raspberry-remote/send 11111 2 1");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe 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) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
try {
|
||||
Toast.makeText(getContext(), "Lampe 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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class HomeFragment extends Fragment {
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
user = prefs.getString("user", null);
|
||||
password = prefs.getString("password", null);
|
||||
ip = prefs.getString("ip", null);
|
||||
@ -55,7 +55,7 @@ public class HomeFragment extends Fragment {
|
||||
homeViewModel =
|
||||
new ViewModelProvider(this).get(HomeViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
@ -74,7 +74,7 @@ public class HomeFragment extends Fragment {
|
||||
passwordInput = (EditText) root.findViewById(R.id.loginpasswordInput);
|
||||
ipInput = (EditText) root.findViewById(R.id.ipInput);
|
||||
loginButton = (Button) root.findViewById(R.id.loginButton);
|
||||
SharedPreferences t = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
SharedPreferences t = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
if (user == null || ip == null) {
|
||||
loginButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ public class HomeFragment extends Fragment {
|
||||
user = userInput.getText().toString();
|
||||
password = passwordInput.getText().toString();
|
||||
ip = ipInput.getText().toString();
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
p.edit().putString("user", user).putString("password", password).putString("ip", ip).apply();
|
||||
Toast.makeText(getContext(), getString(R.string.login_saved), Toast.LENGTH_SHORT).show();
|
||||
if (user == null || ip == null) {
|
||||
@ -120,9 +120,9 @@ public class HomeFragment extends Fragment {
|
||||
logoutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("ip").remove("user").remove("password").commit();
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("ip").remove("user").remove("password").apply();
|
||||
startActivity(requireActivity().getIntent());
|
||||
requireActivity().finish();
|
||||
}
|
||||
});
|
||||
wlan_aus_Button = (Button) root.findViewById(R.id.wlan_aus);
|
||||
|
@ -35,7 +35,7 @@ public class IntroFragment extends Fragment {
|
||||
|
||||
// Build your video Uri
|
||||
Uri uri = Uri.parse("android.resource://" // First start with this,
|
||||
+ getContext().getPackageName() // then retrieve your package name,
|
||||
+ requireContext().getPackageName() // then retrieve your package name,
|
||||
+ "/" // add a slash,
|
||||
+ R.raw.intro); // and then finally add your video resource. Make sure it is stored
|
||||
// in the raw folder.
|
||||
|
@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
@ -33,7 +34,7 @@ public class ZeitsteuerungFragment extends Fragment {
|
||||
zeitsteuerungViewModel =
|
||||
new ViewModelProvider(this).get(ZeitsteuerungViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_zeitsteuerung, container, false);
|
||||
SharedPreferences p = getContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
if (Background != null) {
|
||||
ImageView I = root.findViewById(R.id.Background);
|
||||
|
@ -6,6 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:clickable="true"
|
||||
android:layout_height="match_parent"
|
||||
android:hapticFeedbackEnabled="true"
|
||||
tools:context=".ui.home.HomeFragment">
|
||||
|
||||
<ImageView
|
||||
@ -95,7 +96,7 @@
|
||||
android:textColor="@color/mtrl_btn_text_color_selector"
|
||||
android:textColorHint="@color/mtrl_btn_text_color_selector"
|
||||
app:layout_constraintEnd_toEndOf="@+id/text_home"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/text_home"
|
||||
app:layout_constraintTop_toBottomOf="@+id/login_data" />
|
||||
|
||||
@ -111,7 +112,7 @@
|
||||
android:textColor="@color/mtrl_btn_text_color_selector"
|
||||
android:textColorHint="@color/mtrl_btn_text_color_selector"
|
||||
app:layout_constraintEnd_toEndOf="@+id/text_home"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/text_home"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ipInput" />
|
||||
|
||||
@ -126,7 +127,7 @@
|
||||
android:textColor="@color/mtrl_btn_text_color_selector"
|
||||
android:textColorHint="@color/mtrl_btn_text_color_selector"
|
||||
app:layout_constraintEnd_toEndOf="@+id/text_home"
|
||||
app:layout_constraintHorizontal_bias="0.497"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/text_home"
|
||||
app:layout_constraintTop_toBottomOf="@+id/loginuserInput" />
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.red_blue" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
@ -18,6 +18,8 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorControlActivated">@color/red</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.red_blue.NoActionBar">
|
||||
@ -87,6 +89,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorControlActivated">@color/green</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.orange_turquoise" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
@ -107,6 +110,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorControlActivated">@color/orange</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.yellow_blue" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
@ -127,6 +131,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorControlActivated">@color/yellow</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.pink_green" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
@ -147,6 +152,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorControlActivated">@color/pink</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -43,17 +43,17 @@
|
||||
//settings
|
||||
<string name="farben">COLORS</string>
|
||||
<string name="hintergrund">BACKGROUND</string>
|
||||
<string name="button_hintergrund_wählen">CHOOSE BACKGROUND</string>
|
||||
<string name="button_hintergrund_wählen">"CHOOSE\nBACKGROUND"</string>
|
||||
<string name="sprache">LANGUAGE</string>
|
||||
<string name="einstellungen_zurücksetzen">RESET SETTINGS</string>
|
||||
<string name="button_zurücksetzen">RESET</string>
|
||||
<string name="themes">COLORSCHEME</string>
|
||||
<string name="red_blue">RED\nBLUE</string>
|
||||
<string name="green_yellow">GREEN\nYELLOW</string>
|
||||
<string name="orange_turquoise">ORANGE\nTURQUOISE</string>
|
||||
<string name="yellow_blue">YELLOW\nBLUE</string>
|
||||
<string name="pink_green">PINK\nGREEN</string>
|
||||
<string name="reset_app">RESET\nAPP</string>
|
||||
<string name="red_blue">"RED\nBLUE"</string>
|
||||
<string name="green_yellow">"GREEN\nYELLOW"</string>
|
||||
<string name="orange_turquoise">"ORANGE\nTURQUOISE"</string>
|
||||
<string name="yellow_blue">"YELLOW\nBLUE"</string>
|
||||
<string name="pink_green">"PINK\nGREEN"</string>
|
||||
<string name="reset_app">RESET APP</string>
|
||||
<string name="are_you_sure_to_reset">ARE YOU SURE YOU WANT TO RESET THE APP AND DELETE ALL YOUR SETTINGS?</string>
|
||||
|
||||
//credits
|
||||
|
@ -18,6 +18,7 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:itemBackground">@drawable/button_round</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.red_blue.NoActionBar">
|
||||
|
Loading…
Reference in New Issue
Block a user