mirror of
https://github.com/TimeCrafters/TimeCraftersConfigurationTool.git
synced 2025-12-15 05:02:33 +00:00
Initial work on custom dialogs
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||
|
||||
public class Dialog extends android.app.Dialog {
|
||||
public Dialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.dialog_base);
|
||||
|
||||
ImageButton closeButton = findViewById(R.id.dialogCloseButton);
|
||||
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Point point = new Point();
|
||||
getWindow().getWindowManager().getDefaultDisplay().getSize(point);
|
||||
getWindow().setLayout((int) (point.x * 0.75), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,9 @@ public class SettingsFragment extends Fragment {
|
||||
settingsViewModel =
|
||||
ViewModelProviders.of(this).get(SettingsViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_settings, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_settings);
|
||||
settingsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
return root;
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -13,6 +15,9 @@ import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.R;
|
||||
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.Dialog;
|
||||
|
||||
import static android.view.View.inflate;
|
||||
|
||||
public class TACNETFragment extends Fragment {
|
||||
|
||||
@@ -23,13 +28,25 @@ public class TACNETFragment extends Fragment {
|
||||
TACNETViewModel =
|
||||
ViewModelProviders.of(this).get(TACNETViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_tacnet, container, false);
|
||||
final TextView textView = root.findViewById(R.id.text_tacnet);
|
||||
TACNETViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
});
|
||||
|
||||
Button connect = root.findViewById(R.id.connect);
|
||||
connect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Dialog dialog = new Dialog(getContext());
|
||||
dialog.show();
|
||||
|
||||
((TextView)dialog.findViewById(R.id.dialogTitle)).setText("Add Variable Variable");
|
||||
LinearLayout view = dialog.findViewById(R.id.dialogContent);
|
||||
view.addView(getLayoutInflater().inflate(R.layout.dialog_edit_variable, null));
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/cross.png
Normal file
BIN
app/src/main/res/drawable-hdpi/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 378 B |
BIN
app/src/main/res/drawable-mdpi/cross.png
Normal file
BIN
app/src/main/res/drawable-mdpi/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
BIN
app/src/main/res/drawable-xhdpi/cross.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 460 B |
BIN
app/src/main/res/drawable-xxhdpi/cross.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 780 B |
BIN
app/src/main/res/drawable-xxxhdpi/cross.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/cross.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 987 B |
8
app/src/main/res/drawable/dialog.xml
Normal file
8
app/src/main/res/drawable/dialog.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/dialogBackground" />
|
||||
<corners
|
||||
android:topLeftRadius="8dp"
|
||||
android:topRightRadius="8dp" />
|
||||
</shape>
|
||||
50
app/src/main/res/layout/dialog_base.xml
Normal file
50
app/src/main/res/layout/dialog_base.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/dialogContainer"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="100"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@color/dialogNotice"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialogTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24dp"
|
||||
android:textColor="@color/dialogTitle"
|
||||
android:textFontWeight="800"
|
||||
android:text="[Title Not Set]"
|
||||
android:layout_marginLeft="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/dialogCloseButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/dialog_close"
|
||||
android:src="@drawable/cross"
|
||||
android:backgroundTint="@color/colorDanger"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialogContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/dialogBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
67
app/src/main/res/layout/dialog_edit_variable.xml
Normal file
67
app/src/main/res/layout/dialog_edit_variable.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/variable_name" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/variableName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/variable_name"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/variable_type" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/variable_type"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/variable_value" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/variable_value"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/dialog_cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/dialog_add" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -1,22 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.settings.SettingsFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_settings"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:background="@color/list_even"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_manage_presets" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/list_odd"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_manage_configurations" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -6,10 +6,22 @@
|
||||
<color name="colorSecondary">#006000</color>
|
||||
<color name="colorTertiary">#00d000</color>
|
||||
|
||||
<color name="colorDanger">#800</color>
|
||||
|
||||
<color name="buttonContent">#ffffff</color>
|
||||
<color name="buttonDisabled">#765</color>
|
||||
<color name="navigationButtonSelected">#00a000</color>
|
||||
<color name="navigationButtonHover">#00d000</color>
|
||||
<color name="navigationButtonActive">#00d000</color>
|
||||
<color name="navigationButton">#006000</color>
|
||||
|
||||
<color name="list_even">#555</color>
|
||||
<color name="list_odd">#999</color>
|
||||
|
||||
<color name="dialogBackground">#eee</color>
|
||||
<color name="dialogTitle">#fff</color>
|
||||
<color name="dialogCloseColor">#222</color>
|
||||
<color name="dialogAlert">#f80</color>
|
||||
<color name="dialogError">@color/colorDanger</color>
|
||||
<color name="dialogNotice">#080</color>
|
||||
</resources>
|
||||
@@ -16,4 +16,17 @@
|
||||
<string name="navbar_editor_description">Edit configuration</string>
|
||||
<string name="navbar_settings_description">Manage presets and configuration files</string>
|
||||
<string name="navbar_search_description">Search for groups and actions</string>
|
||||
|
||||
<string name="settings_manage_presets">Manage Presets</string>
|
||||
<string name="settings_manage_configurations">Manage Configurations</string>
|
||||
|
||||
<string name="dialog_close">Close</string>
|
||||
<string name="dialog_cancel">Cancel</string>
|
||||
<string name="dialog_okay">Okay</string>
|
||||
<string name="dialog_add">Add</string>
|
||||
<string name="dialog_update">Update</string>
|
||||
|
||||
<string name="variable_name">Name</string>
|
||||
<string name="variable_type">Type</string>
|
||||
<string name="variable_value">Value</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user