WIP: App works again (with a few ux issues)

This commit is contained in:
2023-11-20 15:53:18 -06:00
parent a06e62a944
commit 2a8093da50
23 changed files with 105 additions and 183 deletions

View File

@@ -3,7 +3,9 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.timecrafters.TimeCraftersConfigurationTool"> package="org.timecrafters.TimeCraftersConfigurationTool">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -11,6 +13,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application <application
android:enableOnBackInvokedCallback="true"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
@@ -20,7 +23,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
tools:targetApi="31"> android:hasFragileUserData="true"
tools:targetApi="34">
<service <service
android:name=".tacnet.TACNETServerService" android:name=".tacnet.TACNETServerService"
android:enabled="true" android:enabled="true"
@@ -40,7 +44,7 @@
<activity <activity
android:exported="true" android:exported="true"
android:name=".LauncherActivity" android:name=".MainActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -49,8 +53,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".MainActivity" />
<receiver <receiver
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"

View File

@@ -1,21 +1,15 @@
package org.timecrafters.TimeCraftersConfigurationTool; package org.timecrafters.TimeCraftersConfigurationTool;
import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend; import org.timecrafters.TimeCraftersConfigurationTool.backend.Backend;
import org.timecrafters.TimeCraftersConfigurationTool.dialogs.PermissionsRequestDialog;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
public class LauncherActivity extends AppCompatActivity { public class LauncherActivity extends AppCompatActivity {
private static final int REQUEST_WRITE_PERMISSION = 70; // private static final int REQUEST_WRITE_PERMISSION = 70;
private static final String TAG = "LauncherActivity"; private static final String TAG = "LauncherActivity";
private static final long timerDelay = 2_000; private static final long timerDelay = 2_000;
private static final long timerQuickDelay = 250; // Give LauncherActivity enough time to do first paint private static final long timerQuickDelay = 250; // Give LauncherActivity enough time to do first paint
@@ -31,33 +25,14 @@ public class LauncherActivity extends AppCompatActivity {
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
if (havePermissions()) { if (Backend.instance() == null) {
if (Backend.instance() == null) { new Backend(getApplicationContext());
new Backend();
}
if (Backend.instance().getSettings().mobileDisableLauncherDelay) {
startTimer(timerQuickDelay);
} else {
startTimer(timerDelay);
}
} else {
new PermissionsRequestDialog().show(getSupportFragmentManager(), null);
} }
}
@Override if (Backend.instance().getSettings().mobileDisableLauncherDelay) {
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { startTimer(timerQuickDelay);
switch (requestCode) { } else {
case REQUEST_WRITE_PERMISSION: { startTimer(timerDelay);
if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
// Permission granted
startTimer(timerDelayAfterPermissionRequest);
} else {
// Permission not given
new PermissionsRequestDialog().show(getSupportFragmentManager(), null);
}
}
} }
} }
@@ -72,14 +47,4 @@ public class LauncherActivity extends AppCompatActivity {
} }
}, milliseconds); }, milliseconds);
} }
private boolean havePermissions() {
return ContextCompat.checkSelfPermission(LauncherActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PERMISSION_GRANTED;
}
public void requestStoragePermissions() {
ActivityCompat.requestPermissions(LauncherActivity.this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
REQUEST_WRITE_PERMISSION);
}
} }

View File

