Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-DeskClock: Commit

packages/apps/DeskClock


Commit MetaInfo

Révisionc1a90e6b1607eaf15cacbc329ce51dec56ceb2fe (tree)
l'heure2010-04-18 00:13:01
AuteurWallace Wang <wallage@qq.c...>
CommiterChih-Wei Huang

Message de Log

set alarm volume adjustable and disable vibrate for platform

Change Summary

Modification

--- a/src/com/android/deskclock/AlarmAlert.java
+++ b/src/com/android/deskclock/AlarmAlert.java
@@ -67,7 +67,7 @@ public class AlarmAlert extends Activity {
6767 @Override
6868 protected void onCreate(Bundle icicle) {
6969 super.onCreate(icicle);
70-
70+ AlarmClock.setVolumeControlForPlatform(this);
7171 mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
7272
7373 // Get the volume/camera button behavior setting
--- a/src/com/android/deskclock/AlarmClock.java
+++ b/src/com/android/deskclock/AlarmClock.java
@@ -48,6 +48,8 @@ import android.widget.ImageButton;
4848 import android.widget.ImageView;
4949 import android.widget.ListView;
5050 import android.widget.TextView;
51+import android.os.SystemProperties;
52+import android.media.AudioManager;
5153
5254 import java.util.Calendar;
5355
@@ -66,6 +68,7 @@ public class AlarmClock extends Activity implements OnItemClickListener {
6668 private LayoutInflater mFactory;
6769 private ListView mAlarmsList;
6870 private Cursor mCursor;
71+ private static boolean volumeAdjustable;
6972
7073 private void updateIndicatorAndAlarm(boolean enabled, ImageView bar,
7174 Alarm alarm) {
@@ -199,6 +202,8 @@ public class AlarmClock extends Activity implements OnItemClickListener {
199202 @Override
200203 protected void onCreate(Bundle icicle) {
201204 super.onCreate(icicle);
205+ volumeAdjustable=SystemProperties.getBoolean("ro.alarm.volume.adjustable",false);
206+ AlarmClock.setVolumeControlForPlatform(this);
202207
203208 mFactory = LayoutInflater.from(this);
204209 mPrefs = getSharedPreferences(PREFERENCES, 0);
@@ -324,4 +329,16 @@ public class AlarmClock extends Activity implements OnItemClickListener {
324329 intent.putExtra(Alarms.ALARM_ID, (int) id);
325330 startActivity(intent);
326331 }
332+
333+ public static void setVolumeControlForPlatform(Activity context){
334+ if (isVolumeAdjustable()){
335+ context.setVolumeControlStream(AudioManager.STREAM_ALARM);
336+ }else{
337+ //Use default stream type,the default type use a fixed volume
338+ context.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
339+ }
340+ }
341+ public static boolean isVolumeAdjustable(){
342+ return volumeAdjustable;
343+ }
327344 }
--- a/src/com/android/deskclock/DeskClock.java
+++ b/src/com/android/deskclock/DeskClock.java
@@ -785,6 +785,7 @@ public class DeskClock extends Activity {
785785 @Override
786786 protected void onCreate(Bundle icicle) {
787787 super.onCreate(icicle);
788+ AlarmClock.setVolumeControlForPlatform(this);
788789
789790 mRNG = new Random();
790791
--- a/src/com/android/deskclock/SetAlarm.java
+++ b/src/com/android/deskclock/SetAlarm.java
@@ -67,6 +67,7 @@ public class SetAlarm extends PreferenceActivity
6767 @Override
6868 protected void onCreate(Bundle icicle) {
6969 super.onCreate(icicle);
70+ AlarmClock.setVolumeControlForPlatform(this);
7071
7172 addPreferencesFromResource(R.xml.alarm_prefs);
7273
@@ -85,6 +86,7 @@ public class SetAlarm extends PreferenceActivity
8586 mTimePref = findPreference("time");
8687 mAlarmPref = (AlarmPreference) findPreference("alarm");
8788 mVibratePref = (CheckBoxPreference) findPreference("vibrate");
89+ mVibratePref.setEnabled(!AlarmClock.isVolumeAdjustable());
8890 mRepeatPref = (RepeatPreference) findPreference("setRepeat");
8991
9092 Intent i = getIntent();
@@ -101,7 +103,7 @@ public class SetAlarm extends PreferenceActivity
101103 mHour = alarm.hour;
102104 mMinutes = alarm.minutes;
103105 mRepeatPref.setDaysOfWeek(alarm.daysOfWeek);
104- mVibratePref.setChecked(alarm.vibrate);
106+ mVibratePref.setChecked(alarm.vibrate && !AlarmClock.isVolumeAdjustable());
105107 // Give the alert uri to the preference.
106108 mAlarmPref.setAlert(alarm.alert);
107109 updateTime();
--- a/src/com/android/deskclock/SettingsActivity.java
+++ b/src/com/android/deskclock/SettingsActivity.java
@@ -44,6 +44,7 @@ public class SettingsActivity extends PreferenceActivity
4444 @Override
4545 protected void onCreate(Bundle savedInstanceState) {
4646 super.onCreate(savedInstanceState);
47+ AlarmClock.setVolumeControlForPlatform(this);
4748 addPreferencesFromResource(R.xml.settings);
4849 }
4950
Afficher sur ancien navigateur de dépôt.