Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq authored Jan 2, 2025
2 parents 9fe8568 + 9256100 commit a96380a
Show file tree
Hide file tree
Showing 181 changed files with 1,573 additions and 916 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@
<activity
android:name=".activities.editor.view.ViewCodeEditorActivity"
android:configChanges="orientation|screenSize" />

<activity
android:name=".activities.editor.view.CodeViewerActivity"
android:configChanges="orientation|screenSize" />

<activity
android:name=".activities.preview.LayoutPreviewActivity"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/a/a/a/Fw.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
viewHolder.binding.imgActivity.setImageResource(getImageResByOptions(projectFileBean.options));
viewHolder.binding.tvScreenName.setText(projectFileBean.getXmlName());
viewHolder.binding.tvActivityName.setText(projectFileBean.getJavaName());
viewHolder.binding.imgDelete.setImageResource(projectFileBean.isSelected ? R.drawable.ic_checkmark_green_48dp : R.drawable.ic_trashcan_white_48dp);
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/a/a/a/Fx.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,12 @@ private String getBlockCode(BlockBean bean, ArrayList<String> params) {
break;
}
}
opcode = String.format("%s.setTypeface(Typeface.createFromAsset(getAssets(),\"fonts/%s.ttf\"), %s);", params.get(0), params.get(1), opcode);
String fontName = params.get(1);
if ("default_font".equals(fontName)) {
opcode = String.format("%s.setTypeface(Typeface.DEFAULT, %s);", params.get(0), opcode);
} else {
opcode = String.format("%s.setTypeface(Typeface.createFromAsset(getAssets(),\"fonts/%s.ttf\"), %s);", params.get(0), fontName, opcode);
}
break;
case "getText":
opcode = String.format("%s.getText().toString()", params.get(0));
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/a/a/a/ZA.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import android.app.Dialog;
import android.content.Context;
import android.view.Window;
import android.widget.TextView;

import androidx.core.view.WindowCompat;

import com.airbnb.lottie.LottieAnimationView;
import pro.sketchware.R;

Expand All @@ -20,6 +23,12 @@ public ZA(Context context) {
TextView tvProgress = findViewById(R.id.tv_progress);
tvProgress.setText(Helper.getResString(R.string.common_message_loading));
super.setCancelable(false);

Window window = getWindow();
if (window != null) {
window.setStatusBarColor(0);
WindowCompat.setDecorFitsSystemWindows(window, false);
}
}