@@ -8,8 +8,10 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@@ -53,10 +55,9 @@ public class MainActivity extends AppCompatActivity {
NavigationUI.setupWithNavController(navView, navController); NavigationUI.setupWithNavController(navView, navController);
if (Backend.instance() == null) { if (Backend.instance() == null) {
new Backend(); new Backend(getApplicationContext());
} }
Backend.instance().applicationContext = getApplicationContext();
Backend.instance().mainActivity = this; Backend.instance().mainActivity = this;
if (Backend.instance().getSettings().mobileShowNavigationLabels) { if (Backend.instance().getSettings().mobileShowNavigationLabels) {
@@ -77,7 +78,11 @@ public class MainActivity extends AppCompatActivity {
registerReceiver(new TACNETOnBootReceiver(), new IntentFilter(Intent.ACTION_BOOT_COMPLETED)); registerReceiver(new TACNETOnBootReceiver(), new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
if (getIntent().getBooleanExtra("navigate_to_tacnet", false)) { if (getIntent().getBooleanExtra("navigate_to_tacnet", false)) {
navController.navigate(R.id.navigation_tacnet); //--- Emulate clicking on menu item...
navView.getMenu().performIdentifierAction(R.id.navigation_tacnet, 0);
//--- ...because using this function breaks the Editor nav button, for reasons :|
// navController.navigate(R.id.navigation_tacnet, null);
} }
startTACNETStatusIndictator(); startTACNETStatusIndictator();

View File

@@ -67,13 +67,15 @@ public class Backend {
return storage; return storage;
} }
public Backend() { public Backend(Context applicationContext) {
if (Backend.instance() != null) { if (Backend.instance() != null) {
throw(new RuntimeException("Backend instance already exists!")); throw(new RuntimeException("Backend instance already exists!"));
} else { } else {
instance = this; instance = this;
} }
this.applicationContext = applicationContext;
loadSettings(); loadSettings();
if (!settings.config.isEmpty()) { if (!settings.config.isEmpty()) {
loadConfig(settings.config); loadConfig(settings.config);
@@ -120,6 +122,18 @@ public class Backend {
return lastServerError; return lastServerError;
} }
public String getRootPath() {
return String.format("%s%s", applicationContext.getExternalFilesDir("").getAbsolutePath(), File.separator + "TimeCrafters_Configuration_Tool");
}
public String getConfigsPath() {
return String.format("%s%s", getRootPath(), File.separator + "/configs");
}
public String getSettingsPath() {
return String.format("%s%s", getRootPath(), File.separator + "settings.json");
}
public Config getConfig() { public Config getConfig() {
return config; return config;
} }
@@ -147,7 +161,7 @@ public class Backend {
public boolean hasConfigChanged() { return configChanged; } public boolean hasConfigChanged() { return configChanged; }
public String configPath(String name) { public String configPath(String name) {
return TAC.CONFIGS_PATH + File.separator + name + ".json"; return getConfigsPath() + File.separator + name + ".json";
} }
public void loadConfig(String name) { public void loadConfig(String name) {
@@ -249,7 +263,7 @@ public class Backend {
public ArrayList<String> configsList() { public ArrayList<String> configsList() {
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
File directory = new File(TAC.CONFIGS_PATH); File directory = new File(getConfigsPath());
FilenameFilter filter = new FilenameFilter() { FilenameFilter filter = new FilenameFilter() {
@Override @Override
public boolean accept(File dir, String name) { public boolean accept(File dir, String name) {
@@ -302,7 +316,7 @@ public class Backend {
} }
public void loadSettings() { public void loadSettings() {
File settingsFile = new File(TAC.SETTINGS_PATH); File settingsFile = new File(getSettingsPath());
if (!settingsFile.exists()) { if (!settingsFile.exists()) {
Log.i(TAG, "Writing default settings.json"); Log.i(TAG, "Writing default settings.json");
@@ -319,7 +333,7 @@ public class Backend {
public void saveSettings() { public void saveSettings() {
Log.i(TAG, "Settings: " + gsonForSettings().toJson(settings)); Log.i(TAG, "Settings: " + gsonForSettings().toJson(settings));
writeToFile(TAC.SETTINGS_PATH, gsonForSettings().toJson(settings)); writeToFile(getSettingsPath(), gsonForSettings().toJson(settings));
} }
public void sortGroups() { public void sortGroups() {
@@ -369,7 +383,7 @@ public class Backend {
} }
public void writeDefaultSettings() { public void writeDefaultSettings() {
settings = new Settings(TACNET.DEFAULT_HOSTNAME, TACNET.DEFAULT_PORT, "", false, false, false); settings = new Settings(TACNET.DEFAULT_HOSTNAME, TACNET.DEFAULT_PORT, "", true, false, false);
saveSettings(); saveSettings();
} }
@@ -402,7 +416,7 @@ public class Backend {
public boolean writeToFile(String filePath, String content) { public boolean writeToFile(String filePath, String content) {
try { try {
if (filePath.startsWith(TAC.ROOT_PATH)) { if (filePath.startsWith(getRootPath())) {
createFolders(filePath); createFolders(filePath);
FileWriter writer = new FileWriter(filePath); FileWriter writer = new FileWriter(filePath);
@@ -422,8 +436,8 @@ public class Backend {
} }
private void createFolders(String filePath) throws IOException { private void createFolders(String filePath) throws IOException {
File rootPath = new File(TAC.ROOT_PATH); File rootPath = new File(getRootPath());
File configsPath = new File(TAC.CONFIGS_PATH); File configsPath = new File(getConfigsPath());
if (!rootPath.exists()) { if (!rootPath.exists()) {
rootPath.mkdir(); rootPath.mkdir();

View File

@@ -1,25 +1,15 @@
package org.timecrafters.TimeCraftersConfigurationTool.backend; package org.timecrafters.TimeCraftersConfigurationTool.backend;
import android.app.Application;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import java.io.File; import java.io.File;
public class TAC { public class TAC {
// TODO: Update filesystem handling
public static final String ROOT_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "TimeCrafters_Configuration_Tool",
CONFIGS_PATH = ROOT_PATH + File.separator + "/configs",
SETTINGS_PATH = ROOT_PATH + File.separator + "settings.json";
public static final int CONFIG_SPEC_VERSION = 2; public static final int CONFIG_SPEC_VERSION = 2;
// Set COMPETITION_MODE to true to disable automatic TACNET server start
public static final boolean BUILD_COMPETITION_MODE = false;
public static final boolean BUILD_AUTO_START = true;
static public boolean allowAutoServerStart() { static public boolean allowAutoServerStart() {
return !TAC.BUILD_COMPETITION_MODE && return Backend.instance().getSettings().mobileStartServerAtBoot;
TAC.BUILD_AUTO_START ||
Backend.instance() != null && Backend.instance().getSettings().mobileStartServerAtBoot;
} }
} }

View File

@@ -110,7 +110,7 @@ public class ActionDialog extends TimeCraftersDialog {
Backend.instance().sortActions(group); Backend.instance().sortActions(group);
Backend.instance().configChanged(); Backend.instance().configChanged();
ActionsFragment fragment = (ActionsFragment) getFragmentManager().getPrimaryNavigationFragment(); ActionsFragment fragment = (ActionsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateActions(); fragment.populateActions();
} }

View File

@@ -72,7 +72,7 @@ public class AddFromPresetDialog extends TimeCraftersDialog {
bundle.putBoolean("is_cloning_preset", true); bundle.putBoolean("is_cloning_preset", true);
bundle.putInt("group_index", index); bundle.putInt("group_index", index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "clone_group_preset"); dialog.show(getParentFragmentManager(), "clone_group_preset");
dismiss(); dismiss();
} }
@@ -107,7 +107,7 @@ public class AddFromPresetDialog extends TimeCraftersDialog {
bundle.putInt("group_index", getArguments().getInt("group_index")); bundle.putInt("group_index", getArguments().getInt("group_index"));
bundle.putInt("action_index", index); bundle.putInt("action_index", index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "clone_action_preset"); dialog.show(getParentFragmentManager(), "clone_action_preset");
dismiss(); dismiss();
} }

View File

@@ -110,7 +110,7 @@ public class CloneDialog extends TimeCraftersDialog {
Backend.instance().sortActions(group); Backend.instance().sortActions(group);
Backend.instance().configChanged(); Backend.instance().configChanged();
ActionsFragment fragment = (ActionsFragment) getFragmentManager().getPrimaryNavigationFragment(); ActionsFragment fragment = (ActionsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateActions(); fragment.populateActions();
} }
@@ -124,7 +124,7 @@ public class CloneDialog extends TimeCraftersDialog {
Backend.instance().sortGroups(); Backend.instance().sortGroups();
Backend.instance().configChanged(); Backend.instance().configChanged();
GroupsFragment fragment = (GroupsFragment) getFragmentManager().getPrimaryNavigationFragment(); GroupsFragment fragment = (GroupsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateGroups(); fragment.populateGroups();
} }

View File

@@ -110,7 +110,7 @@ public class ConfigurationDialog extends TimeCraftersDialog {
} }
} }
ConfigurationsFragment fragment = (ConfigurationsFragment) getFragmentManager().getPrimaryNavigationFragment(); ConfigurationsFragment fragment = (ConfigurationsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateConfigFiles(); fragment.populateConfigFiles();
} }

View File

@@ -96,7 +96,7 @@ public class GroupDialog extends TimeCraftersDialog {
Backend.instance().sortGroups(); Backend.instance().sortGroups();
Backend.instance().configChanged(); Backend.instance().configChanged();
GroupsFragment fragment = (GroupsFragment) getFragmentManager().getPrimaryNavigationFragment(); GroupsFragment fragment = (GroupsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateGroups(); fragment.populateGroups();
} }

View File

@@ -1,51 +0,0 @@
package org.timecrafters.TimeCraftersConfigurationTool.dialogs;
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 org.timecrafters.TimeCraftersConfigurationTool.LauncherActivity;
import org.timecrafters.TimeCraftersConfigurationTool.MainActivity;
import org.timecrafters.TimeCraftersConfigurationTool.R;
import org.timecrafters.TimeCraftersConfigurationTool.backend.TAC;
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersDialog;
public class PermissionsRequestDialog extends TimeCraftersDialog {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setCancelable(false);
View root = super.onCreateView(inflater, container, savedInstanceState);
((TextView)root.findViewById(R.id.dialog_title)).setText("Storage Permission Required");
LinearLayout view = root.findViewById(R.id.dialog_content);
view.addView(getLayoutInflater().inflate(R.layout.dialog_permission_request, null));
((TextView)view.findViewById(R.id.message)).setText("Permission is required to access external storage:\n\n" + TAC.ROOT_PATH);
Button quitButton = view.findViewById(R.id.quit_button);
Button continueButton = view.findViewById(R.id.continue_button);
quitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
((MainActivity) getActivity()).close();
}
});
continueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
((LauncherActivity) getActivity()).requestStoragePermissions();
}
});
return root;
}
}

View File

@@ -190,10 +190,10 @@ public class PresetDialog extends TimeCraftersDialog {
Backend.instance().getConfig().getPresets().getGroups().add(groupClone); Backend.instance().getConfig().getPresets().getGroups().add(groupClone);
Backend.instance().sortGroupPresets(); Backend.instance().sortGroupPresets();
GroupsFragment fragment = (GroupsFragment) getFragmentManager().getPrimaryNavigationFragment(); GroupsFragment fragment = (GroupsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
Snackbar.make(fragment.getActivity().findViewById(R.id.snackbar_host), "Saved group preset: " + presetName, Snackbar.LENGTH_LONG).show(); Snackbar.make(fragment.getActivity().findViewById(R.id.snackbar_host), "Saved group preset: " + presetName, Snackbar.LENGTH_LONG).show();
} else { // Don't repopulate presets when it is not possible } else { // Don't repopulate presets when it is not possible
PresetsFragment fragment = (PresetsFragment) getFragmentManager().getPrimaryNavigationFragment(); PresetsFragment fragment = (PresetsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
Backend.instance().sortGroupPresets(); Backend.instance().sortGroupPresets();
fragment.populatePresets(); fragment.populatePresets();
@@ -224,10 +224,10 @@ public class PresetDialog extends TimeCraftersDialog {
Backend.instance().getConfig().getPresets().getActions().add(actionClone); Backend.instance().getConfig().getPresets().getActions().add(actionClone);
Backend.instance().sortActionsPresets(); Backend.instance().sortActionsPresets();
ActionsFragment fragment = (ActionsFragment) getFragmentManager().getPrimaryNavigationFragment(); ActionsFragment fragment = (ActionsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
Snackbar.make(fragment.getActivity().findViewById(R.id.snackbar_host), "Saved action preset: " + presetName, Snackbar.LENGTH_LONG).show(); Snackbar.make(fragment.getActivity().findViewById(R.id.snackbar_host), "Saved action preset: " + presetName, Snackbar.LENGTH_LONG).show();
} else { // Don't repopulate presets when it is not possible } else { // Don't repopulate presets when it is not possible
PresetsFragment fragment = (PresetsFragment) getFragmentManager().getPrimaryNavigationFragment(); PresetsFragment fragment = (PresetsFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
Backend.instance().sortActionsPresets(); Backend.instance().sortActionsPresets();

View File

@@ -164,7 +164,7 @@ public class VariableDialog extends TimeCraftersDialog {
Backend.instance().sortVariables(action); Backend.instance().sortVariables(action);
Backend.instance().configChanged(); Backend.instance().configChanged();
VariablesFragment fragment = (VariablesFragment) getFragmentManager().getPrimaryNavigationFragment(); VariablesFragment fragment = (VariablesFragment) getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateVariables(); fragment.populateVariables();
} }

View File

@@ -130,7 +130,7 @@ public class PacketHandler {
return; return;
} }
final String path = TAC.CONFIGS_PATH + File.separator + configName + ".json"; final String path = Backend.instance().getConfigsPath() + File.separator + configName + ".json";
Backend.instance().writeToFile(path, json); Backend.instance().writeToFile(path, json);
@@ -145,7 +145,7 @@ public class PacketHandler {
Log.i(TAG, "Got request for config: " + packet.getContent()); Log.i(TAG, "Got request for config: " + packet.getContent());
Packet pkt; Packet pkt;
if (Backend.instance().configsList().contains(configName)) { if (Backend.instance().configsList().contains(configName)) {
final String path = TAC.CONFIGS_PATH + File.separator + configName + ".json"; final String path = Backend.instance().getConfigsPath() + File.separator + configName + ".json";
String content = Backend.instance().readFromFile(path); String content = Backend.instance().readFromFile(path);
pkt = packetUploadConfig(configName, content); pkt = packetUploadConfig(configName, content);

View File

@@ -61,7 +61,7 @@ public class TACNETConnectionService extends Service {
private void foregroundify() { private void foregroundify() {
Intent notificationIntent = new Intent(this, MainActivity.class); Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.putExtra("navigate_to_tacnet", true); notificationIntent.putExtra("navigate_to_tacnet", true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID) NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("TACNET Connection") .setContentTitle("TACNET Connection")

View File

@@ -38,7 +38,7 @@ public class TACNETServerService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
if (Backend.instance() == null) { if (Backend.instance() == null) {
new Backend(); new Backend(getApplicationContext());
} }
} }
@@ -102,7 +102,7 @@ public class TACNETServerService extends Service {
private void foregroundify() { private void foregroundify() {
Intent notificationIntent = new Intent(this, MainActivity.class); Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.putExtra("navigate_to_tacnet", true); notificationIntent.putExtra("navigate_to_tacnet", true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE | FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID) NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("TACNET Server") .setContentTitle("TACNET Server")

View File

@@ -78,7 +78,7 @@ public class ActionsFragment extends TimeCraftersFragment {
} }
bundle.putInt("group_index", getArguments().getInt("group_index")); bundle.putInt("group_index", getArguments().getInt("group_index"));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "add_action"); dialog.show(getParentFragmentManager(), "add_action");
} }
}); });
@@ -164,7 +164,7 @@ public class ActionsFragment extends TimeCraftersFragment {
bundle.putInt("group_index", getArguments().getInt("group_index")); bundle.putInt("group_index", getArguments().getInt("group_index"));
bundle.putInt("action_index", group.getActions().indexOf(action)); bundle.putInt("action_index", group.getActions().indexOf(action));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "edit_action"); dialog.show(getParentFragmentManager(), "edit_action");
} }
}); });
@@ -184,7 +184,7 @@ public class ActionsFragment extends TimeCraftersFragment {
Backend.instance().configChanged(); Backend.instance().configChanged();
Backend.getStorage().remove(deleteActionKey); Backend.getStorage().remove(deleteActionKey);
ActionsFragment fragment = (ActionsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); ActionsFragment fragment = (ActionsFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateActions(); fragment.populateActions();
} }
@@ -192,7 +192,7 @@ public class ActionsFragment extends TimeCraftersFragment {
}; };
Backend.getStorage().put(deleteActionKey, actionRunner); Backend.getStorage().put(deleteActionKey, actionRunner);
dialog.show(getFragmentManager(), deleteActionKey); dialog.show(getParentFragmentManager(), deleteActionKey);
} }
}); });
@@ -217,7 +217,7 @@ public class ActionsFragment extends TimeCraftersFragment {
bundle.putInt("group_index", getArguments().getInt("group_index")); bundle.putInt("group_index", getArguments().getInt("group_index"));
bundle.putInt("action_index", action_index); bundle.putInt("action_index", action_index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "clone_dialog"); dialog.show(getParentFragmentManager(), "clone_dialog");
return true; return true;
} else if (itemID == R.id.save_as_preset) { } else if (itemID == R.id.save_as_preset) {
PresetDialog dialog = new PresetDialog(); PresetDialog dialog = new PresetDialog();
@@ -226,7 +226,7 @@ public class ActionsFragment extends TimeCraftersFragment {
bundle.putInt("action_index", action_index); bundle.putInt("action_index", action_index);
bundle.putBoolean("is_new_preset", true); bundle.putBoolean("is_new_preset", true);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "preset_dialog"); dialog.show(getParentFragmentManager(), "preset_dialog");
return true; return true;
} else { } else {
return false; return false;
@@ -256,7 +256,7 @@ public class ActionsFragment extends TimeCraftersFragment {
} }
bundle.putInt("group_index", getArguments().getInt("group_index")); bundle.putInt("group_index", getArguments().getInt("group_index"));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "add_from_preset_dialog"); dialog.show(getParentFragmentManager(), "add_from_preset_dialog");
return true; return true;
} else { } else {
return false; return false;

View File

@@ -62,7 +62,7 @@ public class GroupsFragment extends TimeCraftersFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
GroupDialog dialog = new GroupDialog(); GroupDialog dialog = new GroupDialog();
dialog.show(getFragmentManager(), "add_group"); dialog.show(getParentFragmentManager(), "add_group");
} }
}); });
@@ -141,7 +141,7 @@ public class GroupsFragment extends TimeCraftersFragment {
bundle.putInt("group_index", config.getGroups().indexOf(group)); bundle.putInt("group_index", config.getGroups().indexOf(group));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "rename_group"); dialog.show(getParentFragmentManager(), "rename_group");
} }
}); });
@@ -162,7 +162,7 @@ public class GroupsFragment extends TimeCraftersFragment {
Backend.instance().configChanged(); Backend.instance().configChanged();
Backend.getStorage().remove(deleteActionKey); Backend.getStorage().remove(deleteActionKey);
GroupsFragment fragment = (GroupsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); GroupsFragment fragment = (GroupsFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateGroups(); fragment.populateGroups();
} }
@@ -170,7 +170,7 @@ public class GroupsFragment extends TimeCraftersFragment {
}; };
Backend.getStorage().put(deleteActionKey, action); Backend.getStorage().put(deleteActionKey, action);
dialog.show(getFragmentManager(), deleteActionKey); dialog.show(getParentFragmentManager(), deleteActionKey);
} }
}); });
@@ -194,7 +194,7 @@ public class GroupsFragment extends TimeCraftersFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt("group_index", group_index); bundle.putInt("group_index", group_index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "clone_dialog"); dialog.show(getParentFragmentManager(), "clone_dialog");
return true; return true;
} else if (itemID == R.id.save_as_preset) { } else if (itemID == R.id.save_as_preset) {
@@ -203,7 +203,7 @@ public class GroupsFragment extends TimeCraftersFragment {
bundle.putBoolean("is_new_preset", true); bundle.putBoolean("is_new_preset", true);
bundle.putInt("group_index", group_index); bundle.putInt("group_index", group_index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "preset_dialog"); dialog.show(getParentFragmentManager(), "preset_dialog");
return true; return true;
} else { } else {
@@ -230,7 +230,7 @@ public class GroupsFragment extends TimeCraftersFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBoolean("show_actions", false); bundle.putBoolean("show_actions", false);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "add_from_preset_dialog"); dialog.show(getParentFragmentManager(), "add_from_preset_dialog");
return true; return true;
} else { } else {
return false; return false;

View File

@@ -79,7 +79,7 @@ public class VariablesFragment extends TimeCraftersFragment {
} }
bundle.putInt("action_index", getArguments().getInt("action_index")); bundle.putInt("action_index", getArguments().getInt("action_index"));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "add_variable"); dialog.show(getParentFragmentManager(), "add_variable");
} }
}); });
@@ -122,7 +122,7 @@ public class VariablesFragment extends TimeCraftersFragment {
bundle.putInt("action_index", getArguments().getInt("action_index")); bundle.putInt("action_index", getArguments().getInt("action_index"));
bundle.putInt("variable_index", action.getVariables().indexOf(variable)); bundle.putInt("variable_index", action.getVariables().indexOf(variable));
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "edit_variable"); dialog.show(getParentFragmentManager(), "edit_variable");
} }
}); });
@@ -142,7 +142,7 @@ public class VariablesFragment extends TimeCraftersFragment {
Backend.instance().configChanged(); Backend.instance().configChanged();
Backend.getStorage().remove(deleteActionKey); Backend.getStorage().remove(deleteActionKey);
VariablesFragment fragment = (VariablesFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); VariablesFragment fragment = (VariablesFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateVariables(); fragment.populateVariables();
} }
@@ -150,7 +150,7 @@ public class VariablesFragment extends TimeCraftersFragment {
}; };
Backend.getStorage().put(deleteActionKey, actionRunner); Backend.getStorage().put(deleteActionKey, actionRunner);
dialog.show(getFragmentManager(), deleteActionKey); dialog.show(getParentFragmentManager(), deleteActionKey);
} }
}); });

