Android Open Source - Sharinger Share Intent List Builder






From Project

Back to project page Sharinger.

License

The source code is released under:

Apache License

If you think the Android project Sharinger listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mobi.tarantio.tools.sharinger.app;
/*from  ww  w. j a va  2  s  .  c o  m*/
import android.content.pm.ResolveInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * ?????? ???????? ???????? ???? ????
 * Created by kolipass on 15.06.14.
 */
public class ShareIntentListBuilder {
    private CheckDecorator checkDecorator = new CheckNonExported(new CheckSharingerPackage(null));

    public ShareIntentListBuilder() {
        CheckDecorator checkDecorator = new CheckNonExported(new CheckSharingerPackage(null));
    }

    /**
     * ???????????? ?? ???????. ????? ????? ?? ??????????? ???????????? ?????????
     *
     * @param checkDecorator
     */
    public ShareIntentListBuilder(CheckDecorator checkDecorator) {
        this.checkDecorator = checkDecorator;
    }

    public List<ResolveInfo> build(List<ResolveInfo> activities) {

        List<ResolveInfo> resolveInfos = new ArrayList<ResolveInfo>();
        for (ResolveInfo info : activities) {
            if (checkDecorator == null || checkDecorator.check(info)) {
                resolveInfos.add(info);
            }
        }
        return resolveInfos;
    }

    interface Checker {
        public boolean check(ResolveInfo info);
    }

    abstract class CheckDecorator implements Checker {
        protected Checker decorator;

        protected CheckDecorator(Checker decorator) {
            this.decorator = decorator;
        }

        public boolean check(ResolveInfo info) {
            return info != null && (decorator == null || decorator.check(info));
        }
    }

    /**
     * ??????, ??? ???????????? ?? ???????????????? ????????
     */
    class CheckNonExported extends CheckDecorator {
        protected CheckNonExported(Checker decorator) {
            super(decorator);
        }

        @Override
        public boolean check(ResolveInfo info) {
            return super.check(info) && info.activityInfo.exported;
        }
    }

    /**
     * ??????, ??? ???????????? ????? ???????? Sharinger'?
     */
    class CheckSharingerPackage extends CheckDecorator {

        protected CheckSharingerPackage(Checker decorator) {
            super(decorator);
        }

        @Override
        public boolean check(ResolveInfo info) {
            return super.check(info) && !info.activityInfo.packageName.contains("sharinger");
        }
    }
}




Java Source Code List

mobi.tarantio.tools.sharinger.app.CopyToClipboardActivity.java
mobi.tarantio.tools.sharinger.app.ExpandableTextView.java
mobi.tarantio.tools.sharinger.app.IntentHandler.java
mobi.tarantio.tools.sharinger.app.ShareIntentListBuilder.java
mobi.tarantio.tools.sharinger.app.ShareListActivity.java
mobi.tarantio.tools.sharinger.app.SystemBarTintManager.java
mobi.tarantio.tools.sharinger.app.TextViewActivity.java
mobi.tarantio.tools.sharinger.app.test.java