Stubbed Presets and Configurations activities, stubbed fragment for configurations

This commit is contained in:
2020-06-28 18:42:36 -05:00
parent e9cf747f12
commit 27ca41a416
20 changed files with 178 additions and 11 deletions

2
.idea/misc.xml generated
View File

@@ -39,7 +39,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -23,6 +23,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.settings.presets.PresetsActivity"
android:label="@string/settings_manage_presets">
</activity>
<activity
android:name=".ui.settings.configurations.ConfigurationsActivity"
android:label="@string/settings_manage_configurations">
</activity>
</application>
</manifest>

View File

@@ -1,9 +1,11 @@
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -13,6 +15,8 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import org.timecrafters.TimeCraftersConfigurationTool.R;
import org.timecrafters.TimeCraftersConfigurationTool.ui.settings.configurations.ConfigurationsActivity;
import org.timecrafters.TimeCraftersConfigurationTool.ui.settings.presets.PresetsActivity;
public class SettingsFragment extends Fragment {
@@ -23,6 +27,23 @@ public class SettingsFragment extends Fragment {
settingsViewModel =
ViewModelProviders.of(this).get(SettingsViewModel.class);
View root = inflater.inflate(R.layout.fragment_settings, container, false);
final Button managePresets = root.findViewById(R.id.manage_presets);
final Button manageConfigurations = root.findViewById(R.id.manage_configurations);
managePresets.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), PresetsActivity.class));
}
});
manageConfigurations.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), ConfigurationsActivity.class));
}
});
settingsViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {

View File

@@ -0,0 +1,24 @@
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings.configurations;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import org.timecrafters.TimeCraftersConfigurationTool.R;
public class ConfigurationsActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_configurations);
LinearLayout v = findViewById(R.id.configurations);
v.setBackgroundColor(getResources().getColor(R.color.list_even));
View vv = v.inflate(getApplicationContext(), R.layout.fragment_configuration, null);
v.addView(vv);
}
}

View File

@@ -0,0 +1,6 @@
package org.timecrafters.TimeCraftersConfigurationTool.ui.settings.presets;
import androidx.appcompat.app.AppCompatActivity;
public class PresetsActivity extends AppCompatActivity {
}

View File

@@ -1,10 +1,13 @@
package org.timecrafters.TimeCraftersConfigurationTool.ui.tacnet;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -13,10 +16,12 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import org.timecrafters.TimeCraftersConfigurationTool.R;
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.VariableDialog;
public class TACNETFragment extends Fragment {
private static final String TAG = "TACNETFragment";
private TACNETViewModel TACNETViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
@@ -24,14 +29,44 @@ public class TACNETFragment extends Fragment {
TACNETViewModel =
ViewModelProviders.of(this).get(TACNETViewModel.class);
View root = inflater.inflate(R.layout.fragment_tacnet, container, false);
TACNETViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
final EditText hostname = root.findViewById(R.id.hostname);
final EditText port = root.findViewById(R.id.port);
final Button connectButton = root.findViewById(R.id.tacnet_connect);
final Button startServerButton = root.findViewById(R.id.tacnet_start_server);
hostname.setText(Backend.instance().getSettings().hostname);
port.setText(String.valueOf(Backend.instance().getSettings().port));
hostname.addTextChangedListener(new TextWatcher() {
@Override
public void onChanged(@Nullable String s) {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
Backend.instance().getSettings().hostname = hostname.getText().toString();
Backend.instance().settingsChanged();
}
});
Button connect = root.findViewById(R.id.connect);
connect.setOnClickListener(new View.OnClickListener() {
port.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
Backend.instance().getSettings().port = Integer.parseInt(port.getText().toString());
Backend.instance().settingsChanged();
}
});
connectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
VariableDialog dialog = new VariableDialog();
@@ -39,6 +74,20 @@ public class TACNETFragment extends Fragment {
}
});
startServerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
VariableDialog dialog = new VariableDialog();
dialog.show(getFragmentManager(), null);
}
});
TACNETViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
}
});
return root;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="@+id/configurations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,38 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/configuration"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/configuration_name"
style="@style/Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/rename_configuration"
style="@style/Widget.AppCompat.ImageButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/gear"
app:layout_constraintStart_toStartOf="@+id/configuration_name"
app:layout_constraintTop_toTopOf="@+id/configuration_name" />
<ImageButton
android:id="@+id/delete_configuration"
style="@style/Widget.AppCompat.ImageButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/trash"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>

View File

@@ -16,7 +16,7 @@
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/button4"
android:id="@+id/manage_presets"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_manage_presets" />
@@ -32,7 +32,7 @@
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/button5"
android:id="@+id/manage_configurations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_manage_configurations" />

View File

@@ -21,7 +21,7 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/tacnet_connect"
android:id="@+id/tacnet_connect_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
@@ -48,7 +48,7 @@
android:text="@string/tacnet_hostname" />
<EditText
android:id="@+id/editTextTextPersonName"
android:id="@+id/hostname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
@@ -71,14 +71,14 @@
android:inputType="number" />
<Button
android:id="@+id/connect"
android:id="@+id/tacnet_connect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/tacnet_connect" />
</LinearLayout>
<LinearLayout
android:id="@+id/tacnet_server"
android:id="@+id/tacnet_server_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"