Skip to content

Commit ee20640

Browse files
committed
优化文件选择dialog
1 parent 76ad17e commit ee20640

File tree

9 files changed

+255
-43
lines changed

9 files changed

+255
-43
lines changed

app/src/main/java/com/ichtj/basetools/install/InstallAPkAty.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
import android.os.Bundle;
6+
import android.text.TextUtils;
67
import android.util.Log;
78
import android.view.View;
89
import android.widget.RadioButton;
@@ -12,6 +13,8 @@
1213
import androidx.core.content.FileProvider;
1314

1415
import com.face_chtj.base_iotutils.AppsUtils;
16+
import com.face_chtj.base_iotutils.FileDialogSelectUtils;
17+
import com.face_chtj.base_iotutils.ShellUtils;
1518
import com.face_chtj.base_iotutils.TimeUtils;
1619
import com.face_chtj.base_iotutils.ToastUtils;
1720
import com.ichtj.basetools.R;
@@ -24,6 +27,7 @@
2427
import java.io.FileOutputStream;
2528
import java.io.IOException;
2629
import java.io.InputStream;
30+
import java.util.List;
2731

2832
/**
2933
* Create on 2020/7/13
@@ -127,6 +131,23 @@ public void getResult(boolean isComplete, String err) {
127131
});
128132
}
129133

134+
public void adbInstallClick(View view) {
135+
FileDialogSelectUtils fileDialogSelectUtils =new FileDialogSelectUtils(this, new File("/sdcard/"), new FileDialogSelectUtils.FileSelectCallback() {
136+
@Override
137+
public void onFileSelected(List<File> selected) {
138+
if (selected==null&&selected.size()<=0){
139+
return;
140+
}
141+
Log.d(TAG, "onFileSelected: "+selected);
142+
// ShellUtils.CommandResult commandResult=ShellUtils.execCommand("pm install -r /sdcard/pkgSearch.apk",true);
143+
// Log.d(TAG, "onFileSelected: commandResult>>"+commandResult);
144+
}
145+
}).setSizeRatio(0.5f,0.5f,30).setSingleSelect(true);
146+
fileDialogSelectUtils.show();
147+
}
148+
149+
150+
130151
public void silenceInstall(View view) {
131152
// 启动文件选择器
132153
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

app/src/main/res/layout/activity_install_apk.xml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6+
android:background="#C6BBBB"
67
android:orientation="vertical">
78

89
<com.face_chtj.base_iotutils.view.TopTitleBar
@@ -20,60 +21,66 @@
2021
android:layout_height="wrap_content"
2122
android:onClick="pmInstall"
2223
android:text="安装(PM INSTALL)"
23-
android:textSize="@dimen/small_text_size"
24+
android:textSize="@dimen/large_text_size"
2425
android:visibility="gone" />
2526

2627
<Button
2728
android:layout_width="wrap_content"
2829
android:layout_height="wrap_content"
2930
android:onClick="pmUnInstall"
3031
android:text="卸载(PM UNINSTALL)"
31-
android:textSize="@dimen/small_text_size"
32+
android:textSize="@dimen/large_text_size"
3233
android:visibility="gone" />
3334

3435
<Button
3536
android:layout_width="wrap_content"
3637
android:layout_height="wrap_content"
3738
android:onClick="systemApiInstall"
3839
android:text="安装(SYTEM API)"
39-
android:textSize="@dimen/small_text_size"
40+
android:textSize="@dimen/large_text_size"
4041
android:visibility="gone" />
4142

4243
<Button
4344
android:layout_width="wrap_content"
4445
android:layout_height="wrap_content"
4546
android:onClick="systemApiUnInstall"
4647
android:text="卸载(SYTEM API)"
47-
android:textSize="@dimen/small_text_size"
48+
android:textSize="@dimen/large_text_size"
4849
android:visibility="gone" />
4950

51+
<Button
52+
android:layout_width="wrap_content"
53+
android:layout_height="wrap_content"
54+
android:onClick="adbInstallClick"
55+
android:text="ADB安装"
56+
android:textSize="@dimen/large_text_size" />
5057
<Button
5158
android:layout_width="wrap_content"
5259
android:layout_height="wrap_content"
5360
android:onClick="silenceInstall"
5461
android:text="静默安装"
55-
android:textSize="@dimen/small_text_size" />
62+
android:textSize="@dimen/large_text_size" />
5663

5764
<Button
5865
android:layout_width="wrap_content"
5966
android:layout_height="wrap_content"
6067
android:onClick="silenceUnInstall"
6168
android:text="静默卸载"
62-
android:textSize="@dimen/small_text_size" />
69+
android:textSize="@dimen/large_text_size" />
6370

6471
<TextView
6572
android:layout_width="wrap_content"
6673
android:layout_height="wrap_content"
6774
android:layout_marginTop="25dp"
6875
android:text="以下为美团测试静默升级的相关安装:"
69-
android:textSize="@dimen/small_text_size" />
76+
android:textSize="@dimen/large_text_size" />
7077

7178
<TextView
7279
android:id="@+id/tvNowVersion"
7380
android:layout_width="wrap_content"
7481
android:layout_height="wrap_content"
7582
android:text="当前apk版本:"
76-
android:textSize="@dimen/small_text_size" />
83+
android:textSize="@dimen/large_text_size" />
7784

7885
<LinearLayout
7986
android:layout_width="wrap_content"
@@ -92,14 +99,14 @@
9299
android:layout_height="wrap_content"
93100
android:checked="true"
94101
android:text=""
95-
android:textSize="@dimen/small_text_size" />
102+
android:textSize="@dimen/large_text_size" />
96103

97104
<RadioButton
98105
android:id="@+id/rbOld"
99106
android:layout_width="wrap_content"
100107
android:layout_height="wrap_content"
101108
android:text=""
102-
android:textSize="@dimen/small_text_size" />
109+
android:textSize="@dimen/large_text_size" />
103110
</RadioGroup>
104111

105112
<Button
@@ -108,15 +115,15 @@
108115
android:layout_gravity="center"
109116
android:onClick="intentInstallApkClick"
110117
android:text="安装版本1.1"
111-
android:textSize="@dimen/small_text_size" />
118+
android:textSize="@dimen/large_text_size" />
112119

113120
<Button
114121
android:layout_width="wrap_content"
115122
android:layout_height="wrap_content"
116123
android:layout_gravity="center"
117124
android:onClick="otherInstallApkClick"
118125
android:text="pkgInstall"
119-
android:textSize="@dimen/small_text_size" />
126+
android:textSize="@dimen/large_text_size" />
120127
</LinearLayout>
121128

122129
</LinearLayout>

0 commit comments

Comments
 (0)