/*
* Copyright (C) 2007 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.
*/
package net.sunyidingophone.environmental;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.SeekBar.OnSeekBarChangeListener;
/**
* Demonstrates how to use a seek bar
*/
public class AudioConsole extends Activity implements OnSeekBarChangeListener
{
AudioWrapper mAudioWrapper = null;
TextView title, call_title, system_title, ring_title, music_title, alarm_title, notify_title, total, infor = null;
TextView call_infor, system_infor, ring_infor, music_infor, alarm_infor, notify_infor = null;
TextView call_level, system_level, ring_level, music_level, alarm_level, notify_level = null;
SeekBar mCallSeekBar, mSysSeekBar, mRingSeekBar, mMusicSeekBar, mAlarmSeekBar, mNotifySeekBar = null;
int oldVol, newVol = 0;
TextView textArray[] = {
call_level,
system_level,
ring_level,
music_level,
alarm_level,
notify_level
};
SeekBar seekbarArray[] = {
mCallSeekBar,
mSysSeekBar,
mRingSeekBar,
mMusicSeekBar,
mAlarmSeekBar,
mNotifySeekBar
};
private BroadcastReceiver mRingVolReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context arg0, Intent intent)
{
String action = intent.getAction();
if(action.equals(AudioManager.ACTION_AUDIO_BECOMING_SILENT))
{
int streamType = intent.getIntExtra(AudioManager.EXTRA_ACTIVE_STREAM_TYPE, -1);
if (streamType == AudioManager.STREAM_SYSTEM)
{
updateRingProgress();
}
}
}
};
public void updateRingProgress()
{
mAudioWrapper = new AudioWrapper(this);
int curvol = mAudioWrapper.getCurVolume(2);
int maxvol = mAudioWrapper.getMaxVolume(2);
int progress = (int)((float)curvol/(float)maxvol*100.0);
mRingSeekBar.setProgress(progress);
ring_level.setText(curvol + "/" + maxvol);
setTextColor();
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.audio_console);
IntentFilter filter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_SILENT);
registerReceiver(mRingVolReceiver, filter);
mAudioWrapper = new AudioWrapper(this);
mCallSeekBar = (SeekBar)findViewById(R.id.call_seek);
mSysSeekBar = (SeekBar)findViewById(R.id.system_seek);
mRingSeekBar = (SeekBar)findViewById(R.id.ring_seek);
mMusicSeekBar = (SeekBar)findViewById(R.id.music_seek);
mAlarmSeekBar = (SeekBar)findViewById(R.id.alarm_seek);
mNotifySeekBar = (SeekBar)findViewById(R.id.notification_seek);
call_title = (TextView)this.findViewById(R.id.call_title);
call_infor = (TextView)this.findViewById(R.id.call_infor);
call_level = (TextView)this.findViewById(R.id.call_level);
system_title = (TextView)this.findViewById(R.id.system_title);
system_infor = (TextView)this.findViewById(R.id.system_infor);
system_level = (TextView)this.findViewById(R.id.system_level);
ring_title = (TextView)this.findViewById(R.id.ring_title);
ring_infor = (TextView)this.findViewById(R.id.ring_infor);
ring_level = (TextView)this.findViewById(R.id.ring_level);
music_title = (TextView)this.findViewById(R.id.music_title);
music_infor = (TextView)this.findViewById(R.id.music_infor);
music_level = (TextView)this.findViewById(R.id.music_level);
alarm_title = (TextView)this.findViewById(R.id.alarm_title);
alarm_infor = (TextView)this.findViewById(R.id.alarm_infor);
alarm_level = (TextView)this.findViewById(R.id.alarm_level);
notify_title = (TextView)this.findViewById(R.id.notification_title);
notify_infor = (TextView)this.findViewById(R.id.notification_infor);
notify_level = (TextView)this.findViewById(R.id.notification_level);
mCallSeekBar.setOnSeekBarChangeListener(this);
mSysSeekBar.setOnSeekBarChangeListener(this);
mRingSeekBar.setOnSeekBarChangeListener(this);
mMusicSeekBar.setOnSeekBarChangeListener(this);
mAlarmSeekBar.setOnSeekBarChangeListener(this);
mNotifySeekBar.setOnSeekBarChangeListener(this);
call_title.setText("VOICECALL VOLUME");
call_infor.setText("Control incoming call volume levels");
call_level.setText(mAudioWrapper.getCurVolume(0) + "/" + mAudioWrapper.getMaxVolume(0));
system_title.setText("SYSTEM VOLUME");
system_infor.setText("Control system volume levels");
system_level.setText(mAudioWrapper.getCurVolume(1) + "/" + mAudioWrapper.getMaxVolume(1));
ring_title.setText("RINGER VOLUME");
ring_infor.setText("Control incomging call volume levels");
ring_level.setText(mAudioWrapper.getCurVolume(2) + "/" + mAudioWrapper.getMaxVolume(2));
music_title.setText("MUSIC VOLUME");
music_infor.setText("Control media player volume levels");
music_level.setText(mAudioWrapper.getCurVolume(3) + "/" + mAudioWrapper.getMaxVolume(3));
alarm_title.setText("ALARM VOLUME");
alarm_infor.setText("Control alarm volume levels");
alarm_level.setText(mAudioWrapper.getCurVolume(4) + "/" + mAudioWrapper.getMaxVolume(4));
notify_title.setText("NOTIFICATION VOLUME");
notify_infor.setText("Control notification volume levels");
notify_level.setText(mAudioWrapper.getCurVolume(5) + "/" + mAudioWrapper.getMaxVolume(5));
updateProgress();
setTextColor();
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch)
{
updateVolume(seekBar, (float)progress);
}
public void onStartTrackingTouch(SeekBar seekBar)
{
if(seekBar == mCallSeekBar)
oldVol = mAudioWrapper.getCurVolume(0);
else if(seekBar == mSysSeekBar)
oldVol = mAudioWrapper.getCurVolume(1);
else if(seekBar == mRingSeekBar)
oldVol = mAudioWrapper.getCurVolume(2);
else if(seekBar == mMusicSeekBar)
oldVol = mAudioWrapper.getCurVolume(3);
else if(seekBar == mAlarmSeekBar)
oldVol = mAudioWrapper.getCurVolume(4);
else
oldVol = mAudioWrapper.getCurVolume(5);
}
public void onStopTrackingTouch(SeekBar seekBar)
{
setTextColor();
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.audio_toast_layout, (ViewGroup) findViewById(R.id.audio_toast_layout));
ImageView image = (ImageView) layout.findViewById(R.id.image);
TextView text
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
环保卫士是一款手机环保软件,通过该软件用户可以查看目前手机的环保指数(目前分为5级),主要对您手机的噪声,通话,能量部分进行有效的管理,同时通过一些行为来使自己的手机更加环保,从而达到低炭生活,同时软件定期会发布一些环保小贴士,宣传环保理念,指导用户怎么样更加高效的低炭生活.软件分为噪声管理,能量管理,通话质量管理,环保小贴士,四大功能,通过这些功能来管理手机以及用户的环保行为.使我们的地球更加绿色. 源码供大家参考,互相学习。
资源推荐
资源详情
资源评论
收起资源包目录
Environmental.zip (87个子文件)
.project 849B
default.properties 364B
bin
resources.ap_ 484KB
AndroidManifest.xml 4KB
src
net
sunyidingophone
environmental
BatteryWrapper.java 3KB
WidgetUpdateService.java 7KB
AudioWrapper.java 6KB
CallLogEntry.java 852B
EnvironmentalMain.java 3KB
Locationlistens.java 1KB
EfficientAdapter2.java 5KB
WidgetTipContainer.java 5KB
EnvironmentalTipMain.java 6KB
CallWrapper.java 7KB
CallListReport.java 3KB
WidgetTip.java 1KB
Sensorlistens.java 1KB
DBTest.java 5KB
LocationWrapper.java 1KB
DBWrapper.java 5KB
PublishedTips.java 6KB
LocationAction.java 4KB
EnergyWrapper.java 8KB
EnergyConsole.java 14KB
AudioConsole.java 17KB
EnergyRating.java 3KB
CallConsole.java 2KB
AudioRating.java 3KB
MiniEnvironmentalWidget.java 2KB
CallRating.java 3KB
SensorWrapper.java 2KB
EfficientAdapter.java 5KB
res
values
arrays.xml 1KB
text_style.xml 1KB
strings.xml 7KB
values-en
arrays.xml 1KB
strings.xml 8KB
layout
about.xml 604B
audio_toast_layout.xml 1KB
audio_console.xml 12KB
location_action.xml 1KB
minienvironmental.xml 1KB
energy_console.xml 8KB
rating_detail.xml 1KB
tipmain.xml 965B
list_item_icon_text.xml 1KB
list_item_icon_text2.xml 1KB
xml
minisetting.xml 250B
values-zh-rCN
arrays.xml 1KB
strings.xml 8KB
drawable
ring_icon.png 9KB
mo_call.png 6KB
battery_0.png 30KB
tree_icon.png 6KB
battery_40.png 36KB
rating_e.png 4KB
main_icon.png 6KB
fire_icon.png 6KB
mt_call.png 6KB
rating_b.png 7KB
icon48x48_1.png 5KB
icon48x48_2.png 3KB
widget_frame.png 6KB
icon_call.png 16KB
icon_tips.png 14KB
seekbar_frame.png 1KB
rating_c.png 7KB
call_icon.png 6KB
alarm_icon.png 10KB
music_icon.png 6KB
my_green_progress.xml 955B
icon_energy.png 23KB
battery_80.png 35KB
icon_about.png 13KB
rating_d.png 6KB
battery_20.png 37KB
battery_10.png 34KB
icon_audio.png 19KB
battery_100.png 33KB
battery_00.png 35KB
notification_icon.png 5KB
battery_60.png 35KB
battery_50.png 35KB
system_icon.png 6KB
rating_a.png 7KB
.classpath 280B
gen
net
sunyidingophone
environmental
R.java 13KB
assets
共 87 条
- 1
资源评论
robbit2002
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功