Android Open Source - SecNote Import Dialog Fragment






From Project

Back to project page SecNote.

License

The source code is released under:

Apache License

If you think the Android project SecNote 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.baraccasoftware.securenotes.app;
/* ww  w . ja  va 2  s. co m*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Environment;


import com.baraccasoftware.securenotes.object.DAO;

import java.io.File;

/**
 * Created by angelo on 08/01/14.
 */
public class ImportDialogFragment extends DialogFragment {
    NoteListActivity mActivity;

    public ImportDialogFragment(){};

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mActivity = (NoteListActivity) activity;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final String[] fileList = getFileList();
        AlertDialog.Builder builder  = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.action_inport)
                .setItems(fileList,new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int which) {
                    mActivity.importNotes(fileList[which]);
                    }
                })
                .setCancelable(true);
        return builder.create();
    }

    /**
     * this method reads file in folder
     * @return
     */
    private String[] getFileList() {
        File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), DAO.FOLDER);
        String[] listFileString = new String[1];
        if(folder.mkdirs()||folder.isDirectory()){
            File[] list = folder.listFiles();
            listFileString = new String[list.length];
            for(int i = 0;i<list.length;i++){
                listFileString[i] = list[i].getName();
            }
        }
        return listFileString;
    }
}




Java Source Code List

com.baraccasoftware.securenotes.app.ExportDialogFragment.java
com.baraccasoftware.securenotes.app.ImportDialogFragment.java
com.baraccasoftware.securenotes.app.InfoActivity.java
com.baraccasoftware.securenotes.app.InfoFragment.java
com.baraccasoftware.securenotes.app.LockedAppFragment.java
com.baraccasoftware.securenotes.app.LogInFragment.java
com.baraccasoftware.securenotes.app.MainActivity.java
com.baraccasoftware.securenotes.app.NoteDetailActivity.java
com.baraccasoftware.securenotes.app.NoteDetailFragment.java
com.baraccasoftware.securenotes.app.NoteListActivity.java
com.baraccasoftware.securenotes.app.NoteListFragment.java
com.baraccasoftware.securenotes.app.RegisterFragment.java
com.baraccasoftware.securenotes.app.SetPasswordFragment.java
com.baraccasoftware.securenotes.app.SettingsActivity.java
com.baraccasoftware.securenotes.app.SettingsFragment.java
com.baraccasoftware.securenotes.exception.LoadBitmapException.java
com.baraccasoftware.securenotes.object.ActivityUtilityInterface.java
com.baraccasoftware.securenotes.object.BitmapUtility.java
com.baraccasoftware.securenotes.object.Crypto.java
com.baraccasoftware.securenotes.object.DAO.java
com.baraccasoftware.securenotes.object.Encryptor.java
com.baraccasoftware.securenotes.object.ImageLoader.java
com.baraccasoftware.securenotes.object.NoteUtility.java
com.baraccasoftware.securenotes.object.Note.java
com.baraccasoftware.securenotes.object.PBKDF2Encryptor.java
com.baraccasoftware.securenotes.object.PasswordPreference.java
com.baraccasoftware.securenotes.object.SecureDatabaseHelper.java
com.baraccasoftware.securenotes.widget.NoteAdapter.java
com.baraccasoftware.securenotes.widget.SlidingDrawer.java
com.baraccasoftware.securenotes.widget.SwipeDismissListViewTouchListener.java
com.baraccasoftware.securenotes.widget.UndoBarController.java