extract string resource in AppManage

This commit is contained in:
BinTianqi
2024-03-02 18:04:08 +08:00
parent 377deca99a
commit 01d6fef6de
2 changed files with 115 additions and 82 deletions

View File

@@ -71,7 +71,7 @@ fun ApplicationManage(){
TextField( TextField(
value = pkgName, value = pkgName,
onValueChange = { pkgName = it }, onValueChange = { pkgName = it },
label = { Text("包名") }, label = { Text(stringResource(R.string.package_name)) },
modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp), modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}) keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()})
@@ -82,14 +82,14 @@ fun ApplicationManage(){
TextField( TextField(
value = pkgName, value = pkgName,
onValueChange = { pkgName = it }, onValueChange = { pkgName = it },
label = { Text("包名") }, label = { Text(stringResource(R.string.package_name)) },
modifier = Modifier.fillMaxWidth().padding(horizontal = 2.dp,vertical = 2.dp), modifier = Modifier.fillMaxWidth().padding(horizontal = 2.dp,vertical = 2.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}) keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()})
) )
}else{Spacer(Modifier.padding(vertical = 2.dp))} }else{Spacer(Modifier.padding(vertical = 2.dp))}
if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Text(text = "作用域: 工作资料", style = bodyTextStyle, textAlign = TextAlign.Center,modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp)) Text(text = stringResource(R.string.scope_is_work_profile), style = bodyTextStyle, textAlign = TextAlign.Center,modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp))
} }
Button( Button(
@@ -100,7 +100,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp) modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)
){ ){
Text("应用详情") Text(stringResource(R.string.app_info))
} }
if(VERSION.SDK_INT>=24&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=24&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
@@ -120,9 +120,9 @@ fun ApplicationManage(){
try { try {
myDpm.setAlwaysOnVpnPackage(myComponent, pkgName, b) myDpm.setAlwaysOnVpnPackage(myComponent, pkgName, b)
} catch(e: java.lang.UnsupportedOperationException) { } catch(e: java.lang.UnsupportedOperationException) {
Toast.makeText(myContext, "不支持", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.unsupported), Toast.LENGTH_SHORT).show()
} catch(e: NameNotFoundException) { } catch(e: NameNotFoundException) {
Toast.makeText(myContext, "未安装", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.not_installed), Toast.LENGTH_SHORT).show()
} }
} }
} }
@@ -130,31 +130,31 @@ fun ApplicationManage(){
if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){ if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
var state by remember{mutableStateOf(myDpm.isUninstallBlocked(myComponent,pkgName))} var state by remember{mutableStateOf(myDpm.isUninstallBlocked(myComponent,pkgName))}
Text(text = "防卸载", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.block_uninstall), style = typography.titleLarge, color = titleColor)
Text("当前状态:${if(state){"打开"}else{"关闭"}}") Text(stringResource(R.string.current_state, stringResource(if(state){R.string.enabled}else{R.string.disabled})))
Text(text = "有时候无法正确获取防卸载状态", style = bodyTextStyle) Text(text = stringResource(R.string.sometimes_get_wrong_block_uninstall_state), style = bodyTextStyle)
Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) { Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) {
Button( Button(
onClick = { onClick = {
focusMgr.clearFocus() focusMgr.clearFocus()
myDpm.setUninstallBlocked(myComponent,pkgName,true) myDpm.setUninstallBlocked(myComponent,pkgName,true)
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
state = myDpm.isUninstallBlocked(myComponent,pkgName) state = myDpm.isUninstallBlocked(myComponent,pkgName)
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("打开") Text(stringResource(R.string.enable))
} }
Button( Button(
onClick = { onClick = {
focusMgr.clearFocus() focusMgr.clearFocus()
myDpm.setUninstallBlocked(myComponent,pkgName,false) myDpm.setUninstallBlocked(myComponent,pkgName,false)
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
state = myDpm.isUninstallBlocked(myComponent,pkgName) state = myDpm.isUninstallBlocked(myComponent,pkgName)
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
){ ){
Text("关闭") Text(stringResource(R.string.disable))
} }
} }
} }
@@ -172,11 +172,11 @@ fun ApplicationManage(){
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refresh();inited=true} if(!inited){refresh();inited=true}
Text(text = "禁止用户控制", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.ucd), style = typography.titleLarge, color = titleColor)
Text(text = "用户将无法清除应用的存储空间和缓存", style = bodyTextStyle) Text(text = stringResource(R.string.ucd_desc), style = bodyTextStyle)
Text(text = "应用列表:") Text(text = stringResource(R.string.app_list_is))
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(listText==""){""}else{listText}, style = bodyTextStyle, color = titleColor) Text(text = if(listText==""){stringResource(R.string.none)}else{listText}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -186,12 +186,12 @@ fun ApplicationManage(){
myDpm.setUserControlDisabledPackages(myComponent,pkgList) myDpm.setUserControlDisabledPackages(myComponent,pkgList)
refresh() refresh()
}else{ }else{
Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
} }
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
){ ){
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -200,42 +200,42 @@ fun ApplicationManage(){
myDpm.setUserControlDisabledPackages(myComponent,pkgList) myDpm.setUserControlDisabledPackages(myComponent,pkgList)
refresh() refresh()
}else{ }else{
Toast.makeText(myContext, "不存在", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show()
} }
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
){ ){
Text("移除") Text(stringResource(R.string.remove))
} }
} }
Button( Button(
onClick = { myDpm.setUserControlDisabledPackages(myComponent, listOf()); refresh() }, onClick = { myDpm.setUserControlDisabledPackages(myComponent, listOf()); refresh() },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
){ ){
Text("清空列表") Text(stringResource(R.string.clear_list))
} }
} }
} }
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
val grantState = mapOf( val grantState = mapOf(
PERMISSION_GRANT_STATE_DEFAULT to "由用户决定", PERMISSION_GRANT_STATE_DEFAULT to stringResource(R.string.decide_by_user),
PERMISSION_GRANT_STATE_GRANTED to "允许", PERMISSION_GRANT_STATE_GRANTED to stringResource(R.string.granted),
PERMISSION_GRANT_STATE_DENIED to "拒绝" PERMISSION_GRANT_STATE_DENIED to stringResource(R.string.denied)
) )
Column(modifier = sections()){ Column(modifier = sections()){
var inputPermission by remember{mutableStateOf("android.permission.")} var inputPermission by remember{mutableStateOf("android.permission.")}
var currentState by remember{mutableStateOf(grantState[myDpm.getPermissionGrantState(myComponent,pkgName,inputPermission)])} var currentState by remember{mutableStateOf(grantState[myDpm.getPermissionGrantState(myComponent,pkgName,inputPermission)])}
Text(text = "权限管理", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.permission_manage), style = typography.titleLarge, color = titleColor)
OutlinedTextField( OutlinedTextField(
value = inputPermission, value = inputPermission,
label = { Text("权限")}, label = { Text(stringResource(R.string.permission))},
onValueChange = {inputPermission = it}, onValueChange = {inputPermission = it},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 2.dp) modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 2.dp)
) )
Text("当前状态:$currentState", style = bodyTextStyle) Text(stringResource(R.string.current_state, currentState?:stringResource(R.string.unknown)), style = bodyTextStyle)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
onClick = { onClick = {
@@ -244,7 +244,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("允许") Text(stringResource(R.string.grant))
} }
Button( Button(
onClick = { onClick = {
@@ -253,7 +253,7 @@ fun ApplicationManage(){
}, },
Modifier.fillMaxWidth(0.96F) Modifier.fillMaxWidth(0.96F)
) { ) {
Text("拒绝") Text(stringResource(R.string.deny))
} }
} }
Button( Button(
@@ -263,14 +263,14 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("由用户决定") Text(stringResource(R.string.decide_by_user))
} }
} }
} }
if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "跨资料应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.cross_profile_package), style = typography.titleLarge, color = titleColor)
var list by remember{mutableStateOf("")} var list by remember{mutableStateOf("")}
val refresh = { val refresh = {
crossProfilePkg = myDpm.getCrossProfilePackages(myComponent) crossProfilePkg = myDpm.getCrossProfilePackages(myComponent)
@@ -281,7 +281,7 @@ fun ApplicationManage(){
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refresh();inited=true} if(!inited){refresh();inited=true}
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(list==""){""}else{list}, style = bodyTextStyle, color = titleColor) Text(text = if(list==""){stringResource(R.string.none)}else{list}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -292,7 +292,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -302,7 +302,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("移除") Text(stringResource(R.string.remove))
} }
} }
} }
@@ -320,10 +320,10 @@ fun ApplicationManage(){
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refresh();inited=true} if(!inited){refresh();inited=true}
Text(text = "跨资料微件", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.cross_profile_widget), style = typography.titleLarge, color = titleColor)
Text(text = "(跨资料桌面小部件提供者)", style = bodyTextStyle) Text(text = stringResource(R.string.cross_profile_widget_desc), style = bodyTextStyle)
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(list==""){""}else{list}, style = bodyTextStyle, color = titleColor) Text(text = if(list==""){stringResource(R.string.none)}else{list}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -333,7 +333,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
){ ){
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -342,7 +342,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
){ ){
Text("移除") Text(stringResource(R.string.remove))
} }
} }
} }
@@ -366,16 +366,16 @@ fun ApplicationManage(){
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refreshPolicy(); refreshText(); inited = true} if(!inited){refreshPolicy(); refreshText(); inited = true}
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "凭据管理策略", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.credential_manage_policy), style = typography.titleLarge, color = titleColor)
RadioButtonItem("",{policyType==-1},{policyType=-1}) RadioButtonItem(stringResource(R.string.none),{policyType==-1},{policyType=-1})
RadioButtonItem("黑名单",{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST}) RadioButtonItem(stringResource(R.string.blacklist),{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST})
RadioButtonItem("白名单",{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST}) RadioButtonItem(stringResource(R.string.whitelist),{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST})
RadioButtonItem("白名单和系统应用",{policyType==PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM},{policyType=PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM}) RadioButtonItem(stringResource(R.string.whitelist_and_system_app),{policyType==PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM},{policyType=PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM})
AnimatedVisibility(policyType!=-1) { AnimatedVisibility(policyType!=-1) {
Column { Column {
Text("应用列表") Text("应用列表")
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(credentialListText!=""){ credentialListText }else{ "" }, style = bodyTextStyle, color = titleColor) Text(text = if(credentialListText!=""){ credentialListText }else{ stringResource(R.string.none) }, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -385,7 +385,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -394,7 +394,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("移除") Text(stringResource(R.string.remove))
} }
} }
} }
@@ -408,9 +408,9 @@ fun ApplicationManage(){
}else{ }else{
myDpm.credentialManagerPolicy = null myDpm.credentialManagerPolicy = null
} }
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}catch(e:java.lang.IllegalArgumentException){ }catch(e:java.lang.IllegalArgumentException){
Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
}finally { }finally {
refreshPolicy() refreshPolicy()
refreshText() refreshText()
@@ -418,14 +418,14 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
if(isProfileOwner(myDpm)||isDeviceOwner(myDpm)){ if(isProfileOwner(myDpm)||isDeviceOwner(myDpm)){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "许可的无障碍应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.permitted_accessibility_app), style = typography.titleLarge, color = titleColor)
var listText by remember{ mutableStateOf("") } var listText by remember{ mutableStateOf("") }
val refreshList = { val refreshList = {
listText = "" listText = ""
@@ -439,20 +439,20 @@ fun ApplicationManage(){
refreshList(); inited=true refreshList(); inited=true
} }
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(listText==""){""}else{listText}, style = bodyTextStyle, color = titleColor) Text(text = if(listText==""){stringResource(R.string.none)}else{listText}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
onClick = { permittedAccessibility.add(pkgName); refreshList()}, onClick = { permittedAccessibility.add(pkgName); refreshList()},
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { permittedAccessibility.remove(pkgName); refreshList() }, onClick = { permittedAccessibility.remove(pkgName); refreshList() },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("移除") Text(stringResource(R.string.remove))
} }
} }
Button( Button(
@@ -465,14 +465,14 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text(text = "应用") Text(text = stringResource(R.string.apply))
} }
} }
} }
if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){ if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "许可的输入法", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.permitted_ime), style = typography.titleLarge, color = titleColor)
var imeListText by remember{ mutableStateOf("") } var imeListText by remember{ mutableStateOf("") }
val refreshList = { val refreshList = {
imeListText = "" imeListText = ""
@@ -485,20 +485,20 @@ fun ApplicationManage(){
refreshList();inited=true refreshList();inited=true
} }
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(imeListText==""){""}else{imeListText}, style = bodyTextStyle, color = titleColor) Text(text = if(imeListText==""){stringResource(R.string.none)}else{imeListText}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
onClick = { permittedIme.add(pkgName); refreshList() }, onClick = { permittedIme.add(pkgName); refreshList() },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { permittedIme.remove(pkgName); refreshList()}, onClick = { permittedIme.remove(pkgName); refreshList()},
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("移除") Text(stringResource(R.string.remove))
} }
} }
Button( Button(
@@ -510,15 +510,14 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
if(VERSION.SDK_INT>=28&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=28&&isDeviceOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "保持卸载的应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.keep_uninstalled_pkgs), style = typography.titleLarge, color = titleColor)
Text(text = "作用未知", style = bodyTextStyle)
var listText by remember{mutableStateOf("")} var listText by remember{mutableStateOf("")}
val refresh = { val refresh = {
listText = "" listText = ""
@@ -532,7 +531,7 @@ fun ApplicationManage(){
refresh(); inited=true refresh(); inited=true
} }
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){ SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())){
Text(text = if(listText==""){""}else{listText}, style = bodyTextStyle, color = titleColor) Text(text = if(listText==""){stringResource(R.string.none)}else{listText}, style = bodyTextStyle, color = titleColor)
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -542,7 +541,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
){ ){
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -551,7 +550,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
){ ){
Text("移除") Text(stringResource(R.string.remove))
} }
} }
Button( Button(
@@ -560,11 +559,11 @@ fun ApplicationManage(){
myDpm.setKeepUninstalledPackages(myComponent, keepUninstallPkg) myDpm.setKeepUninstalledPackages(myComponent, keepUninstallPkg)
val getList = myDpm.getKeepUninstalledPackages(myComponent) val getList = myDpm.getKeepUninstalledPackages(myComponent)
if(getList!=null){ keepUninstallPkg = getList } if(getList!=null){ keepUninstallPkg = getList }
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
){ ){
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
@@ -576,7 +575,7 @@ fun ApplicationManage(){
val onClear = DevicePolicyManager.OnClearApplicationUserDataListener { pkg: String, succeed: Boolean -> val onClear = DevicePolicyManager.OnClearApplicationUserDataListener { pkg: String, succeed: Boolean ->
Looper.prepare() Looper.prepare()
focusMgr.clearFocus() focusMgr.clearFocus()
val toastText = if(pkg!=""){"$pkg\n"}else{""} + "数据清除" + if(succeed){"成功"}else{"失败"} val toastText = if(pkg!=""){"$pkg\n"}else{""} + myContext.getString(R.string.clear_data) + myContext.getString(if(succeed){R.string.success}else{R.string.fail})
Toast.makeText(myContext, toastText, Toast.LENGTH_SHORT).show() Toast.makeText(myContext, toastText, Toast.LENGTH_SHORT).show()
Looper.loop() Looper.loop()
} }
@@ -585,7 +584,7 @@ fun ApplicationManage(){
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm), enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp) modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp)
) { ) {
Text("清除应用存储") Text(stringResource(R.string.clear_app_data))
} }
} }
@@ -594,21 +593,20 @@ fun ApplicationManage(){
onClick = { onClick = {
try{ try{
myDpm.setDefaultDialerApplication(pkgName) myDpm.setDefaultDialerApplication(pkgName)
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}catch(e:IllegalArgumentException){ }catch(e:IllegalArgumentException){
Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
} }
}, },
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm), enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp) modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp)
) { ) {
Text("设为默认拨号应用") Text(stringResource(R.string.set_default_dialer))
} }
} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "卸载应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.uninstall_app), style = typography.titleLarge, color = titleColor)
Text(text = "静默卸载需Device owner", style = bodyTextStyle)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
onClick = { onClick = {
@@ -619,7 +617,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("静默卸载") Text(stringResource(R.string.silent_uninstall))
} }
Button( Button(
onClick = { onClick = {
@@ -629,14 +627,13 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("请求卸载") Text(stringResource(R.string.request_uninstall))
} }
} }
} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "安装应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.install_app), style = typography.titleLarge, color = titleColor)
Text(text = "静默安装需Device owner", style = bodyTextStyle)
Button( Button(
onClick = { onClick = {
focusMgr.clearFocus() focusMgr.clearFocus()
@@ -647,7 +644,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("选择APK...") Text(stringResource(R.string.select_apk))
} }
var selected by remember{mutableStateOf(false)} var selected by remember{mutableStateOf(false)}
LaunchedEffect(selected){apkSelected{selected = apkUri!=null}} LaunchedEffect(selected){apkSelected{selected = apkUri!=null}}
@@ -657,7 +654,7 @@ fun ApplicationManage(){
onClick = { uriToStream(myContext, apkUri){stream -> installPackage(myContext,stream)} }, onClick = { uriToStream(myContext, apkUri){stream -> installPackage(myContext,stream)} },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("静默安装") Text(stringResource(R.string.silent_install))
} }
Button( Button(
onClick = { onClick = {
@@ -668,7 +665,7 @@ fun ApplicationManage(){
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("请求安装") Text(stringResource(R.string.request_install))
} }
} }
} }

