android4.0修改bug系列一

1.修改workspace和AppGridView中字体显示不全的问题

(1)packages/apps/Launcher2/src/com/android/launcher2/BubbleTextView.java是表示workspace里面的app,是继承TextView,设置图标和应用名。

packages/apps/Launcher2/res/values-sw600dp/styles.xml中加入以下标记的两行,则修改workspace中应用名为两行。

 <style name="WorkspaceIcon.Landscape">
         <item name="android:drawablePadding">0dp</item>
         <item name="android:paddingLeft">4dp</item>
         <item name="android:paddingRight">4dp</item>
         <item name="android:paddingTop">@dimen/app_icon_padding_top</item>
         <item name="android:paddingBottom">0dp</item>
         <item name="android:singleLine">false</item>
         <item name="android:maxLines">2</item>
         <item name="android:textSize">13sp</item>
     </style>
(2)
packages/apps/Launcher2/src/com/android/launcher2/PagedViewIcon.java是表示AppGridView里面的appview,也是继承与TextView

packages/apps/Launcher2/res/values-sw600dp/styles.xml中加入以下标记的两行,则修改AppGridView中应用名为两行。
    <style name=" WorkspaceIcon.Portrait.AppsCustomize">竖屏的时候
        <item name="android:background">@null</item>
        <item name="android:paddingTop">0dp</item>
        <item name="android:paddingBottom">0dp</item>
        <item name="android:paddingLeft">0dp</item>
        <item name="android:paddingRight">0dp</item>
        <item name="android:drawablePadding">4dp</item>
  <item name="android:singleLine">false</item>
        <item name="android:textSize">13sp</item>
    </style>
    <style name=" WorkspaceIcon.Landscape.AppsCustomize">横屏的时候
        <item name="android:background">@null</item>
        <item name="android:paddingTop">0dp</item>
        <item name="android:paddingBottom">0dp</item>
        <item name="android:drawablePadding">0dp</item>
        <item name="android:textSize">13sp</item>
        <item name="android:singleLine">false</item>

        <item name="android:maxLines">2</item>
    </style>

2.修改闹钟内容
(1)闹钟响起的时候,触摸任意位置就暂停再响
定义一个boolean myclockflag=true;
在updateLayout()函数中
private void updateLayout() {
119         LayoutInflater inflater = LayoutInflater.from(this);
120
121         setContentView(inflater.inflate(getLayoutResId(), null));
122
123         /* snooze behavior: pop a snooze confirmation view, kick alarm
124            manager. */
125         Button snooze = (Button) findViewById(R.id.snooze);
126         snooze.requestFocus();
127         snooze.setOnClickListener(new Button.OnClickListener() {
128             public void onClick(View v) {
129                  myclockflag=true;点击了暂停
130                 snooze();
131                 
132             }
133         });
134
135         /* dismiss button: close notification */
136         findViewById(R.id.dismiss).setOnClickListener(
137                 new Button.OnClickListener() {
138                     public void onClick(View v) {
139                          myclockflag=false;    点击了取消
140                         dismiss(false);
141                     }
142                 });
143
144         /* Set the title from the passed in alarm */
145         setTitle();
146     }

  public void onDestroy() {
246         super.onDestroy();
247 //        if (Log.LOGV) Log.v("AlarmAlert.onDestroy()");
248         if(myclockflag) 这是一个dialog形式的activity,只要点击其他地方,就会被终止,所以最关键是这部。
249        {
250            snooze();  这是一个暂停再响的函数
251        }
252         // No longer care about the alarm being killed.
253         unregisterReceiver(mReceiver);
254     }


(2)闹钟响起的时候,不会弹出对话框,显示取消和暂停
在private void handleIntent(Context context, Intent intent)中
加入 context.startActivity(alarmAlert);即可

(3)设置闹钟后,发一个通知
packages/apps/DeskClock/src/com/android/deskclock/AlarmClock.java中

 View doneButton = findViewById(R.id.done);
        if (doneButton != null) {
            doneButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                                createnotifcation();//点击完成时弹出通知
                    finish();
                }
            });
        }

  private void createnotifcation()  //弹出通知的函数实现
    {


        final AlarmTimeAdapter adapter2 = new AlarmTimeAdapter(this, mCursor);


        NM=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        Notification clocknf=new Notification(R.drawable.ic_clock_alarm_on,getString(R.string.clocksucess), System.currentTimeMillis());
        if(adapter2.isEmpty())
        {
                if(hasShowNotification)
                {
                        NM.cancel(1);
                }
                hasShowNotification = false;
        }
        else
        {
                Log.i("shao", "adapter2.getCount()--"+adapter2.getCount());
                for(int i=0;i<adapter2.getCount();i++)
                {
                        Alarm aa=new Alarm((Cursor)(adapter2.getItem(i)));
                        if(!aa.enabled)
                        {
                                count++;
                        }
                }
                if(count<adapter2.getCount())
                {
                        clocknf.flags=Notification.FLAG_ONGOING_EVENT;
                Intent myintent=new Intent(getApplicationContext(),AlarmClock.class);
                myintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                PendingIntent contentintent=PendingIntent.getActivity(getApplicationContext(), 0, myintent, PendingIntent.FLAG_UPDATE_CURRENT);
                clocknf.setLatestEventInfo(getApplicationContext(), getString(R.string.setclock),"", contentintent);
                NM.notify(1, clocknf);
                hasShowNotification=true;
                }
                else
                {
                        NM.cancel(1);
                }
        }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值