View File

@@ -43,7 +43,7 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ConfigurationDialog dialog = new ConfigurationDialog(); ConfigurationDialog dialog = new ConfigurationDialog();
dialog.show(getFragmentManager(), "add_configuration"); dialog.show(getParentFragmentManager(), "add_configuration");
} }
}); });
@@ -93,7 +93,7 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
bundle.putString("config_name", configFile); bundle.putString("config_name", configFile);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "rename_configuration"); dialog.show(getParentFragmentManager(), "rename_configuration");
} }
}); });
@@ -118,7 +118,7 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
Backend.instance().loadConfig(""); Backend.instance().loadConfig("");
} }
ConfigurationsFragment fragment = (ConfigurationsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); ConfigurationsFragment fragment = (ConfigurationsFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populateConfigFiles(); fragment.populateConfigFiles();
} }
@@ -131,7 +131,7 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
Backend.getStorage().put(deleteActionKey, action); Backend.getStorage().put(deleteActionKey, action);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), deleteActionKey); dialog.show(getParentFragmentManager(), deleteActionKey);
} }
}); });

View File

@@ -85,7 +85,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt("group_index", group_index); bundle.putInt("group_index", group_index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "preset_dialog"); dialog.show(getParentFragmentManager(), "preset_dialog");
} }
}); });
@@ -109,7 +109,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Backend.instance().configChanged(); Backend.instance().configChanged();
} }
PresetsFragment fragment = (PresetsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); PresetsFragment fragment = (PresetsFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populatePresets(); fragment.populatePresets();
} }
@@ -118,7 +118,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Backend.getStorage().put(deletePresetKey, action); Backend.getStorage().put(deletePresetKey, action);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), deletePresetKey); dialog.show(getParentFragmentManager(), deletePresetKey);
} }
}); });
@@ -163,7 +163,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt("action_index", action_index); bundle.putInt("action_index", action_index);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), "preset_dialog"); dialog.show(getParentFragmentManager(), "preset_dialog");
} }
}); });
@@ -187,7 +187,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Backend.instance().configChanged(); Backend.instance().configChanged();
} }
PresetsFragment fragment = (PresetsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment(); PresetsFragment fragment = (PresetsFragment) dialog.getParentFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) { if (fragment != null) {
fragment.populatePresets(); fragment.populatePresets();
} }
@@ -196,7 +196,7 @@ public class PresetsFragment extends TimeCraftersFragment {
Backend.getStorage().put(deletePresetKey, action); Backend.getStorage().put(deletePresetKey, action);
dialog.setArguments(bundle); dialog.setArguments(bundle);
dialog.show(getFragmentManager(), deletePresetKey); dialog.show(getParentFragmentManager(), deletePresetKey);
} }
}); });

