prepared for editing existing buttons

prepared for data export and import
This commit is contained in:
JG-Cody 2021-08-13 17:09:47 +02:00
parent a21d8d8931
commit 975243e1e2
7 changed files with 168 additions and 7 deletions

View File

@ -59,6 +59,17 @@ public class SettingsFragment extends Fragment {
} }
}); });
Button Export = root.findViewById(R.id.button_export);
Export.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
showExportDialog();
}
});
Button Reset = root.findViewById(R.id.button_reset); Button Reset = root.findViewById(R.id.button_reset);
Reset.setOnClickListener(new View.OnClickListener() { Reset.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -268,7 +279,33 @@ public class SettingsFragment extends Fragment {
editor.putString("Language", lang); editor.putString("Language", lang);
editor.apply(); editor.apply();
} }
private void showExportDialog() {
final String[] listItems = {"EXPORT BACKGROUND", "EXPORT LANGUAGESETTINGS", "EXPORT THEMESETTINGS", "EXPORT TABS"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
mBuilder.setTitle(getString(R.string.export_settings));
mBuilder.setMultiChoiceItems(listItems, selection, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Vibrator vr = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE);
assert vr != null;
vr.vibrate(100);
if (i == 0) {
} else if (i == 1) {
} else if (i == 2) {
} else if (i == 3) {
}
dialogInterface.dismiss();
}
});
AlertDialog mDialog = mBuilder.create();
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; //style id
mDialog.show();
}
} }

View File

@ -6,6 +6,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -116,13 +117,16 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
public void bindView(View view, ListItem item) { public void bindView(View view, ListItem item) {
String[] strings = item.getStrings(); String[] strings = item.getStrings();
ImageView Remove = view.findViewById(R.id.image_remove); ImageView Remove = view.findViewById(R.id.image_remove);
ImageView Edit = view.findViewById(R.id.image_edit);
if (MainActivity.editmode) { if (MainActivity.editmode) {
Remove.setVisibility(View.VISIBLE); Remove.setVisibility(View.VISIBLE);
Edit.setVisibility(View.VISIBLE);
} }
else { else {
Remove.setVisibility(View.GONE); Remove.setVisibility(View.GONE);
Edit.setVisibility(View.GONE);
} }
Remove.setOnClickListener(new View.OnClickListener() { Remove.setOnClickListener(new View.OnClickListener() {
@ -136,6 +140,33 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
} }
} }
}); });
Edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(item.getType()) {
case SINGLEBUTTON:
{
Toast.makeText(v.getContext(), "SINGLEBUTTON",Toast.LENGTH_LONG).show();
break;
}
case DOUBLEBUTTON:
{
Toast.makeText(v.getContext(), "DOUBLEBUTTON",Toast.LENGTH_LONG).show();
break;
}
case SPACE:
{
Toast.makeText(v.getContext(), "SPACE",Toast.LENGTH_LONG).show();
break;
}
case HEADLINE:
{
Toast.makeText(v.getContext(), "HEADLINE",Toast.LENGTH_LONG).show();
break;
}
}
}
});
switch(item.getType()) { switch(item.getType()) {
case SINGLEBUTTON: case SINGLEBUTTON:
{ {
@ -191,4 +222,5 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
return itemView; return itemView;
} }
} }
} }

View File

@ -38,6 +38,19 @@
android:text="Button2" android:text="Button2"
app:backgroundTint="@null" /> app:backgroundTint="@null" />
<ImageView
android:id="@+id/image_edit"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight="0"
app:srcCompat="@drawable/mode_edit_black_24dp"
app:tint="?attr/colorOnPrimary"
tools:ignore="VectorDrawableCompat">
</ImageView>
<ImageView <ImageView
android:id="@+id/image_remove" android:id="@+id/image_remove"
android:layout_width="40dp" android:layout_width="40dp"

View File

