Android Open Source - lostpets Picture File Manager






From Project

Back to project page lostpets.

License

The source code is released under:

GNU General Public License

If you think the Android project lostpets 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 fr.esiea.mobile.lostpets.util;
//www . j a v  a 2  s.  co m
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;

import java.io.File;
import java.io.IOException;
import java.text.Normalizer;

/**
 * Created by david on 01/11/2014.
 */
//This class manages picture file in device
public class PictureFileManager {

    private static String m_currentPhotoPath;

    public PictureFileManager() {
    }

    //Create file
    public static String createFileName (String param) {
        String petName = Normalizer.normalize(param, Normalizer.Form.NFD);
        petName = petName.replaceAll("[^\\p{ASCII}]", "");
        petName = petName + ".jpg";
        return petName;
    }

    //Create picture file
    public static File createImageFile(String fileName) throws IOException {
        // Create an image file name
        File picture = new File (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), fileName);

        m_currentPhotoPath = picture.getAbsolutePath();
        return picture;
    }

    //Add picture in gallery
    public static void galleryAddPic(Context context) {
        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        File f = new File(m_currentPhotoPath);
        Uri contentUri = Uri.fromFile(f);
        mediaScanIntent.setData(contentUri);
        context.sendBroadcast(mediaScanIntent);
    }

    public static String getM_currentPhotoPath() {
        return m_currentPhotoPath;
    }
}




Java Source Code List

fr.esiea.mobile.lostpets.ApplicationTest.java
fr.esiea.mobile.lostpets.activity.CreateLostPetActivity.java
fr.esiea.mobile.lostpets.activity.InfosActivity.java
fr.esiea.mobile.lostpets.activity.MainActivity.java
fr.esiea.mobile.lostpets.activity.MapsActivity.java
fr.esiea.mobile.lostpets.activity.PetActivity.java
fr.esiea.mobile.lostpets.activity.PetMarkerActivity.java
fr.esiea.mobile.lostpets.activity.TakePictureActivity.java
fr.esiea.mobile.lostpets.adapter.PetAdapter.java
fr.esiea.mobile.lostpets.dao.UserDataSource.java
fr.esiea.mobile.lostpets.dao.WebServiceDAO.java
fr.esiea.mobile.lostpets.fragment.PetFragment.java
fr.esiea.mobile.lostpets.fragment.PetListFragment.java
fr.esiea.mobile.lostpets.model.Pet.java
fr.esiea.mobile.lostpets.model.Pets.java
fr.esiea.mobile.lostpets.model.User.java
fr.esiea.mobile.lostpets.sql.MySQLiteHelper.java
fr.esiea.mobile.lostpets.util.PictureFileManager.java