/*
* Copyright (C) 2009 The Undried 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.superdeskclock;
import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
import static android.os.BatteryManager.BATTERY_STATUS_FULL;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.AbsoluteLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
/**
* DeskClock clock view for desk docks.
*/
@SuppressWarnings("deprecation")
public class DeskClock extends Activity {
private static final boolean DEBUG = false;
private static final String LOG_TAG = "DeskClock";
// Alarm action for midnight (so we can update the date display).
private static final String ACTION_MIDNIGHT = "com.android.superdeskclock.MIDNIGHT";
// Interval between forced polls of the weather widget.
private final long QUERY_WEATHER_DELAY = 60 * 60 * 1000; // 1 hr
// Intent to broadcast for dock settings.
private static final String DOCK_SETTINGS_ACTION = "com.android.settings.DOCK_SETTINGS";
// Delay before engaging the burn-in protection mode (green-on-black).
private final long SCREEN_SAVER_TIMEOUT = 5 * 60 * 1000; // 5 min
// Repositioning delay in screen saver.
private final long SCREEN_SAVER_MOVE_DELAY = 60 * 1000; // 1 min
// Color to use for text & graphics in screen saver mode.
private final int SCREEN_SAVER_COLOR = 0xFF308030;
private final int SCREEN_SAVER_COLOR_DIM = 0xFF183018;
// Opacity of black layer between clock display and wallpaper.
private final float DIM_BEHIND_AMOUNT_NORMAL = 0.4f;
private final float DIM_BEHIND_AMOUNT_DIMMED = 0.8f; // higher contrast when display dimmed
// Internal message IDs.
private final int QUERY_WEATHER_DATA_MSG = 0x1000;
private final int UPDATE_WEATHER_DISPLAY_MSG = 0x1001;
private final int SCREEN_SAVER_TIMEOUT_MSG = 0x2000;
private final int SCREEN_SAVER_MOVE_MSG = 0x2001;
// Weather widget query information.
private static final String GENIE_PACKAGE_ID = "com.google.android.apps.genie.geniewidget";
private static final String WEATHER_CONTENT_AUTHORITY = GENIE_PACKAGE_ID + ".weather";
private static final String WEATHER_CONTENT_PATH = "/weather/current";
private static final String[] WEATHER_CONTENT_COLUMNS = new String[] {
"location",
"timestamp",
"temperature",
"highTemperature",
"lowTemperature",
"iconUrl",
"iconResId",
"description",
};
private static final String ACTION_GENIE_REFRESH = "com.google.android.apps.genie.REFRESH";
// State variables follow.
private DigitalClock mTime;
private TextView mDate;
private TextView mNextAlarm = null;
private TextView mBatteryDisplay;
private TextView mWeatherCurrentTemperature;
private TextView mWeatherHighTemperature;
private TextView mWeatherLowTemperature;
private TextView mWeatherLocation;
private ImageView mWeatherIcon;
private String mWeatherCurrentTemperatureString;
private String mWeatherHighTemperatureString;
private String mWeatherLowTemperatureString;
private String mWeatherLocationString;
private Drawable mWeatherIconDrawable;
private Resources mGenieResources = null;
private boolean mDimmed = false;
private boolean mScreenSaverMode = false;
private String mDateFormat;
private int mBatteryLevel = -1;
private boolean mPluggedIn = false;
private boolean mLaunchedFromDock = false;
private Random mRNG;
private PendingIntent mMidnightIntent;
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (DEBUG) Log.d(LOG_TAG, "mIntentReceiver.onReceive: action=" + action + ", intent=" + intent);
if (Intent.ACTION_DATE_CHANGED.equals(action) || ACTION_MIDNIGHT.equals(action)) {
refreshDate();
} else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
handleBatteryUpdate(
intent.getIntExtra("status", BATTERY_STATUS_UNKNOWN),
intent.getIntExtra("level", 0));
}
// else if (UiModeManager.ACTION_EXIT_DESK_MODE.equals(action)) {
// if (mLaunchedFromDock) {
// // moveTaskToBack(false);
// finish();
// }
// mLaunchedFromDock = false;
// }
}
};
private final Handler mHandy = new Handler() {
@Override
public void handleMessage(Message m) {
if (m.what == QUERY_WEATHER_DATA_MSG) {
new Thread() { public void run() { queryWeatherData(); } }.start();
scheduleWeatherQueryDelayed(QUERY_WEATHER_DELAY);
} else if (m.what == UPDATE_WEATHER_DISPLAY_MSG) {
updateWeatherDisplay();
} else if (m.what == SCREEN_SAVER_TIMEOUT_MSG) {
saveScreen();
} else if (m.what == SCREEN_SAVER_MOVE_MSG) {
moveScreenSaver();
}
}
};
private final ContentObserver mContentObserver = new ContentObserver(mHandy) {
@Override
public void onChange(boolean selfChange) {
if (DEBUG) Log.d(LOG_TAG, "content observer notified that weather changed");
refreshWeather();
}
};
private void moveScreenSaver() {
moveScreenSaverTo(-1,-1);
}
private void moveScreenSaverTo(int x, int y) {
if (!mScreenSaverMode) return;
final View saver_view = findViewById(R.id.saver_view);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (x < 0 ||
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
40个Android应用程序源代码 (593个子文件)
resources.ap_ 1.45MB
resources.ap_ 351KB
resources.ap_ 51KB
DeskClock.apk 409KB
MyAnalogClock.apk 62KB
AndroidManifest.xml.bak 6KB
DeskClock.class 21KB
Alarms.class 14KB
SetAlarm.class 13KB
ReviewMain.class 11KB
Main.class 11KB
OperationOfBooks.class 11KB
AlarmClock.class 9KB
Review.class 9KB
DataAccess.class 9KB
studyWord.class 9KB
study.class 8KB
CalcScreen.class 8KB
AlarmAlertFullScreen.class 8KB
AlarmKlaxon.class 8KB
TimerClock.class 7KB
AnalogClock.class 7KB
Test.class 6KB
AlarmReceiver.class 6KB
AlarmProvider.class 6KB
ChooseBellActivity.class 5KB
DigitalClock.class 5KB
EditWord.class 5KB
RotateAnimationClock.class 5KB
Attention.class 5KB
SqlHelper.class 4KB
ImportBook.class 4KB
Main$3.class 4KB
AlarmClock$AlarmTimeAdapter.class 4KB
SetBellPreference.class 4KB
Wordroid_Widget.class 4KB
TestList.class 4KB
Preference.class 4KB
Alarm.class 4KB
timePreference.class 3KB
ReviewMain$3.class 3KB
CalcScreen$4.class 3KB
Test$2.class 3KB
makeNotify.class 3KB
SettingsActivity.class 3KB
R$id.class 3KB
ImportBook$4.class 3KB
RepeatPreference.class 3KB
AlarmAlert.class 3KB
Alarm$DaysOfWeek.class 3KB
R$drawable.class 3KB
R$string.class 3KB
R$id.class 3KB
ReviewMain$2$1.class 3KB
AlarmClock$AlarmTimeAdapter$1.class 3KB
Compute.class 3KB
RotateAnimation.class 3KB
study$3$1.class 2KB
R$drawable.class 2KB
ReviewMain$2.class 2KB
ImportBook$1.class 2KB
study$3.class 2KB
Test$3.class 2KB
WordList.class 2KB
CalcScreen$2.class 2KB
ImportBook$4$1.class 2KB
AlarmProvider$DatabaseHelper.class 2KB
Attention$1.class 2KB
Test$1.class 2KB
SetBellPreference$1.class 2KB
AnalogClock$2.class 2KB
TimerClock$3.class 2KB
AnalogAppWidgetProvider.class 2KB
studyWord$1.class 2KB
Alarm$Columns.class 2KB
Review$1.class 2KB
ReviewMain$6.class 2KB
SetAlarm$3.class 2KB
ReviewMain$5.class 2KB
DeskClock$6.class 2KB
ReviewMain$3$1.class 2KB
DigitalClock$1.class 2KB
ReviewMain$4.class 2KB
CalcScreen$3.class 2KB
TTS.class 2KB
RotateAnimationClock$3.class 2KB
DeskClock$5.class 2KB
DeskClock$11.class 2KB
AlarmPreference.class 2KB
study$1.class 2KB
study$8.class 2KB
AlarmAlertFullScreen$1.class 2KB
AlarmClock$AlarmTimeAdapter$1$1.class 2KB
Word.class 2KB
BookList.class 2KB
EditWord$1.class 2KB
SetAlarm$5.class 2KB
study$6.class 1KB
study$4.class 1KB
AlarmInitReceiver.class 1KB
共 593 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- 不甘平凡的小鸟2014-05-19太好了,看源码理解最好了
- jackyxio20142014-06-24很不错,例子很全面,最主要不要下载分。楼主好人
- qq_166984792014-06-20不错的教学材料
- 嘟嘟酱2014-07-15很经典很好用·
naruto与程序员
- 粉丝: 6
- 资源: 50
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Java项目:在线蛋糕商城系统(java+jsp+mysql)源码+数据库+期末大作业.zip
- ZapyaClient10_7-1.apk
- 织梦cms站长导航网站源码.zip
- 基于SSM+MySQL的网络投票调查问卷系统源码+数据库(java期末大作业).zip
- 基于jsp+servlet的宠物商城网站系统源码+数据库(java期末大作业).zip
- 基于Python+Tensorflow实现声纹识别+源代码+文档说明.zip
- java-leetcode题解之第112题路径总和.zip
- java-leetcode题解之第111题二叉树的最小深度.zip
- java-leetcode题解之第110题平衡二叉树.zip
- java-leetcode题解之第109题有序链表转换二叉搜索树.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功