@ -34,19 +34,16 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="-25dp" android:layout_marginStart="-25dp"
android:layout_marginLeft="-25dp"
android:layout_marginTop="-25dp" android:layout_marginTop="-25dp"
android:layout_marginEnd="-25dp" android:layout_marginEnd="-25dp"
android:layout_marginRight="-25dp"
android:layout_marginBottom="-25dp" android:layout_marginBottom="-25dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/backgroundoverlay" android:src="@drawable/backgroundoverlay"
app:layout_constraintBottom_toBottomOf="@+id/button_reset" app:layout_constraintBottom_toBottomOf="@+id/button_export"
app:layout_constraintEnd_toEndOf="@+id/button_theme_red_blue" app:layout_constraintEnd_toEndOf="@+id/button_theme_red_blue"
app:layout_constraintHorizontal_bias="1.0" app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/themes" app:layout_constraintStart_toStartOf="@+id/themes"
app:layout_constraintTop_toTopOf="@+id/button_theme_red_blue" app:layout_constraintTop_toTopOf="@+id/button_theme_red_blue" />
app:layout_constraintVertical_bias="1.0" />
<TextView <TextView
android:id="@+id/background" android:id="@+id/background"
@ -123,6 +120,21 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/button_reset" /> app:layout_constraintTop_toTopOf="@+id/button_reset" />
<TextView
android:id="@+id/reset_import_export"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal|left"
android:text="@string/reset_settings"
android:textAlignment="center"
android:textColor="@color/mtrl_btn_text_color_selector"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/divider4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider4" />
<Button <Button
android:id="@+id/button_reset" android:id="@+id/button_reset"
android:layout_width="140dp" android:layout_width="140dp"
@ -136,6 +148,30 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider3" /> app:layout_constraintTop_toBottomOf="@+id/divider3" />
<Button
android:id="@+id/button_export"
android:layout_width="140dp"
android:layout_height="55dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="35dp"
android:background="@drawable/button_round"
android:text="@string/button_export"
app:backgroundTint="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/reset_import_export" />
<Button
android:id="@+id/button_import"
android:layout_width="140dp"
android:layout_height="55dp"
android:layout_marginStart="35dp"
android:layout_marginTop="10dp"
android:background="@drawable/button_round"
android:text="@string/button_import"
app:backgroundTint="@null"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/reset_import_export" />
<Button <Button
android:id="@+id/button_theme_red_blue" android:id="@+id/button_theme_red_blue"
android:layout_width="140dp" android:layout_width="140dp"
@ -264,14 +300,25 @@
app:layout_constraintStart_toStartOf="@+id/divider" app:layout_constraintStart_toStartOf="@+id/divider"
app:layout_constraintTop_toBottomOf="@+id/button_language" /> app:layout_constraintTop_toBottomOf="@+id/button_language" />
<View
android:id="@+id/divider4"
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="@drawable/background_full"
app:layout_constraintEnd_toEndOf="@+id/divider"
app:layout_constraintStart_toStartOf="@+id/divider"
app:layout_constraintTop_toBottomOf="@+id/button_reset" />
<Space <Space
android:id="@+id/space"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="50dp" android:layout_marginTop="50dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_reset" /> app:layout_constraintTop_toBottomOf="@+id/button_export" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

View File

@ -19,6 +19,20 @@
android:text="TEXT" android:text="TEXT"
app:backgroundTint="@null" /> app:backgroundTint="@null" />
<ImageView
android:id="@+id/image_edit"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight="0"
android:visibility="visible"
app:srcCompat="@drawable/mode_edit_black_24dp"
app:tint="?attr/colorOnPrimary"
tools:ignore="VectorDrawableCompat">
</ImageView>
<ImageView <ImageView
android:id="@+id/image_remove" android:id="@+id/image_remove"
android:layout_width="40dp" android:layout_width="40dp"

View File

@ -28,12 +28,27 @@
android:text="Button2" android:text="Button2"
app:backgroundTint="@null" /> app:backgroundTint="@null" />
<ImageView
android:id="@+id/image_edit"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight="0"
android:visibility="visible"
app:srcCompat="@drawable/mode_edit_black_24dp"
app:tint="?attr/colorOnPrimary"
tools:ignore="VectorDrawableCompat">
</ImageView>
<ImageView <ImageView
android:id="@+id/image_remove" android:id="@+id/image_remove"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="5dp" android:layout_margin="5dp"
android:layout_weight="0"
android:visibility="visible" android:visibility="visible"
app:srcCompat="@drawable/clear_black_24dp" app:srcCompat="@drawable/clear_black_24dp"
app:tint="?attr/colorOnPrimary" app:tint="?attr/colorOnPrimary"

View File

@ -43,6 +43,9 @@
<string name="language">LANGUAGE</string> <string name="language">LANGUAGE</string>
<string name="reset_settings">RESET SETTINGS</string> <string name="reset_settings">RESET SETTINGS</string>
<string name="button_reset">RESET</string> <string name="button_reset">RESET</string>
<string name="button_import">IMPORT</string>
<string name="button_export">EXPORT</string>
<string name="export_settings">EXPORT-SETTINGS</string>
<string name="color_scheme">COLORSCHEME</string> <string name="color_scheme">COLORSCHEME</string>
<string name="red_blue">"RED\nBLUE"</string> <string name="red_blue">"RED\nBLUE"</string>
<string name="green_yellow">"GREEN\nYELLOW"</string> <string name="green_yellow">"GREEN\nYELLOW"</string>