// Path: app/src/main/java/it/skarafaz/mercury/fragment/ProgressDialogFragment.java
// public class ProgressDialogFragment extends DialogFragment {
//     public static final String TAG = "PROGRESS_DIALOG";
//     private static final String CONTENT_ARG = "CONTENT_ARG";
// 
//     @BindView(R.id.message)
//     protected TextView message;
// 
//     private String content;
// 
//     public static ProgressDialogFragment newInstance(String content) {
//         ProgressDialogFragment fragment = new ProgressDialogFragment();
//         Bundle args = new Bundle();
//         args.putString(CONTENT_ARG, content);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setStyle(STYLE_NO_FRAME, R.style.DialogTransparent);
//         setCancelable(false);
// 
//         content = getArguments() != null ? getArguments().getString(CONTENT_ARG) : null;
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.dialog_fragment_progress, container, false);
//         ButterKnife.bind(this, view);
// 
//         message.setText(content);
// 
//         return view;
//     }
// }


import android.view.ViewConfiguration;
import it.skarafaz.mercury.fragment.ProgressDialogFragment;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
/*
 * Mercury-SSH
 * Copyright (C) 2017 Skarafaz
 *
 * This file is part of Mercury-SSH.
 *
 * Mercury-SSH is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Mercury-SSH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Mercury-SSH.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.skarafaz.mercury;



public class MercuryApplication extends Application {
    private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
    private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
    private static Context context;

    public static Context getContext() {
        return context;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        context = this;

        EventBus.builder().addIndex(new EventBusIndex()).build();

        // hack for devices with hw options button
        try {
            ViewConfiguration config = ViewConfiguration.get(this);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception e) {
            logger.error(e.getMessage().replace("\n", " "));
        }
    }

    public static void showProgressDialog(FragmentManager manager, String content) {
        FragmentTransaction transaction = manager.beginTransaction();
// Path: app/src/main/java/it/skarafaz/mercury/fragment/ProgressDialogFragment.java
// public class ProgressDialogFragment extends DialogFragment {
//     public static final String TAG = "PROGRESS_DIALOG";
//     private static final String CONTENT_ARG = "CONTENT_ARG";
// 
//     @BindView(R.id.message)
//     protected TextView message;
// 
//     private String content;
// 
//     public static ProgressDialogFragment newInstance(String content) {
//         ProgressDialogFragment fragment = new ProgressDialogFragment();
//         Bundle args = new Bundle();
//         args.putString(CONTENT_ARG, content);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setStyle(STYLE_NO_FRAME, R.style.DialogTransparent);
//         setCancelable(false);
// 
//         content = getArguments() != null ? getArguments().getString(CONTENT_ARG) : null;
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.dialog_fragment_progress, container, false);
//         ButterKnife.bind(this, view);
// 
//         message.setText(content);
// 
//         return view;
//     }
// }


// Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
import android.view.ViewConfiguration;
import it.skarafaz.mercury.fragment.ProgressDialogFragment;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;

/*
 * Mercury-SSH
 * Copyright (C) 2017 Skarafaz
 *
 * This file is part of Mercury-SSH.
 *
 * Mercury-SSH is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Mercury-SSH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Mercury-SSH.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.skarafaz.mercury;



public class MercuryApplication extends Application {
    private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
    private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
    private static Context context;

    public static Context getContext() {
        return context;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        context = this;

        EventBus.builder().addIndex(new EventBusIndex()).build();

        // hack for devices with hw options button
        try {
            ViewConfiguration config = ViewConfiguration.get(this);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception e) {
            logger.error(e.getMessage().replace("\n", " "));
        }
    }

    public static void showProgressDialog(FragmentManager manager, String content) {
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);