// Path: app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
// 
//     public static final String NIGHTMODE = "nightmode";
//     public static final String TWO_ROW = "two_row";
//     public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
//     public static final String DIRECTORY_NAME = "directory";
// 
//     public static final String VERSION = "version";
// 
//     final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
// 
//     private PrefManager prefManager;
//     private Preference myAskSD,myVers;
// 
//     @Override
//     public void onCreate(final Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         addPreferencesFromResource(R.xml.preferences);
// 
//         myAskSD = findPreference("grant_access");
//         myAskSD.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
//             public boolean onPreferenceClick(Preference preference) {
//                 //open browser or intent here
//                 AskForWriteSDPermission();
//                 return true;
//             }
//         });
// 
//         myVers = findPreference("version");
//         myVers.setTitle(getVersionApp(getActivity()));
//     }
// 
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
//                                           String key) {
//         if (key.equals(NIGHTMODE)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(TWO_ROW)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(SWIPE_ACTIVITY_WALL)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(DIRECTORY_NAME)){
//             Preference preference = findPreference(key);
//             if (preference instanceof EditTextPreference){
//                 EditTextPreference editTextPreference =  (EditTextPreference)preference;
//                 if (editTextPreference.getText().trim().length() > 0){
//                     editTextPreference.setSummary(editTextPreference.getText());
//                 }else{
//                     editTextPreference.setText("Not change");
//                 }
//             }
//         }
// 
//         if (key.equals(VERSION)){
//             Preference customPref = findPreference(key);
//             customPref.setSummary(getVersionApp(getActivity()));
//         }
// 
//     }
//     public static String getVersionApp(Context context){
//         PackageInfo pInfo = null;
//         String str = null;
//         try {
//             pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//         }
//         String version = pInfo.versionName;
//         int verCode = pInfo.versionCode;
//         str =  context.getString(R.string.app_name)+" "+" "+version+" ( "+verCode+" ) ";
//         return str;
//     }
// 
//     /**
//      *  Start method for asking the permission to write SD card
//      */
//     protected void AskForWriteSDPermission() {
//         if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
//             int hasWriteSDPermission = getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
//             if (hasWriteSDPermission != PackageManager.PERMISSION_GRANTED) {
//                 requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
//                         REQUEST_CODE_ASK_PERMISSIONS);
//                 return;
//             }
//         }
//     }
// 
//     @Override
//     public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
//         switch (requestCode) {
//             case REQUEST_CODE_ASK_PERMISSIONS:
//                 if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                     // Permission Granted
//                     prefManager = new PrefManager(getActivity());
//                     prefManager.setCanWriteSd(true);;
//                     CreateDirectory();
//                     Toast.makeText(getActivity(), R.string.can_download_wall, Toast.LENGTH_SHORT)
//                             .show();
//                 } else {
//                     // Permission Denied
//                     Toast.makeText(getActivity(), R.string.cant_download_wall, Toast.LENGTH_SHORT)
//                             .show();
//                 }
//                 break;
//             default:
//                 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//         }
//     }
// 
//     protected void CreateDirectory(){
//         File wallpaperDirectory = new File("/sdcard/WallApp/");
//         wallpaperDirectory.mkdirs();
//     }
// 
//     // End asking permission for SD card
// }


import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Explode;
import android.view.Window;
import com.botty.wall.R;
import com.botty.wall.fragment.SettingsFragment;
package com.botty.wall.activity;



public class Settings extends AppCompatActivity {

    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // inside your activity (if you did not enable transitions in your theme)
            getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
            getWindow().setEnterTransition(new Explode());
            // set an exit transition
            getWindow().setExitTransition(new Explode());
        }

        setContentView(R.layout.activity_settings);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

// Path: app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
// 
//     public static final String NIGHTMODE = "nightmode";
//     public static final String TWO_ROW = "two_row";
//     public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
//     public static final String DIRECTORY_NAME = "directory";
// 
//     public static final String VERSION = "version";
// 
//     final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
// 
//     private PrefManager prefManager;
//     private Preference myAskSD,myVers;
// 
//     @Override
//     public void onCreate(final Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         addPreferencesFromResource(R.xml.preferences);
// 
//         myAskSD = findPreference("grant_access");
//         myAskSD.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
//             public boolean onPreferenceClick(Preference preference) {
//                 //open browser or intent here
//                 AskForWriteSDPermission();
//                 return true;
//             }
//         });
// 
//         myVers = findPreference("version");
//         myVers.setTitle(getVersionApp(getActivity()));
//     }
// 
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
//                                           String key) {
//         if (key.equals(NIGHTMODE)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(TWO_ROW)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(SWIPE_ACTIVITY_WALL)) {
//             sharedPreferences.getBoolean(key, true);
//         } else if (key.equals(DIRECTORY_NAME)){
//             Preference preference = findPreference(key);
//             if (preference instanceof EditTextPreference){
//                 EditTextPreference editTextPreference =  (EditTextPreference)preference;
//                 if (editTextPreference.getText().trim().length() > 0){
//                     editTextPreference.setSummary(editTextPreference.getText());
//                 }else{
//                     editTextPreference.setText("Not change");
//                 }
//             }
//         }
// 
//         if (key.equals(VERSION)){
//             Preference customPref = findPreference(key);
//             customPref.setSummary(getVersionApp(getActivity()));
//         }
// 
//     }
//     public static String getVersionApp(Context context){
//         PackageInfo pInfo = null;
//         String str = null;
//         try {
//             pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//         }
//         String version = pInfo.versionName;
//         int verCode = pInfo.versionCode;
//         str =  context.getString(R.string.app_name)+" "+" "+version+" ( "+verCode+" ) ";
//         return str;
//     }
// 
//     /**
//      *  Start method for asking the permission to write SD card
//      */
//     protected void AskForWriteSDPermission() {
//         if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
//             int hasWriteSDPermission = getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
//             if (hasWriteSDPermission != PackageManager.PERMISSION_GRANTED) {
//                 requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
//                         REQUEST_CODE_ASK_PERMISSIONS);
//                 return;
//             }
//         }
//     }
// 
//     @Override
//     public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
//         switch (requestCode) {
//             case REQUEST_CODE_ASK_PERMISSIONS:
//                 if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                     // Permission Granted
//                     prefManager = new PrefManager(getActivity());
//                     prefManager.setCanWriteSd(true);;
//                     CreateDirectory();
//                     Toast.makeText(getActivity(), R.string.can_download_wall, Toast.LENGTH_SHORT)
//                             .show();
//                 } else {
//                     // Permission Denied
//                     Toast.makeText(getActivity(), R.string.cant_download_wall, Toast.LENGTH_SHORT)
//                             .show();
//                 }
//                 break;
//             default:
//                 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//         }
//     }
// 
//     protected void CreateDirectory(){
//         File wallpaperDirectory = new File("/sdcard/WallApp/");
//         wallpaperDirectory.mkdirs();
//     }
// 
//     // End asking permission for SD card
// }


// Path: app/src/main/java/com/botty/wall/activity/Settings.java
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Explode;
import android.view.Window;
import com.botty.wall.R;
import com.botty.wall.fragment.SettingsFragment;

package com.botty.wall.activity;



public class Settings extends AppCompatActivity {

    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // inside your activity (if you did not enable transitions in your theme)
            getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
            getWindow().setEnterTransition(new Explode());
            // set an exit transition
            getWindow().setExitTransition(new Explode());
        }

        setContentView(R.layout.activity_settings);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

        getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();