View File

@@ -17,6 +17,13 @@
<string name="deactivated">未激活</string> <string name="deactivated">未激活</string>
<string name="activate">激活</string> <string name="activate">激活</string>
<string name="deactivate">撤销</string> <string name="deactivate">撤销</string>
<string name="blacklist">黑名单</string>
<string name="whitelist">白名单</string>
<string name="granted">允许</string>
<string name="denied">拒绝</string>
<string name="grant">允许</string>
<string name="deny">拒绝</string>
<string name="current_state">当前状态:%1$s</string>
<string name="reason">原因</string> <string name="reason">原因</string>
<string name="custom">自定义</string> <string name="custom">自定义</string>
<string name="unknown">未知</string> <string name="unknown">未知</string>
@@ -120,11 +127,40 @@
<string name="will_delete_work_profile">将会删除工作资料</string> <string name="will_delete_work_profile">将会删除工作资料</string>
<string name="api34_or_above_wipedata_cannot_in_system_user">API34或以上将不能在系统用户中使用WipeData</string> <string name="api34_or_above_wipedata_cannot_in_system_user">API34或以上将不能在系统用户中使用WipeData</string>
<!--AppManage-->
<string name="app_manage">应用管理</string> <string name="app_manage">应用管理</string>
<string name="suspend">挂起</string> <string name="suspend">挂起</string>
<string name="hide">隐藏</string> <string name="hide">隐藏</string>
<string name="isapphidden_desc">如果隐藏,有可能是没安装</string> <string name="isapphidden_desc">如果隐藏,有可能是没安装</string>
<string name="permission">权限</string> <string name="permission">权限</string>
<string name="scope_is_work_profile">作用域: 工作资料</string>
<string name="app_info">应用详情</string>
<string name="not_installed">未安装</string>
<string name="block_uninstall">防卸载</string>
<string name="sometimes_get_wrong_block_uninstall_state">有时候无法正确获取防卸载状态</string>
<string name="ucd">禁止用户控制</string>
<string name="ucd_desc">用户将无法清除应用的存储空间和缓存</string>
<string name="app_list_is">应用列表:</string>
<string name="clear_list">清空列表</string>
<string name="permission_manage">权限管理</string>
<string name="cross_profile_package">跨资料应用</string>
<string name="cross_profile_widget">跨资料微件</string>
<string name="cross_profile_widget_desc">(跨资料桌面小部件提供者)</string>
<string name="credential_manage_policy">凭据管理策略</string>
<string name="whitelist_and_system_app">白名单和系统应用</string>
<string name="permitted_accessibility_app">许可的无障碍应用</string>
<string name="permitted_ime">许可的输入法</string>
<string name="keep_uninstalled_pkgs">保持卸载的应用</string>
<string name="clear_data">数据清除</string>
<string name="clear_app_data">清除应用存储</string>
<string name="set_default_dialer">设为默认拨号应用</string>
<string name="uninstall_app">卸载应用</string>
<string name="silent_uninstall">静默卸载</string>
<string name="request_uninstall">请求卸载</string>
<string name="install_app">安装应用</string>
<string name="select_apk" tools:ignore="TypographyEllipsis">选择APK...</string>
<string name="silent_install">静默安装</string>
<string name="request_install">请求安装</string>
<string name="user_restrict">用户限制</string> <string name="user_restrict">用户限制</string>
<string name="config_mobile_network">配置移动数据</string> <string name="config_mobile_network">配置移动数据</string>