Initial widget commit
This commit is contained in:
parent
f9124a14b0
commit
eb02af99fd
|
@ -15,6 +15,16 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<receiver android:name="layout.FrameWidget">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.appwidget.provider"
|
||||||
|
android:resource="@xml/frame_widget_info" />
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -0,0 +1,45 @@
|
||||||
|
package layout;
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.appwidget.AppWidgetProvider;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
|
import horse.jaeil.microframe.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of App Widget functionality.
|
||||||
|
*/
|
||||||
|
public class FrameWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
|
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
|
||||||
|
int appWidgetId) {
|
||||||
|
|
||||||
|
CharSequence widgetText = context.getString(R.string.appwidget_text);
|
||||||
|
// Construct the RemoteViews object
|
||||||
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.frame_widget);
|
||||||
|
// views.setTextViewText(R.id.appwidget_text, widgetText);
|
||||||
|
|
||||||
|
// Instruct the widget manager to update the widget
|
||||||
|
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||||
|
// There may be multiple widgets active, so update all of them
|
||||||
|
for (int appWidgetId : appWidgetIds) {
|
||||||
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnabled(Context context) {
|
||||||
|
// Enter relevant functionality for when the first widget is created
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisabled(Context context) {
|
||||||
|
// Enter relevant functionality for when the last widget is disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
|
@ -0,0 +1,21 @@
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#09C"
|
||||||
|
android:padding="@dimen/widget_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/appwidget_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:background="#09C"
|
||||||
|
android:contentDescription="@string/appwidget_text"
|
||||||
|
android:text="@string/appwidget_text"
|
||||||
|
android:textColor="#ff0000"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold|italic" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Refer to App Widget Documentation for margin information
|
||||||
|
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
||||||
|
-->
|
||||||
|
<dimen name="widget_margin">0dp</dimen>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -2,4 +2,10 @@
|
||||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Refer to App Widget Documentation for margin information
|
||||||
|
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
||||||
|
-->
|
||||||
|
<dimen name="widget_margin">8dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MicroFrame</string>
|
<string name="app_name">MicroFrame</string>
|
||||||
<string name="about_text">Version: 0.1\nAuthor: Tim Van Baak</string>
|
<string name="about_text">Version: 0.1.1\nAuthor: Tim Van Baak</string>
|
||||||
|
<string name="appwidget_text">WAITAMINUTE</string>
|
||||||
|
<string name="add_widget">Add widget????</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:initialKeyguardLayout="@layout/frame_widget"
|
||||||
|
android:initialLayout="@layout/frame_widget"
|
||||||
|
android:minHeight="40dp"
|
||||||
|
android:minWidth="40dp"
|
||||||
|
android:previewImage="@drawable/example_appwidget_preview"
|
||||||
|
android:resizeMode="horizontal|vertical"
|
||||||
|
android:updatePeriodMillis="86400000"
|
||||||
|
android:widgetCategory="home_screen"></appwidget-provider>
|
Loading…
Reference in New Issue