2 Copyright (C) 2014 Samsung Electronics Polska Sp. z o.o.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU AFFERO General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 You may obtain a copy of the License at
10 http://www.gnu.org/licenses/agpl-3.0.txt
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 package com.samsung.srpol.data;
23 import java.util.ArrayList;
25 import android.content.Context;
26 import android.content.res.Resources.NotFoundException;
27 import android.graphics.drawable.Drawable;
29 public class Subcategory {
31 public static final int CAN_SEND_DATA_SUB_CATEGORY_ID = 1;
32 public static final String CAN_SEND_DATA_SUB_CATEGORY_HEADER = "uprawnienia do przesyĆu danych";
33 private static final String DARK_SUFIX = "_dark";
34 private static final String DISABLE_SUFIX = "_disable";
35 private static int mIdGenerator = 2;
37 private int mSubcatId;
38 private String mHeader;
39 private String mDescription;
41 private Drawable mIconDrawable;
42 private Drawable mIconDarkDrawable;
43 private Drawable mIconDisabledDrawable;
44 private ArrayList<String> mPermissions;
46 public Subcategory(Context context, String header, String description,
47 String icon, ArrayList<String> permissions) {
49 mDescription = description;
50 if (mHeader.equals(CAN_SEND_DATA_SUB_CATEGORY_HEADER)) {
51 mSubcatId = CAN_SEND_DATA_SUB_CATEGORY_ID;
53 mSubcatId = mIdGenerator;
54 mIdGenerator = mIdGenerator << 1;
57 String packageName = context.getPackageName();
58 mIconRes = context.getResources().getIdentifier(icon, "drawable",
60 mIconDrawable = context.getResources().getDrawable(mIconRes);
62 int iconDarkRes = context.getResources().getIdentifier(
63 icon.concat(DARK_SUFIX), "drawable", packageName);
65 mIconDarkDrawable = context.getResources().getDrawable(iconDarkRes);
66 } catch (NotFoundException ex) {
67 mIconDarkDrawable = mIconDrawable;
70 int iconDisableRes = context.getResources().getIdentifier(icon.concat(DISABLE_SUFIX), "drawable", packageName);
72 mIconDisabledDrawable = context.getResources().getDrawable(iconDisableRes);
73 } catch (NotFoundException ex) {
74 mIconDisabledDrawable = mIconDrawable;
77 mPermissions = permissions;
80 public ArrayList<String> getPermissions() {
88 public String getHeader() {
92 public Drawable getIconDrawable() {
96 public Drawable getDarkIcon() {
97 return mIconDarkDrawable;
100 public Drawable getDisabledIcon() {
101 return mIconDisabledDrawable;
104 public String getDescription() {
108 public static void resetGenerator() {