PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/com/leinardi/ubuntucountdownwidget/customviews/DonateDialogPreference.java

https://code.google.com/p/ubuntu-countdown-widget/
Java | 58 lines | 27 code | 10 blank | 21 comment | 1 complexity | e476d8dc31cbb3dfce60b0d608c597f2 MD5 | raw file
Possible License(s): GPL-3.0
  1. /**
  2. * Kitchen Timer
  3. * Copyright (C) 2010 Roberto Leinardi
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package com.leinardi.ubuntucountdownwidget.customviews;
  20. import android.content.Context;
  21. import android.content.res.TypedArray;
  22. import android.preference.DialogPreference;
  23. import android.util.AttributeSet;
  24. import com.leinardi.analytics.AnalyticsUtils;
  25. import com.leinardi.ubuntucountdownwidget.R;
  26. import com.leinardi.ubuntucountdownwidget.utils.Utils;
  27. public class DonateDialogPreference extends DialogPreference {
  28. Context mContext;
  29. String fileName;
  30. public DonateDialogPreference(Context context, AttributeSet attrs) {
  31. super(context, attrs);
  32. mContext = context;
  33. TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MyDialogPreference);
  34. fileName = a.getString(R.styleable.MyDialogPreference_fileName);
  35. }
  36. // protected void onPrepareDialogBuilder(Builder builder) {
  37. // builder.setView(Utils.dialogWebView(mContext, fileName));
  38. // }
  39. @Override
  40. protected void onDialogClosed(boolean positiveResult) {
  41. super.onDialogClosed(positiveResult);
  42. AnalyticsUtils.getInstance(mContext).trackEvent(
  43. "DonateDialog", "ButtonSelected", positiveResult ? "Yes" : "No", 0);
  44. if (positiveResult) {
  45. Utils.getInstance().donate(mContext);
  46. }
  47. }
  48. }