diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/InputPreferences.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/InputPreferences.java index 078da0623..aa5d5eff7 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/InputPreferences.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/InputPreferences.java @@ -3,6 +3,7 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; +import android.widget.Toast; import androidx.annotation.Nullable; import androidx.preference.Preference; @@ -39,6 +40,8 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S profile.setName(name); ControllerProfileManager.add(profile); refreshScreenProfileList(); + } else { + Toast.makeText(requireContext(), R.string.invalid_name, Toast.LENGTH_SHORT).show(); } }).setTitle(R.string.create_profile).show(); }); @@ -66,15 +69,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S } public String formatName(String name) { - name = String.valueOf(name); - while (name.startsWith(" ")) { - name = name.substring(1); - } - while (name.endsWith(" ")) { - name = name.substring(0, name.length() - 1); - } - name = name.replaceAll("\\s\\s", " "); - return name; + return name.trim().replaceAll("\\s\\s", " "); } private void refresh() { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/GsonConfigParser.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/GsonConfigParser.java index 99c1419b4..0fde3d2f5 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/GsonConfigParser.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/data/GsonConfigParser.java @@ -1,11 +1,12 @@ package com.panda3ds.pandroid.data; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.panda3ds.pandroid.lang.Task; import com.panda3ds.pandroid.utils.FileUtils; public class GsonConfigParser { - private final Gson gson = new Gson(); + private final Gson gson = new GsonBuilder().setPrettyPrinting().create(); private final String name; public GsonConfigParser(String name) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/mapping/ControllerMapper.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/mapping/ControllerMapper.java index a7cbc3a1e..4ad85fe6d 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/mapping/ControllerMapper.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/controller/mapping/ControllerMapper.java @@ -87,17 +87,17 @@ protected void dispatchDraw(Canvas canvas) { } public void drawSelected(Canvas canvas, Paint paint) { - int[] mePosition = new int[2]; - int[] viewPosition = new int[2]; + int[] absolutePosition = new int[2]; + int[] selectedViewPosition = new int[2]; - selectedView.getLocationOnScreen(viewPosition); - getLocationOnScreen(mePosition); + selectedView.getLocationOnScreen(selectedViewPosition); + getLocationOnScreen(absolutePosition); int width = selectedView.getLayoutParams().width; int height = selectedView.getLayoutParams().height; - int x = viewPosition[0] - mePosition[0]; - int y = viewPosition[1] - mePosition[1]; + int x = selectedViewPosition[0] - absolutePosition[0]; + int y = selectedViewPosition[1] - absolutePosition[1]; canvas.drawRect(x, y, x + width, y + height, paint); } diff --git a/src/pandroid/app/src/main/res/values-pt-rBR/strings.xml b/src/pandroid/app/src/main/res/values-pt-rBR/strings.xml index 2af6a39d8..18edc50f0 100644 --- a/src/pandroid/app/src/main/res/values-pt-rBR/strings.xml +++ b/src/pandroid/app/src/main/res/values-pt-rBR/strings.xml @@ -34,4 +34,5 @@ Nome Disposições de controle Disposição de controle padrão + Nome Invalido \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/values/strings.xml b/src/pandroid/app/src/main/res/values/strings.xml index c6e386df9..2f08ab713 100644 --- a/src/pandroid/app/src/main/res/values/strings.xml +++ b/src/pandroid/app/src/main/res/values/strings.xml @@ -35,4 +35,5 @@ Name Screen gamepad layouts Default screen gamepad layout + Invalid name \ No newline at end of file