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
51efa8f7
Commit
51efa8f7
authored
Jun 12, 2012
by
Vance Turnewitsch
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:mit-cml/app-inventor-private
parents
4bc7a174
d89d9325
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
27 deletions
+97
-27
appinventor/appengine/src/com/google/appinventor/client/youngandroid/YoungAndroidFormUpgrader.java
...nventor/client/youngandroid/YoungAndroidFormUpgrader.java
+14
-2
appinventor/blockslib/src/openblocks/yacodeblocks/BlockSaveFile.java
.../blockslib/src/openblocks/yacodeblocks/BlockSaveFile.java
+14
-2
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
...c/com/google/appinventor/components/common/YaVersion.java
+9
-3
appinventor/components/src/com/google/appinventor/components/runtime/AccelerometerSensor.java
...e/appinventor/components/runtime/AccelerometerSensor.java
+43
-2
appinventor/docs/learn/reference/components/sensors.html
appinventor/docs/learn/reference/components/sensors.html
+14
-0
sample-.gitignore
sample-.gitignore
+3
-0
sample-.hgignore
sample-.hgignore
+0
-18
No files found.
appinventor/appengine/src/com/google/appinventor/client/youngandroid/YoungAndroidFormUpgrader.java
View file @
51efa8f7
...
...
@@ -195,8 +195,10 @@ public final class YoungAndroidFormUpgrader {
// NOTE(lizlooney,user) - when a component changes, increment the component's version
// number in com.google.appinventor.components.common.YaVersion and add code here to upgrade
// properties as necessary.
if
(
componentType
.
equals
(
"AccelerometerSensor"
)){
srcCompVersion
=
upgradeAccelerometerSensorProperties
(
componentProperties
,
srcCompVersion
);
if
(
componentType
.
equals
(
"ActivityStarter"
))
{
}
else
if
(
componentType
.
equals
(
"ActivityStarter"
))
{
srcCompVersion
=
upgradeActivityStarterProperties
(
componentProperties
,
srcCompVersion
);
}
else
if
(
componentType
.
equals
(
"Ball"
))
{
...
...
@@ -321,6 +323,16 @@ public final class YoungAndroidFormUpgrader {
}
}
private
static
int
upgradeAccelerometerSensorProperties
(
Map
<
String
,
JSONValue
>
componentProperties
,
int
srcCompVersion
)
{
if
(
srcCompVersion
<
2
)
{
// The AccelerometerSensor.MinimumInterval property was added.
// No properties need to be modified to upgrade to version 2.
srcCompVersion
=
2
;
}
return
srcCompVersion
;
}
private
static
int
upgradeActivityStarterProperties
(
Map
<
String
,
JSONValue
>
componentProperties
,
int
srcCompVersion
)
{
if
(
srcCompVersion
<
2
)
{
...
...
appinventor/blockslib/src/openblocks/yacodeblocks/BlockSaveFile.java
View file @
51efa8f7
...
...
@@ -382,7 +382,10 @@ public class BlockSaveFile {
// number in com.google.appinventor.components.common.YaVersion and add code here to upgrade blocks
// as necessary.
if
(
genus
.
equals
(
"ActivityStarter"
))
{
if
(
genus
.
equals
(
"AccelerometerSensor"
)){
blkCompVersion
=
upgradeAccelerometerSensorBlocks
(
blkCompVersion
,
componentName
);
}
else
if
(
genus
.
equals
(
"ActivityStarter"
))
{
blkCompVersion
=
upgradeActivityStarterBlocks
(
blkCompVersion
,
componentName
);
}
else
if
(
genus
.
equals
(
"Ball"
))
{
...
...
@@ -495,6 +498,15 @@ public class BlockSaveFile {
}
}
private
int
upgradeAccelerometerSensorBlocks
(
int
blkCompVersion
,
String
componentName
)
{
if
(
blkCompVersion
<
2
)
{
// The AccelerometerSensor.MinimumInterval property was added.
// No blocks need to be modified to upgrade to version 2.
blkCompVersion
=
2
;
}
return
blkCompVersion
;
}
private
int
upgradeActivityStarterBlocks
(
int
blkCompVersion
,
String
componentName
)
{
if
(
blkCompVersion
<
2
)
{
// The ActivityStarter.DataType, ActivityStarter.ResultType, and ActivityStarter.ResultUri
...
...
appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
View file @
51efa8f7
...
...
@@ -168,8 +168,10 @@ public class YaVersion {
// - IMAGEPICKER_COMPONENT_VERSION was incremented to 4.
// - LISTPICKER_COMPONENT_VERSION was incremented to 5.
// - PHONENUMBERPICKER_COMPONENT_VERSION was incremented to 4.
// For YOUNG_ANDROID_VERSION 55:
// - ACCELEROMETERSENSOR_COMPONENT_VERSION was incremented to 2.
public
static
final
int
YOUNG_ANDROID_VERSION
=
5
4
;
public
static
final
int
YOUNG_ANDROID_VERSION
=
5
5
;
// ............................... Blocks Language Version Number ...............................
...
...
@@ -237,7 +239,11 @@ public class YaVersion {
// 4. Add code in openblocks.yacodeblocks.BlockSaveFile#upgradeComponentBlocks to
// upgrade the .blk file contents
public
static
final
int
ACCELEROMETERSENSOR_COMPONENT_VERSION
=
1
;
//For ACCELEROMETERSENSOR_COMPONENT_VERSION 2:
// - AccelerometerSensor.MinimumInterval property was added.
// - AccelerometerSensor.AccelerationChanged method was modified to wait for
// the minimum interval to elapse before calling a shaking event when necessary.
public
static
final
int
ACCELEROMETERSENSOR_COMPONENT_VERSION
=
2
;
// For ACTIVITYSTARTER_COMPONENT_VERSION 2:
// - The ActivityStarter.DataType, ActivityStarter.ResultType, and ActivityStarter.ResultUri
...
...
appinventor/components/src/com/google/appinventor/components/runtime/AccelerometerSensor.java
View file @
51efa8f7
...
...
@@ -87,6 +87,12 @@ public class AccelerometerSensor extends AndroidNonvisibleComponent
// Indicates whether the accelerometer should generate events
private
boolean
enabled
;
//Specifies the minimum time interval between calls to Shaking()
private
int
minimumInterval
;
//Specifies the time when Shaking() was last called
private
long
timeLastShook
;
private
Sensor
accelerometerSensor
;
/**
...
...
@@ -103,6 +109,35 @@ public class AccelerometerSensor extends AndroidNonvisibleComponent
sensorManager
=
(
SensorManager
)
container
.
$context
().
getSystemService
(
Context
.
SENSOR_SERVICE
);
accelerometerSensor
=
sensorManager
.
getDefaultSensor
(
Sensor
.
TYPE_ACCELEROMETER
);
startListening
();
MinimumInterval
(
400
);
}
/**
* Returns the minimum interval required between calls to Shaking(),
* in milliseconds.
* Once the phone starts being shaken, all further Shaking() calls will be ignored
* until the interval has elapsed.
* @return minimum interval in ms
*/
@SimpleProperty
(
category
=
PropertyCategory
.
BEHAVIOR
,
description
=
"The minimum interval between phone shakes"
)
public
int
MinimumInterval
()
{
return
minimumInterval
;
}
/**
* Specifies the minimum interval required between calls to Shaking(),
* in milliseconds.
* Once the phone starts being shaken, all further Shaking() calls will be ignored
* until the interval has elapsed.
* @param interval minimum interval in ms
*/
@DesignerProperty
(
editorType
=
PropertyTypeConstants
.
PROPERTY_TYPE_NON_NEGATIVE_INTEGER
,
defaultValue
=
"400"
)
//Default value derived by trial of 12 people on 3 different devices
@SimpleProperty
public
void
MinimumInterval
(
int
interval
)
{
minimumInterval
=
interval
;
}
/**
...
...
@@ -118,7 +153,13 @@ public class AccelerometerSensor extends AndroidNonvisibleComponent
addToSensorCache
(
Y_CACHE
,
yAccel
);
addToSensorCache
(
Z_CACHE
,
zAccel
);
if
(
isShaking
(
X_CACHE
,
xAccel
)
||
isShaking
(
Y_CACHE
,
yAccel
)
||
isShaking
(
Z_CACHE
,
zAccel
))
{
long
currentTime
=
System
.
currentTimeMillis
();
//Checks whether the phone is shaking and the minimum interval
//has elapsed since the last registered a shaking event.
if
((
isShaking
(
X_CACHE
,
xAccel
)
||
isShaking
(
Y_CACHE
,
yAccel
)
||
isShaking
(
Z_CACHE
,
zAccel
))
&&
(
timeLastShook
==
0
||
currentTime
>=
timeLastShook
+
minimumInterval
)){
timeLastShook
=
currentTime
;
Shaking
();
}
...
...
appinventor/docs/learn/reference/components/sensors.html
View file @
51efa8f7
...
...
@@ -138,6 +138,20 @@
<dd>
Acceleration in the Z-dimension.
</dd>
<dt>
<code
class=
"c2"
>
MinimumInterval
</code>
</dt>
<dd>
Minimum time interval between phone shakes.
<br/>
You may want to change the time interval depending on the activity you want to perform when the phone is shaken.
For example, you may want the phone to say "Stop shaking me" each time the user shakes the phone. At shorter time intervals, this
will produce an unwanted echo effect.
In another case, you may want a quick flick of the phone to be considered a single shake and perhaps increment a
counter each time the phone shakes. In cases such as this, a shorter time interval will be more appropriate to properly count the shakes.
</dd>
</dl>
<h3>
Events
...
...
sample-.gitignore
View file @
51efa8f7
# You can copy and/or modify this file to create your own .gitignore file.
# This keeps generated files from being added to source control management.
.gitignore
.classpath
.project
bin/
build/
reports/
.DS_Store*
sample-.hgignore
deleted
100644 → 0
View file @
4bc7a174
# You can copy and/or modify this file to create your own .hgignore file.
# This keeps generated files from being added to source control management.
^\.hgignore
^appinventor/build/
^appinventor/reports/
^appinventor/appengine/build
^appinventor/appengine/reports
^appinventor/buildserver/build
^appinventor/buildserver/reports
^appinventor/blockseditor/build
^appinventor/blockseditor/reports
^appinventor/blockslib/build
^appinventor/blockslib/reports
^appinventor/common/build
^appinventor/common/reports
^appinventor/components/build
^appinventor/components/reports
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