| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 public HelpfulCheckBoxPreference(final Context context, final AttributeSet att
rs) | 38 public HelpfulCheckBoxPreference(final Context context, final AttributeSet att
rs) |
| 39 { | 39 { |
| 40 super(context, attrs); | 40 super(context, attrs); |
| 41 } | 41 } |
| 42 | 42 |
| 43 @Override | 43 @Override |
| 44 protected void onBindView(final View view) | 44 protected void onBindView(final View view) |
| 45 { | 45 { |
| 46 super.onBindView(view); | 46 super.onBindView(view); |
| 47 | 47 |
| 48 final ImageView helpImage = new ImageView(this.getContext()); | 48 final ImageView helpImage = new ImageView(getContext()); |
| 49 final ViewGroup widgetFrameView = ((ViewGroup)view.findViewById(android.R.id
.widget_frame)); | 49 final ViewGroup widgetFrameView = ((ViewGroup) view.findViewById(android.R.i
d.widget_frame)); |
| 50 if (widgetFrameView == null) | 50 if (widgetFrameView == null) |
| 51 { | |
| 52 return; | 51 return; |
| 53 } | |
| 54 widgetFrameView.setVisibility(View.VISIBLE); | 52 widgetFrameView.setVisibility(View.VISIBLE); |
| 55 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5; | 53 final int rightPaddingDip = android.os.Build.VERSION.SDK_INT < 14 ? 8 : 5; |
| 56 final float mDensity = this.getContext().getResources().getDisplayMetrics().
density; | 54 final float mDensity = getContext().getResources().getDisplayMetrics().densi
ty; |
| 57 if (widgetFrameView instanceof LinearLayout) | 55 if (widgetFrameView instanceof LinearLayout) |
| 58 { | 56 { |
| 59 ((LinearLayout)widgetFrameView).setOrientation(LinearLayout.HORIZONTAL); | 57 ((LinearLayout) widgetFrameView).setOrientation(LinearLayout.HORIZONTAL); |
| 60 } | 58 } |
| 61 widgetFrameView.addView(helpImage, 0); | 59 widgetFrameView.addView(helpImage, 0); |
| 62 helpImage.setImageResource(R.drawable.ic_menu_help); | 60 helpImage.setImageResource(R.drawable.ic_menu_help); |
| 63 helpImage.setPadding(helpImage.getPaddingLeft(), helpImage.getPaddingTop(),
(int)(mDensity * rightPaddingDip), helpImage.getPaddingBottom()); | 61 helpImage.setPadding(helpImage.getPaddingLeft(), helpImage.getPaddingTop(),
(int) (mDensity * rightPaddingDip), helpImage.getPaddingBottom()); |
| 64 helpImage.setOnClickListener(new OnClickListener() | 62 helpImage.setOnClickListener(new OnClickListener() |
| 65 { | 63 { |
| 66 @Override | 64 @Override |
| 67 public void onClick(final View v) | 65 public void onClick(final View v) |
| 68 { | 66 { |
| 69 if (HelpfulCheckBoxPreference.this.helpClickListener != null) | 67 if (helpClickListener != null) |
| 70 { | 68 { |
| 71 HelpfulCheckBoxPreference.this.helpClickListener.onClick(helpImage); | 69 helpClickListener.onClick(helpImage); |
| 72 } | 70 } |
| 73 else if (HelpfulCheckBoxPreference.this.url != null) | 71 else if (url != null) |
| 74 { | 72 { |
| 75 final Uri uri = Uri.parse(HelpfulCheckBoxPreference.this.url); | 73 final Uri uri = Uri.parse(url); |
| 76 final Intent intent = new Intent(Intent.ACTION_VIEW, uri); | 74 final Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| 77 HelpfulCheckBoxPreference.this.getContext().startActivity(intent); | 75 HelpfulCheckBoxPreference.this.getContext().startActivity(intent); |
| 78 } | 76 } |
| 79 } | 77 } |
| 80 }); | 78 }); |
| 81 } | 79 } |
| 82 | 80 |
| 83 public void setOnHelpClickListener(final OnClickListener l) | 81 public void setOnHelpClickListener(final OnClickListener l) |
| 84 { | 82 { |
| 85 this.helpClickListener = l; | 83 helpClickListener = l; |
| 86 } | 84 } |
| 87 | 85 |
| 88 public void setHelpUrl(final String url) | 86 public void setHelpUrl(final String url) |
| 89 { | 87 { |
| 90 this.url = url; | 88 this.url = url; |
| 91 } | 89 } |
| 92 } | 90 } |
| LEFT | RIGHT |