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
1b734ac2
Commit
1b734ac2
authored
May 09, 2022
by
Aayush Gupta
Browse files
Merge branch '5381-duplicate-widgets' into 'master'
Don't add widget if it already exists See merge request
!89
parents
9f9e27f9
e2ca2539
Pipeline
#184207
passed with stage
in 4 minutes and 39 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 @
1b734ac2
...
...
@@ -143,7 +143,6 @@ import foundation.e.blisslauncher.features.suggestions.SuggestionProvider;
import
foundation.e.blisslauncher.features.suggestions.SuggestionsResult
;
import
foundation.e.blisslauncher.features.usagestats.AppUsageStats
;
import
foundation.e.blisslauncher.features.weather.DeviceStatusService
;
import
foundation.e.blisslauncher.features.weather.WeatherAppWidgetProvider
;
import
foundation.e.blisslauncher.features.weather.WeatherPreferences
;
import
foundation.e.blisslauncher.features.weather.WeatherSourceListenerService
;
import
foundation.e.blisslauncher.features.weather.WeatherUpdateService
;
...
...
@@ -420,22 +419,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 @
1b734ac2
...
...
@@ -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 @
1b734ac2
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