// Path: src/main/java/de/fahrgemeinschaft/ContactProvider.java
// public static final class CONTACT {
//     public static final String USER = "user";
//     public static final String EMAIL = "Email";
//     public static final String PLATE = "NumberPlate";
//     public static final String MOBILE = "Mobile";
//     public static final String LANDLINE = "Landline";
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/EditTextImageButton.java
// public interface TextListener {
//     public void onTextChange(String key, String text);
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/PrivacyImageButton.java
// public class PrivacyImageButton extends EditTextImageButton
//                 implements OnClickListener {
// 
//     static final String android = "http://schemas.android.com/apk/res/android";
// 
// 
//     private int privacy;
//     private int imageResId;
//     private PrivacyListener privacyListener;
// 
// 
//     public PrivacyImageButton(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         setImageResource(attrs.getAttributeResourceValue(
//                 android, SRC, R.drawable.icn_dropdown));
//         icon.setOnClickListener(this);
//     }
// 
//     public void setImageResource(int resourceId) {
//         imageResId = resourceId;
//         setVisibility(privacy);
//     }
// 
//     public int getPrivacy() {
//         return privacy;
//     }
// 
//     public void setPrivacy(int privacy) {
//         this.privacy = privacy;
//         switch (privacy) {
//         case 1:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_anyone);
//             break;
//         case 4:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_members);
//             break;
//         case 0:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_request);
//             break;
//         case 5:
//             text.setEnabled(false);
//             drawIcons(R.drawable.icn_visibility_none);
//             break;
//         }
//     }
// 
//     @Override
//     public void onClick(View v) {
//         AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
//         builder.setTitle(getResources().getString(R.string.visibility));
//         builder.setItems(R.array.visibility,
//                 new DialogInterface.OnClickListener() {
//             
//             @Override   // must match @array/visibility in strings.xml
//             public void onClick(DialogInterface dialog, int click_idx) {
//                 switch (click_idx) {
//                 case 0: // anyone
//                     setPrivacy(1);
//                     break;
//                 case 1: // members
//                     setPrivacy(4);
//                     break;
//                 case 2: // request
//                     setPrivacy(0);
//                     break;
//                 case 3: // none
//                     setPrivacy(5);
//                     break;
//                 }
//                 if (privacyListener != null)
//                     privacyListener.onPrivacyChange(key, privacy);
//             }
//         }).show();
//     }
// 
//     private void drawIcons(int resId) {
//         icon.setImageDrawable(new LayerDrawable(new Drawable[] {
//                 getResources().getDrawable(imageResId),
//                 getResources().getDrawable(resId)
//         }));
//     }
// 
//     public void setPrivacyListener(String key, PrivacyListener listener) {
//         this.privacyListener = listener;
//         this.key = key;
//     }
// 
//     public interface PrivacyListener {
//         public void onPrivacyChange(String key, int visibility);
//     }
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/PrivacyImageButton.java
// public interface PrivacyListener {
//     public void onPrivacyChange(String key, int visibility);
// }


import org.json.JSONException;
import org.json.JSONObject;
import org.teleportr.Ride;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
import de.fahrgemeinschaft.ContactProvider.CONTACT;
import de.fahrgemeinschaft.util.EditTextImageButton.TextListener;
import de.fahrgemeinschaft.util.PrivacyImageButton;
import de.fahrgemeinschaft.util.PrivacyImageButton.PrivacyListener;
/**
 * Fahrgemeinschaft / Ridesharing App
 * Copyright (c) 2013 by it's authors.
 * Some rights reserved. See LICENSE..
 *
 */

package de.fahrgemeinschaft;





