added custom background option
This commit is contained in:
parent
316a04df19
commit
1b12a92fbb
@ -4,6 +4,9 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission."/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
@ -2,14 +2,21 @@ package de.jg_cody.Teraplex;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
@ -17,8 +24,10 @@ import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
@ -31,6 +40,10 @@ import androidx.navigation.ui.NavigationUI;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
|
||||
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
|
||||
@ -40,7 +53,7 @@ import de.jg_cody.Teraplex.ui.home.HomeFragment;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements AddButtonDialog.AddButtonDialogListener {
|
||||
|
||||
public static int RESULT_LOAD_IMAGE = 0;
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
|
||||
@Override
|
||||
@ -188,6 +201,13 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
startActivity(in);
|
||||
}
|
||||
|
||||
public void menurighttoplogout(MenuItem i) {
|
||||
Toast.makeText(this, "LOGOUT", Toast.LENGTH_LONG).show();
|
||||
getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().remove("ip").remove("user").remove("password").commit();
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
|
||||
public void menurighttopschliessen(MenuItem i) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
finishAffinity();
|
||||
@ -195,6 +215,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
}
|
||||
|
||||
private void showChooseElement() {
|
||||
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "OPTION3"};
|
||||
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
|
||||
@ -216,4 +237,81 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
|
||||
Uri selectedImage = data.getData();
|
||||
String[] filePathColumn = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = getContentResolver().query(selectedImage,
|
||||
filePathColumn, null, null, null);
|
||||
cursor.moveToFirst();
|
||||
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
|
||||
String picturePath = cursor.getString(columnIndex);
|
||||
cursor.close();
|
||||
// String picturePath contains the path of selected Image
|
||||
try {
|
||||
InputStream Background= getContentResolver().openInputStream(selectedImage);
|
||||
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
||||
int len;
|
||||
byte[] buf = new byte[1024];
|
||||
while((len = Background.read(buf)) > 0) {
|
||||
bOut.write(buf, 0, len);
|
||||
}
|
||||
Background.close();
|
||||
SharedPreferences p = getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
p.edit().putString("Background", Base64.getEncoder().encodeToString(bOut.toByteArray())).apply();
|
||||
loadBackground();
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
private void loadBackground() {
|
||||
SharedPreferences p = getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
|
||||
String Background = p.getString("Background", null);
|
||||
ImageView I = findViewById(R.id.Background);
|
||||
byte[] BA = Base64.getDecoder().decode(Background);
|
||||
I.setImageBitmap(BitmapFactory.decodeByteArray(BA, 0, BA.length));
|
||||
|
||||
}
|
||||
public static int getScreenWidth() {
|
||||
return Resources.getSystem().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
public static int getScreenHeight() {
|
||||
return Resources.getSystem().getDisplayMetrics().heightPixels;
|
||||
}
|
||||
public static Bitmap scaleCenterCrop(Bitmap source, int newHeight,
|
||||
int newWidth) {
|
||||
int sourceWidth = source.getWidth();
|
||||
int sourceHeight = source.getHeight();
|
||||
|
||||
float xScale = (float) newWidth / sourceWidth;
|
||||
float yScale = (float) newHeight / sourceHeight;
|
||||
float scale = Math.max(xScale, yScale);
|
||||
|
||||
// Now get the size of the source bitmap when scaled
|
||||
float scaledWidth = scale * sourceWidth;
|
||||
float scaledHeight = scale * sourceHeight;
|
||||
|
||||
float left = (newWidth - scaledWidth) / 2;
|
||||
float top = (newHeight - scaledHeight) / 2;
|
||||
|
||||
RectF targetRect = new RectF(left, top, left + scaledWidth, top
|
||||
+ scaledHeight);//from ww w .j a va 2s. co m
|
||||
|
||||
Bitmap dest = Bitmap.createBitmap(newWidth, newHeight,
|
||||
source.getConfig());
|
||||
Canvas canvas = new Canvas(dest);
|
||||
canvas.drawBitmap(source, null, targetRect, null);
|
||||
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,44 @@
|
||||
package de.jg_cody.Teraplex.ui.Credits;
|
||||
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
public class CreditsFragment extends Fragment {
|
||||
|
||||
private CreditsViewModel creditsViewModel;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
}
|
@ -1,25 +1,34 @@
|
||||
package de.jg_cody.Teraplex.ui.Einstellungen;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
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.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.rarepebble.colorpicker.ColorPickerView;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
@ -29,11 +38,20 @@ public class EinstellungenFragment extends Fragment {
|
||||
private EinstellungenViewModel einstellungenViewModel;
|
||||
Button button_colorpicker;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
button_colorpicker = (Button) root.findViewById(R.id.button_colorpicker);
|
||||
button_colorpicker.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -91,6 +109,16 @@ public class EinstellungenFragment extends Fragment {
|
||||
}
|
||||
|
||||
});
|
||||
Button choose_background = root.findViewById(R.id.button_pickimage);
|
||||
choose_background.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(
|
||||
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
getActivity().startActivityForResult(i, MainActivity.RESULT_LOAD_IMAGE);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return root;
|
||||
|
@ -1,22 +1,15 @@
|
||||
package de.jg_cody.Teraplex.ui.Flur;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import de.jg_cody.Teraplex.ActivityCricketers;
|
||||
import de.jg_cody.Teraplex.Cricketer;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@ -24,9 +17,21 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import de.jg_cody.Teraplex.ActivityCricketers;
|
||||
import de.jg_cody.Teraplex.Cricketer;
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
|
||||
public class FlurFragment extends Fragment implements View.OnClickListener {
|
||||
|
||||
@ -39,11 +44,20 @@ public class FlurFragment extends Fragment implements View.OnClickListener {
|
||||
List<String> teamList = new ArrayList<>();
|
||||
ArrayList<Cricketer> cricketersList = new ArrayList<>();
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
layoutList = root.findViewById(R.id.layout_list);
|
||||
buttonAdd = root.findViewById(R.id.button_add);
|
||||
|
@ -1,19 +1,29 @@
|
||||
package de.jg_cody.Teraplex.ui.Konsole;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
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.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
import de.jg_cody.Teraplex.SSH_connection;
|
||||
|
||||
@ -32,11 +42,20 @@ public class KonsoleFragment extends Fragment {
|
||||
|
||||
private KonsoleViewModel konsoleViewModel;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
befehlInput = (EditText) root.findViewById(R.id.befehlInput);
|
||||
SendCommandButton = (Button) root.findViewById(R.id.SendCommandButton);
|
||||
SendCommandButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -1,21 +1,30 @@
|
||||
package de.jg_cody.Teraplex.ui.Schlafzimmer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
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.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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;
|
||||
import de.jg_cody.Teraplex.SSH_connection;
|
||||
|
||||
@ -32,6 +41,7 @@ public class SchlafzimmerFragment extends Fragment {
|
||||
|
||||
private SchlafzimmerViewModel schlafzimmerViewModel;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
@ -42,6 +52,14 @@ 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);
|
||||
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_schlafzimmer);
|
||||
schlafzimmerViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
|
@ -1,20 +1,29 @@
|
||||
package de.jg_cody.Teraplex.ui.home;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
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.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
import de.jg_cody.Teraplex.SSH_connection;
|
||||
|
||||
@ -34,6 +43,7 @@ public class HomeFragment extends Fragment {
|
||||
|
||||
private HomeViewModel homeViewModel;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
|
||||
@ -44,12 +54,20 @@ 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);
|
||||
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_home);
|
||||
final TextView login_data = root.findViewById(R.id.login_data);
|
||||
if (user == null || ip == null) {
|
||||
login_data.setText(R.string.please_login);
|
||||
} else {
|
||||
login_data.setText(getString(R.string.sie_sind_als_angemeldet).replace("{IP}", ip ).replace("{USERNAME}", user ));
|
||||
login_data.setText(getString(R.string.sie_sind_als_angemeldet).replace("{IP}", ip).replace("{USERNAME}", user));
|
||||
}
|
||||
userInput = (EditText) root.findViewById(R.id.loginuserInput);
|
||||
passwordInput = (EditText) root.findViewById(R.id.loginpasswordInput);
|
||||
|
@ -1,28 +1,47 @@
|
||||
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
|
||||
|
@ -1,15 +1,25 @@
|
||||
package de.jg_cody.Teraplex.ui.zeitsteuerung;
|
||||
|
||||
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.TimePicker;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
public class ZeitsteuerungFragment extends Fragment {
|
||||
@ -17,11 +27,20 @@ public class ZeitsteuerungFragment extends Fragment {
|
||||
private ZeitsteuerungViewModel zeitsteuerungViewModel;
|
||||
TimePicker timePicker;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
TimePicker timePicker = (TimePicker) root.findViewById(R.id.timePicker);
|
||||
timePicker.setIs24HourView(true);
|
||||
return root;
|
||||
|
@ -15,7 +15,7 @@
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.727"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
@ -74,7 +74,7 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/Background" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nightmode"
|
||||
@ -119,7 +119,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/sprache" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_pickimage2"
|
||||
android:id="@+id/button_pickimage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_hintergrund_wählen"
|
||||
|
@ -4,10 +4,21 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
|
@ -2,6 +2,8 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_kueche"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,7 +7,7 @@
|
||||
tools:context=".ui.home.HomeFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:id="@+id/LoginBackground"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/teraplex_login"
|
||||
|
@ -7,17 +7,5 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.kueche.KuecheFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -7,19 +7,6 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.Schlafzimmer.SchlafzimmerFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/schlafzimmeru3an"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -7,18 +7,6 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.zeitsteuerung.ZeitsteuerungFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/Background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/befehlInput2"
|
||||
|
@ -34,6 +34,7 @@
|
||||
<item
|
||||
android:id="@+id/logout"
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:onClick="menurighttoplogout"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/menu_logout"
|
||||
app:showAsAction="never" />
|
||||
|
Loading…
Reference in New Issue
Block a user