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
3abb556f
Unverified
Commit
3abb556f
authored
Mar 21, 2019
by
ZhengCornell
Committed by
Jeffrey I. Schiller
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of percent lengths when changing width/height in blocks
Change-Id: Ic56482d73262b9a1ddab955e8560f975f42d87a0
parent
5d0e66cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
appinventor/components/src/com/google/appinventor/components/runtime/AndroidViewComponent.java
.../appinventor/components/runtime/AndroidViewComponent.java
+9
-3
appinventor/components/src/com/google/appinventor/components/runtime/Form.java
...s/src/com/google/appinventor/components/runtime/Form.java
+23
-7
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/AndroidViewComponent.java
View file @
3abb556f
...
...
@@ -61,7 +61,7 @@ public abstract class AndroidViewComponent extends VisibleComponent {
}
/**
* Specifies whether the component should be visible on the screen. Value is true if the
* Specifies whether the component should be visible on the screen. Value is true if the
* component is showing and false if hidden.
* @param visibility desired state
*/
...
...
@@ -98,8 +98,11 @@ public abstract class AndroidViewComponent extends VisibleComponent {
public
void
Width
(
int
width
)
{
container
.
setChildWidth
(
this
,
width
);
lastSetWidth
=
width
;
if
(
width
<=
Component
.
LENGTH_PERCENT_TAG
)
if
(
width
<=
Component
.
LENGTH_PERCENT_TAG
)
{
container
.
$form
().
registerPercentLength
(
this
,
width
,
Form
.
PercentStorageRecord
.
Dim
.
WIDTH
);
}
else
{
container
.
$form
().
unregisterPercentLength
(
this
,
Form
.
PercentStorageRecord
.
Dim
.
WIDTH
);
}
}
/**
...
...
@@ -184,8 +187,11 @@ public abstract class AndroidViewComponent extends VisibleComponent {
public
void
Height
(
int
height
)
{
container
.
setChildHeight
(
this
,
height
);
lastSetHeight
=
height
;
if
(
height
<=
Component
.
LENGTH_PERCENT_TAG
)
if
(
height
<=
Component
.
LENGTH_PERCENT_TAG
)
{
container
.
$form
().
registerPercentLength
(
this
,
height
,
Form
.
PercentStorageRecord
.
Dim
.
HEIGHT
);
}
else
{
container
.
$form
().
unregisterPercentLength
(
this
,
Form
.
PercentStorageRecord
.
Dim
.
HEIGHT
);
}
}
/**
...
...
appinventor/components/src/com/google/appinventor/components/runtime/Form.java
View file @
3abb556f
...
...
@@ -86,6 +86,7 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
...
...
@@ -269,7 +270,8 @@ public class Form extends AppInventorCompatActivity
int
length
;
Dim
dim
;
}
private
ArrayList
<
PercentStorageRecord
>
dimChanges
=
new
ArrayList
();
// private ArrayList<PercentStorageRecord> dimChanges = new ArrayList();
private
LinkedHashMap
<
Integer
,
PercentStorageRecord
>
dimChanges
=
new
LinkedHashMap
();
private
static
class
MultiDexInstaller
extends
AsyncTask
<
Form
,
Void
,
Boolean
>
{
Form
ourForm
;
...
...
@@ -686,11 +688,10 @@ public class Form extends AppInventorCompatActivity
// We first make a copy of the existing dimChanges list
// because while we are replaying it, it is being appended to
Log
.
d
(
LOG_TAG
,
"ReplayFormOrientation()"
);
ArrayList
<
PercentStorageRecord
>
temp
=
(
ArrayList
<
PercentStorageRecord
>)
dimChanges
.
clone
();
LinkedHashMap
<
Integer
,
PercentStorageRecord
>
temp
=
(
LinkedHashMap
<
Integer
,
PercentStorageRecord
>)
dimChanges
.
clone
();
dimChanges
.
clear
();
// Empties it out
for
(
int
i
=
0
;
i
<
temp
.
size
();
i
++)
{
// Iterate over the list...
PercentStorageRecord
r
=
temp
.
get
(
i
);
// Iterate temp
for
(
PercentStorageRecord
r
:
temp
.
values
())
{
if
(
r
.
dim
==
PercentStorageRecord
.
Dim
.
HEIGHT
)
{
r
.
component
.
Height
(
r
.
length
);
}
else
{
...
...
@@ -699,8 +700,23 @@ public class Form extends AppInventorCompatActivity
}
}
private
Integer
generateHashCode
(
AndroidViewComponent
component
,
PercentStorageRecord
.
Dim
dim
)
{
if
(
dim
==
PercentStorageRecord
.
Dim
.
HEIGHT
)
{
return
component
.
hashCode
()
*
2
+
1
;
}
else
{
return
component
.
hashCode
()
*
2
;
}
}
public
void
registerPercentLength
(
AndroidViewComponent
component
,
int
length
,
PercentStorageRecord
.
Dim
dim
)
{
dimChanges
.
add
(
new
PercentStorageRecord
(
component
,
length
,
dim
));
PercentStorageRecord
r
=
new
PercentStorageRecord
(
component
,
length
,
dim
);
Integer
key
=
generateHashCode
(
component
,
dim
);
dimChanges
.
put
(
key
,
r
);
}
public
void
unregisterPercentLength
(
AndroidViewComponent
component
,
PercentStorageRecord
.
Dim
dim
)
{
// iterate map, remove all entry match this
dimChanges
.
remove
(
generateHashCode
(
component
,
dim
));
}
private
static
int
generateNewRequestCode
()
{
...
...
@@ -2451,7 +2467,7 @@ public class Form extends AppInventorCompatActivity
view
=
frameLayout
;
}
InputMethodManager
imm
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
}
protected
void
updateTitle
()
{
...
...
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