- Copy some framework resources into the app.
- Add a new layout to SetAlarm to avoid using an internal id to obtain the
content view.
- Use a string literal to identify the ALARM_CHANGED intent. This is not ideal
but is better than exposing the actual intent string for now.
LOCAL_OVERRIDES_PACKAGES := AlarmClock
+LOCAL_SDK_VERSION := current
+
include $(BUILD_PACKAGE)
<item android:state_pressed="false"
android:drawable="@android:color/background_dark" />
<item android:state_pressed="true"
- android:drawable="@*android:drawable/list_selector_background_pressed" />
+ android:drawable="@drawable/list_selector_background_pressed" />
</selector>
android:layout_height="1dip"
android:scaleType="fitXY"
android:gravity="fill_horizontal"
- android:src="@*android:drawable/dialog_divider_horizontal_light"
+ android:src="@drawable/dialog_divider_horizontal_light"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"/>
</com.android.deskclock.DontPressWithParentLayout>
<ImageView
- android:src="@*android:drawable/divider_vertical_dark"
+ android:src="@drawable/divider_vertical_dark"
android:background="?android:attr/windowBackground"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="top"
android:paddingTop="6dip"
android:paddingRight="10dip"
- android:src="@*android:drawable/ic_dialog_time"/>
+ android:src="@drawable/ic_dialog_time"/>
<TextView android:id="@+id/header_time"
style="?android:attr/textAppearanceLarge"
+++ /dev/null
-<?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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- style="@android:style/ButtonBar">
-
- <Button android:id="@+id/alarm_save"
- android:focusable="true"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/done"/>
-
- <Button android:id="@+id/alarm_cancel"
- android:focusable="true"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/revert"/>
-
- <Button android:id="@+id/alarm_delete"
- android:focusable="true"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:text="@string/delete"/>
-
-</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2010, 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:drawSelectorOnTop="false"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ style="@android:style/ButtonBar">
+
+ <Button android:id="@+id/alarm_save"
+ android:focusable="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/done"/>
+
+ <Button android:id="@+id/alarm_cancel"
+ android:focusable="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/revert"/>
+
+ <Button android:id="@+id/alarm_delete"
+ android:focusable="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/delete"/>
+
+ </LinearLayout>
+
+</LinearLayout>
respond. This is a sign of an error; if the weather widget is not
present on the device, we show nothing at all. -->
<string name="weather_fetch_failure">Weather information currently unavailable.</string>
+
+ <!-- String matching the lock screen format for displaying the date. -->
+ <string name="full_wday_month_day_no_year" translatable="false">EEEE, MMMM d</string>
</resources>
@Override
public void onCreate() {
- mVibrator = new Vibrator();
+ mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Listen for incoming calls to kill the alarm.
mTelephonyManager =
(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// Must reset the media player to clear the error state.
mMediaPlayer.reset();
setDataSourceFromResource(getResources(), mMediaPlayer,
- com.android.internal.R.raw.fallbackring);
+ R.raw.fallbackring);
startAlarm(mMediaPlayer);
} catch (Exception ex2) {
// At this point we just don't play anything.
* Tells the StatusBar whether the alarm is enabled or disabled
*/
private static void setStatusBarIcon(Context context, boolean enabled) {
- Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED);
+ Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED");
alarmChanged.putExtra("alarmSet", enabled);
context.sendBroadcast(alarmChanged);
}
// reload the date format in case the user has changed settings
// recently
- mDateFormat = getString(com.android.internal.R.string.full_wday_month_day_no_year);
+ mDateFormat = getString(R.string.full_wday_month_day_no_year);
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
- mContext.registerReceiver(mIntentReceiver, filter);
+ getContext().registerReceiver(mIntentReceiver, filter);
}
/* monitor 12/24-hour display preference */
mFormatChangeObserver = new FormatChangeObserver();
- mContext.getContentResolver().registerContentObserver(
+ getContext().getContentResolver().registerContentObserver(
Settings.System.CONTENT_URI, true, mFormatChangeObserver);
updateTime();
mAttached = false;
if (mLive) {
- mContext.unregisterReceiver(mIntentReceiver);
+ getContext().unregisterReceiver(mIntentReceiver);
}
- mContext.getContentResolver().unregisterContentObserver(
+ getContext().getContentResolver().unregisterContentObserver(
mFormatChangeObserver);
}
}
private void setDateFormat() {
- mFormat = Alarms.get24HourMode(mContext) ? Alarms.M24 : M12;
+ mFormat = Alarms.get24HourMode(getContext()) ? Alarms.M24 : M12;
mAmPm.setShowAmPm(mFormat == M12);
}
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ // Override the default content view.
+ setContentView(R.layout.set_alarm);
+
addPreferencesFromResource(R.xml.alarm_prefs);
// Get each preference so we can retrieve the value later.
// their own.
getListView().setItemsCanFocus(true);
- // Grab the content view so we can modify it.
- FrameLayout content = (FrameLayout) getWindow().getDecorView()
- .findViewById(com.android.internal.R.id.content);
-
- // Get the main ListView and remove it from the content view.
- ListView lv = getListView();
- content.removeView(lv);
-
- // Create the new LinearLayout that will become the content view and
- // make it vertical.
- LinearLayout ll = new LinearLayout(this);
- ll.setOrientation(LinearLayout.VERTICAL);
-
- // Have the ListView expand to fill the screen minus the save/cancel
- // buttons.
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LayoutParams.MATCH_PARENT,
- LayoutParams.WRAP_CONTENT);
- lp.weight = 1;
- ll.addView(lv, lp);
-
- // Inflate the buttons onto the LinearLayout.
- View v = LayoutInflater.from(this).inflate(
- R.layout.save_cancel_alarm, ll);
-
// Attach actions to each button.
- Button b = (Button) v.findViewById(R.id.alarm_save);
+ Button b = (Button) findViewById(R.id.alarm_save);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Enable the alarm when clicking "Done"
finish();
}
});
- b = (Button) v.findViewById(R.id.alarm_cancel);
+ b = (Button) findViewById(R.id.alarm_cancel);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
- b = (Button) v.findViewById(R.id.alarm_delete);
+ b = (Button) findViewById(R.id.alarm_delete);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
deleteAlarm();
}
});
-
- // Replace the old content view with our new one.
- setContentView(ll);
}
@Override