added Colorpicker

This commit is contained in:
JG-Cody 2021-05-31 19:25:14 +02:00
parent 287218fbc6
commit e673ca3fb0
6 changed files with 46 additions and 117 deletions

View File

@ -44,6 +44,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.0.1'
} }
repositories { repositories {
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }

View File

@ -1,10 +1,14 @@
package de.jg_cody.Teraplex.ui.Einstellungen; package de.jg_cody.Teraplex.ui.Einstellungen;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -12,11 +16,14 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import com.rarepebble.colorpicker.ColorPickerView;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
public class EinstellungenFragment extends Fragment { public class EinstellungenFragment extends Fragment {
private EinstellungenViewModel einstellungenViewModel; private EinstellungenViewModel einstellungenViewModel;
Button button_colorpicker;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
@ -30,6 +37,26 @@ public class EinstellungenFragment extends Fragment {
textView.setText(s); textView.setText(s);
} }
}); });
button_colorpicker = (Button) root.findViewById(R.id.button_colorpicker);
button_colorpicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Toast.makeText(getContext(), "Colorpicker", Toast.LENGTH_SHORT).show();
final ColorPickerView picker = new ColorPickerView(getContext());
picker.setColor(0xff12345);
new AlertDialog.Builder(getContext()).setView(picker).setTitle(R.string.colorpicker).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} catch (Exception e) {
}
}
});
return root; return root;
} }
} }

View File

@ -38,7 +38,7 @@
android:id="@+id/background" android:id="@+id/background"
android:layout_width="193dp" android:layout_width="193dp"
android:layout_height="33dp" android:layout_height="33dp"
android:layout_marginTop="50dp" android:layout_marginTop="100dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="HINTERGRUND" android:text="HINTERGRUND"
android:textAlignment="center" android:textAlignment="center"
@ -137,9 +137,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="RESET" android:text="RESET"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/reset_settings" /> app:layout_constraintTop_toBottomOf="@+id/reset_settings" />
<Button
android:id="@+id/button_colorpicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORPICKER"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spThemes" />
<Button <Button
android:id="@+id/button_pickimage" android:id="@+id/button_pickimage"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,24 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
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" />
<TextView <TextView
android:id="@+id/text_kueche" android:id="@+id/text_kueche"
@ -34,99 +16,4 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<TextView </PreferenceScreen>
android:id="@+id/background"
android:layout_width="193dp"
android:layout_height="33dp"
android:layout_marginTop="200dp"
android:text="Raumtemperatur in °C"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/sprache"
android:layout_width="193dp"
android:layout_height="33dp"
android:text="Elektrogeräte EIN/AUS"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal" />
<SeekBar
android:id="@+id/seekBar"
style="@android:style/Widget.DeviceDefault.Light.SeekBar"
android:layout_width="235dp"
android:layout_height="45dp"
android:max="30"
android:progress="15"
app:layout_constraintBottom_toTopOf="@+id/sprache"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/background" />
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:text="Steckdose 1 "
android:textColor="#FFFFFF"
app:layout_constraintBottom_toTopOf="@+id/switch3"
app:layout_constraintEnd_toStartOf="@+id/switch2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sprache" />
<Switch
android:id="@+id/switch3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_marginBottom="200dp"
android:text="Steckdose 3 "
android:textColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/switch4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/switch1" />
<Switch
android:id="@+id/switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:text="Steckdose 2 "
android:textColor="#FFFFFF"
app:layout_constraintBottom_toTopOf="@+id/switch4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/switch1"
app:layout_constraintTop_toBottomOf="@+id/sprache" />
<Switch
android:id="@+id/switch4"
android:layout_width="129dp"
android:layout_height="22dp"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="200dp"
android:text="Steckdose 4 "
android:textColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/switch3"
app:layout_constraintTop_toBottomOf="@+id/switch2" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -30,6 +30,9 @@
<string name="menu_sprache">SPRACHE</string> <string name="menu_sprache">SPRACHE</string>
<string name="menu_schliessen">SCHLIESSEN</string> <string name="menu_schliessen">SCHLIESSEN</string>
<string name="colorpicker">WÄHLE DEINE FARBE</string>
<string name="ok">OK</string>
<string-array name="theme_array"> <string-array name="theme_array">
<item>RED</item> <item>RED</item>
<item>GREEN</item> <item>GREEN</item>

View File

@ -4,3 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
android.enableJetifier=true