PageRenderTime 1ms CodeModel.GetById 70ms app.highlight 3ms RepoModel.GetById 49ms 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
 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
20package com.leinardi.ubuntucountdownwidget.customviews;
21
22import android.content.Context;
23import android.content.res.TypedArray;
24import android.preference.DialogPreference;
25import android.util.AttributeSet;
26
27import com.leinardi.analytics.AnalyticsUtils;
28import com.leinardi.ubuntucountdownwidget.R;
29import com.leinardi.ubuntucountdownwidget.utils.Utils;
30
31public class DonateDialogPreference extends DialogPreference {
32    Context mContext;
33    String fileName;
34
35    public DonateDialogPreference(Context context, AttributeSet attrs) {
36        super(context, attrs);
37
38        mContext = context;
39        TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MyDialogPreference);
40        fileName = a.getString(R.styleable.MyDialogPreference_fileName);
41    }
42
43    // protected void onPrepareDialogBuilder(Builder builder) {
44    // builder.setView(Utils.dialogWebView(mContext, fileName));
45    // }
46
47    @Override
48    protected void onDialogClosed(boolean positiveResult) {
49        super.onDialogClosed(positiveResult);
50
51        AnalyticsUtils.getInstance(mContext).trackEvent(
52                "DonateDialog", "ButtonSelected", positiveResult ? "Yes" : "No", 0);
53
54        if (positiveResult) {
55            Utils.getInstance().donate(mContext);
56        }
57    }
58}