create a simple widget config activity
This commit is contained in:
parent
80f5637a9f
commit
fb5ccc50dc
|
@ -29,6 +29,12 @@
|
||||||
android:name="android.appwidget.provider"
|
android:name="android.appwidget.provider"
|
||||||
android:resource="@xml/widget_info"/>
|
android:resource="@xml/widget_info"/>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<activity android:name=".MyWidgetConfigure">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package calculator.simplemobiletools.com.simple_calculator;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
|
||||||
|
public class MyWidgetConfigure extends Activity {
|
||||||
|
private int widgetId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.widget_config);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
final Bundle extras = intent.getExtras();
|
||||||
|
if (extras != null) {
|
||||||
|
widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
|
||||||
|
finish();
|
||||||
|
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.config_save)
|
||||||
|
public void saveConfig() {
|
||||||
|
final Intent resultValue = new Intent();
|
||||||
|
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
||||||
|
setResult(RESULT_OK, resultValue);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/config_save"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Save"/>
|
||||||
|
</RelativeLayout>
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:configure="calculator.simplemobiletools.com.simple_calculator.MyWidgetConfigure"
|
||||||
android:initialLayout="@layout/activity_main"
|
android:initialLayout="@layout/activity_main"
|
||||||
android:minHeight="250dp"
|
android:minHeight="250dp"
|
||||||
android:minWidth="250dp">
|
android:minWidth="250dp">
|
||||||
|
|
Loading…
Reference in New Issue