/*
* Copyright (C) 2013 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.deskclock.alarms;
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.v4.app.NotificationManagerCompat;
import android.text.format.DateFormat;
import android.widget.Toast;
import com.android.deskclock.AlarmAlertWakeLock;
import com.android.deskclock.AlarmClockFragment;
import com.android.deskclock.AlarmUtils;
import com.android.deskclock.AsyncHandler;
import com.android.deskclock.DeskClock;
import com.android.deskclock.LogUtils;
import com.android.deskclock.R;
import com.android.deskclock.Utils;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.Alarm;
import com.android.deskclock.provider.AlarmInstance;
import com.android.deskclock.settings.SettingsActivity;
import java.util.Calendar;
import java.util.List;
/**
* This class handles all the state changes for alarm instances. You need to
* register all alarm instances with the state manager if you want them to
* be activated. If a major time change has occurred (ie. TIMEZONE_CHANGE, TIMESET_CHANGE),
* then you must also re-register instances to fix their states.
*
* Please see {@link #registerInstance) for special transitions when major time changes
* occur.
*
* Following states:
*
* SILENT_STATE:
* This state is used when the alarm is activated, but doesn't need to display anything. It
* is in charge of changing the alarm instance state to a LOW_NOTIFICATION_STATE.
*
* LOW_NOTIFICATION_STATE:
* This state is used to notify the user that the alarm will go off
* {@link AlarmInstance#LOW_NOTIFICATION_HOUR_OFFSET}. This
* state handles the state changes to HIGH_NOTIFICATION_STATE, HIDE_NOTIFICATION_STATE and
* DISMISS_STATE.
*
* HIDE_NOTIFICATION_STATE:
* This is a transient state of the LOW_NOTIFICATION_STATE, where the user wants to hide the
* notification. This will sit and wait until the HIGH_PRIORITY_NOTIFICATION should go off.
*
* HIGH_NOTIFICATION_STATE:
* This state behaves like the LOW_NOTIFICATION_STATE, but doesn't allow the user to hide it.
* This state is in charge of triggering a FIRED_STATE or DISMISS_STATE.
*
* SNOOZED_STATE:
* The SNOOZED_STATE behaves like a HIGH_NOTIFICATION_STATE, but with a different message. It
* also increments the alarm time in the instance to reflect the new snooze time.
*
* FIRED_STATE:
* The FIRED_STATE is used when the alarm is firing. It will start the AlarmService, and wait
* until the user interacts with the alarm via SNOOZED_STATE or DISMISS_STATE change. If the user
* doesn't then it might be change to MISSED_STATE if auto-silenced was enabled.
*
* MISSED_STATE:
* The MISSED_STATE is used when the alarm already fired, but the user could not interact with
* it. At this point the alarm instance is dead and we check the parent alarm to see if we need
* to disable or schedule a new alarm_instance. There is also a notification shown to the user
* that he/she missed the alarm and that stays for
* {@link AlarmInstance#MISSED_TIME_TO_LIVE_HOUR_OFFSET} or until the user acknownledges it.
*
* DISMISS_STATE:
* This is really a transient state that will properly delete the alarm instance. Use this state,
* whenever you want to get rid of the alarm instance. This state will also check the alarm
* parent to see if it should disable or schedule a new alarm instance.
*/
public final class AlarmStateManager extends BroadcastReceiver {
// These defaults must match the values in res/xml/settings.xml
private static final String DEFAULT_SNOOZE_MINUTES = "10";
// Intent action to trigger an instance state change.
public static final String CHANGE_STATE_ACTION = "change_state";
// Intent action to show the alarm and dismiss the instance
public static final String SHOW_AND_DISMISS_ALARM_ACTION = "show_and_dismiss_alarm";
// Intent action for an AlarmManager alarm serving only to set the next alarm indicators
private static final String INDICATOR_ACTION = "indicator";
// System intent action to notify AppWidget that we changed the alarm text.
public static final String SYSTEM_ALARM_CHANGE_ACTION = "android.intent.action.ALARM_CHANGED";
// Extra key to set the desired state change.
public static final String ALARM_STATE_EXTRA = "intent.extra.alarm.state";
// Extra key to indicate the state change was launched from a notification.
public static final String FROM_NOTIFICATION_EXTRA = "intent.extra.from.notification";
// Extra key to set the global broadcast id.
private static final String ALARM_GLOBAL_ID_EXTRA = "intent.extra.alarm.global.id";
// Intent category tags used to dismiss, snooze or delete an alarm
public static final String ALARM_DISMISS_TAG = "DISMISS_TAG";
public static final String ALARM_SNOOZE_TAG = "SNOOZE_TAG";
public static final String ALARM_DELETE_TAG = "DELETE_TAG";
// Intent category tag used when schedule state change intents in alarm manager.
private static final String ALARM_MANAGER_TAG = "ALARM_MANAGER";
// Buffer time in seconds to fire alarm instead of marking it missed.
public static final int ALARM_FIRE_BUFFER = 15;
// A factory for the current time; can be mocked for testing purposes.
private static CurrentTimeFactory sCurrentTimeFactory;
// Schedules alarm state transitions; can be mocked for testing purposes.
private static StateChangeScheduler sStateChangeScheduler =
new AlarmManagerStateChangeScheduler();
private static Calendar getCurrentTime() {
return sCurrentTimeFactory == null ?
Calendar.getInstance() : sCurrentTimeFactory.getCurrentTime();
}
static void setCurrentTimeFactory(CurrentTimeFactory currentTimeFactory) {
sCurrentTimeFactory = currentTimeFactory;
}
static void setStateChangeScheduler(StateChangeScheduler stateChangeScheduler) {
if (stateChangeScheduler == null) {
stateChangeScheduler = new AlarmManagerStateChangeScheduler();
}
sStateChangeScheduler = stateChangeScheduler;
}
public static int getGlobalIntentId(Context context) {
SharedPreferences prefs = Utils.getDefaultSharedPreferences(context);
return prefs.getInt(ALARM_GLOBAL_ID_EXTRA, -1);
}
public static void updateGlobalIntentId(Context context) {
SharedPreferences prefs = Utils.getDefaultSharedPreferences(context);
int globalId = prefs.getInt(ALARM_GLOBAL_ID_EXTRA, -1) + 1;
prefs.edit().putInt(ALARM_GLOBAL_ID_EXTRA, globalId).commit();
}
/**
* Find and notify system what the next alarm that will fire. This is used
* to update text in the system and widgets.
*
* @param context application context
*/
public static void updateNextAlarm(Context context) {
final AlarmInstance nextAlarm = getNextFiringAlarm(context);
if (Utils.isPreL()) {
updateNextAlarmInSystemSettings(context, nextAl
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 项目是使用 Android 操作系统和相关开发工具开发的一款移动应用程序。Android 平台提供了丰富的功能和接口,开发人员可以使用 Java 或 Kotlin 等编程语言编写 Android 应用程序。Android 项目也可以是针对特定设备或特定需求进行自定义开发的软件解决方案。 以下是 Android 项目的一些主要特点和资料介绍: 1. 开放源代码:Android 是基于 Linux 内核的开源操作系统,开发人员可以自由获取、使用和修改源代码。 2. 多样化的硬件设备支持:Android 支持多种硬件设备和屏幕尺寸,可以运行于手机、平板电脑、电视、手表等多种设备上。 3. 灵活的用户界面:Android 提供了丰富的用户界面控件和布局方式,可以实现漂亮、个性化的用户界面。 4. 响应式设计:Android 应用程序可以根据设备类型、屏幕尺寸等因素调整布局和显示方式,以适应不同的设备和用户需求。 5. 多媒体支持:Android 支持常见的音频、视频、图像等多媒体格式,可以实现各种多媒体应用。 6. 数据存储:Android 提供了多种数据存储方式,包括 SQLite 数据库、文件存储、SharedPreferences 等。 7. 网络通信:Android 支持多种网络通信方式,包括 HTTP、TCP、UDP 等。 8. 社交媒体集成:Android 提供了集成社交媒体的功能,可以实现与 Facebook、Twitter、Google+ 等社交媒体的交互。 # 注意 1. 本资源仅用于开源学习和技术交流。 2. 部分字体以及插图等来自网络,若是侵权请联系删除。 3. 不可商用,一切后果由使用者承担。
资源推荐
资源详情
资源评论
收起资源包目录
Android系统 时钟 APP.zip (600个子文件)
gradlew.bat 2KB
.gitignore 176B
.gitignore 7B
.gitignore 7B
build.gradle 792B
build.gradle 546B
build.gradle 522B
settings.gradle 34B
gradlew 5KB
gradle-wrapper.jar 53KB
AlarmStateManager.java 45KB
TimePickerDialog.java 38KB
TimerModel.java 35KB
RadialPickerLayout.java 34KB
MonthView.java 29KB
Utils.java 29KB
TimerFragment.java 26KB
AlarmActivity.java 25KB
CountingTimerView.java 24KB
AsyncRingtonePlayer.java 24KB
CitySelectionActivity.java 23KB
HandleApiCalls.java 19KB
DatePickerDialog.java 19KB
DayPickerView.java 18KB
StopwatchFragment.java 18KB
DeskClock.java 17KB
DataModel.java 17KB
AlarmInstance.java 17KB
RadialSelectorView.java 17KB
Alarm.java 16KB
SettingsActivity.java 15KB
ClockFragment.java 15KB
HandleDeskClockApiCalls.java 15KB
RadialTextsView.java 15KB
StopwatchModel.java 14KB
AlarmNotifications.java 14KB
DigitalAppWidgetProvider.java 14KB
ClockProvider.java 13KB
LapsAdapter.java 12KB
CircleView.java 11KB
AlarmClockFragment.java 11KB
AlarmService.java 11KB
Timer.java 10KB
ClockDatabaseHelper.java 10KB
ExpiredTimersActivity.java 10KB
AlarmUpdateHandler.java 9KB
AnalogClock.java 9KB
CityModel.java 9KB
ExpandedAlarmViewHolder.java 9KB
TimerSetupView.java 9KB
DigitalWidgetViewsFactory.java 8KB
AlarmTimeClickHandler.java 8KB
TimerDAO.java 8KB
ScreensaverActivity.java 8KB
FetchMatchingAlarmsAction.java 7KB
AmPmCirclesView.java 7KB
DaysOfWeek.java 7KB
LabelDialogFragment.java 7KB
NumberPickerCompat.java 7KB
Screensaver.java 7KB
StopwatchCircleView.java 7KB
ClockContract.java 7KB
MonthAdapter.java 7KB
WidgetUtils.java 7KB
DeskClockBackupAgent.java 7KB
TimePickerCompat.java 7KB
CircleButtonsLayout.java 6KB
SettingsDAO.java 6KB
TimerService.java 6KB
CityDAO.java 6KB
City.java 6KB
StopwatchDAO.java 6KB
EllipsizeLayout.java 6KB
VerticalViewPager.java 6KB
TimerPagerAdapter.java 6KB
YearPickerView.java 6KB
AlarmTimeAdapter.java 5KB
TimerCircleView.java 5KB
AnimatorUtils.java 5KB
TimerView.java 5KB
Utils.java 5KB
CrescendoLengthDialog.java 5KB
TimerItem.java 5KB
CollapsedAlarmViewHolder.java 5KB
TextTime.java 5KB
SnoozeLengthDialog.java 5KB
AlarmTimeViewHolder.java 4KB
BaseActivity.java 4KB
LogUtils.java 4KB
AlarmUtils.java 4KB
CircleView.java 4KB
AlarmModel.java 4KB
AlarmSelectionActivity.java 4KB
Events.java 4KB
TimerItemFragment.java 4KB
AlarmInitReceiver.java 4KB
SearchMenuItemController.java 4KB
ActionBarMenuManager.java 3KB
Stopwatch.java 3KB
RtlViewPager.java 3KB
共 600 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
阿齐Archie
- 粉丝: 1w+
- 资源: 2301
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 解决未在远程桌面会话中捕获到鼠标,vmguest.iso软件分享给大家
- JSP+SQL基于WEB的开放性实验管理系统设计与实现(源代码+论文+开题报告+中英文献+答辩PPT).rar
- log4net配置文件!!!!!!!!!!!!!!!!!
- 河南统计面板数据集(2010-2022年).xlsx
- OrcaleDBHelper帮助类!!!!!!!!!!!!
- log4net帮助类,用来写日志!!!!!!!!!!!!!
- Windows10时间同步源
- 信呼OA系统2.1.7版源码
- 3122080306 邹子轩 实验报告二.docx
- 基于STM32 NUCLEO板设计彩色LED照明灯(纯cubeMX开发)(大赛作品,文档完整,可直接运行)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功