Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
android_packages_apps_DeskClock
Commits
219b399b
Commit
219b399b
authored
Aug 19, 2020
by
/e/ robot
Browse files
Merge remote-tracking branch 'origin/lineage-17.1' into v1-q
parents
91fadd24
67527f30
Changes
15
Hide whitespace changes
Inline
Side-by-side
Android.bp
View file @
219b399b
android_app {
name: "DeskClock",
resource_dirs: ["res"],
sdk_version: "current",
overrides: ["AlarmClock"],
srcs: [
"src/**/*.java",
"gen/**/*.java",
],
platform_apis: true,
product_specific: true,
static_libs: [
"androidx.annotation_annotation",
...
...
@@ -25,7 +25,6 @@ android_app {
"androidx.appcompat_appcompat",
"androidx.gridlayout_gridlayout",
"androidx.recyclerview_recyclerview",
"org.lineageos.platform.internal",
],
required: [
"com.android.deskclock_whitelist"
...
...
AndroidManifest.xml
View file @
219b399b
...
...
@@ -149,6 +149,7 @@
android:excludeFromRecents=
"true"
android:resizeableActivity=
"false"
android:showOnLockScreen=
"true"
android:showWhenLocked=
"true"
android:taskAffinity=
""
android:windowSoftInputMode=
"stateAlwaysHidden"
/>
...
...
res/layout/alarm_volume_preference.xml
View file @
219b399b
...
...
@@ -35,7 +35,7 @@
android:paddingEnd=
"12dp"
android:paddingTop=
"4dp"
android:paddingBottom=
"4dp"
>
<
com.
android.internal.
widget.
PreferenceImageView
<android
x.preference
.internal.PreferenceImageView
android:id=
"@android:id/icon"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
/>
...
...
@@ -70,7 +70,7 @@
android:orientation=
"vertical"
>
<SeekBar
android:id=
"@
*android:
id/seekbar"
android:id=
"@
+
id/seekbar"
android:layout_gravity=
"center_vertical"
android:paddingStart=
"12dp"
android:layout_width=
"match_parent"
...
...
src/com/android/deskclock/DeskClock.java
View file @
219b399b
...
...
@@ -303,9 +303,9 @@ public class DeskClock extends BaseActivity
@Override
protected
void
onStart
()
{
super
.
onStart
();
DataModel
.
getDataModel
().
addSilentSettingsListener
(
mSilentSettingChangeWatcher
);
DataModel
.
getDataModel
().
setApplicationInForeground
(
true
);
super
.
onStart
();
}
@Override
...
...
src/com/android/deskclock/NotificationUtils.java
View file @
219b399b
...
...
@@ -27,9 +27,6 @@ import android.util.Log;
import
androidx.core.app.NotificationManagerCompat
;
import
com.android.deskclock.Utils
;
import
com.android.deskclock.alarms.AlarmNotifications
;
import
com.android.deskclock.data.StopwatchNotificationBuilder
;
import
com.android.deskclock.data.TimerNotificationBuilder
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
src/com/android/deskclock/data/StopwatchNotificationBuilder.java
View file @
219b399b
...
...
@@ -49,7 +49,7 @@ import static android.view.View.VISIBLE;
/**
* Builds notification to reflect the latest state of the stopwatch and recorded laps.
*/
public
class
StopwatchNotificationBuilder
{
class
StopwatchNotificationBuilder
{
public
Notification
build
(
Context
context
,
NotificationModel
nm
,
Stopwatch
stopwatch
)
{
@StringRes
final
int
eventLabel
=
R
.
string
.
label_notification
;
...
...
src/com/android/deskclock/data/TimerNotificationBuilder.java
View file @
219b399b
...
...
@@ -55,7 +55,7 @@ import static android.text.format.DateUtils.SECOND_IN_MILLIS;
/**
* Builds notifications to reflect the latest state of the timers.
*/
public
class
TimerNotificationBuilder
{
class
TimerNotificationBuilder
{
private
static
final
int
REQUEST_CODE_UPCOMING
=
0
;
private
static
final
int
REQUEST_CODE_MISSING
=
1
;
...
...
src/com/android/deskclock/provider/Alarm.java
View file @
219b399b
...
...
@@ -32,7 +32,6 @@ import androidx.loader.content.CursorLoader;
import
com.android.deskclock.R
;
import
com.android.deskclock.data.DataModel
;
import
com.android.deskclock.data.Weekdays
;
import
lineageos.app.ProfileManager
;
import
java.util.Calendar
;
import
java.util.LinkedList
;
...
...
@@ -64,7 +63,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
RINGTONE
,
DELETE_AFTER_USE
,
INCREASING_VOLUME
,
PROFILE
};
private
static
final
String
[]
QUERY_ALARMS_WITH_INSTANCES_COLUMNS
=
{
...
...
@@ -78,7 +76,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
ClockDatabaseHelper
.
ALARMS_TABLE_NAME
+
"."
+
RINGTONE
,
ClockDatabaseHelper
.
ALARMS_TABLE_NAME
+
"."
+
DELETE_AFTER_USE
,
ClockDatabaseHelper
.
ALARMS_TABLE_NAME
+
"."
+
INCREASING_VOLUME
,
ClockDatabaseHelper
.
ALARMS_TABLE_NAME
+
"."
+
PROFILE
,
ClockDatabaseHelper
.
INSTANCES_TABLE_NAME
+
"."
+
ClockContract
.
InstancesColumns
.
ALARM_STATE
,
ClockDatabaseHelper
.
INSTANCES_TABLE_NAME
+
"."
+
ClockContract
.
InstancesColumns
.
_ID
,
...
...
@@ -104,8 +101,8 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
private
static
final
int
LABEL_INDEX
=
6
;
private
static
final
int
RINGTONE_INDEX
=
7
;
private
static
final
int
DELETE_AFTER_USE_INDEX
=
8
;
private
static
final
int
INCREASING_VOLUME_INDEX
=
10
;
private
static
final
int
PROFILE_INDEX
=
11
;
private
static
final
int
INCREASING_VOLUME_INDEX
=
9
;
private
static
final
int
INSTANCE_STATE_INDEX
=
9
;
public
static
final
int
INSTANCE_ID_INDEX
=
10
;
public
static
final
int
INSTANCE_YEAR_INDEX
=
11
;
...
...
@@ -116,7 +113,7 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
public
static
final
int
INSTANCE_LABEL_INDEX
=
16
;
public
static
final
int
INSTANCE_VIBRATE_INDEX
=
17
;
private
static
final
int
COLUMN_COUNT
=
PROFIL
E_INDEX
+
1
;
private
static
final
int
COLUMN_COUNT
=
INCREASING_VOLUM
E_INDEX
+
1
;
private
static
final
int
ALARM_JOIN_INSTANCE_COLUMN_COUNT
=
INSTANCE_VIBRATE_INDEX
+
1
;
public
static
ContentValues
createContentValues
(
Alarm
alarm
)
{
...
...
@@ -133,7 +130,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
values
.
put
(
LABEL
,
alarm
.
label
);
values
.
put
(
DELETE_AFTER_USE
,
alarm
.
deleteAfterUse
);
values
.
put
(
INCREASING_VOLUME
,
alarm
.
increasingVolume
?
1
:
0
);
values
.
put
(
PROFILE
,
alarm
.
profile
.
toString
());
if
(
alarm
.
alert
==
null
)
{
// We want to put null, so default alarm changes
values
.
putNull
(
RINGTONE
);
...
...
@@ -296,7 +292,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
public
Uri
alert
;
public
boolean
deleteAfterUse
;
public
boolean
increasingVolume
;
public
UUID
profile
;
public
int
instanceState
;
public
int
instanceId
;
...
...
@@ -315,7 +310,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
this
.
alert
=
DataModel
.
getDataModel
().
getDefaultAlarmRingtoneUri
();
this
.
deleteAfterUse
=
false
;
this
.
increasingVolume
=
false
;
this
.
profile
=
ProfileManager
.
NO_PROFILE
;
}
public
Alarm
(
Cursor
c
)
{
...
...
@@ -328,7 +322,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
label
=
c
.
getString
(
LABEL_INDEX
);
deleteAfterUse
=
c
.
getInt
(
DELETE_AFTER_USE_INDEX
)
==
1
;
increasingVolume
=
c
.
getInt
(
INCREASING_VOLUME_INDEX
)
==
1
;
profile
=
getProfileFromCursor
(
c
);
if
(
c
.
getColumnCount
()
==
ALARM_JOIN_INSTANCE_COLUMN_COUNT
)
{
instanceState
=
c
.
getInt
(
INSTANCE_STATE_INDEX
);
...
...
@@ -355,7 +348,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
alert
=
p
.
readParcelable
(
null
);
deleteAfterUse
=
p
.
readInt
()
==
1
;
increasingVolume
=
p
.
readInt
()
==
1
;
profile
=
ParcelUuid
.
CREATOR
.
createFromParcel
(
p
).
getUuid
();
}
/**
...
...
@@ -365,17 +357,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
return
getContentUri
(
id
);
}
private
static
UUID
getProfileFromCursor
(
Cursor
c
)
{
if
(!
c
.
isNull
(
PROFILE_INDEX
))
{
try
{
return
UUID
.
fromString
(
c
.
getString
(
PROFILE_INDEX
));
}
catch
(
IllegalArgumentException
ex
)
{
// fall back to no profile
}
}
return
ProfileManager
.
NO_PROFILE
;
}
public
String
getLabelOrDefault
(
Context
context
)
{
return
label
.
isEmpty
()
?
context
.
getString
(
R
.
string
.
default_label
)
:
label
;
}
...
...
@@ -402,7 +383,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
p
.
writeParcelable
(
alert
,
flags
);
p
.
writeInt
(
deleteAfterUse
?
1
:
0
);
p
.
writeInt
(
increasingVolume
?
1
:
0
);
p
.
writeParcelable
(
new
ParcelUuid
(
profile
),
0
);
}
public
int
describeContents
()
{
...
...
@@ -416,7 +396,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
result
.
mLabel
=
label
;
result
.
mRingtone
=
alert
;
result
.
mIncreasingVolume
=
increasingVolume
;
result
.
mProfile
=
profile
;
return
result
;
}
...
...
@@ -498,7 +477,6 @@ public final class Alarm implements Parcelable, ClockContract.AlarmsColumns {
", label='"
+
label
+
'\''
+
", deleteAfterUse="
+
deleteAfterUse
+
", increasingVolume="
+
increasingVolume
+
", profile="
+
profile
+
'}'
;
}
}
src/com/android/deskclock/provider/AlarmInstance.java
View file @
219b399b
...
...
@@ -29,7 +29,6 @@ import com.android.deskclock.LogUtils;
import
com.android.deskclock.R
;
import
com.android.deskclock.alarms.AlarmStateManager
;
import
com.android.deskclock.data.DataModel
;
import
lineageos.app.ProfileManager
;
import
java.util.Calendar
;
import
java.util.LinkedList
;
...
...
@@ -69,8 +68,7 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
RINGTONE
,
ALARM_ID
,
ALARM_STATE
,
INCREASING_VOLUME
,
PROFILE
INCREASING_VOLUME
};
/**
...
...
@@ -89,9 +87,8 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
private
static
final
int
ALARM_ID_INDEX
=
9
;
private
static
final
int
ALARM_STATE_INDEX
=
10
;
private
static
final
int
INCREASING_VOLUME_INDEX
=
11
;
private
static
final
int
PROFILE_INDEX
=
12
;
private
static
final
int
COLUMN_COUNT
=
PROFIL
E_INDEX
+
1
;
private
static
final
int
COLUMN_COUNT
=
INCREASING_VOLUM
E_INDEX
+
1
;
public
static
ContentValues
createContentValues
(
AlarmInstance
instance
)
{
ContentValues
values
=
new
ContentValues
(
COLUMN_COUNT
);
...
...
@@ -116,7 +113,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
values
.
put
(
ALARM_ID
,
instance
.
mAlarmId
);
values
.
put
(
ALARM_STATE
,
instance
.
mAlarmState
);
values
.
put
(
INCREASING_VOLUME
,
instance
.
mIncreasingVolume
?
1
:
0
);
values
.
put
(
PROFILE
,
instance
.
mProfile
.
toString
());
return
values
;
}
...
...
@@ -305,7 +301,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
public
Long
mAlarmId
;
public
int
mAlarmState
;
public
boolean
mIncreasingVolume
;
public
UUID
mProfile
;
public
AlarmInstance
(
Calendar
calendar
,
Long
alarmId
)
{
this
(
calendar
);
...
...
@@ -320,7 +315,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
mRingtone
=
null
;
mAlarmState
=
SILENT_STATE
;
mIncreasingVolume
=
false
;
mProfile
=
ProfileManager
.
NO_PROFILE
;
}
public
AlarmInstance
(
AlarmInstance
instance
)
{
...
...
@@ -336,7 +330,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
this
.
mAlarmId
=
instance
.
mAlarmId
;
this
.
mAlarmState
=
instance
.
mAlarmState
;
this
.
mIncreasingVolume
=
instance
.
mIncreasingVolume
;
this
.
mProfile
=
instance
.
mProfile
;
}
public
AlarmInstance
(
Cursor
c
,
boolean
joinedTable
)
{
...
...
@@ -372,15 +365,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
}
mAlarmState
=
c
.
getInt
(
ALARM_STATE_INDEX
);
mIncreasingVolume
=
c
.
getInt
(
INCREASING_VOLUME_INDEX
)
==
1
;
if
(
c
.
isNull
(
PROFILE_INDEX
))
{
mProfile
=
ProfileManager
.
NO_PROFILE
;
}
else
{
try
{
mProfile
=
UUID
.
fromString
(
c
.
getString
(
PROFILE_INDEX
));
}
catch
(
IllegalArgumentException
ex
)
{
mProfile
=
ProfileManager
.
NO_PROFILE
;
}
}
}
/**
...
...
@@ -497,7 +481,6 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
", mAlarmId="
+
mAlarmId
+
", mAlarmState="
+
mAlarmState
+
", mIncreasingVolume="
+
mIncreasingVolume
+
", mProfile="
+
mProfile
+
'}'
;
}
}
src/com/android/deskclock/provider/ClockContract.java
View file @
219b399b
...
...
@@ -90,12 +90,6 @@ public final class ClockContract {
* <P>Type: BOOLEAN</P>
*/
public
static
final
String
INCREASING_VOLUME
=
"incvol"
;
/**
* Profile to change to when alarm triggers
* <P>Type: STRING</P>
*/
public
static
final
String
PROFILE
=
"profile"
;
}
/**
...
...
src/com/android/deskclock/provider/ClockDatabaseHelper.java
View file @
219b399b
...
...
@@ -28,7 +28,6 @@ import android.text.TextUtils;
import
com.android.deskclock.LogUtils
;
import
com.android.deskclock.data.Weekdays
;
import
lineageos.app.ProfileManager
;
import
java.util.Calendar
;
import
java.util.UUID
;
...
...
@@ -70,13 +69,16 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
*/
private
static
final
int
VERSION_10
=
11
;
/**
* Removed change profile
*/
private
static
final
int
VERSION_11
=
12
;
// This creates a default alarm at 8:30 for every Mon,Tue,Wed,Thu,Fri
private
static
final
String
DEFAULT_ALARM_1
=
"(8, 30, 31, 0, 1, '', NULL, 0, 0, "
+
ProfileManager
.
NO_PROFILE
.
toString
()
+
");"
;
private
static
final
String
DEFAULT_ALARM_1
=
"(8, 30, 31, 0, 1, '', NULL, 0, 0);"
;
// This creates a default alarm at 9:30 for every Sat,Sun
private
static
final
String
DEFAULT_ALARM_2
=
"(9, 00, 96, 0, 1, '', NULL, 0, 0, "
+
ProfileManager
.
NO_PROFILE
.
toString
()
+
");"
;
private
static
final
String
DEFAULT_ALARM_2
=
"(9, 00, 96, 0, 1, '', NULL, 0, 0);"
;
// Database and table names
static
final
String
DATABASE_NAME
=
"alarms.db"
;
...
...
@@ -85,8 +87,8 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
static
final
String
INSTANCES_TABLE_NAME
=
"alarm_instances"
;
private
static
final
String
SELECTED_CITIES_TABLE_NAME
=
"selected_cities"
;
private
static
void
createAlarmsTable
(
SQLiteDatabase
db
)
{
db
.
execSQL
(
"CREATE TABLE "
+
ALARMS_TABLE_NAME
+
" ("
+
private
static
void
createAlarmsTable
(
SQLiteDatabase
db
,
String
alarmsTableName
)
{
db
.
execSQL
(
"CREATE TABLE "
+
alarmsTableName
+
" ("
+
ClockContract
.
AlarmsColumns
.
_ID
+
" INTEGER PRIMARY KEY,"
+
ClockContract
.
AlarmsColumns
.
HOUR
+
" INTEGER NOT NULL, "
+
ClockContract
.
AlarmsColumns
.
MINUTES
+
" INTEGER NOT NULL, "
+
...
...
@@ -96,14 +98,12 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
ClockContract
.
AlarmsColumns
.
LABEL
+
" TEXT NOT NULL, "
+
ClockContract
.
AlarmsColumns
.
RINGTONE
+
" TEXT, "
+
ClockContract
.
AlarmsColumns
.
DELETE_AFTER_USE
+
" INTEGER NOT NULL DEFAULT 0, "
+
ClockContract
.
AlarmsColumns
.
INCREASING_VOLUME
+
" INTEGER NOT NULL DEFAULT 0, "
+
ClockContract
.
AlarmsColumns
.
PROFILE
+
" TEXT NOT NULL DEFAULT '"
+
ProfileManager
.
NO_PROFILE
.
toString
()
+
"');"
);
ClockContract
.
AlarmsColumns
.
INCREASING_VOLUME
+
" INTEGER NOT NULL DEFAULT 0);"
);
LogUtils
.
i
(
"Alarms Table created"
);
}
private
static
void
createInstanceTable
(
SQLiteDatabase
db
)
{
db
.
execSQL
(
"CREATE TABLE "
+
INSTANCES_TABLE_NAME
+
" ("
+
private
static
void
createInstanceTable
(
SQLiteDatabase
db
,
String
instanceTableName
)
{
db
.
execSQL
(
"CREATE TABLE "
+
instanceTableName
+
" ("
+
ClockContract
.
InstancesColumns
.
_ID
+
" INTEGER PRIMARY KEY,"
+
ClockContract
.
InstancesColumns
.
YEAR
+
" INTEGER NOT NULL, "
+
ClockContract
.
InstancesColumns
.
MONTH
+
" INTEGER NOT NULL, "
+
...
...
@@ -117,20 +117,18 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
ClockContract
.
InstancesColumns
.
ALARM_ID
+
" INTEGER REFERENCES "
+
ALARMS_TABLE_NAME
+
"("
+
ClockContract
.
AlarmsColumns
.
_ID
+
") "
+
"ON UPDATE CASCADE ON DELETE CASCADE, "
+
ClockContract
.
InstancesColumns
.
INCREASING_VOLUME
+
" INTEGER NOT NULL DEFAULT 0, "
+
ClockContract
.
InstancesColumns
.
PROFILE
+
" TEXT NOT NULL DEFAULT '"
+
ProfileManager
.
NO_PROFILE
.
toString
()
+
"');"
);
ClockContract
.
InstancesColumns
.
INCREASING_VOLUME
+
" INTEGER NOT NULL DEFAULT 0);"
);
LogUtils
.
i
(
"Instance table created"
);
}
public
ClockDatabaseHelper
(
Context
context
)
{
super
(
context
,
DATABASE_NAME
,
null
,
VERSION_1
0
);
super
(
context
,
DATABASE_NAME
,
null
,
VERSION_1
1
);
}
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
createAlarmsTable
(
db
);
createInstanceTable
(
db
);
createAlarmsTable
(
db
,
ALARMS_TABLE_NAME
);
createInstanceTable
(
db
,
INSTANCES_TABLE_NAME
);
// insert default alarms
LogUtils
.
i
(
"Inserting default alarms"
);
...
...
@@ -144,8 +142,7 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
ClockContract
.
AlarmsColumns
.
LABEL
+
cs
+
ClockContract
.
AlarmsColumns
.
RINGTONE
+
cs
+
ClockContract
.
AlarmsColumns
.
DELETE_AFTER_USE
+
cs
+
ClockContract
.
AlarmsColumns
.
INCREASING_VOLUME
+
cs
+
ClockContract
.
AlarmsColumns
.
PROFILE
+
") VALUES "
;
ClockContract
.
AlarmsColumns
.
INCREASING_VOLUME
+
") VALUES "
;
db
.
execSQL
(
insertMe
+
DEFAULT_ALARM_1
);
db
.
execSQL
(
insertMe
+
DEFAULT_ALARM_2
);
}
...
...
@@ -164,8 +161,8 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
INSTANCES_TABLE_NAME
+
";"
);
// Create new alarms table and copy over the data
createAlarmsTable
(
db
);
createInstanceTable
(
db
);
createAlarmsTable
(
db
,
ALARMS_TABLE_NAME
);
createInstanceTable
(
db
,
INSTANCES_TABLE_NAME
);
LogUtils
.
i
(
"Copying old alarms to new table"
);
final
String
[]
OLD_TABLE_COLUMNS
=
{
...
...
@@ -177,8 +174,7 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
"vibrate"
,
"message"
,
"alert"
,
"incvol"
,
"profile"
"incvol"
};
try
(
Cursor
cursor
=
db
.
query
(
OLD_ALARMS_TABLE_NAME
,
OLD_TABLE_COLUMNS
,
null
,
null
,
null
,
null
,
null
))
{
...
...
@@ -202,16 +198,6 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
}
alarm
.
increasingVolume
=
cursor
.
getInt
(
8
)
==
1
;
if
(
cursor
.
isNull
(
9
))
{
alarm
.
profile
=
ProfileManager
.
NO_PROFILE
;
}
else
{
try
{
alarm
.
profile
=
UUID
.
fromString
(
cursor
.
getString
(
9
));
}
catch
(
IllegalArgumentException
ex
)
{
alarm
.
profile
=
ProfileManager
.
NO_PROFILE
;
}
}
// Save new version of alarm and create alarm instance for it
db
.
insert
(
ALARMS_TABLE_NAME
,
null
,
Alarm
.
createContentValues
(
alarm
));
if
(
alarm
.
enabled
)
{
...
...
@@ -238,11 +224,53 @@ class ClockDatabaseHelper extends SQLiteOpenHelper {
if
(
oldVersion
<
VERSION_10
)
{
db
.
execSQL
(
"ALTER TABLE "
+
ALARMS_TABLE_NAME
+
" ADD COLUMN
"
+
ClockContract
.
AlarmsColumns
.
PROFILE
+
" TEXT NOT NULL DEFAULT '
"
+
ProfileManager
.
NO_PROFILE
+
"
';"
);
+
" ADD COLUMN
profile"
+
" TEXT NOT NULL DEFAULT '';"
);
db
.
execSQL
(
"ALTER TABLE "
+
INSTANCES_TABLE_NAME
+
" ADD COLUMN "
+
ClockContract
.
InstancesColumns
.
PROFILE
+
" TEXT NOT NULL DEFAULT '"
+
ProfileManager
.
NO_PROFILE
+
"';"
);
+
" ADD COLUMN profile"
+
" TEXT NOT NULL DEFAULT '';"
);
}
if
(
oldVersion
<
VERSION_11
)
{
LogUtils
.
i
(
"Copying alarms to temporary table"
);
final
String
TEMP_ALARMS_TABLE_NAME
=
ALARMS_TABLE_NAME
+
"_temp"
;
final
String
TEMP_INSTANCES_TABLE_NAME
=
INSTANCES_TABLE_NAME
+
"_temp"
;
createAlarmsTable
(
db
,
TEMP_ALARMS_TABLE_NAME
);
createInstanceTable
(
db
,
TEMP_INSTANCES_TABLE_NAME
);
final
String
[]
OLD_TABLE_COLUMNS
=
{
ClockContract
.
AlarmsColumns
.
_ID
,
ClockContract
.
AlarmsColumns
.
HOUR
,
ClockContract
.
AlarmsColumns
.
MINUTES
,
ClockContract
.
AlarmsColumns
.
DAYS_OF_WEEK
,
ClockContract
.
AlarmsColumns
.
ENABLED
,
ClockContract
.
AlarmsColumns
.
VIBRATE
,
ClockContract
.
AlarmsColumns
.
LABEL
,
ClockContract
.
AlarmsColumns
.
RINGTONE
,
ClockContract
.
AlarmsColumns
.
DELETE_AFTER_USE
,
ClockContract
.
AlarmsColumns
.
INCREASING_VOLUME
};
try
(
Cursor
cursor
=
db
.
query
(
ALARMS_TABLE_NAME
,
OLD_TABLE_COLUMNS
,
null
,
null
,
null
,
null
,
null
))
{
final
Calendar
currentTime
=
Calendar
.
getInstance
();
while
(
cursor
!=
null
&&
cursor
.
moveToNext
())
{
final
Alarm
alarm
=
new
Alarm
(
cursor
);
// Save new version of alarm and create alarm instance for it
db
.
insert
(
TEMP_ALARMS_TABLE_NAME
,
null
,
Alarm
.
createContentValues
(
alarm
));
if
(
alarm
.
enabled
)
{
AlarmInstance
newInstance
=
alarm
.
createInstanceAfter
(
currentTime
);
db
.
insert
(
TEMP_INSTANCES_TABLE_NAME
,
null
,
AlarmInstance
.
createContentValues
(
newInstance
));
}
}
}
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
ALARMS_TABLE_NAME
+
";"
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
INSTANCES_TABLE_NAME
+
";"
);
db
.
execSQL
(
"ALTER TABLE "
+
TEMP_ALARMS_TABLE_NAME
+
" RENAME TO "
+
ALARMS_TABLE_NAME
+
";"
);
db
.
execSQL
(
"ALTER TABLE "
+
TEMP_INSTANCES_TABLE_NAME
+
" RENAME TO "
+
INSTANCES_TABLE_NAME
+
";"
);
}
}
...
...
src/com/android/deskclock/provider/ClockProvider.java
View file @
219b399b
...
...
@@ -77,8 +77,6 @@ public class ClockProvider extends ContentProvider {
ALARMS_TABLE_NAME
+
"."
+
AlarmsColumns
.
DELETE_AFTER_USE
);
sAlarmsWithInstancesProjection
.
put
(
ALARMS_TABLE_NAME
+
"."
+
AlarmsColumns
.
INCREASING_VOLUME
,
ALARMS_TABLE_NAME
+
"."
+
AlarmsColumns
.
INCREASING_VOLUME
);
sAlarmsWithInstancesProjection
.
put
(
ALARMS_TABLE_NAME
+
"."
+
AlarmsColumns
.
PROFILE
,
ALARMS_TABLE_NAME
+
"."
+
AlarmsColumns
.
PROFILE
);
sAlarmsWithInstancesProjection
.
put
(
INSTANCES_TABLE_NAME
+
"."
+
InstancesColumns
.
ALARM_STATE
,
INSTANCES_TABLE_NAME
+
"."
+
InstancesColumns
.
ALARM_STATE
);
...
...
src/com/android/deskclock/settings/AlarmVolumePreference.java
View file @
219b399b
...
...
@@ -61,10 +61,10 @@ public class AlarmVolumePreference extends Preference {
// Disable click feedback for this preference.
holder
.
itemView
.
setClickable
(
false
);
mSeekbar
=
(
SeekBar
)
holder
.
findViewById
(
com
.
android
.
internal
.
R
.
id
.
seekbar
);
mSeekbar
=
(
SeekBar
)
holder
.
findViewById
(
R
.
id
.
seekbar
);
mSeekbar
.
setMax
(
audioManager
.
getStreamMaxVolume
(
STREAM_ALARM
));
mSeekbar
.
setProgress
(
audioManager
.
getStreamVolume
(
STREAM_ALARM
));
mAlarmIcon
=
(
ImageView
)
holder
.
findViewById
(
com
.
android
.
internal
.
R
.
id
.
icon
);
mAlarmIcon
=
(
ImageView
)
holder
.
findViewById
(
android
.
R
.
id
.
icon
);
onSeekbarChanged
();
...
...
src/com/android/deskclock/timer/TimerFragment.java
View file @
219b399b
...
...
@@ -687,6 +687,11 @@ public final class TimerFragment extends DeskClockFragment {
}
private
Timer
getTimer
()
{
if
(
mAdapter
==
null
)
{
TimerPagerAdapter
adapter
=
new
TimerPagerAdapter
(
getFragmentManager
());
return
adapter
.
getCount
()
==
0
?
null
:
adapter
.
getTimer
(
0
);
}
if
(
mViewPager
==
null
)
{
return
null
;
}
...
...
src/com/android/deskclock/timer/TimerPagerAdapter.java
View file @
219b399b
...
...
@@ -137,7 +137,10 @@ class TimerPagerAdapter extends PagerAdapter implements TimerListener {
if
(
mCurrentTransaction
!=
null
)
{
mCurrentTransaction
.
commitAllowingStateLoss
();
mCurrentTransaction
=
null
;
mFragmentManager
.
executePendingTransactions
();
if
(!
mFragmentManager
.
isDestroyed
())
{
mFragmentManager
.
executePendingTransactions
();
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment