Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
BlissLauncher
Commits
613c4237
Commit
613c4237
authored
Sep 17, 2021
by
Amit Kumar
💻
Browse files
Add initial database integration
parent
04ae0817
Changes
4
Show whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/blisslauncher/core/customviews/LauncherPagedView.java
View file @
613c4237
...
...
@@ -37,6 +37,7 @@ import foundation.e.blisslauncher.BuildConfig;
import
foundation.e.blisslauncher.R
;
import
foundation.e.blisslauncher.core.Utilities
;
import
foundation.e.blisslauncher.core.customviews.pageindicators.PageIndicatorDots
;
import
foundation.e.blisslauncher.core.database.DatabaseManager
;
import
foundation.e.blisslauncher.core.database.model.ApplicationItem
;
import
foundation.e.blisslauncher.core.database.model.FolderItem
;
import
foundation.e.blisslauncher.core.database.model.LauncherItem
;
...
...
@@ -299,8 +300,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
||
launcherItem
.
screenId
>
mScreenOrder
.
size
()
-
1
)
{
workspaceScreen
=
insertNewWorkspaceScreen
(
mScreenOrder
.
size
());
}
launcherItem
.
screenId
=
mScreenOrder
.
size
()
-
1
;
launcherItem
.
cell
=
workspaceScreen
.
getChildCount
();
GridLayout
.
Spec
rowSpec
=
GridLayout
.
spec
(
GridLayout
.
UNDEFINED
);
GridLayout
.
Spec
colSpec
=
GridLayout
.
spec
(
GridLayout
.
UNDEFINED
);
GridLayout
.
LayoutParams
iconLayoutParams
=
...
...
@@ -310,7 +309,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
iconLayoutParams
.
setGravity
(
Gravity
.
CENTER
);
appView
.
setLayoutParams
(
iconLayoutParams
);
appView
.
setTextVisibility
(
true
);
//appView.setWithText(true);
workspaceScreen
.
addView
(
appView
);
}
else
if
(
launcherItem
.
container
==
Constants
.
CONTAINER_HOTSEAT
)
{
GridLayout
.
Spec
rowSpec
=
GridLayout
.
spec
(
GridLayout
.
UNDEFINED
);
...
...
@@ -321,7 +319,6 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
iconLayoutParams
.
height
=
mLauncher
.
getDeviceProfile
().
getHotseatCellHeightPx
();
iconLayoutParams
.
width
=
mLauncher
.
getDeviceProfile
().
getCellWidthPx
();
appView
.
setLayoutParams
(
iconLayoutParams
);
//appView.setWithText(false);
mLauncher
.
getHotseat
().
getLayout
().
addView
(
appView
);
}
}
...
...
@@ -1399,6 +1396,9 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
mTargetCell, resultSpan, CellLayout.MODE_ON_DROP
);
}*/
Log
.
i
(
TAG
,
"onDrop: Test here"
);
int
[]
resultSpan
=
new
int
[
2
];
mTargetCell
=
dropTargetLayout
.
performReorder
((
int
)
mDragViewVisualCenter
[
0
],
(
int
)
mDragViewVisualCenter
[
1
],
1
,
1
,
spanX
,
spanY
,
cell
,
...
...
@@ -1442,7 +1442,7 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
lp.cellVSpan = item.spanY;
lp.isLockedToGrid = true;*/
//TODO: Update the launcher database here.
updateDatabase
(
getWorkspaceAndHotseatCellLayouts
());
}
else
{
onNoCellFound
(
dropTargetLayout
);
...
...
@@ -1456,6 +1456,8 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
}
}
Log
.
i
(
TAG
,
"onDrop: Test here2"
);
final
CellLayout
parent
=
(
CellLayout
)
cell
.
getParent
();
if
(
d
.
dragView
.
hasDrawn
())
{
if
(
droppedOnOriginalCellDuringTransition
)
{
...
...
@@ -1484,6 +1486,43 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
}
}
private
void
updateDatabase
(
ArrayList
<
CellLayout
>
layouts
)
{
List
<
LauncherItem
>
items
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
layouts
.
size
();
i
++)
{
CellLayout
cellLayout
=
layouts
.
get
(
i
);
long
screenId
=
getIdForScreen
(
cellLayout
);
long
container
;
if
(
cellLayout
.
getContainerType
()
==
CellLayout
.
WORKSPACE
)
{
container
=
Constants
.
CONTAINER_DESKTOP
;
}
else
if
(
cellLayout
.
getContainerType
()
==
CellLayout
.
HOTSEAT
)
{
container
=
Constants
.
CONTAINER_HOTSEAT
;
}
else
{
throw
new
IllegalArgumentException
(
"Container type can only be CellLayout.WORKSPACE or CellLayout.HOTSEAT"
);
}
for
(
int
j
=
0
;
j
<
cellLayout
.
getChildCount
();
j
++)
{
LauncherItem
launcherItem
=
(
LauncherItem
)
cellLayout
.
getChildAt
(
j
).
getTag
();
launcherItem
.
cell
=
j
;
launcherItem
.
screenId
=
screenId
;
launcherItem
.
container
=
container
;
if
(
launcherItem
.
itemType
==
Constants
.
ITEM_TYPE_FOLDER
)
{
FolderItem
folderItem
=
(
FolderItem
)
launcherItem
;
items
.
add
(
folderItem
);
for
(
int
k
=
0
;
k
<
folderItem
.
items
.
size
();
k
++)
{
LauncherItem
item
=
folderItem
.
items
.
get
(
k
);
item
.
container
=
Long
.
parseLong
(
folderItem
.
id
);
item
.
cell
=
k
;
items
.
add
(
item
);
}
}
else
{
items
.
add
(
launcherItem
);
}
}
}
DatabaseManager
.
getManager
(
getContext
()).
saveItems
(
items
);
}
boolean
createUserFolderIfNecessary
(
View
newView
,
long
container
,
CellLayout
target
,
int
[]
targetCell
,
float
distance
,
boolean
external
,
DragView
dragView
...
...
@@ -1553,7 +1592,8 @@ public class LauncherPagedView extends PagedView<PageIndicatorDots> implements V
invalidate
();
post
(()
->
{
if
(
fi
.
cell
%
2
==
0
)
{
folderView
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
wobble
));
folderView
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
wobble
));
}
else
{
folderView
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
wobble_reverse
));
...
...
app/src/main/java/foundation/e/blisslauncher/core/database/DatabaseManager.java
View file @
613c4237
...
...
@@ -9,6 +9,8 @@ import foundation.e.blisslauncher.core.database.model.LauncherItem;
import
foundation.e.blisslauncher.core.database.model.WidgetItem
;
import
foundation.e.blisslauncher.core.executors.AppExecutors
;
import
foundation.e.blisslauncher.core.utils.Constants
;
import
foundation.e.blisslauncher.features.test.CellLayout
;
import
foundation.e.blisslauncher.features.test.IconTextView
;
import
io.reactivex.Single
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -46,7 +48,10 @@ public class DatabaseManager {
public
void
saveLayouts
(
List
<
GridLayout
>
pages
,
GridLayout
dock
)
{
List
<
GridLayout
>
tempPages
=
pages
;
GridLayout
tempDock
=
dock
;
mAppExecutors
.
diskIO
().
execute
(()
->
saveLauncherItems
(
tempPages
,
tempDock
));
}
public
void
saveItems
(
final
List
<
LauncherItem
>
items
)
{
mAppExecutors
.
diskIO
().
execute
(()
->
LauncherDB
.
getDatabase
(
mContext
).
launcherDao
().
insertAll
(
items
));
}
private
void
saveLauncherItems
(
final
List
<
GridLayout
>
pages
,
final
GridLayout
dock
)
{
...
...
app/src/main/java/foundation/e/blisslauncher/features/test/CellLayout.kt
View file @
613c4237
...
...
@@ -94,8 +94,6 @@ open class CellLayout @JvmOverloads constructor(
private
val
mDragOutlinePaint
=
Paint
()
private
var
mEaseOutInterpolator
:
TimeInterpolator
?
=
null
open
var
containerType
=
Constants
.
CONTAINER_DESKTOP
private
var
cellWidth
:
Int
=
0
private
var
cellHeight
:
Int
=
0
...
...
@@ -196,6 +194,8 @@ open class CellLayout @JvmOverloads constructor(
}
}
fun
getContainerType
()
=
mContainerType
open
fun
getCellContentHeight
():
Int
{
return
Math
.
min
(
measuredHeight
,
...
...
@@ -226,7 +226,7 @@ open class CellLayout @JvmOverloads constructor(
val
cHeight
:
Int
=
getCellContentHeight
()
val
cellPaddingY
=
0f
.
coerceAtLeast
((
lp
.
height
-
cHeight
)
/
2f
).
toInt
()
var
cellPaddingX
:
Int
if
(
c
ontainerType
==
Constants
.
CONTAINER_DESKTOP
)
{
if
(
mC
ontainerType
==
WORKSPACE
)
{
cellPaddingX
=
dp
.
workspaceCellPaddingXPx
}
else
{
cellPaddingX
=
(
dp
.
edgeMarginPx
/
2f
).
toInt
()
...
...
@@ -840,6 +840,13 @@ open class CellLayout @JvmOverloads constructor(
dragView
.
layoutParams
=
iconLayoutParams
addView
(
dragView
,
index
)
// Update item info after reordering so that we always save correct state in database.
// TODO: May optimize this
val
item
:
LauncherItem
=
dragView
.
tag
as
LauncherItem
item
.
container
=
if
(
mContainerType
==
HOTSEAT
)
Constants
.
CONTAINER_HOTSEAT
else
Constants
.
CONTAINER_DESKTOP
item
.
cell
=
index
(
dragView
as
IconTextView
).
applyFromShortcutItem
(
item
)
/*copySolutionToTempState(finalSolution, dragView)
setItemPlacementDirty(true)
animateItemsToSolution(finalSolution, dragView!!, mode == MODE_ON_DROP)
...
...
app/src/main/java/foundation/e/blisslauncher/features/test/TestActivity.kt
View file @
613c4237
...
...
@@ -1092,7 +1092,7 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
}
private
fun
showApps
(
launcherItems
:
List
<
LauncherItem
?>)
{
if
(
hotseat
!=
null
)
hotseat
.
resetLayout
(
false
)
hotseat
.
resetLayout
(
false
)
workspace
.
bindItems
(
launcherItems
)
}
...
...
Write
Preview
Supports
Markdown
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