aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard/android/preference/DonatePreference.java
blob: 6ae0622cc93769af92301e83cfe1fa7f14ab39d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright © 2019 WireGuard LLC. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package com.wireguard.android.preference;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.AttributeSet;

import com.wireguard.android.Application;
import com.wireguard.android.BuildConfig;
import com.wireguard.android.R;

import java.util.Locale;

import androidx.annotation.Nullable;
import androidx.preference.Preference;

public class DonatePreference extends Preference {
    public DonatePreference(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public CharSequence getSummary() { return getContext().getString(R.string.donate_summary); }

    @Override
    public CharSequence getTitle() { return getContext().getString(R.string.donate_title); }

    @Override
    protected void onClick() {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.wireguard.com/donations/"));
        try {
            getContext().startActivity(intent);
        } catch (final ActivityNotFoundException ignored) {
        }
    }

}