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.ui;
23 import java.util.List;
25 import com.nhaarman.listviewanimations.appearance.AnimationAdapter;
26 import com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter;
27 import com.samsung.srpol.R;
28 import com.samsung.srpol.data.Category;
29 import com.samsung.srpol.data.Subcategory;
30 import com.samsung.srpol.loader.AppListLoader;
32 import android.content.Context;
33 import android.content.Intent;
34 import android.net.Uri;
35 import android.os.Bundle;
36 import android.support.v7.app.ActionBarActivity;
37 import android.view.LayoutInflater;
38 import android.view.View;
39 import android.view.ViewGroup;
40 import android.view.View.OnClickListener;
41 import android.widget.ArrayAdapter;
42 import android.widget.ImageButton;
43 import android.widget.ImageView;
44 import android.widget.ListView;
45 import android.widget.TextView;
47 public class PopupActivity extends ActionBarActivity {
49 public static final String POPUP_CATEGORY = "POPUP_CATEGORY";
51 private Category mCategory;
52 private ThreatsAdapter mAdapter;
55 protected void onCreate(Bundle savedInstanceState) {
56 super.onCreate(savedInstanceState);
57 setContentView(R.layout.activity_popup);
59 Intent intent = getIntent();
61 categotyId = intent.getIntExtra(POPUP_CATEGORY, -1);
64 TextView header = (TextView) findViewById(R.id.header_text);
65 List<Category> containerList = AppListLoader.getCategories();
66 if (containerList != null && categotyId >= 0) {
67 mCategory = containerList.get(categotyId);
68 header.setText(getString(R.string.apps_that)
69 + mCategory.getHeader());
72 ListView listview = (ListView) findViewById(R.id.threats_list);
73 mAdapter = new ThreatsAdapter(this);
74 for (Subcategory subCat : mCategory.getSubCategories())
76 AnimationAdapter adapter = new AlphaInAnimationAdapter(mAdapter);
77 adapter.setAbsListView(listview);
78 listview.setAdapter(adapter);
80 ImageButton back = (ImageButton) findViewById(R.id.back_button);
81 back.setOnClickListener(new OnClickListener() {
84 public void onClick(View arg0) {
89 ImageButton more = (ImageButton) findViewById(R.id.moreinfo_button);
90 more.setOnClickListener(new OnClickListener() {
93 public void onClick(View v) {
94 Intent intent = new Intent(Intent.ACTION_VIEW, Uri
95 .parse(mCategory.getLink()));
96 startActivity(intent);
101 private class ThreatsAdapter extends ArrayAdapter<Subcategory> {
103 private class ViewHolder {
105 TextView description;
108 public ThreatsAdapter(Context context) {
109 super(context, R.layout.threats_list_item);
113 public boolean isEnabled(int position) {
118 public View getView(int position, View convertView, ViewGroup parent) {
120 if (convertView == null) {
121 LayoutInflater inflater = getLayoutInflater();
122 convertView = inflater.inflate(R.layout.threats_list_item,
124 holder = new ViewHolder();
125 holder.icon = (ImageView) convertView
126 .findViewById(R.id.threat_icon);
127 holder.description = (TextView) convertView
128 .findViewById(R.id.threat_text);
129 convertView.setTag(holder);
131 holder = (ViewHolder) convertView.getTag();
134 Subcategory item = getItem(position);
136 holder.icon.setImageDrawable(item.getIconDrawable());
137 holder.description.setText(item.getDescription());
138 holder.description.setTextColor(getResources().getColor(
139 android.R.color.white));