Skip to content

Commit

Permalink
IDE-166 Fix Bug where 1D Script View is reset to English (#4791)
Browse files Browse the repository at this point in the history
  • Loading branch information
jANI0x authored Nov 23, 2023
1 parent 0dcbc33 commit 41312b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2023 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -106,18 +106,17 @@ class CatblocksScriptFragment(
}

setHasOptionsMenu(true)

val view = View.inflate(activity, R.layout.fragment_catblocks, null)
val webView = view.findViewById<WebView>(R.id.catblocksWebView)
initWebView(webView)
this.webview = webView

return view
}

@SuppressLint("SetJavaScriptEnabled")
private fun initWebView(catblocksWebView: WebView) {
catblocksWebView.settings.javaScriptEnabled = true

if (BuildConfig.FEATURE_CATBLOCKS_DEBUGABLE) {
WebView.setWebContentsDebuggingEnabled(true)
}
Expand Down Expand Up @@ -197,15 +196,13 @@ class CatblocksScriptFragment(

override fun run() {
SettingsFragment.setUseCatBlocks(context, false)

val scriptFragment: ScriptFragment = if (brickToFocus == null) {
ScriptFragment()
} else if (brickToFocus is ScriptBrick) {
ScriptFragment.newInstance((brickToFocus as ScriptBrick).script)
} else {
ScriptFragment.newInstance(brickToFocus)
}

val fragmentTransaction = parentFragmentManager.beginTransaction()
fragmentTransaction.replace(
R.id.fragment_container, scriptFragment,
Expand Down Expand Up @@ -240,8 +237,7 @@ class CatblocksScriptFragment(
}

@JavascriptInterface
fun getCurrentLanguage(): String =
Locale.getDefault().toString().replace("_", "-")
fun getCurrentLanguage(): String = Locale.getDefault().toString().replace("_", "-")

@JavascriptInterface
fun isRTL(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
* Copyright (C) 2010-2023 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -289,6 +289,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
listView.setClipToPadding(false);

activity = (SpriteActivity) getActivity();
SettingsFragment.setToChosenLanguage(activity);

scriptFinder = view.findViewById(R.id.findview);
scriptFinder.setOnResultFoundListener((sceneIndex, spriteIndex, brickIndex, totalResults,
Expand Down Expand Up @@ -898,7 +899,7 @@ private void switchToCatblocks() {

CatblocksScriptFragment catblocksFragment = new CatblocksScriptFragment(firstVisibleBrickID);

FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
FragmentTransaction fragmentTransaction = getParentFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, catblocksFragment,
CatblocksScriptFragment.Companion.getTAG());
fragmentTransaction.commit();
Expand Down

0 comments on commit 41312b1

Please sign in to comment.