upload android base code part7
This commit is contained in:
parent
4e516ec6ed
commit
841ae54672
25229 changed files with 1709508 additions and 0 deletions
16
android/development/apps/BuildWidget/Android.mk
Normal file
16
android/development/apps/BuildWidget/Android.mk
Normal file
|
@ -0,0 +1,16 @@
|
|||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := samples tests
|
||||
|
||||
# Only compile source java files in this apk.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := BuildWidget
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
18
android/development/apps/BuildWidget/AndroidManifest.xml
Normal file
18
android/development/apps/BuildWidget/AndroidManifest.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.buildwidget"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="3" />
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<receiver android:name=".BuildWidget" android:label="@string/widget_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_build" />
|
||||
</receiver>
|
||||
<service android:name=".BuildWidget$UpdateService" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
android/development/apps/BuildWidget/res/drawable-hdpi/icon.png
Normal file
BIN
android/development/apps/BuildWidget/res/drawable-hdpi/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
BIN
android/development/apps/BuildWidget/res/drawable-mdpi/icon.png
Normal file
BIN
android/development/apps/BuildWidget/res/drawable-mdpi/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
77
android/development/apps/BuildWidget/res/layout/widget.xml
Normal file
77
android/development/apps/BuildWidget/res/layout/widget.xml
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/block1x1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
style="@style/Text.BuildInfo.Fancy"
|
||||
android:textSize="18dip"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
style="@style/Text.BuildInfo.Fancy"
|
||||
android:textSize="14dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toRightOf="@id/block1x1"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/build_extra"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="32dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:minWidth="60dp"
|
||||
style="@style/Text.BuildInfo.Fancy"
|
||||
android:textSize="10dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/platlogo"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="3dp"
|
||||
android:src="@*android:drawable/platlogo"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_weight="0"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="droidgreen">#FFA4C639</color>
|
||||
</resources>
|
20
android/development/apps/BuildWidget/res/values/strings.xml
Normal file
20
android/development/apps/BuildWidget/res/values/strings.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Build Number</string>
|
||||
<string name="widget_name">Build Number</string>
|
||||
</resources>
|
20
android/development/apps/BuildWidget/res/values/styles.xml
Normal file
20
android/development/apps/BuildWidget/res/values/styles.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Text" />
|
||||
|
||||
<style name="Text.BuildInfo">
|
||||
<!-- <item name="android:typeface">monospace</item>-->
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:textColor">@color/droidgreen</item>
|
||||
<item name="android:shadowColor">@android:color/black</item>
|
||||
<item name="android:shadowDx">0</item>
|
||||
<item name="android:shadowDy">0</item>
|
||||
<item name="android:shadowRadius">3.0</item>
|
||||
</style>
|
||||
|
||||
<style name="Text.BuildInfo.Fancy">
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
<item name="android:shadowColor">@color/droidgreen</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minResizeWidth="72dip"
|
||||
android:minResizeHeight="72dip"
|
||||
android:minWidth="72dip"
|
||||
android:minHeight="72dip"
|
||||
android:updatePeriodMillis="0"
|
||||
android:initialLayout="@layout/widget"
|
||||
android:resizeMode="horizontal"
|
||||
/>
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.buildwidget;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.format.Time;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Define a simple widget that shows the Wiktionary "Word of the day." To build
|
||||
* an update we spawn a background {@link Service} to perform the API queries.
|
||||
*/
|
||||
public class BuildWidget extends AppWidgetProvider {
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
|
||||
int[] appWidgetIds) {
|
||||
// To prevent any ANR timeouts, we perform the update in a service
|
||||
context.startService(new Intent(context, UpdateService.class));
|
||||
}
|
||||
|
||||
public static class UpdateService extends Service {
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
// Build the widget update
|
||||
RemoteViews updateViews = buildUpdate(this);
|
||||
|
||||
// Push update for this widget to the home screen
|
||||
ComponentName thisWidget = new ComponentName(this, BuildWidget.class);
|
||||
AppWidgetManager manager = AppWidgetManager.getInstance(this);
|
||||
manager.updateAppWidget(thisWidget, updateViews);
|
||||
}
|
||||
|
||||
public RemoteViews buildUpdate(Context context) {
|
||||
// Pick out month names from resources
|
||||
Resources res = context.getResources();
|
||||
RemoteViews updateViews = new RemoteViews(
|
||||
context.getPackageName(), R.layout.widget);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context,
|
||||
0 /* no requestCode */,
|
||||
new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS),
|
||||
0 /* no flags */);
|
||||
updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent);
|
||||
|
||||
updateViews.setTextViewText(R.id.build_info, android.os.Build.ID);
|
||||
updateViews.setTextViewText(R.id.build_date,
|
||||
DateUtils.formatDateTime(context, android.os.Build.TIME,
|
||||
DateUtils.FORMAT_NUMERIC_DATE));
|
||||
updateViews.setTextViewText(R.id.build_extra, android.os.Build.FINGERPRINT);
|
||||
return updateViews;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// We don't need to bind to this service
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue