]> git.ipfire.org Git - thirdparty/strongswan.git/blob
0bfbbcfa502b997be9723c6b1c3accc925d20e14
[thirdparty/strongswan.git] /
1 /*
2 * Copyright (C) 2017 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 package org.strongswan.android.ui.adapter;
17
18 import android.content.pm.ApplicationInfo;
19 import android.content.pm.PackageManager;
20 import android.graphics.drawable.Drawable;
21 import android.support.annotation.NonNull;
22
23 import java.text.Collator;
24
25 public class SelectedApplicationEntry implements Comparable<SelectedApplicationEntry>
26 {
27 private final ApplicationInfo mInfo;
28 private final Drawable mIcon;
29 private final String mName;
30 private boolean mSelected;
31
32 public SelectedApplicationEntry(PackageManager packageManager, ApplicationInfo info)
33 {
34 mInfo = info;
35 CharSequence name = info.loadLabel(packageManager);
36 mName = name == null ? info.packageName : name.toString();
37 mIcon = info.loadIcon(packageManager);
38 }
39
40 public void setSelected(boolean selected)
41 {
42 mSelected = selected;
43 }
44
45 public boolean isSelected()
46 {
47 return mSelected;
48 }
49
50 public ApplicationInfo getInfo()
51 {
52 return mInfo;
53 }
54
55 public Drawable getIcon()
56 {
57 return mIcon;
58 }
59
60 @Override
61 public String toString()
62 {
63 return mName;
64 }
65
66 @Override
67 public int compareTo(@NonNull SelectedApplicationEntry another)
68 {
69 return Collator.getInstance().compare(toString(), another.toString());
70 }
71 }