Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-AlarmClock: Commit

packages/apps/AlarmClock


Commit MetaInfo

Revision84a2c78bf380df8e84973d6bbbcae6173addd8c5 (tree)
Time2010-04-16 20:13:07
AuthorWallace Wang <wallage@qq.c...>
CommiterChih-Wei Huang

Log Message

set alarm volume adjustable and disable the vibrate

Change Summary

Incremental Difference

--- a/src/com/android/alarmclock/AlarmAlert.java
+++ b/src/com/android/alarmclock/AlarmAlert.java
@@ -67,6 +67,7 @@ public class AlarmAlert extends Activity {
6767 @Override
6868 protected void onCreate(Bundle icicle) {
6969 super.onCreate(icicle);
70+ AlarmClock.setVolumeControlForPlatform(this);
7071
7172 mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
7273
--- a/src/com/android/alarmclock/AlarmClock.java
+++ b/src/com/android/alarmclock/AlarmClock.java
@@ -44,6 +44,8 @@ import android.widget.CursorAdapter;
4444 import android.widget.ListView;
4545 import android.widget.TextView;
4646 import android.widget.CheckBox;
47+import android.os.SystemProperties;
48+import android.media.AudioManager;
4749
4850 import java.util.Calendar;
4951 import java.text.DateFormatSymbols;
@@ -70,6 +72,7 @@ public class AlarmClock extends Activity implements OnItemClickListener {
7072 private View mClock = null;
7173 private ListView mAlarmsList;
7274 private Cursor mCursor;
75+ private static boolean volumeAdjustable;
7376
7477 private String mAm, mPm;
7578
@@ -198,6 +201,8 @@ public class AlarmClock extends Activity implements OnItemClickListener {
198201 @Override
199202 protected void onCreate(Bundle icicle) {
200203 super.onCreate(icicle);
204+ volumeAdjustable=SystemProperties.getBoolean("ro.alarm.volume.adjustable",false);
205+ AlarmClock.setVolumeControlForPlatform(this);
201206
202207 String[] ampm = new DateFormatSymbols().getAmPmStrings();
203208 mAm = ampm[0];
@@ -380,4 +385,15 @@ public class AlarmClock extends Activity implements OnItemClickListener {
380385 private void saveClockVisibility() {
381386 mPrefs.edit().putBoolean(PREF_SHOW_CLOCK, getClockVisibility()).commit();
382387 }
388+ public static void setVolumeControlForPlatform(Activity context) {
389+ if (isVolumeAdjustable()) {
390+ context.setVolumeControlStream(AudioManager.STREAM_ALARM);
391+ } else {
392+ // Use default stream type,the default type use a fixed volume
393+ context.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
394+ }
395+ }
396+ public static boolean isVolumeAdjustable(){
397+ return volumeAdjustable;
398+ }
383399 }
--- a/src/com/android/alarmclock/ClockPicker.java
+++ b/src/com/android/alarmclock/ClockPicker.java
@@ -45,6 +45,7 @@ public class ClockPicker extends Activity implements
4545 public void onCreate(Bundle icicle) {
4646 super.onCreate(icicle);
4747 requestWindowFeature(Window.FEATURE_NO_TITLE);
48+ AlarmClock.setVolumeControlForPlatform(this);
4849
4950 mFactory = LayoutInflater.from(this);
5051 setContentView(R.layout.clockpicker);
--- a/src/com/android/alarmclock/SetAlarm.java
+++ b/src/com/android/alarmclock/SetAlarm.java
@@ -66,6 +66,7 @@ public class SetAlarm extends PreferenceActivity
6666 @Override
6767 protected void onCreate(Bundle icicle) {
6868 super.onCreate(icicle);
69+ AlarmClock.setVolumeControlForPlatform(this);
6970
7071 addPreferencesFromResource(R.xml.alarm_prefs);
7172
@@ -83,6 +84,7 @@ public class SetAlarm extends PreferenceActivity
8384 mTimePref = findPreference("time");
8485 mAlarmPref = (AlarmPreference) findPreference("alarm");
8586 mVibratePref = (CheckBoxPreference) findPreference("vibrate");
87+ mVibratePref.setEnabled(!AlarmClock.isVolumeAdjustable());
8688 mRepeatPref = (RepeatPreference) findPreference("setRepeat");
8789
8890 Intent i = getIntent();
@@ -99,7 +101,7 @@ public class SetAlarm extends PreferenceActivity
99101 mHour = alarm.hour;
100102 mMinutes = alarm.minutes;
101103 mRepeatPref.setDaysOfWeek(alarm.daysOfWeek);
102- mVibratePref.setChecked(alarm.vibrate);
104+ mVibratePref.setChecked(alarm.vibrate && !AlarmClock.isVolumeAdjustable());
103105 // Give the alert uri to the preference.
104106 mAlarmPref.setAlert(alarm.alert);
105107 updateTime();
--- a/src/com/android/alarmclock/SettingsActivity.java
+++ b/src/com/android/alarmclock/SettingsActivity.java
@@ -45,6 +45,7 @@ public class SettingsActivity extends PreferenceActivity
4545 protected void onCreate(Bundle savedInstanceState) {
4646 super.onCreate(savedInstanceState);
4747 addPreferencesFromResource(R.xml.settings);
48+ AlarmClock.setVolumeControlForPlatform(this);
4849 }
4950
5051 @Override
Show on old repository browser