Android Open Source - InfoWallpaper Phone






From Project

Back to project page InfoWallpaper.

License

The source code is released under:

MIT License

If you think the Android project InfoWallpaper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.andreashedin.infowallpaper;
// ww  w.  j  a v  a2s  .co  m
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.SmsManager;
import android.util.Log;

public class Phone extends PhoneStateListener {
  private Screen mScreen = new Screen();
  private final static Phone mInstance = new Phone();
  private int mUnreadSMSCount;
  //private int mUnreadGmailCount;
  private int mSignalStrengthGsm = 0;
  
  private Phone() { 
    mUnreadSMSCount = 0;
    //mUnreadGmailCount = 0;
  }
  
  public static Phone instance() {
    return mInstance;
  }
  
  public Screen screen() {
    return mScreen;
  }
  
  public void update(Context context) {
    updateUnreadSmsCount(context);
    //updateUnreadGmailCount(context);
  }
  
  @Override
  public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    mSignalStrengthGsm = signalStrength.getGsmSignalStrength();
    
    if(mSignalStrengthGsm == 99)
      mSignalStrengthGsm = 0;
    
    mSignalStrengthGsm = (int)(((float)mSignalStrengthGsm / 31.0f) * 100.0f);
  }
  
  public int getSignalStrengthGsm() {
    return mSignalStrengthGsm;
  }
  
  public int updateUnreadSmsCount(Context context) {
    final Uri SMS_INBOX = Uri.parse("content://sms/inbox");

    Cursor c = context.getContentResolver().query(SMS_INBOX, null, "read = 0", null, null);
    if(c != null) {
      try {
        mUnreadSMSCount = c.getCount();
      }
      finally {
        c.close();
      }
    }
    
    return mUnreadSMSCount;
  }
  
  public int getUnreadSmsCount() {
    return mUnreadSMSCount;
  }
  

//  public int updateUnreadGmailCount(Context context) {
//    
//    AccountManager am = AccountManager.get(context);
//    Account[] a = am.getAccountsByType("com.google");
//    
//    if(a.length == 0) {
//      mUnreadGmailCount = 0;
//      return 0;
//    }
//    
//      String account = a[0].name;
//      Uri LABELS_URI = Uri.parse("content://gmail-ls/labels/");
//      Uri ACCOUNT_URI = Uri.withAppendedPath(LABELS_URI, account);
//      Cursor cursor = context.getContentResolver().query(ACCOUNT_URI, null, null, null, null);
//
//      mUnreadGmailCount = 0;
//      if(cursor != null) {
//        try {
//          if (cursor.moveToFirst()) {
//            int nameColumn = cursor.getColumnIndex("name");
//              int unreadColumn = cursor.getColumnIndex("numUnreadConversations");
//              do {
//                  String unread = cursor.getString(unreadColumn);
//                  String name = cursor.getString(nameColumn);
//                  int val = 0;
//                  try
//                  {
//                    if(name.equals("^i")) // Inbox
//                      val = Integer.parseInt(unread);
//                  }
//                  catch(Exception ex) {
//                    
//                  }
//                  
//                  mUnreadGmailCount += val;
//              } while (cursor.moveToNext());
//          }
//        }
//        catch(Exception ex) {
//          
//        }
//        finally {
//          cursor.close();
//        }
//      }
//      
//    return mUnreadGmailCount;
//  }
  
//  public int getUnreadGmailCount() {
//    return mUnreadGmailCount;
//  }
}




Java Source Code List

com.andreashedin.general.ColorPickerDialog.java
com.andreashedin.general.CustomizeInfoDialog.java
com.andreashedin.general.EnterStringDialog.java
com.andreashedin.general.PickItemDialog.java
com.andreashedin.general.PositionInfosDialog.java
com.andreashedin.general.SelectConfigurationDialog.java
com.andreashedin.general.TextSizeDialog.java
com.andreashedin.general.WeatherSettingsDialog.java
com.andreashedin.infowallpaper.Background.java
com.andreashedin.infowallpaper.BatteryDataCollector.java
com.andreashedin.infowallpaper.ColorHandler.java
com.andreashedin.infowallpaper.ConfigHandler.java
com.andreashedin.infowallpaper.CurrentSongDataCollector.java
com.andreashedin.infowallpaper.DataCollector.java
com.andreashedin.infowallpaper.DateTimeDataCollector.java
com.andreashedin.infowallpaper.DisplayValuePair.java
com.andreashedin.infowallpaper.InfoData.java
com.andreashedin.infowallpaper.InfoItem.java
com.andreashedin.infowallpaper.LiveInfoSettings.java
com.andreashedin.infowallpaper.LiveInfoWallpaper.java
com.andreashedin.infowallpaper.PhoneStatusDataCollector.java
com.andreashedin.infowallpaper.Phone.java
com.andreashedin.infowallpaper.SaveLoadData.java
com.andreashedin.infowallpaper.Screen.java
com.andreashedin.infowallpaper.WeatherDataCollector.java
com.andreashedin.infowallpaper.WeatherHandler.java