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
5f61f4fa
Commit
5f61f4fa
authored
Jan 13, 2022
by
Amit Kumar
💻
Browse files
Add icons at first empty space always
parent
cadd6987
Pipeline
#156979
passed with stage
in 9 minutes and 14 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/blisslauncher/features/launcher/AppProvider.java
View file @
5f61f4fa
...
@@ -57,6 +57,11 @@ public class AppProvider {
...
@@ -57,6 +57,11 @@ public class AppProvider {
*/
*/
List
<
LauncherItem
>
mLauncherItems
;
List
<
LauncherItem
>
mLauncherItems
;
/**
* Represents all items including the ones which are added when launcher is not running.
*/
AppsRepository
.
AllItems
allItems
;
/**
/**
* Represents networkItems stored in database.
* Represents networkItems stored in database.
*/
*/
...
@@ -207,15 +212,15 @@ public class AppProvider {
...
@@ -207,15 +212,15 @@ public class AppProvider {
private
synchronized
void
handleAllProviderLoaded
()
{
private
synchronized
void
handleAllProviderLoaded
()
{
if
(
appsLoaded
&&
shortcutsLoaded
&&
databaseLoaded
)
{
if
(
appsLoaded
&&
shortcutsLoaded
&&
databaseLoaded
)
{
if
(
mDatabaseItems
==
null
||
mDatabaseItems
.
size
()
<=
0
)
{
if
(
mDatabaseItems
==
null
||
mDatabaseItems
.
size
()
<=
0
)
{
mLauncher
Items
=
prepareDefaultLauncherItems
();
all
Items
=
prepareDefaultLauncherItems
();
}
else
{
}
else
{
mLauncher
Items
=
prepareLauncherItems
();
all
Items
=
prepareLauncherItems
();
}
}
mAppsRepository
.
updateAppsRelay
(
mLauncher
Items
);
mAppsRepository
.
updateA
llA
ppsRelay
(
all
Items
);
}
}
}
}
private
List
<
Launcher
Item
>
prepareLauncherItems
()
{
private
AppsRepository
.
All
Item
s
prepareLauncherItems
()
{
Log
.
d
(
TAG
,
"prepareLauncherItems() called"
);
Log
.
d
(
TAG
,
"prepareLauncherItems() called"
);
/*
/*
...
@@ -332,14 +337,15 @@ public class AppProvider {
...
@@ -332,14 +337,15 @@ public class AppProvider {
Log
.
i
(
TAG
,
"prepareLauncherItems: "
+
mLauncherItem
);
Log
.
i
(
TAG
,
"prepareLauncherItems: "
+
mLauncherItem
);
}
}
applicationItems
.
removeAll
(
mDatabaseItems
);
applicationItems
.
removeAll
(
mDatabaseItems
);
List
<
Application
Item
>
mutableList
=
new
ArrayList
<>(
applicationItems
);
List
<
Launcher
Item
>
mutableList
=
new
ArrayList
<>(
applicationItems
);
mutableList
.
sort
((
app1
,
app2
)
->
{
mutableList
.
sort
((
app1
,
app2
)
->
{
Collator
collator
=
Collator
.
getInstance
();
Collator
collator
=
Collator
.
getInstance
();
return
collator
.
compare
(
app1
.
title
.
toString
(),
app2
.
title
.
toString
());
return
collator
.
compare
(
app1
.
title
.
toString
(),
app2
.
title
.
toString
());
});
});
mLauncherItems
.
addAll
(
mutableList
);
return
mLauncherItems
;
return
new
AppsRepository
.
AllItems
(
mLauncherItems
,
mutableList
)
;
}
}
private
boolean
isAppOnSdcard
(
String
packageName
,
UserHandle
userHandle
)
{
private
boolean
isAppOnSdcard
(
String
packageName
,
UserHandle
userHandle
)
{
...
@@ -411,7 +417,7 @@ public class AppProvider {
...
@@ -411,7 +417,7 @@ public class AppProvider {
return
shortcutItem
;
return
shortcutItem
;
}
}
private
List
<
Launcher
Item
>
prepareDefaultLauncherItems
()
{
private
AppsRepository
.
All
Item
s
prepareDefaultLauncherItems
()
{
List
<
LauncherItem
>
mLauncherItems
=
new
ArrayList
<>();
List
<
LauncherItem
>
mLauncherItems
=
new
ArrayList
<>();
List
<
LauncherItem
>
pinnedItems
=
new
ArrayList
<>();
List
<
LauncherItem
>
pinnedItems
=
new
ArrayList
<>();
PackageManager
pm
=
mContext
.
getPackageManager
();
PackageManager
pm
=
mContext
.
getPackageManager
();
...
@@ -454,7 +460,7 @@ public class AppProvider {
...
@@ -454,7 +460,7 @@ public class AppProvider {
});
});
mLauncherItems
.
addAll
(
pinnedItems
);
mLauncherItems
.
addAll
(
pinnedItems
);
return
mLauncherItems
;
return
new
AppsRepository
.
AllItems
(
mLauncherItems
,
Collections
.
emptyList
())
;
}
}
public
AppsRepository
getAppsRepository
()
{
public
AppsRepository
getAppsRepository
()
{
...
...
app/src/main/java/foundation/e/blisslauncher/features/launcher/AppsRepository.java
View file @
5f61f4fa
...
@@ -3,17 +3,22 @@ package foundation.e.blisslauncher.features.launcher;
...
@@ -3,17 +3,22 @@ package foundation.e.blisslauncher.features.launcher;
import
com.jakewharton.rxrelay2.BehaviorRelay
;
import
com.jakewharton.rxrelay2.BehaviorRelay
;
import
foundation.e.blisslauncher.core.database.model.LauncherItem
;
import
foundation.e.blisslauncher.core.database.model.LauncherItem
;
import
java.util.List
;
import
java.util.List
;
public
class
AppsRepository
{
public
class
AppsRepository
{
private
static
final
String
TAG
=
"AppsRepository"
;
private
static
final
String
TAG
=
"AppsRepository"
;
@Deprecated
private
BehaviorRelay
<
List
<
LauncherItem
>>
appsRelay
;
private
BehaviorRelay
<
List
<
LauncherItem
>>
appsRelay
;
private
BehaviorRelay
<
AllItems
>
allItems
;
private
static
AppsRepository
sAppsRepository
;
private
static
AppsRepository
sAppsRepository
;
private
AppsRepository
()
{
private
AppsRepository
()
{
appsRelay
=
BehaviorRelay
.
create
();
appsRelay
=
BehaviorRelay
.
create
();
allItems
=
BehaviorRelay
.
create
();
}
}
public
static
AppsRepository
getAppsRepository
()
{
public
static
AppsRepository
getAppsRepository
()
{
...
@@ -25,13 +30,43 @@ public class AppsRepository {
...
@@ -25,13 +30,43 @@ public class AppsRepository {
public
void
clearAll
(){
public
void
clearAll
(){
appsRelay
=
BehaviorRelay
.
create
();
appsRelay
=
BehaviorRelay
.
create
();
allItems
=
BehaviorRelay
.
create
();
}
}
public
void
updateAppsRelay
(
List
<
LauncherItem
>
launcherItems
)
{
public
void
updateAppsRelay
(
List
<
LauncherItem
>
launcherItems
)
{
this
.
appsRelay
.
accept
(
launcherItems
);
this
.
appsRelay
.
accept
(
launcherItems
);
}
}
public
void
updateAllAppsRelay
(
AllItems
allItems
)
{
this
.
allItems
.
accept
(
allItems
);
}
public
BehaviorRelay
<
List
<
LauncherItem
>>
getAppsRelay
()
{
public
BehaviorRelay
<
List
<
LauncherItem
>>
getAppsRelay
()
{
return
appsRelay
;
return
appsRelay
;
}
}
public
BehaviorRelay
<
AllItems
>
getAllItemsRelay
()
{
return
allItems
;
}
public
static
class
AllItems
{
private
final
List
<
LauncherItem
>
items
;
private
final
List
<
LauncherItem
>
newAddedItems
;
public
AllItems
(
List
<
LauncherItem
>
items
,
List
<
LauncherItem
>
newAddedItems
)
{
this
.
items
=
items
;
this
.
newAddedItems
=
newAddedItems
;
}
public
List
<
LauncherItem
>
getItems
()
{
return
items
;
}
public
List
<
LauncherItem
>
getNewAddedItems
()
{
return
newAddedItems
;
}
}
}
}
\ No newline at end of file
app/src/main/java/foundation/e/blisslauncher/features/test/TestActivity.kt
View file @
5f61f4fa
...
@@ -87,6 +87,7 @@ import foundation.e.blisslauncher.core.utils.IntegerArray
...
@@ -87,6 +87,7 @@ import foundation.e.blisslauncher.core.utils.IntegerArray
import
foundation.e.blisslauncher.core.utils.ListUtil
import
foundation.e.blisslauncher.core.utils.ListUtil
import
foundation.e.blisslauncher.core.utils.PackageUserKey
import
foundation.e.blisslauncher.core.utils.PackageUserKey
import
foundation.e.blisslauncher.core.utils.UserHandle
import
foundation.e.blisslauncher.core.utils.UserHandle
import
foundation.e.blisslauncher.features.launcher.AppsRepository
import
foundation.e.blisslauncher.features.launcher.Hotseat
import
foundation.e.blisslauncher.features.launcher.Hotseat
import
foundation.e.blisslauncher.features.launcher.SearchInputDisposableObserver
import
foundation.e.blisslauncher.features.launcher.SearchInputDisposableObserver
import
foundation.e.blisslauncher.features.notification.DotInfo
import
foundation.e.blisslauncher.features.notification.DotInfo
...
@@ -1109,12 +1110,12 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
...
@@ -1109,12 +1110,12 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
BlissLauncher
.
getApplication
(
this
)
BlissLauncher
.
getApplication
(
this
)
.
appProvider
.
appProvider
.
appsRepository
.
appsRepository
.
a
pp
sRelay
.
a
llItem
sRelay
.
distinctUntilChanged
()
.
distinctUntilChanged
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeWith
(
object
:
DisposableObserver
<
List
<
Launcher
Item
>
>()
{
.
subscribeWith
(
object
:
DisposableObserver
<
AppsRepository
.
All
Item
s
>()
{
override
fun
onNext
(
launcherItems
:
List
<
Launcher
Item
>
)
{
override
fun
onNext
(
items
:
AppsRepository
.
All
Item
s
)
{
mainHandler
.
post
{
showApps
(
launcherI
tems
)
}
mainHandler
.
post
{
showApps
(
i
tems
)
}
}
}
override
fun
onError
(
e
:
Throwable
)
{
override
fun
onError
(
e
:
Throwable
)
{
...
@@ -1126,14 +1127,15 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
...
@@ -1126,14 +1127,15 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
)
)
}
}
private
fun
showApps
(
launcherItems
:
List
<
Launcher
Item
>
)
{
private
fun
showApps
(
allItems
:
AppsRepository
.
All
Item
s
)
{
hotseat
.
resetLayout
(
false
)
hotseat
.
resetLayout
(
false
)
val
populatedItems
=
populateItemPositions
(
launcherI
tems
)
val
populatedItems
=
populateItemPositions
(
allItems
.
i
tems
)
val
orderedScreenIds
=
IntegerArray
()
val
orderedScreenIds
=
IntegerArray
()
orderedScreenIds
.
addAll
(
collectWorkspaceScreens
(
populatedItems
))
orderedScreenIds
.
addAll
(
collectWorkspaceScreens
(
populatedItems
))
workspace
.
removeAllWorkspaceScreens
()
workspace
.
removeAllWorkspaceScreens
()
workspace
.
bindScreens
(
orderedScreenIds
)
workspace
.
bindScreens
(
orderedScreenIds
)
workspace
.
bindItems
(
populatedItems
,
false
)
workspace
.
bindItems
(
populatedItems
,
false
)
workspace
.
bindItemsAdded
(
allItems
.
newAddedItems
)
}
}
private
fun
populateItemPositions
(
launcherItems
:
List
<
LauncherItem
>):
List
<
LauncherItem
>
{
private
fun
populateItemPositions
(
launcherItems
:
List
<
LauncherItem
>):
List
<
LauncherItem
>
{
...
...
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