This repository has been archived by the owner on Aug 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a launcher widget to toggle all locks.
- Loading branch information
Showing
16 changed files
with
372 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package eu.thedarken.wldonate | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
@MustBeDocumented | ||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME) | ||
annotation class SharedPrefsDir |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/eu/thedarken/wldonate/main/core/WidgetSettingsRepo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package eu.thedarken.wldonate.main.core; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import java.io.File; | ||
|
||
import javax.inject.Inject; | ||
|
||
import eu.thedarken.wldonate.AppComponent; | ||
import eu.thedarken.wldonate.ApplicationContext; | ||
import eu.thedarken.wldonate.SharedPrefsDir; | ||
import timber.log.Timber; | ||
|
||
@AppComponent.Scope | ||
public class WidgetSettingsRepo { | ||
private final Context context; | ||
private final File sharedPrefsDir; | ||
|
||
@Inject | ||
public WidgetSettingsRepo(@SharedPrefsDir File sharedPrefsDir, @ApplicationContext Context context) { | ||
this.sharedPrefsDir = sharedPrefsDir; | ||
this.context = context; | ||
} | ||
|
||
private static String getWidgetPrefsFileName(int appWidgetId) { | ||
return "widget_" + appWidgetId + "_prefs"; | ||
} | ||
|
||
public SharedPreferences getSettings(int appWidgetId) { | ||
return context.getSharedPreferences(getWidgetPrefsFileName(appWidgetId), Context.MODE_PRIVATE); | ||
} | ||
|
||
public void deleteSettings(int appWidgetId) { | ||
File prefs = new File(sharedPrefsDir, getWidgetPrefsFileName(appWidgetId) + ".xml"); | ||
if (prefs.exists() && !prefs.delete()) Timber.e("Failed to delete prefs: %s", prefs.getPath()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/eu/thedarken/wldonate/main/core/widget/ToggleWidgetComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package eu.thedarken.wldonate.main.core.widget | ||
|
||
|
||
import dagger.Subcomponent | ||
import eu.darken.mvpbakery.injection.broadcastreceiver.BroadcastReceiverComponent | ||
|
||
@ToggleWidgetComponent.Scope | ||
@Subcomponent | ||
interface ToggleWidgetComponent : BroadcastReceiverComponent<ToggleWidgetProvider> { | ||
|
||
@Subcomponent.Builder | ||
abstract class Builder : BroadcastReceiverComponent.Builder<ToggleWidgetProvider, ToggleWidgetComponent>() | ||
|
||
@javax.inject.Scope | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Scope | ||
} |
Oops, something went wrong.