The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 17 | package android.appwidget; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | import android.content.ComponentName; |
| 22 | |
| 23 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 24 | * Describes the meta data for an installed AppWidget provider. The fields in this class |
| 25 | * correspond to the fields in the <code><appwidget-provider></code> xml tag. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 27 | public class AppWidgetProviderInfo implements Parcelable { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 29 | * Identity of this AppWidget component. This component should be a {@link |
| 30 | * android.content.BroadcastReceiver}, and it will be sent the AppWidget intents |
| 31 | * {@link android.appwidget as described in the AppWidget package documentation}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | * |
| 33 | * <p>This field corresponds to the <code>android:name</code> attribute in |
| 34 | * the <code><receiver></code> element in the AndroidManifest.xml file. |
| 35 | */ |
| 36 | public ComponentName provider; |
| 37 | |
| 38 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 39 | * Minimum width of the AppWidget, in dp. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | * |
| 41 | * <p>This field corresponds to the <code>android:minWidth</code> attribute in |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 42 | * the AppWidget meta-data file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | */ |
| 44 | public int minWidth; |
| 45 | |
| 46 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 47 | * Minimum height of the AppWidget, in dp. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | * |
| 49 | * <p>This field corresponds to the <code>android:minHeight</code> attribute in |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 50 | * the AppWidget meta-data file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | */ |
| 52 | public int minHeight; |
| 53 | |
| 54 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 55 | * How often, in milliseconds, that this AppWidget wants to be updated. |
| 56 | * The AppWidget manager may place a limit on how often a AppWidget is updated. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | * |
| 58 | * <p>This field corresponds to the <code>android:updatePeriodMillis</code> attribute in |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 59 | * the AppWidget meta-data file. |
Joe Onorato | 851da84 | 2009-07-14 19:49:27 -0700 | [diff] [blame^] | 60 | * |
| 61 | * <p class="note"><b>Note:</b> Updates requested with <code>updatePeriodMillis</code> |
| 62 | * will not be delivered more than once every 30 minutes.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | */ |
| 64 | public int updatePeriodMillis; |
| 65 | |
| 66 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 67 | * The resource id of the initial layout for this AppWidget. This should be |
| 68 | * displayed until the RemoteViews for the AppWidget is available. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | * |
| 70 | * <p>This field corresponds to the <code>android:initialLayout</code> attribute in |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 71 | * the AppWidget meta-data file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | */ |
| 73 | public int initialLayout; |
| 74 | |
| 75 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 76 | * The activity to launch that will configure the AppWidget. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | * |
| 78 | * <p>This class name of field corresponds to the <code>android:configure</code> attribute in |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 79 | * the AppWidget meta-data file. The package name always corresponds to the package containing |
| 80 | * the AppWidget provider. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | */ |
| 82 | public ComponentName configure; |
| 83 | |
| 84 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 85 | * The label to display to the user in the AppWidget picker. If not supplied in the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | * xml, the application label will be used. |
| 87 | * |
| 88 | * <p>This field corresponds to the <code>android:label</code> attribute in |
| 89 | * the <code><receiver></code> element in the AndroidManifest.xml file. |
| 90 | */ |
| 91 | public String label; |
| 92 | |
| 93 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 94 | * The icon to display for this AppWidget in the AppWidget picker. If not supplied in the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | * xml, the application icon will be used. |
| 96 | * |
| 97 | * <p>This field corresponds to the <code>android:icon</code> attribute in |
| 98 | * the <code><receiver></code> element in the AndroidManifest.xml file. |
| 99 | */ |
| 100 | public int icon; |
| 101 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 102 | public AppWidgetProviderInfo() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 106 | * Unflatten the AppWidgetProviderInfo from a parcel. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 108 | public AppWidgetProviderInfo(Parcel in) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | if (0 != in.readInt()) { |
| 110 | this.provider = new ComponentName(in); |
| 111 | } |
| 112 | this.minWidth = in.readInt(); |
| 113 | this.minHeight = in.readInt(); |
| 114 | this.updatePeriodMillis = in.readInt(); |
| 115 | this.initialLayout = in.readInt(); |
| 116 | if (0 != in.readInt()) { |
| 117 | this.configure = new ComponentName(in); |
| 118 | } |
| 119 | this.label = in.readString(); |
| 120 | this.icon = in.readInt(); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | public void writeToParcel(android.os.Parcel out, int flags) { |
| 125 | if (this.provider != null) { |
| 126 | out.writeInt(1); |
| 127 | this.provider.writeToParcel(out, flags); |
| 128 | } else { |
| 129 | out.writeInt(0); |
| 130 | } |
| 131 | out.writeInt(this.minWidth); |
| 132 | out.writeInt(this.minHeight); |
| 133 | out.writeInt(this.updatePeriodMillis); |
| 134 | out.writeInt(this.initialLayout); |
| 135 | if (this.configure != null) { |
| 136 | out.writeInt(1); |
| 137 | this.configure.writeToParcel(out, flags); |
| 138 | } else { |
| 139 | out.writeInt(0); |
| 140 | } |
| 141 | out.writeString(this.label); |
| 142 | out.writeInt(this.icon); |
| 143 | } |
| 144 | |
| 145 | public int describeContents() { |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | /** |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 150 | * Parcelable.Creator that instantiates AppWidgetProviderInfo objects |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 152 | public static final Parcelable.Creator<AppWidgetProviderInfo> CREATOR |
| 153 | = new Parcelable.Creator<AppWidgetProviderInfo>() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | { |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 155 | public AppWidgetProviderInfo createFromParcel(Parcel parcel) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | { |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 157 | return new AppWidgetProviderInfo(parcel); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | } |
| 159 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 160 | public AppWidgetProviderInfo[] newArray(int size) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | { |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 162 | return new AppWidgetProviderInfo[size]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 163 | } |
| 164 | }; |
| 165 | |
| 166 | public String toString() { |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 167 | return "AppWidgetProviderInfo(provider=" + this.provider + ")"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | |