package org.wikipedia.settings;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import org.wikipedia.R;

public class PreferenceMultiLine extends Preference {

    public PreferenceMultiLine(Context ctx, AttributeSet attrs, int defStyle) {
        super(ctx, attrs, defStyle);
    }

    public PreferenceMultiLine(Context ctx, AttributeSet attrs) {
        super(ctx, attrs);
    }

    public PreferenceMultiLine(Context ctx) {
        super(ctx);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        TextView textView = (TextView) view.findViewById(android.R.id.title);
        if (textView != null) {
            textView.setSingleLine(false);
        }
        // Intercept the click listener for this preference, and if the preference has an intent,
        // launch the intent ourselves, so that we can catch the exception if the intent fails.
        this.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (preference.getIntent() != null) {
                    try {
                        getContext().startActivity(preference.getIntent());
                    } catch (ActivityNotFoundException e) {
                        Toast.makeText(getContext(), getContext().getString(R.string.error_browser_not_found), Toast.LENGTH_LONG).show();
                    }
                    return true;
                }
                return false;
            }
        });
    }
}

@@ -1091,16 +1091,165 @@
  fails.%0A
+        // (but only do this if the preference doesn't already have a click listener)%0A        if (this.getOnPreferenceClickListener() == null) %7B%0A    
         
@@ -1312,24 +1312,28 @@
 istener() %7B%0A
+    
             
@@ -1350,24 +1350,28 @@
             
+    
 public boole
@@ -1428,24 +1428,28 @@
             
+  
+  
 if (preferen
@@ -1494,16 +1494,20 @@
         
+    
 try %7B%0A  
@@ -1528,16 +1528,20 @@
         
+ 
+   
 getConte
@@ -1604,16 +1604,20 @@
         
+   
+ 
 %7D catch 
@@ -1644,24 +1644,28 @@
 eption e) %7B%0A
+    
             
@@ -1802,34 +1802,42 @@
                 
-%7D%0A
+    %7D%0A    
                 
@@ -1861,34 +1861,42 @@
                 
-%7D%0A
+    %7D%0A    
                 
@@ -1913,34 +1913,42 @@
 se;%0A            
-%7D%0A
+    %7D%0A    
         %7D);%0A    
@@ -1943,16 +1943,26 @@
     %7D);%0A
+        %7D%0A
     %7D%0A%7D%0A

Fix "logout" preference after crash fix.