aboutsummaryrefslogtreecommitdiffstats
path: root/feeds.conf.default
Commit message (Expand)AuthorAgeFilesLines
* feeds.conf.default: disable management feedJohn Crispin2016-06-131-1/+1
* feeds.conf.default: remove the commented ancient feedsJohn Crispin2016-04-201-7/+0
* feeds.conf.default: add new targets feedFelix Fietkau2015-03-191-0/+1
* Move telephony feed to githubSteven Barth2014-12-111-1/+1
* feeds: switch LuCI to Github repoJo-Philipp Wich2014-10-091-1/+1
* feeds: disable oldpackages by defaultSteven Barth2014-07-291-1/+1
* feeds.conf.default: add management feedLuka Perkov2014-06-121-0/+1
* feeds.conf.default: restore the old package feed temporarilyFlorian Fainelli2014-06-111-1/+1
* Switching default packages feed to githubSteven Barth2014-06-101-1/+2
* feeds.conf.default: the telephony feed is now on git.openwrt.orgFelix Fietkau2014-04-191-1/+1
* feeds.conf.default: fix copy&paste mistake (#15383)Felix Fietkau2014-03-261-1/+1
* feeds: switch to using http(s) urlsFelix Fietkau2014-03-261-3/+3
* feeds: disable the x-wrt feed, it is unmaintainedFelix Fietkau2014-02-031-1/+1
* feeds.conf.default: switch packages feed to git (#13818)Felix Fietkau2013-07-051-1/+1
* move packages related to telephony into its own feedMirko Vogt2013-04-291-0/+1
* feeds: fix syntax errorJo-Philipp Wich2013-04-201-1/+1
* feeds: add openwrt-routing feed and drop bmx6 feed which got merged into open...Jo-Philipp Wich2013-04-201-1/+1
* feeds: add upstream bmx6 openwrt feedJo-Philipp Wich2013-04-161-0/+1
* feeds.conf.default: switch LuCI feed to nbd.name git mirrorJo-Philipp Wich2013-03-251-1/+1
* Add xorg feed to feeds.conf.defaultMichael Büsch2011-11-161-0/+1
* switch to LuCI trunk, should be stable enough for common use nowJo-Philipp Wich2010-11-161-1/+1
* Add lxde feed to feeds.conf.defaultLars-Peter Clausen2010-08-121-0/+1
* add a src-link example to feeds.conf.defaultJo-Philipp Wich2009-12-131-0/+1
* switch back to LuCI main repoJo-Philipp Wich2009-11-071-1/+1
* LuCI main repo is down due to server crash, switch to repo mirrorJo-Philipp Wich2009-11-041-1/+1
* switch to LuCI 0.9.x branchJo-Philipp Wich2009-06-101-1/+1
* feeds.conf.default: Change openwrt feeds urls from https to svnAndy Boyett2009-04-011-5/+5
* Add desktop and xfce feed to feeds.conf.defaultLars-Peter Clausen2009-01-191-0/+2
* move <efl> (Enlightenment Foundation Libraries) and bindings into own feed <f...Mirko Vogt2009-01-171-0/+1
* move <packages/phone> into own feed <feeds/phone> and add entry to <feeds.con...Mirko Vogt2009-01-171-0/+1
* Switched LuCI-SVN to another serverSteven Barth2008-10-161-1/+1
* feeds: Switched to LuCI stable branchSteven Barth2008-09-061-1/+1
* rename feeds.conf to feeds.conf.default, make feeds.conf override feeds.conf....Felix Fietkau2008-08-171-0/+3
nstant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.sufficientlysecure.keychain.ui.adapter;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Highlighter;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
    protected LayoutInflater mInflater;
    protected Activity mActivity;

    protected List<ImportKeysListEntry> mData;

    static class ViewHolder {
        public TextView mainUserId;
        public TextView mainUserIdRest;
        public TextView keyId;
        public TextView fingerprint;
        public TextView algorithm;
        public ImageView status;
        public View userIdsDivider;
        public LinearLayout userIdsList;
        public CheckBox checkBox;
    }

    public ImportKeysAdapter(Activity activity) {
        super(activity, -1);
        mActivity = activity;
        mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public void setData(List<ImportKeysListEntry> data) {

        clear();
        if (data != null) {
            this.mData = data;

            // add data to extended ArrayAdapter
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                addAll(data);
            } else {
                for (ImportKeysListEntry entry : data) {
                    add(entry);
                }
            }
        }
    }

    public List<ImportKeysListEntry> getData() {
        return mData;
    }

    /** This method returns a list of all selected entries, with public keys sorted
     * before secret keys, see ImportExportOperation for specifics.
     * @see org.sufficientlysecure.keychain.operations.ImportExportOperation
     */
    public ArrayList<ImportKeysListEntry> getSelectedEntries() {
        ArrayList<ImportKeysListEntry> result = new ArrayList<>();
        ArrayList<ImportKeysListEntry> secrets = new ArrayList<>();
        if (mData == null) {
            return result;
        }
        for (ImportKeysListEntry entry : mData) {
            if (entry.isSelected()) {
                // add this entry to either the secret or the public list
                (entry.isSecretKey() ? secrets : result).add(entry);
            }
        }
        // add secret keys at the end of the list
        result.addAll(secrets);
        return result;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ImportKeysListEntry entry = mData.get(position);
        Highlighter highlighter = new Highlighter(mActivity, entry.getQuery());
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.import_keys_list_item, null);
            holder.mainUserId = (TextView) convertView.findViewById(R.id.import_item_user_id);
            holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.import_item_user_id_email);
            holder.keyId = (TextView) convertView.findViewById(R.id.import_item_key_id);
            holder.fingerprint = (TextView) convertView.findViewById(R.id.import_item_fingerprint);
            holder.algorithm = (TextView) convertView.findViewById(R.id.import_item_algorithm);
            holder.status = (ImageView) convertView.findViewById(R.id.import_item_status);
            holder.userIdsDivider = convertView.findViewById(R.id.import_item_status_divider);
            holder.userIdsList = (LinearLayout) convertView.findViewById(R.id.import_item_user_ids_list);
            holder.checkBox = (CheckBox) convertView.findViewById(R.id.import_item_selected);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        // main user id
        String userId = entry.getUserIds().get(0);
        String[] userIdSplit = KeyRing.splitUserId(userId);

        // name
        if (userIdSplit[0] != null) {
            // show red user id if it is a secret key
            if (entry.isSecretKey()) {
                holder.mainUserId.setText(mActivity.getString(R.string.secret_key)
                        + " " + userIdSplit[0]);
            } else {
                holder.mainUserId.setText(highlighter.highlight(userIdSplit[0]));
            }
        } else {
            holder.mainUserId.setText(R.string.user_id_no_name);
        }

        // email
        if (userIdSplit[1] != null) {
            holder.mainUserIdRest.setVisibility(View.VISIBLE);
            holder.mainUserIdRest.setText(highlighter.highlight(userIdSplit[1]));
        } else {
            holder.mainUserIdRest.setVisibility(View.GONE);
        }

        holder.keyId.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(getContext(), entry.getKeyIdHex()));

        // don't show full fingerprint on key import
        holder.fingerprint.setVisibility(View.GONE);

        if (entry.getAlgorithm() != null) {
            holder.algorithm.setText(entry.getAlgorithm());
            holder.algorithm.setVisibility(View.VISIBLE);
        } else {
            holder.algorithm.setVisibility(View.GONE);
        }

        if (entry.isRevoked()) {
            KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, State.REVOKED, R.color.bg_gray);
        } else if (entry.isExpired()) {
            KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, State.EXPIRED, R.color.bg_gray);
        }

        if (entry.isRevoked() || entry.isExpired()) {
            holder.status.setVisibility(View.VISIBLE);

            // no more space for algorithm display
            holder.algorithm.setVisibility(View.GONE);

            holder.mainUserId.setTextColor(getContext().getResources().getColor(R.color.bg_gray));
            holder.mainUserIdRest.setTextColor(getContext().getResources().getColor(R.color.bg_gray));
            holder.keyId.setTextColor(getContext().getResources().getColor(R.color.bg_gray));
        } else {
            holder.status.setVisibility(View.GONE);
            holder.algorithm.setVisibility(View.VISIBLE);

            if (entry.isSecretKey()) {
                holder.mainUserId.setTextColor(Color.RED);
            } else {
                holder.mainUserId.setTextColor(Color.BLACK);
            }

            holder.mainUserIdRest.setTextColor(Color.BLACK);
            holder.keyId.setTextColor(Color.BLACK);
        }

        if (entry.getUserIds().size() == 1) {
            holder.userIdsList.setVisibility(View.GONE);
            holder.userIdsDivider.setVisibility(View.GONE);
        } else {
            holder.userIdsList.setVisibility(View.VISIBLE);
            holder.userIdsDivider.setVisibility(View.VISIBLE);

            // destroyLoader view from holder
            holder.userIdsList.removeAllViews();

            // we want conventional gpg UserIDs first, then Keybase ”proofs”
            HashMap<String, HashSet<String>> mergedUserIds = entry.getMergedUserIds();
            ArrayList<Map.Entry<String, HashSet<String>>> sortedIds = new ArrayList<Map.Entry<String, HashSet<String>>>(mergedUserIds.entrySet());
            java.util.Collections.sort(sortedIds, new java.util.Comparator<Map.Entry<String, HashSet<String>>>() {
                @Override
                public int compare(Map.Entry<String, HashSet<String>> entry1, Map.Entry<String, HashSet<String>> entry2) {

                    // sort keybase UserIds after non-Keybase
                    boolean e1IsKeybase = entry1.getKey().contains(":");
                    boolean e2IsKeybase = entry2.getKey().contains(":");
                    if (e1IsKeybase != e2IsKeybase) {
                        return (e1IsKeybase) ? 1 : -1;
                    }
                    return entry1.getKey().compareTo(entry2.getKey());
                }
            });

            for (Map.Entry<String, HashSet<String>> pair : sortedIds) {
                String cUserId = pair.getKey();
                HashSet<String> cEmails = pair.getValue();

                TextView uidView = (TextView) mInflater.inflate(
                        R.layout.import_keys_list_entry_user_id, null);
                uidView.setText(highlighter.highlight(cUserId));
                uidView.setPadding(0, 0, FormattingUtils.dpToPx(getContext(), 8), 0);

                if (entry.isRevoked() || entry.isExpired()) {
                    uidView.setTextColor(getContext().getResources().getColor(R.color.bg_gray));
                } else {
                    uidView.setTextColor(getContext().getResources().getColor(R.color.black));
                }

                holder.userIdsList.addView(uidView);

                for (String email : cEmails) {
                    TextView emailView = (TextView) mInflater.inflate(
                            R.layout.import_keys_list_entry_user_id, null);
                    emailView.setPadding(
                            FormattingUtils.dpToPx(getContext(), 16), 0,
                            FormattingUtils.dpToPx(getContext(), 8), 0);
                    emailView.setText(highlighter.highlight(email));

                    if (entry.isRevoked() || entry.isExpired()) {
                        emailView.setTextColor(getContext().getResources().getColor(R.color.bg_gray));
                    } else {
                        emailView.setTextColor(getContext().getResources().getColor(R.color.black));
                    }

                    holder.userIdsList.addView(emailView);
                }
            }
        }

        holder.checkBox.setChecked(entry.isSelected());

        return convertView;
    }

}