// Path: app/src/main/java/com/koma/filemanager/util/LogUtils.java
// public class LogUtils {
//     private static final boolean IS_DEBUG = true;
//     private static final String TAG = "FileManager";
// 
//     public static void i(String tag, String msg) {
//         if (IS_DEBUG) {
//             Log.i(TAG, buildString(tag, msg));
//         }
//     }
// 
//     public static void e(String tag, String msg) {
//         if (IS_DEBUG) {
//             Log.e(TAG, buildString(tag, msg));
//         }
//     }
// 
//     private static String buildString(String tag, String msg) {
//         StringBuilder sb = new StringBuilder(tag);
//         sb.append("----");
//         sb.append(msg);
//         return sb.toString();
//     }
// }
// 
// Path: app/src/main/java/com/koma/filemanager/util/Constants.java
// public static String[] PERMISSIONS_STORAGE = {Manifest.permission.WRITE_EXTERNAL_STORAGE,
//         Manifest.permission.READ_EXTERNAL_STORAGE};
// 
// Path: app/src/main/java/com/koma/filemanager/util/Constants.java
// public static final int REQUEST_CODE_ASK_PERMISSIONS = 1;


import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import com.koma.filemanager.util.LogUtils;
import butterknife.ButterKnife;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
import static com.koma.filemanager.util.Constants.PERMISSIONS_STORAGE;
import static com.koma.filemanager.util.Constants.REQUEST_CODE_ASK_PERMISSIONS;
        LogUtils.i(TAG, "onCreate");
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED ||
                ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
                        != PackageManager.PERMISSION_GRANTED) {
            requestStoragePermissions();
        }
        mContext = BaseActivity.this;
        setContentView(getLayoutId());
        ButterKnife.bind(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mSubscriptions != null) {
            mSubscriptions.clear();
        }
    }

    protected abstract int getLayoutId();

    private void requestStoragePermissions() {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)
                || ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_CODE_ASK_PERMISSIONS);
        } else {
            // Contact permissions have not been granted yet. Request them directly.
// Path: app/src/main/java/com/koma/filemanager/util/LogUtils.java
// public class LogUtils {
//     private static final boolean IS_DEBUG = true;
//     private static final String TAG = "FileManager";
// 
//     public static void i(String tag, String msg) {
//         if (IS_DEBUG) {
//             Log.i(TAG, buildString(tag, msg));
//         }
//     }
// 
//     public static void e(String tag, String msg) {
//         if (IS_DEBUG) {
//             Log.e(TAG, buildString(tag, msg));
//         }
//     }
// 
//     private static String buildString(String tag, String msg) {
//         StringBuilder sb = new StringBuilder(tag);
//         sb.append("----");
//         sb.append(msg);
//         return sb.toString();
//     }
// }
// 
// Path: app/src/main/java/com/koma/filemanager/util/Constants.java
// public static String[] PERMISSIONS_STORAGE = {Manifest.permission.WRITE_EXTERNAL_STORAGE,
//         Manifest.permission.READ_EXTERNAL_STORAGE};
// 
// Path: app/src/main/java/com/koma/filemanager/util/Constants.java
// public static final int REQUEST_CODE_ASK_PERMISSIONS = 1;


// Path: app/src/main/java/com/koma/filemanager/base/BaseActivity.java
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import com.koma.filemanager.util.LogUtils;
import butterknife.ButterKnife;
import rx.Subscription;
import rx.subscriptions.CompositeSubscription;
import static com.koma.filemanager.util.Constants.PERMISSIONS_STORAGE;
import static com.koma.filemanager.util.Constants.REQUEST_CODE_ASK_PERMISSIONS;

        LogUtils.i(TAG, "onCreate");
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED ||
                ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
                        != PackageManager.PERMISSION_GRANTED) {
            requestStoragePermissions();
        }
        mContext = BaseActivity.this;
        setContentView(getLayoutId());
        ButterKnife.bind(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mSubscriptions != null) {
            mSubscriptions.clear();
        }
    }

    protected abstract int getLayoutId();

    private void requestStoragePermissions() {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)
                || ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_CODE_ASK_PERMISSIONS);
        } else {
            // Contact permissions have not been granted yet. Request them directly.
            ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_CODE_ASK_PERMISSIONS);