Skip to content

Commit

Permalink
fix(value editor): Changed value editor ui as it was not working
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxGalaxy committed Dec 11, 2023
1 parent dae9a2f commit 9c7fd8c
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public void showSection(int section) {
binding.loading.setVisibility(View.GONE);
binding.info.setVisibility(View.GONE);
binding.editor.setVisibility(View.GONE);
binding.stringEditor.setVisibility(View.GONE);
switch (section) {
case 1:
binding.loading.setVisibility(View.VISIBLE);
Expand All @@ -214,6 +215,9 @@ public void showSection(int section) {
case 3:
binding.editor.setVisibility(View.VISIBLE);
break;
case 4:
binding.stringEditor.setVisibility(View.VISIBLE);
break;
}
}

Expand Down
67 changes: 48 additions & 19 deletions app/src/main/java/com/dragon/ide/utils/BlockContentLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import android.widget.LinearLayout;
import android.widget.TextView;
import com.dragon.ide.R;
import com.dragon.ide.listeners.ValueListener;
import com.dragon.ide.objects.Block;
import com.dragon.ide.objects.BlockContent;
import com.dragon.ide.objects.ComplexBlockContent;
import com.dragon.ide.objects.blockcontent.BooleanContent;
import com.dragon.ide.objects.blockcontent.SourceContent;
import com.dragon.ide.ui.dialogs.eventeditor.ValueEditorDialog;
import com.dragon.ide.ui.activities.EventEditorActivity;
import com.dragon.ide.ui.view.BlockDefaultView;
import editor.tsd.editors.ace.AceEditorColors;
import editor.tsd.tools.EditorListeners;
import editor.tsd.tools.Themes;
import editor.tsd.widget.CodeEditorLayout;
import java.util.ArrayList;

public class BlockContentLoader {
Expand Down Expand Up @@ -152,24 +155,50 @@ public SourceContentClickListener(

@Override
public void onClick(View view) {
ValueEditorDialog valueEditorDialog =
new ValueEditorDialog(
activity,
blockContent.getValue(),
language,
new ValueListener() {
if (activity instanceof EventEditorActivity) {
EventEditorActivity mEventEditorActivity = (EventEditorActivity) activity;
mEventEditorActivity.showSection(4);
AceEditorColors aceEditorColors = new AceEditorColors();
aceEditorColors.setEditorBackground("#00000000");
aceEditorColors.setActiveLineColor("#0000002d");
aceEditorColors.setGutterActiveLineColor("#0000002d");
aceEditorColors.setGutterBackground("#00000000");
aceEditorColors.setGutterTextColor(
String.format(
"#%06X",
(0xFFFFFF
& ColorUtils.getColor(
activity, com.google.android.material.R.attr.colorOnSurfaceVariant))));
aceEditorColors.apply(activity);
mEventEditorActivity.binding.codeEditor.setEditor(CodeEditorLayout.AceCodeEditor);
mEventEditorActivity.binding.codeEditor.setCode(blockContent.getValue());
mEventEditorActivity.binding.codeEditor.setTheme(Themes.AceEditorTheme.Light.Default);
mEventEditorActivity.binding.codeEditor.setLanguageMode(language);
mEventEditorActivity.binding.done.setOnClickListener(
(view2) -> {
mEventEditorActivity.binding.codeEditor.getCode(
new EditorListeners() {

@Override
public void onSubmitted(String value) {
blockContent.setValue(value);
tvTextContent.setText(Utils.setWordLimitOnString(50, value));
updateContentPaddingWithText(tvTextContent, ll_source);
}

@Override
public void onError(String error) {}
});
valueEditorDialog.show();
@Override
public void onReceviedCode(String code) {
mEventEditorActivity.runOnUiThread(
() -> {
mEventEditorActivity.showSection(3);
blockContent.setValue(code);
tvTextContent.setText(Utils.setWordLimitOnString(50, code));
updateContentPaddingWithText(tvTextContent, ll_source);
});
}
});
});
mEventEditorActivity.binding.cancel.setOnClickListener(
(view2) -> {
mEventEditorActivity.runOnUiThread(
() -> {
mEventEditorActivity.showSection(3);
});
});
}
}
}

Expand Down
195 changes: 121 additions & 74 deletions app/src/main/res/layout/activity_event_editor.xml
Original file line number Diff line number Diff line change
@@ -1,118 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/root">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/root">

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="60">
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="60">

<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior"
android:id="@+id/appbar">
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$Behavior"
android:id="@+id/appbar">

<com.google.android.material.appbar.MaterialToolbar
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:id="@+id/toolbar" />
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:id="@+id/toolbar" />

</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical"
android:id="@+id/content">
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical"
android:id="@+id/content">

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:gravity="center"
android:id="@+id/loading">
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:gravity="center"
android:id="@+id/loading">

<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:indeterminate="true"
android:id="@+id/progressbar" />
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:indeterminate="true"
android:id="@+id/progressbar" />

</LinearLayout>

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:gravity="center"
android:id="@+id/info">
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:gravity="center"
android:id="@+id/info">

<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="?attr/colorOnSurface"
android:id="@+id/tv_info" />
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="?attr/colorOnSurface"
android:id="@+id/tv_info" />

</LinearLayout>

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:id="@+id/editor">
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/stringEditor">

<editor.tsd.widget.CodeEditorLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:codeEditor="SoraCodeEditor"
android:layout_weight="1"
android:id="@+id/codeEditor" />

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2"
android:gravity="center_horizontal"
android:padding="8dp"
android:orientation="horizontal">

<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_marginEnd="4dp"
style="@style/Widget.Material3.Button.TonalButton"
android:layout_weight="1"
android:id="@+id/cancel"
android:text="@string/cancel" />

<Button
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_marginStart="4dp"
android:layout_weight="1"
android:id="@+id/done"
android:text="@string/done" />

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:visibility="gone"
android:id="@+id/editor">

<com.dragon.ide.ui.view.editor.Editor
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:foregroundGravity="top"
android:id="@+id/relativeBlockListEditorArea"
android:padding="8dp" />
android:layout_height="match_parent"
android:layout_width="match_parent"
android:foregroundGravity="top"
android:padding="8dp"
android:orientation="vertical"
android:id="@+id/relativeBlockListEditorArea" />

</LinearLayout>

</LinearLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/block"
android:layout_margin="16dp"
android:id="@+id/fab"
android:layout_gravity="end|bottom" />
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/block"
android:layout_margin="16dp"
android:id="@+id/fab"
android:layout_gravity="end|bottom" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:visibility="gone"
android:background="?attr/colorSurfaceVariant"
android:orientation="horizontal"
android:layout_weight="40"
android:id="@+id/blockArea">
android:layout_height="0dp"
android:layout_width="match_parent"
android:visibility="gone"
android:background="?attr/colorSurfaceVariant"
android:orientation="horizontal"
android:layout_weight="40"
android:id="@+id/blockArea">

<androidx.recyclerview.widget.RecyclerView
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="?attr/colorSurface"
android:layout_weight="35"
android:id="@+id/blocksHolderList" />
android:layout_height="match_parent"
android:layout_width="0dp"
android:background="?attr/colorSurface"
android:layout_weight="35"
android:id="@+id/blocksHolderList" />

<androidx.recyclerview.widget.RecyclerView
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="65"
android:id="@+id/blockList" />
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="65"
android:id="@+id/blockList" />

</LinearLayout>

Expand Down

0 comments on commit 9c7fd8c

Please sign in to comment.