View File

@@ -36,7 +36,6 @@ public class TACNETHostFragment extends TimeCraftersFragment {
final View root = inflater.inflate(R.layout.fragment_tacnet_host, viewGroup, false); final View root = inflater.inflate(R.layout.fragment_tacnet_host, viewGroup, false);
final LinearLayout container = (LinearLayout) root; final LinearLayout container = (LinearLayout) root;
if (Backend.instance().tacnet().status() != TACNET.Status.NOT_CONNECTED) { if (Backend.instance().tacnet().status() != TACNET.Status.NOT_CONNECTED) {
inflateTACNETConnectionStatus(container); inflateTACNETConnectionStatus(container);
} else if (Backend.instance().getServer() != null) { } else if (Backend.instance().getServer() != null) {

View File

@@ -13,32 +13,30 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="56dp" android:layout_marginBottom="56dp"
app:defaultNavHost="true" app2:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view" app2:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintHorizontal_bias="0.0" app2:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent" app2:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app2:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app2:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" app2:layout_constraintVertical_bias="0.0"
app:navGraph="@navigation/mobile_navigation" /> app2:navGraph="@navigation/mobile_navigation"
tools:layout="@layout/partial_editor" />
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/snackbar_host" android:id="@+id/snackbar_host"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="56dp"
app:layout_constraintBottom_toBottomOf="@id/nav_host_fragment" app2:layout_constraintBottom_toTopOf="@id/nav_view" />
app:layout_constraintStart_toStartOf="@id/nav_host_fragment" />
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view" android:id="@+id/nav_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:visibility="visible" android:visibility="visible"
app2:menu="@menu/bottom_nav_menu"
app2:layout_constraintBottom_toBottomOf="parent" app2:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nav_host_fragment"
app:menu="@menu/bottom_nav_menu"
tools:visibility="visible" /> tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>