Android Open Source - InfoWallpaper Phone Status Data Collector






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;
//from w w  w .  j a  v a2s. c  o  m
public class PhoneStatusDataCollector extends DataCollector {

  private int mSmsCount = 0;
  private int mGsm = 0;
  private int mGmailCount = 0;
  private boolean mShowWhenZero = false;
  
  public static final String UNREAD_SMS = "#sms";
  //public static final String UNREAD_GMAIL = "#gmail";
  public static final String GSM_STRENGTH = "#gsm";
  
  public static boolean contains(String str) {
    if(str.contains(UNREAD_SMS))
      return true;
    //if(str.contains(UNREAD_GMAIL))
    //  return true;
    if(str.contains(GSM_STRENGTH))
      return true;
    return false;
  }
  
  static String getSampleText(String str) {
    return str.replace(UNREAD_SMS, "0").replace(GSM_STRENGTH, "00");
  }
  
  PhoneStatusDataCollector(LiveInfoWallpaper parent, boolean showWhenZero) {
    super(parent);
    
    mShowWhenZero = showWhenZero;
  }

  @Override
  void update(Object object) {
    mSmsCount = Phone.instance().getUnreadSmsCount();
    //mGmailCount = Phone.instance().getUnreadGmailCount();
    mGsm = Phone.instance().getSignalStrengthGsm();
  }

  @Override
  String updateInfoString(String string, boolean numbersAsText) {
    String out = "";
    if(mSmsCount > 0 && string.contains(UNREAD_SMS) || 
        mGsm > 0 && string.contains(GSM_STRENGTH) ||
        mShowWhenZero) { 
      
      String number = "";
      
      if(numbersAsText == false)
        number = String.valueOf(mSmsCount);
      else
        number = getNumberAsText(mSmsCount);
      
      out = string.replace(UNREAD_SMS, number);
      
      //if(numbersAsText == false)
      //  number = String.valueOf(mGmailCount);
      //else
      //  number = getNumberAsText(mGmailCount);
      
      //out = out.replace(UNREAD_GMAIL, number);
      
      if(numbersAsText == false)
        number = String.valueOf(mGsm);
      else
        number = getNumberAsText(mGsm);
      
      out = out.replace(GSM_STRENGTH, number);
    }
    
    return out;
  }

  public void setShowWhenZero(boolean show) {
    mShowWhenZero = show;
  }
}




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