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
3b0f0c24
Commit
3b0f0c24
authored
May 09, 2022
by
Suphon Thanakornpakapong
Browse files
Don't add widget if it already exists
parent
9f9e27f9
Pipeline
#184174
failed with stage
in 2 minutes and 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java
View file @
3b0f0c24
...
...
@@ -420,22 +420,30 @@ public class LauncherActivity extends AppCompatActivity implements
}
private
void
addDefaultWidgets
()
{
int
[]
widgetIds
=
mAppWidgetHost
.
getAppWidgetIds
();
Set
<
ComponentName
>
existingProviders
=
new
HashSet
<>();
for
(
int
widgetId
:
widgetIds
)
{
AppWidgetProviderInfo
info
=
mAppWidgetManager
.
getAppWidgetInfo
(
widgetId
);
existingProviders
.
add
(
info
.
provider
);
}
if
(!
Preferences
.
getAddedEcloudWidget
(
this
))
{
ComponentName
provider
=
DefaultWidgets
.
INSTANCE
.
getEcloudWidget
();
if
(
allocateAndBindWidget
(
provider
))
{
if
(
existingProviders
.
contains
(
provider
)
||
allocateAndBindWidget
(
provider
))
{
Preferences
.
setAddedEcloudWidget
(
this
);
}
}
if
(!
Preferences
.
getAddedPrivacyWidget
(
this
))
{
ComponentName
provider
=
DefaultWidgets
.
INSTANCE
.
getPrivacyWidget
();
if
(
allocateAndBindWidget
(
provider
))
{
if
(
existingProviders
.
contains
(
provider
)
||
allocateAndBindWidget
(
provider
))
{
Preferences
.
setAddedPrivacyWidget
(
this
);
}
}
if
(!
Preferences
.
getAddedWeatherWidget
(
this
))
{
if
(
allocateAndBindWidget
(
WeatherAppWidgetProvider
.
COMPONENT_NAME
))
{
ComponentName
provider
=
DefaultWidgets
.
INSTANCE
.
getWeatherWidget
();
if
(
existingProviders
.
contains
(
provider
)
||
allocateAndBindWidget
(
provider
))
{
Preferences
.
setAddedWeatherWidget
(
this
);
}
}
...
...
app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherAppWidgetProvider.java
View file @
3b0f0c24
...
...
@@ -3,10 +3,13 @@ package foundation.e.blisslauncher.features.weather;
import
android.appwidget.AppWidgetProvider
;
import
android.content.ComponentName
;
import
androidx.annotation.NonNull
;
import
foundation.e.blisslauncher.BuildConfig
;
public
class
WeatherAppWidgetProvider
extends
AppWidgetProvider
{
@NonNull
public
static
final
ComponentName
COMPONENT_NAME
=
new
ComponentName
(
BuildConfig
.
APPLICATION_ID
,
WeatherAppWidgetProvider
.
class
.
getName
());
}
app/src/main/java/foundation/e/blisslauncher/features/widgets/DefaultWidgets.kt
View file @
3b0f0c24
package
foundation.e.blisslauncher.features.widgets
import
android.content.ComponentName
import
foundation.e.blisslauncher.features.weather.WeatherAppWidgetProvider
object
DefaultWidgets
{
val
ecloudWidget
=
ComponentName
(
"foundation.e.drive"
,
"foundation.e.drive.widgets.EDriveWidget"
)
val
privacyWidget
=
ComponentName
(
"foundation.e.advancedprivacy"
,
"foundation.e.privacycentralapp.Widget"
)
val
weatherWidget
=
WeatherAppWidgetProvider
.
COMPONENT_NAME
val
widgets
=
setOf
(
ecloudWidget
,
privacyWidget
)
}
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