// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java
// public enum BackgroundType {
//     SLIDESHOW(0, R.string.slideshow),
//     SOLID_COLOR(1, R.string.solid_color),
//     @Deprecated
//     PICTURE(2, R.string.picture),
//     PICASA_ALBUM(3, R.string.google_photos_album);
// 
//     private int value;
//     private int humanNameRes;
// 
//     BackgroundType(int value, int humanNameRes) {
//         this.value = value;
//         this.humanNameRes = humanNameRes;
//     }
// 
//     public int getValue() {
//         return value;
//     }
// 
//     public int getHumanNameRes() {
//         return humanNameRes;
//     }
// }
// 
// Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java
// public class TwoLineSettingItem extends SettingItem {
//     @BindView(R.id.two_line_settings_item_header)
//     TextView header;
// 
//     @BindView(R.id.two_line_settings_item_sub_header)
//     TextView subHeader;
// 
//     @BindView(R.id.two_line_settings_item_icon)
//     ImageView icon;
// 
//     public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
// 
//     private void init(AttributeSet attrs) {
//         TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem);
// 
// 
//         header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText));
//         subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText));
// 
//         a.recycle();
//     }
// 
//     public TwoLineSettingItem(Context context, AttributeSet attrs) {
//         super(context, attrs);
// 
//         LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//         inflater.inflate(R.layout.two_line_settings_item, this, true);
//         ButterKnife.bind(this);
//         init(attrs);
//     }
// 
//     public void setIcon(Drawable drawable) {
//         if (drawable == null) {
//             icon.setVisibility(View.GONE);
//             return;
//         }
// 
//         icon.setImageDrawable(drawable);
//     }
// 
//     public void setHeaderText(String text) {
//         header.setText(text);
//     }
// 
//     public void setSubHeaderText(String text) {
//         subHeader.setText(text);
//     }
// 
//     public void setHeaderText(int resId) {
//         setHeaderText(getResources().getString(resId));
//     }
// 
//     public void setSubHeaderText(int resId) {
//         setSubHeaderText(getResources().getString(resId));
//     }
// 
// }


import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.Scope;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import com.silver.dan.castdemo.SettingEnums.BackgroundType;
import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding;
import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
                    .load("https://picasaweb.google.com/data/feed/api/user/default?alt=json")
                    .setHeader("Authorization", "Bearer " + googleAccessToken)
                    .asJsonObject()
                    .setCallback(new FutureCallback<JsonObject>() {
                        @Override
                        public void onCompleted(Exception e, JsonObject result) {
                            if (e != null) {
                                // todo error to firebase
                                CharSequence text = "Hit a problem finding your albums";
                                Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show();
                                return;
                            }

                            final List<String> titles = new ArrayList<>();
                            final List<String> albumIds = new ArrayList<>();

                            JsonArray albums = result.get("feed").getAsJsonObject().get("entry").getAsJsonArray();
                            for (int i=0;i<albums.size();i++) {
                                JsonObject album = albums.get(i).getAsJsonObject();
                                titles.add(album.get("title").getAsJsonObject().get("$t").getAsString());
                                albumIds.add(album.get("id").getAsJsonObject().get("$t").getAsString());
                            }

                            new MaterialDialog.Builder(getContext())
                                    .title(R.string.google_photos_album)
                                    .items(titles)
                                    .itemsCallback(new MaterialDialog.ListCallback() {
                                        @Override
                                        public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                                            bindings.setBackgroundGooglePhotosAlbum(titles.get(which), albumIds.get(which));
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java
// public enum BackgroundType {
//     SLIDESHOW(0, R.string.slideshow),
//     SOLID_COLOR(1, R.string.solid_color),
//     @Deprecated
//     PICTURE(2, R.string.picture),
//     PICASA_ALBUM(3, R.string.google_photos_album);
// 
//     private int value;
//     private int humanNameRes;
// 
//     BackgroundType(int value, int humanNameRes) {
//         this.value = value;
//         this.humanNameRes = humanNameRes;
//     }
// 
//     public int getValue() {
//         return value;
//     }
// 
//     public int getHumanNameRes() {
//         return humanNameRes;
//     }
// }
// 
// Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java
// public class TwoLineSettingItem extends SettingItem {
//     @BindView(R.id.two_line_settings_item_header)
//     TextView header;
// 
//     @BindView(R.id.two_line_settings_item_sub_header)
//     TextView subHeader;
// 
//     @BindView(R.id.two_line_settings_item_icon)
//     ImageView icon;
// 
//     public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
// 
//     private void init(AttributeSet attrs) {
//         TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem);
// 
// 
//         header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText));
//         subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText));
// 
//         a.recycle();
//     }
// 
//     public TwoLineSettingItem(Context context, AttributeSet attrs) {
//         super(context, attrs);
// 
//         LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//         inflater.inflate(R.layout.two_line_settings_item, this, true);
//         ButterKnife.bind(this);
//         init(attrs);
//     }
// 
//     public void setIcon(Drawable drawable) {
//         if (drawable == null) {
//             icon.setVisibility(View.GONE);
//             return;
//         }
// 
//         icon.setImageDrawable(drawable);
//     }
// 
//     public void setHeaderText(String text) {
//         header.setText(text);
//     }
// 
//     public void setSubHeaderText(String text) {
//         subHeader.setText(text);
//     }
// 
//     public void setHeaderText(int resId) {
//         setHeaderText(getResources().getString(resId));
//     }
// 
//     public void setSubHeaderText(int resId) {
//         setSubHeaderText(getResources().getString(resId));
//     }
// 
// }


// Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsTheme.java
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.Scope;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import com.silver.dan.castdemo.SettingEnums.BackgroundType;
import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding;
import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

                    .load("https://picasaweb.google.com/data/feed/api/user/default?alt=json")
                    .setHeader("Authorization", "Bearer " + googleAccessToken)
                    .asJsonObject()
                    .setCallback(new FutureCallback<JsonObject>() {
                        @Override
                        public void onCompleted(Exception e, JsonObject result) {
                            if (e != null) {
                                // todo error to firebase
                                CharSequence text = "Hit a problem finding your albums";
                                Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show();
                                return;
                            }

                            final List<String> titles = new ArrayList<>();
                            final List<String> albumIds = new ArrayList<>();

                            JsonArray albums = result.get("feed").getAsJsonObject().get("entry").getAsJsonArray();
                            for (int i=0;i<albums.size();i++) {
                                JsonObject album = albums.get(i).getAsJsonObject();
                                titles.add(album.get("title").getAsJsonObject().get("$t").getAsString());
                                albumIds.add(album.get("id").getAsJsonObject().get("$t").getAsString());
                            }

                            new MaterialDialog.Builder(getContext())
                                    .title(R.string.google_photos_album)
                                    .items(titles)
                                    .itemsCallback(new MaterialDialog.ListCallback() {
                                        @Override
                                        public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                                            bindings.setBackgroundGooglePhotosAlbum(titles.get(which), albumIds.get(which));
                                            bindings.setBackgroundType(BackgroundType.PICASA_ALBUM.getValue());