public void cancelAnimation() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/a/a/a/br.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void bind(ComponentBean componentBean) {
previewBinding.getRoot().setLayoutParams(layoutParams);
previewBinding.icon.setImageResource(oq.a(event.eventName));
previewBinding.iconBg.setBackgroundResource(
R.drawable.circle_bg_white_outline_secondary);
R.drawable.circle_bg_surface);
binding.eventsPreview.addView(previewBinding.getRoot());
availableEvents.remove(event.eventName);
}
Expand Down
102 changes: 51 additions & 51 deletions app/src/main/java/a/a/a/oq.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,60 @@ public static int a(String eventName) {
return switch (eventName) {
case "initializeLogic", "onBackPressed", "onPostCreate", "onStart", "onStop", "onDestroy", "onResume", "onPause", "moreBlock" ->
R.drawable.bg_event_type_activity;
case "onBannerAdClicked", "onClick" -> R.drawable.event_on_click_48dp;
case "onCheckedChange" -> R.drawable.event_on_check_changed_48dp;
case "onItemSelected" -> R.drawable.event_on_item_selected_48dp;
case "onItemClicked" -> R.drawable.event_on_item_clicked_48dp;
case "onItemLongClicked" -> R.drawable.event_on_item_long_clicked_48dp;
case "onTextChanged" -> R.drawable.event_on_text_changed_48dp;
case "onPageStarted" -> R.drawable.event_on_page_started_48dp;
case "onPageFinished" -> R.drawable.event_on_page_finished_48dp;
case "onProgressChanged" -> R.drawable.event_on_progress_changed_48dp;
case "onStartTrackingTouch" -> R.drawable.event_on_start_tracking_touch_48dp;
case "onStopTrackingTouch" -> R.drawable.event_on_stop_tracking_touch_48dp;
case "onAnimationStart" -> R.drawable.event_on_animation_start_48dp;
case "onAnimationEnd" -> R.drawable.event_on_animation_end_48dp;
case "onAnimationCancel" -> R.drawable.event_on_animation_cancel_48dp;
case "onAnimationRepeat" -> R.drawable.event_animation_repeat_48dp;
case "onBindCustomView" -> R.drawable.event_on_bind_custom_view_48dp;
case "onDateChange" -> R.drawable.event_on_date_changed_48dp;
case "onChildAdded" -> R.drawable.event_on_child_added_48dp;
case "onChildChanged" -> R.drawable.event_on_child_changed_48dp;
case "onChildMoved" -> R.drawable.event_on_child_moved_48dp;
case "onChildRemoved", "onDeleteSuccess" -> R.drawable.event_on_child_removed_48dp;
case "onCancelled" -> R.drawable.event_on_cancelled_48dp;
case "onCreateUserComplete" -> R.drawable.event_on_create_user_complete_48dp;
case "onSignInUserComplete" -> R.drawable.event_on_signin_complete_48dp;
case "onResetPasswordEmailSent" -> R.drawable.event_on_reset_password_email_sent_48dp;
case "onSensorChanged" -> R.drawable.event_on_sensor_changed_48dp;
case "onAccuracyChanged" -> R.drawable.event_on_accuracy_changed_48dp;
case "onBannerAdClicked", "onClick" -> R.drawable.ic_mtrl_touch;
case "onCheckedChange" -> R.drawable.ic_mtrl_checkbox;
case "onItemSelected" -> R.drawable.ic_mtrl_pull_down;
case "onItemClicked" -> R.drawable.ic_mtrl_list;
case "onItemLongClicked" -> R.drawable.ic_mtrl_touch_long;
case "onTextChanged" -> R.drawable.ic_mtrl_text_change;
case "onPageStarted" -> R.drawable.ic_mtrl_progress;
case "onPageFinished" -> R.drawable.ic_mtrl_preview;
case "onProgressChanged" -> R.drawable.ic_mtrl_progress_check;
case "onStartTrackingTouch" -> R.drawable.ic_mtrl_track_started;
case "onStopTrackingTouch" -> R.drawable.ic_mtrl_target;
case "onAnimationStart" -> R.drawable.ic_mtrl_sprint;
case "onAnimationEnd" -> R.drawable.ic_mtrl_anim_end;
case "onAnimationCancel" -> R.drawable.ic_mtrl_anim_cancel;
case "onAnimationRepeat" -> R.drawable.ic_mtrl_refresh;
case "onBindCustomView" -> R.drawable.ic_mtrl_bind;
case "onDateChange" -> R.drawable.ic_mtrl_date_changed;
case "onChildAdded" -> R.drawable.ic_mtrl_database_added;
case "onChildChanged" -> R.drawable.ic_mtrl_database_edit;
case "onChildMoved" -> R.drawable.ic_mtrl_database_moved;
case "onChildRemoved", "onDeleteSuccess" -> R.drawable.ic_mtrl_database_off;
case "onCancelled" -> R.drawable.ic_mtrl_cancel;
case "onCreateUserComplete" -> R.drawable.ic_mtrl_user_create;
case "onSignInUserComplete" -> R.drawable.ic_mtrl_signin;
case "onResetPasswordEmailSent" -> R.drawable.ic_mtrl_reset;
case "onSensorChanged" -> R.drawable.ic_mtrl_sensor;
case "onAccuracyChanged" -> R.drawable.ic_mtrl_center;
case "onInterstitialAdLoaded", "onBannerAdLoaded", "onRewardAdLoaded" ->
R.drawable.event_on_ad_loaded;
R.drawable.ic_mtrl_loaded;
case "onBannerAdFailedToLoad", "onInterstitialAdFailedToLoad", "onAdFailedToShowFullScreenContent", "onRewardAdFailedToLoad", "onFailure" ->
R.drawable.event_on_ad_failed_to_load;
case "onAdShowedFullScreenContent", "onBannerAdOpened" -> R.drawable.event_on_ad_opened;
R.drawable.ic_mtrl_load_failed;
case "onAdShowedFullScreenContent", "onBannerAdOpened" -> R.drawable.ic_mtrl_preview;
case "onAdDismissedFullScreenContent", "onBannerAdClosed" ->
R.drawable.event_on_ad_closed;
case "onUploadProgress" -> R.drawable.event_on_upload_progress_48dp;
case "onDownloadProgress" -> R.drawable.event_on_download_progress_48dp;
case "onUploadSuccess" -> R.drawable.event_on_upload_success_48dp;
case "onDownloadSuccess" -> R.drawable.event_on_download_success_48dp;
case "onPictureTaken" -> R.drawable.event_on_picture_taken_48dp;
case "onPictureTakenCancel" -> R.drawable.event_on_picture_taken_cancel_48dp;
case "onFilesPicked" -> R.drawable.event_on_file_picked_48dp;
case "onFilesPickedCancel" -> R.drawable.event_on_file_picked_cancel_48dp;
case "onResponse" -> R.drawable.event_on_response_48dp;
case "onErrorResponse" -> R.drawable.event_on_error_response_48dp;
case "onSpeechResult" -> R.drawable.event_on_speech_result;
case "onSpeechError" -> R.drawable.event_on_speech_error;
case "onConnected" -> R.drawable.event_on_connected_96;
case "onDataReceived" -> R.drawable.event_on_data_received_96;
case "onDataSent" -> R.drawable.event_on_data_sent_96;
case "onConnectionError" -> R.drawable.event_on_connection_error_96;
case "onConnectionStopped" -> R.drawable.event_on_connection_stopped_96;
case "onLocationChanged" -> R.drawable.event_on_location_changed_96;
case "onMapReady" -> R.drawable.event_on_map_ready_96;
case "onMarkerClicked" -> R.drawable.event_on_marker_clicked_96;
R.drawable.ic_mtrl_preview_off;
case "onUploadProgress" -> R.drawable.ic_mtrl_uploading;
case "onDownloadProgress" -> R.drawable.ic_mtrl_downloading;
case "onUploadSuccess" -> R.drawable.ic_mtrl_uploaded;
case "onDownloadSuccess" -> R.drawable.ic_mtrl_download;
case "onPictureTaken" -> R.drawable.ic_mtrl_pic_taken;
case "onPictureTakenCancel" -> R.drawable.ic_mtrl_pic_cancel;
case "onFilesPicked" -> R.drawable.ic_mtrl_file_picked;
case "onFilesPickedCancel" -> R.drawable.ic_mtrl_pick_cancel;
case "onResponse" -> R.drawable.ic_mtrl_sensor;
case "onErrorResponse" -> R.drawable.ic_mtrl_sensor_cancel;
case "onSpeechResult" -> R.drawable.ic_mtrl_speech;
case "onSpeechError" -> R.drawable.ic_mtrl_speech_cancel;
case "onConnected" -> R.drawable.ic_mtrl_bluetooth_connected;
case "onDataReceived" -> R.drawable.ic_mtrl_bt_received;
case "onDataSent" -> R.drawable.ic_mtrl_bt_sent;
case "onConnectionError" -> R.drawable.ic_mtrl_bt_error;
case "onConnectionStopped" -> R.drawable.ic_mtrl_bt_cancel;
case "onLocationChanged" -> R.drawable.ic_mtrl_location_changed;
case "onMapReady" -> R.drawable.ic_mtrl_map_ready;
case "onMarkerClicked" -> R.drawable.ic_mtrl_loc_click;
default -> ManageEvent.d(eventName);
};
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/a/a/a/sy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.besome.sketch.beans.ViewBean;

// todo: move this to another package
// 'sy' is used in ViewPane itens, example ItemLinearLayout
// 'sy' is used in ViewPane items, example ItemLinearLayout
public interface sy {
ViewBean getBean();

Expand All @@ -12,4 +12,4 @@ public interface sy {
void setBean(ViewBean viewBean);

void setSelection(boolean selection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public static Parcelable.Creator<ProjectLibraryBean> getCreator() {

public static int getLibraryIcon(int i) {
return switch (i) {
case 0 -> R.drawable.widget_firebase;
case 1 -> R.drawable.connected_96;
case 2 -> R.drawable.widget_admob;
case 3 -> R.drawable.widget_google_map;
case 0 -> R.drawable.ic_mtrl_firebase;
case 1 -> R.drawable.ic_mtrl_design;
case 2 -> R.drawable.ic_mtrl_admob;
case 3 -> R.drawable.ic_mtrl_map;
case 4 -> R.drawable.ic_mtrl_box;
case 5 -> R.drawable.ic_mtrl_settings_input;
default -> 0;
Expand Down
75 changes: 24 additions & 51 deletions app/src/main/java/com/besome/sketch/design/DesignActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Typeface;
Expand All @@ -24,10 +23,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;

Expand Down Expand Up @@ -96,7 +93,6 @@
import a.a.a.mB;
import a.a.a.rs;
import a.a.a.wq;
import a.a.a.xB;
import a.a.a.yB;
import a.a.a.yq;
import a.a.a.zy;
Expand All @@ -110,7 +106,6 @@
import mod.agus.jcoderz.editor.manage.resource.ManageResourceActivity;
import mod.hey.studios.activity.managers.assets.ManageAssetsActivity;
import mod.hey.studios.activity.managers.java.ManageJavaActivity;
import mod.hey.studios.build.BuildSettings;
import mod.hey.studios.build.BuildSettingsDialog;
import mod.hey.studios.compiler.kotlin.KotlinCompilerBridge;
import mod.hey.studios.project.custom_blocks.CustomBlocksDialog;
Expand All @@ -130,15 +125,16 @@
import mod.jbk.diagnostic.MissingFileException;
import mod.jbk.util.LogUtil;
import mod.khaled.logcat.LogReaderActivity;
import pro.sketchware.utility.ThemeUtils;
import pro.sketchware.R;
import pro.sketchware.activities.appcompat.ManageAppCompatActivity;
import pro.sketchware.activities.editor.command.ManageXMLCommandActivity;
import pro.sketchware.activities.editor.view.ViewCodeEditorActivity;
import pro.sketchware.databinding.ProgressMsgBoxBinding;
import pro.sketchware.utility.FileUtil;
import pro.sketchware.utility.SketchwareUtil;
import pro.sketchware.utility.ThemeUtils;
import pro.sketchware.utility.apk.ApkSignatures;
import pro.sketchware.activities.editor.view.CodeViewerActivity;

public class DesignActivity extends BaseAppCompatActivity implements View.OnClickListener {
public static String sc_id;
Expand Down Expand Up @@ -803,59 +799,36 @@ private void askIfToRestoreOldUnsavedProjectData() {
}

private void showCurrentActivitySrcCode() {
if (projectFile == null) return;
ProgressMsgBoxBinding loadingDialogBinding = ProgressMsgBoxBinding.inflate(getLayoutInflater());
if (projectFile == null) return;
var loadingDialogBinding = ProgressMsgBoxBinding.inflate(getLayoutInflater());
loadingDialogBinding.tvProgress.setText("Generating source code...");
var loadingDialog = new MaterialAlertDialogBuilder(this)
.setTitle("Please wait")
.setCancelable(false)
.setView(loadingDialogBinding.getRoot())
.create();
.setTitle("Please wait")
.setCancelable(false)
.setView(loadingDialogBinding.getRoot())
.create();
loadingDialog.show();

new Thread(() -> {
String filename = fileName.getText().toString();
final String source = new yq(getApplicationContext(), sc_id).getFileSrc(filename, jC.b(sc_id), jC.a(sc_id), jC.c(sc_id));

var dialogBuilder = new MaterialAlertDialogBuilder(this)
.setTitle(filename)
.setCancelable(false)
.setPositiveButton("Dismiss", null);

var filename = fileName.getText().toString();
final String source = new yq(getApplicationContext(), sc_id)
.getFileSrc(filename, jC.b(sc_id), jC.a(sc_id), jC.c(sc_id));
runOnUiThread(() -> {
if (isFinishing()) return;
loadingDialog.dismiss();

CodeEditor editor = new CodeEditor(this);
editor.setTypefaceText(Typeface.MONOSPACE);
editor.setEditable(false);
editor.setTextSize(14);
editor.setText(!source.isEmpty() ? source : "Failed to generate source.");
editor.getComponent(Magnifier.class).setWithinEditorForcibly(true);

if (source.isEmpty()) {
Toast.makeText(this, "Failed to generate source.", Toast.LENGTH_SHORT).show();
return;
}
var intent = new Intent(this, CodeViewerActivity.class);
intent.putExtra("code", source);
intent.putExtra("sc_id", sc_id);
if (filename.endsWith(".xml")) {
editor.setEditorLanguage(CodeEditorLanguages.loadTextMateLanguage(CodeEditorLanguages.SCOPE_NAME_XML));
if (ThemeUtils.isDarkThemeEnabled(getApplicationContext())) {
editor.setColorScheme(CodeEditorColorSchemes.loadTextMateColorScheme(CodeEditorColorSchemes.THEME_DRACULA));
} else {
editor.setColorScheme(CodeEditorColorSchemes.loadTextMateColorScheme(CodeEditorColorSchemes.THEME_GITHUB));
}
intent.putExtra("scheme", CodeViewerActivity.SCHEME_XML);
} else {
editor.setEditorLanguage(new JavaLanguage());
if (ThemeUtils.isDarkThemeEnabled(getApplicationContext())) {
editor.setColorScheme(new SchemeDarcula());
} else {
editor.setColorScheme(new EditorColorScheme());
}
intent.putExtra("scheme", CodeViewerActivity.SCHEME_JAVA);
}

AlertDialog dialog = dialogBuilder.create();
dialog.setView(editor,
(int) getDip(24),
(int) getDip(20),
(int) getDip(24),
(int) getDip(0));
dialog.show();
startActivity(intent);
});
}).start();
}
Expand Down Expand Up @@ -889,7 +862,7 @@ private void showAvailableViews() {
}

/**
* Opens {@link ViewCodeEditor}.
* Opens {@link ViewCodeEditorActivity}.
*/
void toViewCodeEditor() {
if (projectFile == null) return;
Expand Down Expand Up @@ -939,7 +912,7 @@ void toAndroidManifestManager() {
}

/**
* Opens {@link ManageCustomAttributeActivity}.
* Opens {@link ManageAppCompatActivity}.
*/
void toAppCompatInjectionManager() {
if (projectFile == null) return;
Expand Down
Loading

0 comments on commit a96380a

Please sign in to comment.