Android Open Source - AndroidRandomWallpaper R W Global






From Project

Back to project page AndroidRandomWallpaper.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroidRandomWallpaper 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.elbauldelprogramador.randomwallpaper.util;
/*  ww  w.j  a v a  2 s.c o m*/
import java.io.File;
import java.io.FileFilter;
import java.util.Locale;

import android.content.Context;
import android.os.Environment;
import android.widget.Toast;

public class RWGlobal {

  public static final int PICK_FOLDER   = 2;
  public static final int RESULT_NO_PATH  = 3;
  public static final int RESULT_NO_FILES = 4;
  
  /* Preferences Keys */
  public static final String  SHARED_PREFERENCES     = "RandomWallPreferences";
  public static final String  KEY_INTERVAL       = "iv";
  public static final String  KEY_SOURCE_FOLDER     = "if";
  public static final String  KEY_WIDTH        = "dw";
  public static final String  KEY_HEGHT        = "dh";
  public static final String KEY_AT_BOOT        = "sab";
  /* Preferences Defaults */
  public static final  int      DEFAULT_INTERVAL    = 5;
  public static final String  DEFAULT_SOURCE_FOLDER  = RWGlobal.defaultSourceFolder();    
  public static final int      DEFAULT_WIDTH      = -1;
  public static final int     DEFAULT_HEIGHT      = -1;
  public static final boolean DEFAULT_AT_BOOT      = true;
  
  /* Extras for intents */
  public static final String EXTRA_PATH         = "path";
  public static final String EXTRA_HEIGHT        = "height";
  public static final String EXTRA_WIDTH        = "width";
  
  
  public static void toast(Context c, String message){
    Toast.makeText(c, message, Toast.LENGTH_LONG)
    .show();
  }
  
  public static String defaultSourceFolder(){
    return Environment.getExternalStorageDirectory().toString();/* + "/DCIM/Camera";*/
  }
  
  /**
   * 
   * @param path Path where want to find for image files
   * @return true if there is images in that path
   */
  public static boolean thereAreImages(String path){
    File dir = new File(path);
    FileFilter imagesFilter = new FileFilter() {
      
      @Override
      public boolean accept(File pathname) {
        String ext = pathname.getName();
        if( ext.toLowerCase(Locale.ENGLISH).endsWith("jpg") || 
          ext.toLowerCase(Locale.ENGLISH).endsWith(".jpeg") || 
          ext.toLowerCase(Locale.ENGLISH).endsWith(".png")){
          return true;
        }
        return false;
      }
    };
    if (dir.listFiles(imagesFilter).length == 0) 
      return false;
    return true;
  }
}




Java Source Code List

com.elbauldelprogramador.randomwallpaper.Service.java
com.elbauldelprogramador.randomwallpaper.activities.AboutTheApp.java
com.elbauldelprogramador.randomwallpaper.activities.MainActivity.java
com.elbauldelprogramador.randomwallpaper.reveivers.AlarmReceiver.java
com.elbauldelprogramador.randomwallpaper.reveivers.OnBootReceiver.java
com.elbauldelprogramador.randomwallpaper.util.RWGlobal.java
com.elbauldelprogramador.randomwallpaper.util.SimpleFileExplorer.java
com.elbauldelprogramador.randomwallpaper.util.StrictModeWrapper.java