-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update version
- Loading branch information
Showing
23 changed files
with
237 additions
and
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.the0cp.objection | ||
|
||
import android.app.PendingIntent | ||
import android.appwidget.AppWidgetManager | ||
import android.appwidget.AppWidgetProvider | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.widget.RemoteViews | ||
|
||
/** | ||
* Implementation of App Widget functionality. | ||
*/ | ||
class AppWidget : AppWidgetProvider() { | ||
override fun onUpdate( | ||
context: Context, | ||
appWidgetManager: AppWidgetManager, | ||
appWidgetIds: IntArray | ||
) { | ||
// There may be multiple widgets active, so update all of them | ||
for (appWidgetId in appWidgetIds) { | ||
val views = RemoteViews(context.packageName, R.layout.app_widget) | ||
views.setImageViewResource(R.id.imageView, R.drawable.objection) | ||
|
||
val intent = Intent(context, MainActivity::class.java) | ||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) | ||
|
||
views.setOnClickPendingIntent(R.id.widget_root, pendingIntent) | ||
updateAppWidget(context, appWidgetManager, appWidgetId) | ||
} | ||
} | ||
|
||
override fun onEnabled(context: Context) { | ||
// Enter relevant functionality for when the first widget is created | ||
} | ||
|
||
override fun onDisabled(context: Context) { | ||
// Enter relevant functionality for when the last widget is disabled | ||
} | ||
} | ||
|
||
internal fun updateAppWidget( | ||
context: Context, | ||
appWidgetManager: AppWidgetManager, | ||
appWidgetId: Int | ||
) { | ||
// val widgetText = context.getString(R.string.appwidget_text) | ||
// Construct the RemoteViews object | ||
val views = RemoteViews(context.packageName, R.layout.app_widget) | ||
// views.setTextViewText(R.id.appwidget_text, widgetText) | ||
|
||
views.setImageViewResource(R.id.imageView, R.drawable.objection) | ||
// Instruct the widget manager to update the widget | ||
|
||
val intent = Intent(context, MainActivity::class.java) | ||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) | ||
|
||
views.setOnClickPendingIntent(R.id.widget_root, pendingIntent) | ||
appWidgetManager.updateAppWidget(appWidgetId, views) | ||
} |
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"?><!-- | ||
Background for widgets to make the rounded corners based on the | ||
appWidgetRadius attribute value | ||
--> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<corners android:radius="?attr/appWidgetRadius" /> | ||
<solid android:color="?android:attr/colorBackground" /> | ||
</shape> |
10 changes: 10 additions & 0 deletions
10
app/src/main/res/drawable-v21/app_widget_inner_view_background.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"?><!-- | ||
Background for views inside widgets to make the rounded corners based on the | ||
appWidgetInnerRadius attribute value | ||
--> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<corners android:radius="?attr/appWidgetInnerRadius" /> | ||
<solid android:color="?android:attr/colorAccent" /> | ||
</shape> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
style="@style/Widget.Objection.AppWidget.Container" | ||
android:id="@+id/widget_root" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:theme="@style/Base.Theme.Objection.AppWidgetContainer"> | ||
|
||
<ImageView | ||
android:id="@+id/imageView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:visibility="visible" | ||
app:srcCompat="@drawable/objection" | ||
tools:srcCompat="@drawable/objection" /> | ||
</RelativeLayout> |
Oops, something went wrong.