添加动态日历图标功能 


diff --git a/device/sprd/scx35_sp7731gea/overlay/packages/apps/Calendar/res/mipmap-hdpi/ic_launcher_calendar.png b/device/sprd/scx35_sp7731gea/overlay/packages/apps/Calendar/res/mipmap-hdpi/ic_launcher_calendar.png 

index db79b09..9e278b2 100755 

Binary files a/device/sprd/scx35_sp7731gea/overlay/packages/apps/Calendar/res/mipmap-hdpi/ic_launcher_calendar.png and b/device/sprd/scx35_sp7731gea/overlay/packages/apps/Calendar/res/mipmap-hdpi/ic_launcher_calendar.png differ 

diff --git a/packages/apps/Launcher3/src/com/android/launcher3/IconCache.java b/packages/apps/Launcher3/src/com/android/launcher3/IconCache.java 

index 8a07fa9..3bf4e6f 100755 

--- a/packages/apps/Launcher3/src/com/android/launcher3/IconCache.java 

+++ b/packages/apps/Launcher3/src/com/android/launcher3/IconCache.java 

@@ -538,8 +538,13 @@ final int BackGroundDrawId[]={ 

                 entry.title = info.activityInfo.name; 

             } 

 //更新图标 


 +                 if(info.activityInfo.packageName.equals("com.android.calendar")){
 +                       entry.icon = Utilities.createCalendarIconBitmap(getFullResIcon(info), mContext);
 +                 }else{
              entry.icon = Utilities.createIconBitmap(
                      getFullResIcon(info), mContext);
 +                 
 } 

         } 

         return entry; 

     } 

diff --git a/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java b/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java 

old mode 100644 

new mode 100755 

index d7645f0..b0f189d 

--- a/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java 

+++ b/packages/apps/Launcher3/src/com/android/launcher3/LauncherAppState.java 

@@ -101,6 +101,10 @@ public class LauncherAppState { 

         filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); 

         filter.addAction(Intent.ACTION_LOCALE_CHANGED); 

         filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); 


 +               filter.addAction(Intent.ACTION_TIME_CHANGED);
 +               filter.addAction(Intent.ACTION_DATE_CHANGED);
 +               filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); 

         sContext.registerReceiver(mModel, filter); 

         /* SPRD: BugFix bug347797 register shutdown broadcast receiver. @{ */ 

         filter = new IntentFilter(Intent.ACTION_SHUTDOWN); 

diff --git a/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java b/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java 

index 09af49f..59ae00a 100755 

--- a/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java 

+++ b/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java 

@@ -1147,7 +1147,13 @@ public class LauncherModel extends BroadcastReceiver { 

         /* SPRD: BugFix bug347797 If apps can be on external storage, then we don't remove the apps form the DB, when shutdown. @{ */ 

         } else if (Intent.ACTION_SHUTDOWN.equals(action)) { 

             isBeingShutDown = true; 
-        }
//判断日期是否更新
 
+        }else if(Intent.ACTION_DATE_CHANGED.equals(action) ||                 
 +                       Intent.ACTION_TIME_CHANGED.equals(action) ||
 +                       Intent.ACTION_TIMEZONE_CHANGED.equals(action)){
 +                       final String packageName = "com.android.calendar";
 +                       enqueuePackageUpdated(new PackageUpdatedTask(
 +                       PackageUpdatedTask.OP_UPDATE, new String[]{packageName}));
 +               } 

         /* SPRD: BugFix bug347797 If apps can be on external storage, then we don't remove the apps form the DB, when shutdown. @} */ 

     } 

  

diff --git a/packages/apps/Launcher3/src/com/android/launcher3/Utilities.java b/packages/apps/Launcher3/src/com/android/launcher3/Utilities.java 

old mode 100644 

new mode 100755 

index 2eeeead..33eb9a5 

--- a/packages/apps/Launcher3/src/com/android/launcher3/Utilities.java 

+++ b/packages/apps/Launcher3/src/com/android/launcher3/Utilities.java 

@@ -39,7 +39,8 @@ import android.view.View; 

 import android.widget.Toast; 

  

 import java.util.ArrayList; 

- 

+import java.util.Calendar; 

+import android.graphics.Typeface; 

 /** 

  * Various utilities shared amongst the Launcher's classes. 

  */ 

@@ -177,6 +178,38 @@ final class Utilities { 

         } 

     } 

  


 +       static Bitmap createCalendarIconBitmap(Drawable icon, Context context){
 +               Bitmap calendarIcon = createIconBitmap(icon,context);
 +               String dayString  = String.valueOf(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));  //获取日期
 +
 +               synchronized (sCanvas) {
 +               final Canvas canvas = sCanvas;
 +               canvas.setBitmap(calendarIcon);
 +                
 +               final float mDensity = context.getResources().getDisplayMetrics().density;
 +                
 +               Paint mDatePaint = new Paint();
 +               mDatePaint.setTypeface(Typeface.DEFAULT_BOLD);
 +               mDatePaint.setTextSize((int)30F * mDensity);
 +               mDatePaint.setColor(0xff000000);
 +               mDatePaint.setAntiAlias(true);
 +                
 +               Rect rect = new Rect();
 +               mDatePaint.getTextBounds(dayString,0,dayString.length(),rect);
 +               int hoffset = 20;
 +               int width3 = rect.right - rect.left;
 +               int height1 = rect.bottom - rect.top;
 +               int width4 = calendarIcon.getWidth();
 +               int height2 = calendarIcon.getHeight() + hoffset;
 +                
 +               canvas.drawText(dayString,(width4 - width3)/2 - rect.left,(height2 - height1)/2 - rect.top,mDatePaint);
 +                
 +               canvas.setBitmap(null);
 +               return calendarIcon;
 +               }
 +       }
 + 

     /** 

      * Returns a Bitmap representing the thumbnail of the specified Bitmap. 

      *