-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
5 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
40 changes: 40 additions & 0 deletions
40
android/app/src/main/java/now/fortuitous/thanos/widget/SmartFreezeAppWidgetProvider.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,40 @@ | ||
package now.fortuitous.thanos.widget | ||
|
||
import android.app.PendingIntent | ||
import android.appwidget.AppWidgetManager | ||
import android.appwidget.AppWidgetProvider | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.widget.RemoteViews | ||
import github.tornaco.android.thanos.R | ||
import now.fortuitous.thanos.power.SmartFreezeActivity | ||
|
||
class SmartFreezeAppWidgetProvider : AppWidgetProvider() { | ||
|
||
override fun onUpdate( | ||
context: Context, | ||
appWidgetManager: AppWidgetManager, | ||
appWidgetIds: IntArray | ||
) { | ||
appWidgetIds.forEach { appWidgetId -> | ||
val pendingIntent: PendingIntent = PendingIntent.getActivity( | ||
/* context = */ context, | ||
/* requestCode = */ 0, | ||
/* intent = */ Intent(context, SmartFreezeActivity::class.java).apply { | ||
putExtra(SmartFreezeActivity.EXTRA_EXPAND_SEARCH, true) | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) | ||
}, | ||
/* flags = */ PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE | ||
) | ||
|
||
val views: RemoteViews = RemoteViews( | ||
context.packageName, | ||
R.layout.smart_freeze_appwidget | ||
).apply { | ||
setOnClickPendingIntent(R.id.search_layout, pendingIntent) | ||
} | ||
|
||
appWidgetManager.updateAppWidget(appWidgetId, views) | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
android/app/src/main/res/drawable/app_widget_search_bg.xml
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<!-- 背景颜色 --> | ||
<solid android:color="@color/app_widget_search_bg_color" /> | ||
|
||
<!-- 圆角半径 --> | ||
<corners android:radius="20dp" /> | ||
|
||
<!-- 内边距 --> | ||
<padding | ||
android:bottom="8dp" | ||
android:left="8dp" | ||
android:right="8dp" | ||
android:top="8dp" /> | ||
|
||
<!-- 边框 --> | ||
<stroke | ||
android:width="2dp" | ||
android:color="@color/app_widget_search_stroke_color" /> | ||
|
||
</shape> |
24 changes: 24 additions & 0 deletions
24
android/app/src/main/res/layout/smart_freeze_appwidget.xml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<LinearLayout | ||
android:id="@+id/search_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="52dp" | ||
android:layout_gravity="center" | ||
android:background="@drawable/app_widget_search_bg" | ||
android:padding="16dp"> | ||
|
||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:src="@drawable/ic_remix_search_line" | ||
android:tint="@color/app_widget_search_icon_tint_color" | ||
tools:ignore="UseAppTint" /> | ||
|
||
</LinearLayout> | ||
</LinearLayout> |
10 changes: 10 additions & 0 deletions
10
android/app/src/main/res/layout/smart_freeze_appwidget_preview.xml
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="Preview" /> | ||
</LinearLayout> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="app_widget_search_bg_color">#ea000000</color> | ||
<color name="app_widget_search_stroke_color">#ea000000</color> | ||
<color name="app_widget_search_icon_tint_color">#eaffffff</color> | ||
</resources> |
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:description="@string/feature_title_smart_app_freeze" | ||
android:initialLayout="@layout/smart_freeze_appwidget" | ||
android:maxResizeWidth="250dp" | ||
android:maxResizeHeight="80dp" | ||
android:minWidth="40dp" | ||
android:minHeight="40dp" | ||
android:previewImage="@drawable/search_preview" | ||
android:resizeMode="horizontal|vertical" | ||
android:targetCellWidth="1" | ||
android:targetCellHeight="1" | ||
android:updatePeriodMillis="86400000" | ||
android:widgetCategory="home_screen" | ||
android:widgetFeatures="reconfigurable|configuration_optional" | ||
tools:ignore="UnusedAttribute" /> |