Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
0d6b2ee5
Commit
0d6b2ee5
authored
Feb 25, 2024
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
TwoPaneLayout: replace mSlideOffset with isOpened
Change-Id: I5adf1b641a33350e493cbfbbd2daa7a63537acb2
parent
3cfe2dff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jami-android/app/src/main/java/cx/ring/views/twopane/TwoPaneLayout.java
+14
-48
14 additions, 48 deletions
...pp/src/main/java/cx/ring/views/twopane/TwoPaneLayout.java
with
14 additions
and
48 deletions
jami-android/app/src/main/java/cx/ring/views/twopane/TwoPaneLayout.java
+
14
−
48
View file @
0d6b2ee5
...
@@ -104,7 +104,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -104,7 +104,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
* How far the panel is offset from its usual position.
* How far the panel is offset from its usual position.
* range [0, 1] where 0 = open, 1 = closed.
* range [0, 1] where 0 = open, 1 = closed.
*/
*/
private
float
mSlideOffset
=
1
.
f
;
private
boolean
isOpened
=
false
;
private
final
List
<
PanelListener
>
mPanelListeners
=
new
CopyOnWriteArrayList
<>();
private
final
List
<
PanelListener
>
mPanelListeners
=
new
CopyOnWriteArrayList
<>();
...
@@ -212,24 +212,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -212,24 +212,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
}
}
void
updateObscuredViewsVisibility
(
View
panel
)
{
void
updateObscuredViewsVisibility
(
View
panel
)
{
final
boolean
isLayoutRtl
=
isLayoutRtlSupport
();
boolean
visibility
=
!
mCanSlide
||
!
isOpened
;
final
int
startBound
=
isLayoutRtl
?
(
getWidth
()
-
getPaddingRight
())
:
getPaddingLeft
();
final
int
endBound
=
isLayoutRtl
?
getPaddingLeft
()
:
(
getWidth
()
-
getPaddingRight
());
final
int
topBound
=
getPaddingTop
();
final
int
bottomBound
=
getHeight
()
-
getPaddingBottom
();
final
int
left
;
final
int
right
;
final
int
top
;
final
int
bottom
;
if
(
panel
!=
null
&&
panel
.
isOpaque
())
{
left
=
panel
.
getLeft
();
right
=
panel
.
getRight
();
top
=
panel
.
getTop
();
bottom
=
panel
.
getBottom
();
}
else
{
left
=
right
=
top
=
bottom
=
0
;
}
for
(
int
i
=
0
,
childCount
=
getChildCount
();
i
<
childCount
;
i
++)
{
for
(
int
i
=
0
,
childCount
=
getChildCount
();
i
<
childCount
;
i
++)
{
final
View
child
=
getChildAt
(
i
);
final
View
child
=
getChildAt
(
i
);
...
@@ -239,21 +222,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -239,21 +222,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
}
else
if
(
child
.
getVisibility
()
==
GONE
)
{
}
else
if
(
child
.
getVisibility
()
==
GONE
)
{
continue
;
continue
;
}
}
child
.
setVisibility
(
visibility
?
VISIBLE
:
INVISIBLE
);
final
int
clampedChildLeft
=
Math
.
max
(
(
isLayoutRtl
?
endBound
:
startBound
),
child
.
getLeft
());
final
int
clampedChildTop
=
Math
.
max
(
topBound
,
child
.
getTop
());
final
int
clampedChildRight
=
Math
.
min
(
(
isLayoutRtl
?
startBound
:
endBound
),
child
.
getRight
());
final
int
clampedChildBottom
=
Math
.
min
(
bottomBound
,
child
.
getBottom
());
final
int
vis
;
if
(
clampedChildLeft
>=
left
&&
clampedChildTop
>=
top
&&
clampedChildRight
<=
right
&&
clampedChildBottom
<=
bottom
)
{
vis
=
INVISIBLE
;
}
else
{
vis
=
VISIBLE
;
}
child
.
setVisibility
(
vis
);
}
}
}
}
...
@@ -436,7 +405,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -436,7 +405,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
int
childWidthSpec
=
MeasureSpec
.
makeMeasureSpec
(
splitView
.
width
(),
int
childWidthSpec
=
MeasureSpec
.
makeMeasureSpec
(
splitView
.
width
(),
MeasureSpec
.
AT_MOST
);
MeasureSpec
.
AT_MOST
);
child
.
measure
(
childWidthSpec
,
childHeightSpec
);
child
.
measure
(
childWidthSpec
,
childHeightSpec
);
if
((
child
.
getMeasuredWidthAndState
()
&
MEASURED_STATE_TOO_SMALL
)
=
=
1
||
(
if
((
child
.
getMeasuredWidthAndState
()
&
MEASURED_STATE_TOO_SMALL
)
!
=
0
||
(
getMinimumWidth
(
child
)
!=
0
getMinimumWidth
(
child
)
!=
0
&&
splitView
.
width
()
<
getMinimumWidth
(
child
)))
{
&&
splitView
.
width
()
<
getMinimumWidth
(
child
)))
{
childWidthSpec
=
MeasureSpec
.
makeMeasureSpec
(
widthAvailable
-
horizontalMargin
,
childWidthSpec
=
MeasureSpec
.
makeMeasureSpec
(
widthAvailable
-
horizontalMargin
,
...
@@ -496,7 +465,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -496,7 +465,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
int
nextXStart
=
xStart
;
int
nextXStart
=
xStart
;
if
(
mFirstLayout
)
{
if
(
mFirstLayout
)
{
mSlideOffset
=
mCanSlide
&&
mPreservedOpenState
?
0
.
f
:
1
.
f
;
isOpened
=
mCanSlide
&&
mPreservedOpenState
;
}
}
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
...
@@ -515,9 +484,8 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -515,9 +484,8 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
final
int
margin
=
lp
.
leftMargin
+
lp
.
rightMargin
;
final
int
margin
=
lp
.
leftMargin
+
lp
.
rightMargin
;
final
int
range
=
Math
.
min
(
nextXStart
,
width
-
paddingEnd
)
-
xStart
-
margin
;
final
int
range
=
Math
.
min
(
nextXStart
,
width
-
paddingEnd
)
-
xStart
-
margin
;
final
int
lpMargin
=
isLayoutRtl
?
lp
.
rightMargin
:
lp
.
leftMargin
;
final
int
lpMargin
=
isLayoutRtl
?
lp
.
rightMargin
:
lp
.
leftMargin
;
final
int
pos
=
(
i
nt
)
(
range
*
mSlideOffset
)
;
final
int
pos
=
(
i
sOpened
)
?
0
:
range
;
xStart
+=
pos
+
lpMargin
;
xStart
+=
pos
+
lpMargin
;
mSlideOffset
=
(
float
)
pos
/
range
;
}
else
{
}
else
{
xStart
=
nextXStart
;
xStart
=
nextXStart
;
}
}
...
@@ -581,7 +549,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -581,7 +549,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
if
(!
mCanSlide
)
{
if
(!
mCanSlide
)
{
mPreservedOpenState
=
false
;
mPreservedOpenState
=
false
;
}
}
if
(
mFirstLayout
||
slideTo
(
1
.
f
))
{
if
(
mFirstLayout
||
slideTo
(
false
))
{
mPreservedOpenState
=
false
;
mPreservedOpenState
=
false
;
return
true
;
return
true
;
}
}
...
@@ -599,7 +567,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -599,7 +567,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
if
(!
mCanSlide
)
{
if
(!
mCanSlide
)
{
mPreservedOpenState
=
true
;
mPreservedOpenState
=
true
;
}
}
if
(
mFirstLayout
||
slideTo
(
0
.
f
))
{
if
(
mFirstLayout
||
slideTo
(
true
))
{
mPreservedOpenState
=
true
;
mPreservedOpenState
=
true
;
return
true
;
return
true
;
}
}
...
@@ -632,7 +600,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -632,7 +600,7 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
*/
*/
@Override
@Override
public
boolean
isOpen
()
{
public
boolean
isOpen
()
{
return
!
mCanSlide
||
mSlideOffset
==
0
;
return
!
mCanSlide
||
isOpened
;
}
}
/**
/**
...
@@ -673,21 +641,19 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
...
@@ -673,21 +641,19 @@ public class TwoPaneLayout extends ViewGroup implements Openable {
}
}
/**
/**
* Set mDraggingPane to the target X position within its range.
* @param opened position to switch to
*
* @param slideOffset position to animate to
*/
*/
boolean
slideTo
(
float
slideOffset
)
{
boolean
slideTo
(
boolean
opened
)
{
if
(!
mCanSlide
)
{
if
(!
mCanSlide
)
{
// Nothing to do.
// Nothing to do.
return
false
;
return
false
;
}
}
View
slideableView
=
mSlideableView
;
View
slideableView
=
mSlideableView
;
mSlideOffset
=
slideOffset
;
isOpened
=
opened
;
mFirstLayout
=
true
;
requestLayout
();
requestLayout
();
invalidate
();
invalidate
();
boolean
opened
=
slideOffset
==
0
.
f
;
if
(
opened
)
if
(
opened
)
dispatchOnPanelOpened
(
slideableView
);
dispatchOnPanelOpened
(
slideableView
);
else
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment