本文中涉及的DeskClock为android中源生时钟。
问题一:
【操作步骤】clock->右下角图标->settings->snooze length->滑动选择任意时间(不是默认值)->横屏
【实际结果】横屏后时间数值恢复为之前设置的值
【预期结果】时间数值应为所选值
该问题为横屏刷新界面所致
首先我们在manifest文件中添加下面这个属性
android:configChanges="orientation|screenSize"
<activity android:name="SettingsActivity"
android:label="@string/settings"
android:theme="@style/SettingsTheme"
android:taskAffinity=""
android:excludeFromRecents="true"
android:configChanges="orientation|screenSize"
>
然后我们需要在
SettingsActivity.java中添加相应的代码
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
问题二:
问题: 随意输入倒计时时间然后点击后面“×”全部删除,其他三个页面相关按钮(添加闹钟、添加时区、计时按钮)消失,点击对应位置功能还能生效
首先这个问题是因为动画引起的。
我们应该修改src/com/android/deskclock/TimerSetupView.java下的这个文件。
private void setFabButtonVisibility(boolean show) {
final int finalVisibility = show ? View.VISIBLE : View.INVISIBLE;
if (mStart == null || mStart.getVisibility() == finalVisibility) {
// Fab is not initialized yet or already shown/hidden
return;
}
///注意修改是把下面的值进行修改@{
final Animator scaleAnimator = AnimatorUtils.getScaleAnimator(
mStart, show ? 1.0f : 1.0f, show ? 1.0f : 1.0f);
///@}
scaleAnimator.setDuration(AnimatorUtils.ANIM_DURATION_SHORT);
scaleAnimator.addListener(show ? mShowFabAnimatorListener : mHideFabAnimatorListener);
scaleAnimator.start();
}
问题三:
【预置条件】有一个即将到来的闹钟
【操作步骤】拨打电话--- 通话中--观察
【实际结果】通话中, 闹铃无弹出提示
【预期结果】通话中,来闹铃弹出提示框
这个问题我们应该在闹钟的服务框里面添加一个东东
src/com/android/deskclock/alarms/AlarmService.java
/// M: If boot from power off alarm, don't show the notification and alarmActivity @{
if (!PowerOffAlarm.bootFromPoweroffAlarm()) {
/* M:If user is in call, just show alarm notification without AlarmActivity,
* otherwise show Alarm Notification with AlarmActivity
*/
if (inCall) {
mInstanceAlarm = mCurrentAlarm;
AlarmNotifications.updateAlarmNotification(this, mCurrentAlarm);
//增加下面一句代码
AlarmNotifications.showAlarmNotification(this, mCurrentAlarm);
} else {
AlarmNotifications.showAlarmNotification(this, mCurrentAlarm);
}
} /// @}
问题四:
【操作步骤】新建一个在当前时间几分钟后响铃的单次闹钟,下拉状态栏点击DISMISS NOW后,返回idle界面观察
【实际结果】状态栏靠右边还有一个闹钟图标
这个问题比较尴尬,当时想了好久也没弄出来 后来还是我师傅叫我解的。
src/com/android/deskclock/alarms/AlarmStateManager.java 修该这个下面的文件
if (alarm != null && !alarm.daysOfWeek.isRepeating()) {
// Check parent if it needs to reschedule, disable or delete itself
if (instance.mAlarmId != null) {
/// 做出如下修改,去更新闹钟状态{@
AlarmInstance.deleteInstance(context.getContentResolver(), instance.mId);
updateNextAlarm(context);
///@}
updateParentAlarm(context, instance);
}
}
}
问题五:
【操作步骤】时钟->设置>设置“一周从那天开始”>返回闹钟界面->观察设置是否生效
【实际结果】需要退出时钟再次进入,该设置才会生效
【预期结果】不用退出重进,当即生效
这个问题主要是因为设置后没有生效
src/com/android/deskclock/DeskClock.java修改这个文件下的文件
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Recreate the activity if any settings have been changed 如果设置有任何的修改,就重新设置这个页面
/// M:code is commented as recreate disturbing activity resume cycle
if (requestCode == REQUEST_CHANGE_SETTINGS && resultCode == RESULT_OK) {
recreate();
}
}
问题六:
【操作步骤】倒计时提醒界面-》来闹钟提醒-》下拉状态栏-》观察通知栏
【实际结果】通知栏显示Clock is running点击进入的是App info界面
【预期结果】通知栏不显示Clock is running
src/com/android/deskclock/alarms/AlarmService.java |
/**
* M: Set alarmService foreground for the case that alarm's ringtone
* stop because low memory to kill deskclock process @{
*/
Notification notification = new Notification();
notification.flags |= Notification.FLAG_HIDE_NOTIFICATION;
//注释掉下面的代码就可以了
//this.startForeground(NOTIFICATION_KEY_FOREGROUND, notification);
LogUtils.v("Start set the alarmService foreground");
/** @} */
AlarmKlaxon.start(this, mCurrentAlarm,inCall);
sendBroadcast(new Intent(ALARM_ALERT_ACTION));
}