public class EditRideFragment3 extends SherlockFragment
                implements TextListener, PrivacyListener {

    private static final String NAME = "Name";
    private static final String EMPTY = "";
    private PrivacyImageButton mobile;
    private PrivacyImageButton plate;
    private PrivacyImageButton email;
    private PrivacyImageButton land;
    private PrivacyImageButton name;
    private SharedPreferences prefs;



    @Override
    public View onCreateView(final LayoutInflater lI, ViewGroup p, Bundle b) {
        prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        return lI.inflate(R.layout.fragment_ride_edit3, p, false);
    }

    @Override
    public void onViewCreated(View v, Bundle savedInstanceState) {
        super.onViewCreated(v, savedInstanceState);
        email = (PrivacyImageButton) v.findViewById(R.id.email);
        land = (PrivacyImageButton) v.findViewById(R.id.landline);
        mobile = (PrivacyImageButton) v.findViewById(R.id.mobile);
        plate = (PrivacyImageButton) v.findViewById(R.id.plate);
        name = (PrivacyImageButton) v.findViewById(R.id.name);
// Path: src/main/java/de/fahrgemeinschaft/ContactProvider.java
// public static final class CONTACT {
//     public static final String USER = "user";
//     public static final String EMAIL = "Email";
//     public static final String PLATE = "NumberPlate";
//     public static final String MOBILE = "Mobile";
//     public static final String LANDLINE = "Landline";
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/EditTextImageButton.java
// public interface TextListener {
//     public void onTextChange(String key, String text);
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/PrivacyImageButton.java
// public class PrivacyImageButton extends EditTextImageButton
//                 implements OnClickListener {
// 
//     static final String android = "http://schemas.android.com/apk/res/android";
// 
// 
//     private int privacy;
//     private int imageResId;
//     private PrivacyListener privacyListener;
// 
// 
//     public PrivacyImageButton(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         setImageResource(attrs.getAttributeResourceValue(
//                 android, SRC, R.drawable.icn_dropdown));
//         icon.setOnClickListener(this);
//     }
// 
//     public void setImageResource(int resourceId) {
//         imageResId = resourceId;
//         setVisibility(privacy);
//     }
// 
//     public int getPrivacy() {
//         return privacy;
//     }
// 
//     public void setPrivacy(int privacy) {
//         this.privacy = privacy;
//         switch (privacy) {
//         case 1:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_anyone);
//             break;
//         case 4:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_members);
//             break;
//         case 0:
//             text.setEnabled(true);
//             drawIcons(R.drawable.icn_visibility_request);
//             break;
//         case 5:
//             text.setEnabled(false);
//             drawIcons(R.drawable.icn_visibility_none);
//             break;
//         }
//     }
// 
//     @Override
//     public void onClick(View v) {
//         AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
//         builder.setTitle(getResources().getString(R.string.visibility));
//         builder.setItems(R.array.visibility,
//                 new DialogInterface.OnClickListener() {
//             
//             @Override   // must match @array/visibility in strings.xml
//             public void onClick(DialogInterface dialog, int click_idx) {
//                 switch (click_idx) {
//                 case 0: // anyone
//                     setPrivacy(1);
//                     break;
//                 case 1: // members
//                     setPrivacy(4);
//                     break;
//                 case 2: // request
//                     setPrivacy(0);
//                     break;
//                 case 3: // none
//                     setPrivacy(5);
//                     break;
//                 }
//                 if (privacyListener != null)
//                     privacyListener.onPrivacyChange(key, privacy);
//             }
//         }).show();
//     }
// 
//     private void drawIcons(int resId) {
//         icon.setImageDrawable(new LayerDrawable(new Drawable[] {
//                 getResources().getDrawable(imageResId),
//                 getResources().getDrawable(resId)
//         }));
//     }
// 
//     public void setPrivacyListener(String key, PrivacyListener listener) {
//         this.privacyListener = listener;
//         this.key = key;
//     }
// 
//     public interface PrivacyListener {
//         public void onPrivacyChange(String key, int visibility);
//     }
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/PrivacyImageButton.java
// public interface PrivacyListener {
//     public void onPrivacyChange(String key, int visibility);
// }


// Path: src/main/java/de/fahrgemeinschaft/EditRideFragment3.java
import org.json.JSONException;
import org.json.JSONObject;
import org.teleportr.Ride;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
import de.fahrgemeinschaft.ContactProvider.CONTACT;
import de.fahrgemeinschaft.util.EditTextImageButton.TextListener;
import de.fahrgemeinschaft.util.PrivacyImageButton;
import de.fahrgemeinschaft.util.PrivacyImageButton.PrivacyListener;

/**
 * Fahrgemeinschaft / Ridesharing App
 * Copyright (c) 2013 by it's authors.
 * Some rights reserved. See LICENSE..
 *
 */

package de.fahrgemeinschaft;





public class EditRideFragment3 extends SherlockFragment
                implements TextListener, PrivacyListener {

    private static final String NAME = "Name";
    private static final String EMPTY = "";
    private PrivacyImageButton mobile;
    private PrivacyImageButton plate;
    private PrivacyImageButton email;
    private PrivacyImageButton land;
    private PrivacyImageButton name;
    private SharedPreferences prefs;



    @Override
    public View onCreateView(final LayoutInflater lI, ViewGroup p, Bundle b) {
        prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        return lI.inflate(R.layout.fragment_ride_edit3, p, false);
    }

    @Override
    public void onViewCreated(View v, Bundle savedInstanceState) {
        super.onViewCreated(v, savedInstanceState);
        email = (PrivacyImageButton) v.findViewById(R.id.email);
        land = (PrivacyImageButton) v.findViewById(R.id.landline);
        mobile = (PrivacyImageButton) v.findViewById(R.id.mobile);
        plate = (PrivacyImageButton) v.findViewById(R.id.plate);
        name = (PrivacyImageButton) v.findViewById(R.id.name);
        email.setTextListener(CONTACT.EMAIL, this);