Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
86add128
Commit
86add128
authored
Apr 08, 2020
by
Jeffrey I. Schiller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ucr'
Change-Id: I04821ae6834300478a31556aca32b6ef48367dd9
parents
57abaa82
f3f47f9e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
12 deletions
+72
-12
appinventor/appengine/src/com/google/appinventor/client/youngandroid/YoungAndroidFormUpgrader.java
...nventor/client/youngandroid/YoungAndroidFormUpgrader.java
+12
-0
appinventor/blocklyeditor/src/versioning.js
appinventor/blocklyeditor/src/versioning.js
+5
-2
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
...c/com/google/appinventor/components/common/YaVersion.java
+6
-2
appinventor/components/src/com/google/appinventor/components/runtime/Form.java
...s/src/com/google/appinventor/components/runtime/Form.java
+1
-1
appinventor/components/src/com/google/appinventor/components/runtime/Polygon.java
...rc/com/google/appinventor/components/runtime/Polygon.java
+1
-0
appinventor/components/src/com/google/appinventor/components/runtime/YandexTranslate.java
...oogle/appinventor/components/runtime/YandexTranslate.java
+35
-5
appinventor/docs/html/reference/components/media.html
appinventor/docs/html/reference/components/media.html
+7
-1
appinventor/docs/markdown/reference/components/media.md
appinventor/docs/markdown/reference/components/media.md
+5
-1
No files found.
appinventor/appengine/src/com/google/appinventor/client/youngandroid/YoungAndroidFormUpgrader.java
View file @
86add128
...
...
@@ -370,6 +370,8 @@ public final class YoungAndroidFormUpgrader {
srcCompVersion
=
upgradeRectangleProperties
(
componentProperties
,
srcCompVersion
);
}
else
if
(
componentType
.
equals
(
"FeatureCollection"
))
{
srcCompVersion
=
upgradeFeatureCollection
(
componentProperties
,
srcCompVersion
);
}
else
if
(
componentType
.
equals
(
"YandexTranslate"
))
{
srcCompVersion
=
upgradeYandexTranslateProperties
(
componentProperties
,
srcCompVersion
);
}
if
(
srcCompVersion
<
sysCompVersion
)
{
...
...
@@ -1740,6 +1742,16 @@ public final class YoungAndroidFormUpgrader {
return
srcCompVersion
;
}
private
static
int
upgradeYandexTranslateProperties
(
Map
<
String
,
JSONValue
>
componentProperties
,
int
srcCompVersion
)
{
if
(
srcCompVersion
<
2
)
{
// Version 2
// The ApiKey property was added
srcCompVersion
=
2
;
}
return
srcCompVersion
;
}
private
static
void
handlePropertyRename
(
Map
<
String
,
JSONValue
>
componentProperties
,
String
oldPropName
,
String
newPropName
)
{
if
(
componentProperties
.
containsKey
(
oldPropName
))
{
...
...
appinventor/blocklyeditor/src/versioning.js
View file @
86add128
...
...
@@ -2684,7 +2684,7 @@ Blockly.Versioning.AllUpgradeMaps =
//AI2: Added PageLoaded
8
:
"
noUpgrade
"
,
// AI2: Added BeforePageLoad event and Stop, Reload, and ClearCookies methods
9
:
"
noUpgrade
"
,
...
...
@@ -2696,7 +2696,10 @@ Blockly.Versioning.AllUpgradeMaps =
"
YandexTranslate
"
:
{
//This is initial version. Placeholder for future upgrades
1
:
"
noUpgrade
"
1
:
"
noUpgrade
"
,
// AI2: ApiKey property added
2
:
"
noUpgrade
"
}
// End YandexTranslate upgraders
...
...
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
View file @
86add128
...
...
@@ -508,8 +508,10 @@ public class YaVersion {
// - SERIAL_COMPONENT_VERSION was initialized to 1
// For YOUNG_ANDROID_VERSION 205:
// - BLOCKS_LANGUAGE_VERSION was incremented to 31
// For YOUNG_ANDROID_VERSION 206:
// - YANDEX_COMPONENT_VERSION was incremented to 2.
public
static
final
int
YOUNG_ANDROID_VERSION
=
20
5
;
public
static
final
int
YOUNG_ANDROID_VERSION
=
20
6
;
// ............................... Blocks Language Version Number ...............................
...
...
@@ -1334,7 +1336,9 @@ public class YaVersion {
// For YANDEX_COMPONENT_VERSION 1:
// - Initial version.
public
static
final
int
YANDEX_COMPONENT_VERSION
=
1
;
// For YANDEX_COMPONENT_VERSION 2:
// - Added ApiKey property
public
static
final
int
YANDEX_COMPONENT_VERSION
=
2
;
//For PROXIMITYSENSOR_COMPONENT_VERSION: Initial Version
public
static
final
int
PROXIMITYSENSOR_COMPONENT_VERSION
=
1
;
...
...
appinventor/components/src/com/google/appinventor/components/runtime/Form.java
View file @
86add128
...
...
@@ -566,8 +566,8 @@ public class Form extends AppInventorCompatActivity
public
void
onBackPressed
()
{
if
(!
BackPressed
())
{
AnimationUtil
.
ApplyCloseScreenAnimation
(
this
,
closeAnimType
);
super
.
onBackPressed
();
}
super
.
onBackPressed
();
}
@SimpleEvent
(
description
=
"Device back button pressed."
)
...
...
appinventor/components/src/com/google/appinventor/components/runtime/Polygon.java
View file @
86add128
...
...
@@ -112,6 +112,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
clearGeometry
();
map
.
getController
().
updateFeaturePosition
(
this
);
map
.
getController
().
updateFeatureHoles
(
this
);
map
.
getController
().
updateFeatureText
(
this
);
}
@Override
...
...
appinventor/components/src/com/google/appinventor/components/runtime/YandexTranslate.java
View file @
86add128
...
...
@@ -7,24 +7,34 @@
package
com.google.appinventor.components.runtime
;
import
android.app.Activity
;
import
com.google.appinventor.components.annotations.UsesPermissions
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
android.text.TextUtils
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.SimpleEvent
;
import
com.google.appinventor.components.annotations.SimpleFunction
;
import
com.google.appinventor.components.annotations.SimpleObject
;
import
com.google.appinventor.components.annotations.SimpleProperty
;
import
com.google.appinventor.components.annotations.UsesPermissions
;
import
com.google.appinventor.components.common.ComponentCategory
;
import
com.google.appinventor.components.common.PropertyTypeConstants
;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.runtime.util.AsynchUtil
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Use this component to translate words and sentences between different languages. This component
* needs Internet access, as it will request translations to the Yandex.Translate service.
...
...
@@ -66,6 +76,7 @@ public final class YandexTranslate extends AndroidNonvisibleComponent {
public
static
final
String
YANDEX_TRANSLATE_SERVICE_URL
=
"https://translate.yandex.net/api/v1.5/tr.json/translate?key="
;
private
final
String
yandexKey
;
private
String
userYandexKey
=
"DEFAULT"
;
private
final
Activity
activity
;
/**
...
...
@@ -105,7 +116,8 @@ public final class YandexTranslate extends AndroidNonvisibleComponent {
public
void
RequestTranslation
(
final
String
languageToTranslateTo
,
final
String
textToTranslate
)
{
if
(
yandexKey
.
equals
(
""
)){
if
(
TextUtils
.
isEmpty
(
yandexKey
)
&&
(
TextUtils
.
isEmpty
(
userYandexKey
)
||
TextUtils
.
equals
(
userYandexKey
,
"DEFAULT"
)))
{
form
.
dispatchErrorOccurredEvent
(
YandexTranslate
.
this
,
"RequestTranslation"
,
ErrorMessages
.
ERROR_TRANSLATE_NO_KEY_FOUND
);
return
;
...
...
@@ -139,7 +151,8 @@ public final class YandexTranslate extends AndroidNonvisibleComponent {
throws
IOException
,
JSONException
{
final
String
finalURL
=
YANDEX_TRANSLATE_SERVICE_URL
+
this
.
yandexKey
+
((
TextUtils
.
equals
(
this
.
userYandexKey
,
"DEFAULT"
)
||
TextUtils
.
isEmpty
(
this
.
userYandexKey
))?
this
.
yandexKey
:
this
.
userYandexKey
)
+
"&lang="
+
languageToTranslateTo
+
"&text="
+
URLEncoder
.
encode
(
textToTranslate
,
"UTF-8"
);
...
...
@@ -214,4 +227,21 @@ public final class YandexTranslate extends AndroidNonvisibleComponent {
EventDispatcher
.
dispatchEvent
(
this
,
"GotTranslation"
,
responseCode
,
translation
);
}
/**
* The Yandex API Key to use. If set to DEFAULT the platform default key (if any)
* will be used. Otherwise should be set to a valid API key which can be obtained
* from https://tech.yandex.com/translate/. If the platform doesn't have a default
* key and one isn't provided here, an error will be raised.
*/
@DesignerProperty
(
editorType
=
PropertyTypeConstants
.
PROPERTY_TYPE_STRING
,
defaultValue
=
"DEFAULT"
)
@SimpleProperty
(
description
=
"Set the API Key to use with Yandex. "
+
"You do not need to set this if you are using the MIT system because "
+
"MIT has its own key builtin. If set, the key provided here will be "
+
"used instead"
)
public
void
ApiKey
(
String
apiKey
)
{
this
.
userYandexKey
=
apiKey
;
}
}
appinventor/docs/html/reference/components/media.html
View file @
86add128
...
...
@@ -638,7 +638,13 @@
<h3
id=
"YandexTranslate-Properties"
>
Properties
</h3>
<p
class=
"properties"
>
None
</p>
<dl
class=
"properties"
>
<dt
id=
"YandexTranslate.ApiKey"
class=
"text wo"
><em>
ApiKey
</em></dt>
<dd>
The Yandex API Key to use. If set to DEFAULT the platform default key (if any)
will be used. Otherwise should be set to a valid API key which can be obtained
from https://tech.yandex.com/translate/. If the platform doesn’t have a default
key and one isn’t provided here, an error will be raised.
</dd>
</dl>
<h3
id=
"YandexTranslate-Events"
>
Events
</h3>
...
...
appinventor/docs/markdown/reference/components/media.md
View file @
86add128
...
...
@@ -598,8 +598,12 @@ Use this component to translate words and sentences between different languages.
### Properties {#YandexTranslate-Properties}
{:.properties}
None
{:id="YandexTranslate.ApiKey" .text .wo}
*ApiKey*
: The Yandex API Key to use. If set to DEFAULT the platform default key (if any)
will be used. Otherwise should be set to a valid API key which can be obtained
from https://tech.yandex.com/translate/. If the platform doesn't have a default
key and one isn't provided here, an error will be raised.
### Events {#YandexTranslate-Events}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment