Search in sources :

Example 1 with AppInfo

use of io.virtualapp.home.models.AppInfo in project VirtualApp by asLody.

the class CloneAppListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    if (getItemViewType(position) == TYPE_FOOTER) {
        return;
    }
    super.onBindViewHolder(holder, position);
    AppInfo info = mAppList.get(position);
    holder.iconView.setImageDrawable(info.icon);
    holder.nameView.setText(info.name);
    if (isIndexSelected(position)) {
        holder.itemView.setAlpha(1f);
        holder.appCheckView.setImageResource(R.drawable.ic_check);
    } else {
        holder.itemView.setAlpha(0.65f);
        holder.appCheckView.setImageResource(R.drawable.ic_no_check);
    }
    if (info.cloneCount > 0) {
        holder.labelView.setVisibility(View.VISIBLE);
        holder.labelView.setText(info.cloneCount + 1 + "");
    } else {
        holder.labelView.setVisibility(View.INVISIBLE);
    }
    holder.itemView.setOnClickListener(v -> {
        mItemEventListener.onItemClick(info, position);
    });
}
Also used : AppInfo(io.virtualapp.home.models.AppInfo)

Example 2 with AppInfo

use of io.virtualapp.home.models.AppInfo in project VirtualApp by asLody.

the class AppRepository method convertPackageInfoToAppData.

private List<AppInfo> convertPackageInfoToAppData(Context context, List<PackageInfo> pkgList, boolean fastOpen) {
    PackageManager pm = context.getPackageManager();
    List<AppInfo> list = new ArrayList<>(pkgList.size());
    String hostPkg = VirtualCore.get().getHostPkg();
    for (PackageInfo pkg : pkgList) {
        // ignore the host package
        if (hostPkg.equals(pkg.packageName)) {
            continue;
        }
        // ignore the System package
        if (isSystemApplication(pkg)) {
            continue;
        }
        ApplicationInfo applicationInfo = pkg.applicationInfo;
        String path = applicationInfo.sourceDir;
        if (path == null) {
            continue;
        }
        AppInfo info = new AppInfo();
        info.packageName = pkg.packageName;
        info.fastOpen = fastOpen;
        info.path = path;
        info.icon = applicationInfo.loadIcon(pm);
        info.name = applicationInfo.loadLabel(pm);
        InstalledAppInfo installedAppInfo = VirtualCore.get().getInstalledAppInfo(pkg.packageName, 0);
        if (installedAppInfo != null) {
            info.cloneCount = installedAppInfo.getInstalledUsers().length;
        }
        list.add(info);
    }
    return list;
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) InstalledAppInfo(com.lody.virtual.remote.InstalledAppInfo) AppInfo(io.virtualapp.home.models.AppInfo)

Example 3 with AppInfo

use of io.virtualapp.home.models.AppInfo in project VirtualApp by asLody.

the class ListAppFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mRecyclerView = (DragSelectRecyclerView) view.findViewById(R.id.select_app_recycler_view);
    mProgressBar = (ProgressBar) view.findViewById(R.id.select_app_progress_bar);
    mInstallButton = (Button) view.findViewById(R.id.select_app_install_btn);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL));
    mRecyclerView.addItemDecoration(new ItemOffsetDecoration(VUiKit.dpToPx(getContext(), 2)));
    mAdapter = new CloneAppListAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new CloneAppListAdapter.ItemEventListener() {

        @Override
        public void onItemClick(AppInfo info, int position) {
            int count = mAdapter.getSelectedCount();
            if (!mAdapter.isIndexSelected(position)) {
                if (count >= 9) {
                    Toast.makeText(getContext(), "No more then 9 apps can be chosen at a time!", Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            mAdapter.toggleSelected(position);
        }

        @Override
        public boolean isSelectable(int position) {
            return mAdapter.isIndexSelected(position) || mAdapter.getSelectedCount() < 9;
        }
    });
    mAdapter.setSelectionListener(count -> {
        mInstallButton.setEnabled(count > 0);
        mInstallButton.setText(String.format(Locale.ENGLISH, "Install to SandBox (%d)", count));
    });
    mInstallButton.setOnClickListener(v -> {
        Integer[] selectedIndices = mAdapter.getSelectedIndices();
        ArrayList<AppInfoLite> dataList = new ArrayList<AppInfoLite>(selectedIndices.length);
        for (int index : selectedIndices) {
            AppInfo info = mAdapter.getItem(index);
            dataList.add(new AppInfoLite(info.packageName, info.path, info.fastOpen));
        }
        Intent data = new Intent();
        data.putParcelableArrayListExtra(VCommends.EXTRA_APP_INFO_LIST, dataList);
        getActivity().setResult(Activity.RESULT_OK, data);
        getActivity().finish();
    });
    new ListAppPresenterImpl(getActivity(), this, getSelectFrom()).start();
}
Also used : ArrayList(java.util.ArrayList) AppInfoLite(io.virtualapp.home.models.AppInfoLite) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) Intent(android.content.Intent) ItemOffsetDecoration(io.virtualapp.home.adapters.decorations.ItemOffsetDecoration) AppInfo(io.virtualapp.home.models.AppInfo) CloneAppListAdapter(io.virtualapp.home.adapters.CloneAppListAdapter)

Aggregations

AppInfo (io.virtualapp.home.models.AppInfo)3 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 InstalledAppInfo (com.lody.virtual.remote.InstalledAppInfo)1 CloneAppListAdapter (io.virtualapp.home.adapters.CloneAppListAdapter)1 ItemOffsetDecoration (io.virtualapp.home.adapters.decorations.ItemOffsetDecoration)1 AppInfoLite (io.virtualapp.home.models.AppInfoLite)1