|
|
@@ -0,0 +1,160 @@
|
|
|
+package com.sheep.gamegroup.view.activity;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.pm.ApplicationInfo;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.kfzs.android.view.tag.FlowLayout;
|
|
|
+import com.kfzs.android.view.tag.TagAdapter;
|
|
|
+import com.kfzs.android.view.tag.TagFlowLayout;
|
|
|
+import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
+import com.sheep.gamegroup.model.entity.AppInfo;
|
|
|
+import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
+import com.sheep.gamegroup.model.entity.UserLabel;
|
|
|
+import com.sheep.gamegroup.model.entity.UserLabelList;
|
|
|
+import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.SysAppUtil;
|
|
|
+import com.sheep.gamegroup.util.ViewHolder;
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
+import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
+
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.util.Enumeration;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
+import java.util.zip.ZipFile;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import butterknife.OnClick;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by realicing on 2018/6/19.
|
|
|
+ * realicing@sina.com
|
|
|
+ */
|
|
|
+public class ActInstallApkList extends BaseActivity {
|
|
|
+ @Override
|
|
|
+ protected int getLayoutId() {
|
|
|
+ return R.layout.act_user_label_list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @BindView(R.id.user_label_list)
|
|
|
+ RecyclerView user_label_list;
|
|
|
+
|
|
|
+ @BindView(R.id.user_label_commit_tv)
|
|
|
+ TextView user_label_commit_tv;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initView() {
|
|
|
+ TitleBarUtils
|
|
|
+ .getInstance()
|
|
|
+ .setTitle(this, "已经安装的应用列表")
|
|
|
+ .setTitleFinish(this);
|
|
|
+ user_label_commit_tv.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initListener() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initData() {
|
|
|
+ loadData(SysAppUtil.getAppInfos());
|
|
|
+ }
|
|
|
+ private List<AppInfo> appInfoList;
|
|
|
+ private void loadData(List<AppInfo> appInfoList) {
|
|
|
+ this.appInfoList = appInfoList;
|
|
|
+ user_label_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
+ user_label_list.setAdapter(new AdbCommonRecycler<AppInfo>(SheepApp.getInstance(), appInfoList){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getViewIdByType(int type) {
|
|
|
+ return R.layout.app_info_item;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void convert(ViewHolder holder, final AppInfo appInfo) {
|
|
|
+ ImageView app_info_iv = (ImageView)holder.itemView.findViewById(R.id.app_info_iv);
|
|
|
+ TextView app_info_name_tv = (TextView)holder.itemView.findViewById(R.id.app_info_name_tv);
|
|
|
+ TextView app_info_package_name_tv = (TextView)holder.itemView.findViewById(R.id.app_info_package_name_tv);
|
|
|
+ TextView app_info_size_tv = (TextView)holder.itemView.findViewById(R.id.app_info_size_tv);
|
|
|
+ TextView app_info_path_tv = (TextView)holder.itemView.findViewById(R.id.app_info_path_tv);
|
|
|
+ TextView app_info_is_sys_tv = (TextView)holder.itemView.findViewById(R.id.app_info_is_sys_tv);
|
|
|
+ TextView app_info_is_sd_tv = (TextView)holder.itemView.findViewById(R.id.app_info_is_sd_tv);
|
|
|
+
|
|
|
+ app_info_iv.setImageDrawable(appInfo.getIcon());
|
|
|
+ ViewUtil.setText(app_info_name_tv, appInfo.getAppName());
|
|
|
+ ViewUtil.setText(app_info_package_name_tv, appInfo.getPackageName());
|
|
|
+ ViewUtil.setText(app_info_size_tv, appInfo.getApkSize());
|
|
|
+ ViewUtil.setText(app_info_path_tv, appInfo.getSourceDir());
|
|
|
+ ViewUtil.setText(app_info_is_sys_tv, appInfo.isUserApp() ? "用户app":"系统app");
|
|
|
+ ViewUtil.setText(app_info_is_sd_tv, appInfo.isSD() ? "SD卡" : "手机内存");
|
|
|
+
|
|
|
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ onClickItem(view, appInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onClickItem(View view, final AppInfo appInfo) {
|
|
|
+ readApp(appInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void readApp(AppInfo appInfo) {
|
|
|
+ String sourceDir = appInfo.getSourceDir();
|
|
|
+ ZipFile zipfile = null;
|
|
|
+ try {
|
|
|
+ zipfile = new ZipFile(sourceDir);
|
|
|
+ Enumeration<?> entries = zipfile.entries();
|
|
|
+ while (entries.hasMoreElements()) {
|
|
|
+ ZipEntry entry = ((ZipEntry) entries.nextElement());
|
|
|
+ String entryName = entry.getName();
|
|
|
+ if (entryName.contains("../")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ LogUtil.println("readApp", appInfo.getAppName(), appInfo.getPackageName(), entryName);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (zipfile != null) {
|
|
|
+ try {
|
|
|
+ zipfile.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @OnClick({R.id.user_label_commit_tv})
|
|
|
+ public void onViewClicked(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.user_label_commit_tv:
|
|
|
+ toCommit();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void toCommit() {
|
|
|
+ }
|
|
|
+
|
|
|
+}
|