Skip to content

Commit

Permalink
refactor: add USER_PRESENT on widget actions
Browse files Browse the repository at this point in the history
When user unlocks its phone, widgets are then updated.
It is a start... api < 17 does not have a good way to detect when screen is active

Relative to #95
  • Loading branch information
ojacquemart committed Aug 31, 2016
1 parent db9b425 commit 2ade08d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@

<receiver android:name=".ui.widget.StationWidgetProvider" android:label="@string/widget_label">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.vlille.checker.widget.Provider.action.REFRESH" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.USER_PRESENT"/>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="com.vlille.checker.widget.Provider.action.REFRESH"/>
</intent-filter>

<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);

Log.d(TAG, "onReceive " + intent.getAction());
if (isBootCompletedOrRefreshAction(intent)) {
if (isSupportedAction(intent)) {
setupWidgets(context, AppWidgetManager.getInstance(context));
}
}

private boolean isBootCompletedOrRefreshAction(Intent intent) {
return Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) || ACTION_REFRESH.equals(intent.getAction());
private boolean isSupportedAction(Intent intent) {
return Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())
|| Intent.ACTION_USER_PRESENT.equals(intent.getAction())
|| ACTION_REFRESH.equals(intent.getAction());
}

@Override
Expand Down

0 comments on commit 2ade08d

Please sign in to comment.