新增公司打包工具
This commit is contained in:
parent
862c17c90f
commit
c8a82d2ba8
31
README.md
31
README.md
@ -1,37 +1,10 @@
|
||||
# 安卓sdk工具
|
||||
|
||||
#### 介绍
|
||||
用于安卓sdk做热更新常用的一些工具
|
||||
用于工作上安卓sdk做热更新常用的一些工具
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
1. 要用签名工具则必须配好jarsigner环境
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 码云特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
|
||||
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
|
@ -1,5 +0,0 @@
|
||||
package com.qy.Interfaces;
|
||||
|
||||
public abstract class DalogAbs {
|
||||
public abstract void onSuccess();
|
||||
}
|
6
src/com/qy/Interfaces/DialogInterface.java
Normal file
6
src/com/qy/Interfaces/DialogInterface.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.qy.Interfaces;
|
||||
|
||||
public abstract class DialogInterface {
|
||||
public void onSuccess(){};
|
||||
public void onOut(Object data){};
|
||||
}
|
@ -223,7 +223,7 @@ public class AppMain extends JFrame {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
setTitle("\u8F6C\u6362\u5668v2.10");
|
||||
setTitle("\u8F6C\u6362\u5668v2.2");
|
||||
// TODO Auto-generated constructor stub
|
||||
setSize(900, 456);
|
||||
getContentPane().setLayout(null);
|
||||
@ -653,6 +653,16 @@ public class AppMain extends JFrame {
|
||||
});
|
||||
menu.add(autoSDK);
|
||||
|
||||
JMenuItem autoOutApk = new JMenuItem("自动更新SDK");
|
||||
autoOutApk.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AutoOutAPKUi();
|
||||
}
|
||||
});
|
||||
menu.add(autoOutApk);
|
||||
|
||||
|
||||
mnBasetools = new JMenu("Base64\u5DE5\u5177");
|
||||
menuBar.add(mnBasetools);
|
||||
|
||||
|
30
src/com/qy/ui/AutoOutAPKAddChannelUi.form
Normal file
30
src/com/qy/ui/AutoOutAPKAddChannelUi.form
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.qy.ui.AutoOutAPKAddChannelUi">
|
||||
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="3f7c2" class="javax.swing.JComboBox" binding="comboBox1" default-binding="true">
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="5af35" binding="inputPanel" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties>
|
||||
<background color="-12828863"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="11955" class="javax.swing.JButton" binding="submit" default-binding="true">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties>
|
||||
<text value="提交"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
99
src/com/qy/ui/AutoOutAPKAddChannelUi.java
Normal file
99
src/com/qy/ui/AutoOutAPKAddChannelUi.java
Normal file
@ -0,0 +1,99 @@
|
||||
package com.qy.ui;
|
||||
|
||||
import com.qy.Interfaces.DialogInterface;
|
||||
import com.qy.utils.Tools;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class AutoOutAPKAddChannelUi {
|
||||
private JComboBox<String> comboBox1;
|
||||
private JPanel panel1;
|
||||
private JButton submit;
|
||||
private JPanel inputPanel;
|
||||
private JSONObject json;
|
||||
private List<JTextField> list=new ArrayList<>();
|
||||
private DialogInterface inter;
|
||||
private JFrame frame;
|
||||
|
||||
public AutoOutAPKAddChannelUi(DialogInterface inter, JFrame frame) {
|
||||
this.inter=inter;
|
||||
this.frame=frame;
|
||||
json= Tools.loadConfig(new File("gameConfig.json"));
|
||||
init();
|
||||
}
|
||||
private void init(){
|
||||
Vector<String> vector=new Vector<>(json.keySet());
|
||||
comboBox1.setModel(new DefaultComboBoxModel<>(vector));
|
||||
comboBox1.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setData(comboBox1.getSelectedIndex());
|
||||
}
|
||||
});
|
||||
submit.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Map<String,String> map=new HashMap<>();
|
||||
map.put("NAME",name);
|
||||
for (JTextField textField : list) {
|
||||
map.put(textField.getName(),textField.getText());
|
||||
}
|
||||
inter.onOut(map);
|
||||
AutoOutAPKAddChannelUi.this.frame.dispose();
|
||||
}
|
||||
});
|
||||
GridLayout layout=new GridLayout(-1,1);
|
||||
inputPanel.setLayout(layout);
|
||||
inputPanel.setBackground(Color.black);
|
||||
setData(0);
|
||||
}
|
||||
private String name="";
|
||||
private void setData(int index){
|
||||
inputPanel.removeAll();
|
||||
inputPanel.updateUI();
|
||||
list.clear();
|
||||
JSONArray item = null;
|
||||
int i=0;
|
||||
for (String key : json.keySet()) {
|
||||
if(i==index){
|
||||
item=json.getJSONArray(key);
|
||||
name=key;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(item==null){
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j <item.length(); j++) {
|
||||
String data=item.getString(j);
|
||||
JTextField textField=new JTextField();
|
||||
textField.setName(data);
|
||||
textField.setText(data);
|
||||
textField.setToolTipText(data);
|
||||
textField.setSize(100,20);
|
||||
list.add(textField);
|
||||
inputPanel.add(textField);
|
||||
}
|
||||
}
|
||||
public static void newInstance(DialogInterface inter){
|
||||
JFrame frame = new JFrame("添加渠道参数");
|
||||
frame.setContentPane(new AutoOutAPKAddChannelUi(inter,frame).panel1);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setSize(400,400);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
}
|
||||
}
|
138
src/com/qy/ui/AutoOutAPKUi.form
Normal file
138
src/com/qy/ui/AutoOutAPKUi.form
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.qy.ui.AutoOutAPKUi">
|
||||
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="504" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="81cbe" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="dc3b8" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="包名"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c1cf4" class="javax.swing.JTextField" binding="packageName">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="7e384" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="GameID"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="65e28" class="javax.swing.JTextField" binding="gameId">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="8089a" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="极光Key"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b231c" class="javax.swing.JTextField" binding="jiguang">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="bcc75" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="渠道参数"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="21c9" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="17397" class="javax.swing.JList" binding="list1" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="2" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="2f96a" class="javax.swing.JButton" binding="addChannel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="添加"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e99fb" class="javax.swing.JButton" binding="removeChannel">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="移除"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="8617" class="javax.swing.JButton" binding="start">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="提交"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="77e44" class="javax.swing.JLabel" binding="appPath">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="选择游戏母包"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4b896" class="javax.swing.JButton" binding="selectAppPath" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<maximum-size width="100" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="选择"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
177
src/com/qy/ui/AutoOutAPKUi.java
Normal file
177
src/com/qy/ui/AutoOutAPKUi.java
Normal file
@ -0,0 +1,177 @@
|
||||
package com.qy.ui;
|
||||
|
||||
import com.qy.Interfaces.DialogInterface;
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import com.qy.utils.ApkSignTools;
|
||||
import com.qy.utils.AutoOutAPKTools;
|
||||
import com.qy.utils.Tools;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
public class AutoOutAPKUi {
|
||||
private JPanel panel1;
|
||||
private JTextField packageName;
|
||||
private JTextField gameId;
|
||||
private JTextField jiguang;
|
||||
private JList<String> list1;
|
||||
private JButton addChannel;
|
||||
private JButton removeChannel;
|
||||
private JButton start;
|
||||
private JButton selectAppPath;
|
||||
private JLabel appPath;
|
||||
|
||||
private LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||
private LinkedHashMap<String, Object> channel = new LinkedHashMap<>();
|
||||
private Vector<String> vector = new Vector<String>();
|
||||
|
||||
|
||||
public AutoOutAPKUi() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
JFrame frame = new JFrame("马甲包出包工具1.0");
|
||||
frame.setContentPane(panel1);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setSize(420, 400);
|
||||
frame.setVisible(true);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
list1.setListData(vector);
|
||||
addChannel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AutoOutAPKAddChannelUi.newInstance(new DialogInterface() {
|
||||
@Override
|
||||
public void onOut(Object data) {
|
||||
super.onOut(data);
|
||||
Map<?, ?> channel = (Map<?, ?>) data;
|
||||
AutoOutAPKUi.this.channel.put((String) channel.get("NAME"), channel);
|
||||
vector.add((String) channel.get("NAME"));
|
||||
list1.setListData(vector);
|
||||
list1.updateUI();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
removeChannel.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String name = vector.get(list1.getSelectedIndex());
|
||||
vector.remove(list1.getSelectedIndex());
|
||||
channel.remove(name);
|
||||
list1.setListData(vector);
|
||||
list1.updateUI();
|
||||
}
|
||||
});
|
||||
start.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String gid = gameId.getText();
|
||||
String jid = jiguang.getText();
|
||||
String pid = packageName.getText();
|
||||
String path = appPath.getText();
|
||||
if (StringUtils.isEmpty(gid) || StringUtils.isEmpty(pid) || StringUtils.isEmpty(path)) {
|
||||
new TextToDialog("警告", "有参数未填写");
|
||||
return;
|
||||
}
|
||||
Map<String, String> cmap = new HashMap<>();
|
||||
for (String key : channel.keySet()) {
|
||||
Map<?, ?> map = (Map<?, ?>) channel.get(key);
|
||||
for (Object o : map.keySet()) {
|
||||
if (!o.equals("NAME")) {
|
||||
cmap.put((String) o, (String) map.get(o));
|
||||
}
|
||||
}
|
||||
}
|
||||
AutoOutAPKTools tools = new AutoOutAPKTools(gid, cmap);
|
||||
JSONObject json=new JSONObject();
|
||||
JSONObject pa=new JSONObject();
|
||||
JSONObject ji=new JSONObject();
|
||||
pa.put("key","${packagename}");
|
||||
pa.put("value",pid);
|
||||
ji.put("key","${JPUSH_KEY}");
|
||||
ji.put("value",jid);
|
||||
json.put("package=",pa);
|
||||
json.put("JPUSH_APPKEY",ji);
|
||||
tools.setAppPath(path);
|
||||
tools.setManifestMap(json);
|
||||
tools.start(new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
LinkedHashMap<String,String> keyMap=ApkSignUi.loadKeys();
|
||||
Vector<String> adbList = new Vector<String>(keyMap.keySet());
|
||||
JComboBox<String> keysList=new JComboBox<String>(adbList);
|
||||
keysList.setBounds(157, 50, 200, 27);
|
||||
new TextToDialog("选择签名", keysList, new DialogInterface() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
String key=adbList.get(keysList.getSelectedIndex());
|
||||
String tmp=keyMap.get(key);
|
||||
if(!StringUtils.isEmpty(tmp)){
|
||||
JSONObject json=new JSONObject(tmp);
|
||||
ApkSignTools signTools=new ApkSignTools();
|
||||
signTools.setSignFile(new File(json.getString("file")));
|
||||
signTools.setApkFile(new File(path));
|
||||
signTools.setKeyStorePassword(json.getString("alias_password"));
|
||||
signTools.setName(json.getString("alias"));
|
||||
signTools.setSignKey(json.getString("password"));
|
||||
if(signTools.sign()){
|
||||
try {
|
||||
String apkName="./apk_out/game_"+System.currentTimeMillis()+".apk";
|
||||
Tools.copyFile(signTools.getApkFile().getAbsolutePath()+"_sign.apk",apkName,true);
|
||||
Desktop.getDesktop().open(new File(apkName).getParentFile());
|
||||
System.out.println("签名完成");
|
||||
} catch (IOException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
tools.clear();
|
||||
}else {
|
||||
new TextToDialog("警告","签名失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
selectAppPath.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser jFile = new JFileChooser(new File(new File("").getAbsolutePath()));
|
||||
jFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
jFile.showOpenDialog(null);
|
||||
File path = jFile.getSelectedFile();
|
||||
appPath.setText(path.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AutoOutAPKUi();
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.qy.Interfaces.DalogAbs;
|
||||
import com.qy.Interfaces.DialogInterface;
|
||||
import com.qy.sms.SDKTools;
|
||||
|
||||
import java.awt.Desktop;
|
||||
@ -71,7 +71,7 @@ public class SMSToolsUi extends JFrame {
|
||||
SDKTools.start(new File("").getAbsolutePath());
|
||||
btnNewButton.setText(path);
|
||||
btnNewButton.setEnabled(true);
|
||||
new TextToDialog("提示", "计费SDK生成成功,请选择保存位置", new DalogAbs() {
|
||||
new TextToDialog("提示", "计费SDK生成成功,请选择保存位置", new DialogInterface() {
|
||||
File sdk;
|
||||
|
||||
@Override
|
||||
@ -85,7 +85,7 @@ public class SMSToolsUi extends JFrame {
|
||||
File sdk_ = new File(
|
||||
sdk.getAbsolutePath() + "/" + "计费sdk" + SDKTools.version + ".zip");
|
||||
SDKTools.buildSDK(sdk_);
|
||||
new TextToDialog("完成", "任务已完成", new DalogAbs() {
|
||||
new TextToDialog("完成", "任务已完成", new DialogInterface() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -16,7 +16,7 @@ import javax.swing.border.LineBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import com.qy.Interfaces.DalogAbs;
|
||||
import com.qy.Interfaces.DialogInterface;
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import com.qy.utils.ApkSignTools;
|
||||
import com.qy.utils.SmaliUtils;
|
||||
@ -361,7 +361,7 @@ public class SmaliUi extends JFrame {
|
||||
Vector<String> adbList = new Vector<String>(keyMap.keySet());
|
||||
JComboBox<String> keysList=new JComboBox<String>(adbList);
|
||||
keysList.setBounds(157, 50, 200, 27);
|
||||
new TextToDialog("选择签名", keysList, new DalogAbs() {
|
||||
new TextToDialog("选择签名", keysList, new DialogInterface() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
String key=adbList.get(keysList.getSelectedIndex());
|
||||
|
@ -5,22 +5,22 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.qy.Interfaces.DalogAbs;
|
||||
import com.qy.Interfaces.DialogInterface;
|
||||
|
||||
|
||||
public class TextToDialog extends JFrame {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DalogAbs abs;
|
||||
DialogInterface abs;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public TextToDialog(String title, String text, DalogAbs abs) {
|
||||
public TextToDialog(String title, String text, DialogInterface abs) {
|
||||
super(title);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.abs=abs;
|
||||
initView(text,null);
|
||||
}
|
||||
public TextToDialog(String title, JComponent view,DalogAbs abs){
|
||||
public TextToDialog(String title, JComponent view, DialogInterface abs){
|
||||
super(title);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.abs=abs;
|
||||
|
@ -74,6 +74,7 @@ public class ApkSignTools {
|
||||
}
|
||||
public void setApkFile(File apkFile) {
|
||||
this.apkFile = apkFile;
|
||||
System.out.println("APK:"+apkFile.getAbsolutePath());
|
||||
}
|
||||
public boolean chack() {
|
||||
// TODO Auto-generated method stub
|
||||
|
116
src/com/qy/utils/AutoOutAPKTools.java
Normal file
116
src/com/qy/utils/AutoOutAPKTools.java
Normal file
@ -0,0 +1,116 @@
|
||||
package com.qy.utils;
|
||||
|
||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||
import com.qy.ui.ApkSignUi;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class AutoOutAPKTools {
|
||||
private String gameId;
|
||||
private Map<String,String> channel;
|
||||
private JSONObject manifestMap;
|
||||
private String appPath;
|
||||
private SmaliApkToolsPath inter;
|
||||
|
||||
public AutoOutAPKTools(String gameId, Map<String, String> channel) {
|
||||
this.gameId = gameId;
|
||||
this.channel = channel;
|
||||
}
|
||||
public void setAppPath(String path){
|
||||
this.appPath=path;
|
||||
}
|
||||
public void setManifestMap(JSONObject map){
|
||||
this.manifestMap=map;
|
||||
}
|
||||
public void start(SmaliApkToolsPath inter){
|
||||
this.inter=inter;
|
||||
outLog("复制游戏文件夹");
|
||||
String newAppPath=appPath+"_"+gameId+"_"+Tools.getRandomString(6);
|
||||
Tools.copy_dir(appPath,newAppPath);
|
||||
outLog("游戏游戏文件夹复制完成");
|
||||
appPath=newAppPath;
|
||||
outLog("修改Manifest");
|
||||
alterManifest(new File(appPath+File.separator+"AndroidManifest.xml"));
|
||||
outLog("Manifest修改完成,开始生成assets");
|
||||
outAssets();
|
||||
outLog("生成完毕");
|
||||
new SmaliUtils().bale(appPath, appPath + File.separator + "game_.apk", new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
inter.smaliPath(appPath + File.separator + "game_.apk");
|
||||
}
|
||||
});
|
||||
}
|
||||
public void clear(){
|
||||
Tools.deleteFiles(appPath);
|
||||
}
|
||||
private void alterManifest(File manifest){
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder();
|
||||
try {
|
||||
List<String> keys=new ArrayList<>(manifestMap.keySet());
|
||||
|
||||
BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(manifest), StandardCharsets.UTF_8));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
for (String key : keys) {
|
||||
if(tmp.contains(key)){
|
||||
JSONObject json=manifestMap.getJSONObject(key);
|
||||
tmp=tmp.replace(json.getString("key"),json.getString("value"));
|
||||
}
|
||||
}
|
||||
str.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
Tools.saveConfig(manifest,str.toString());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(str);
|
||||
}
|
||||
}
|
||||
private void outAssets(){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("GAME_ID=").append(gameId).append("\n");
|
||||
for (String key : channel.keySet()) {
|
||||
builder.append(key).append("=").append(channel.get(key)).append("\n");
|
||||
}
|
||||
Tools.saveConfig(new File(appPath+File.separator+"assets"+File.separator+"kusdkconf.ini"),
|
||||
builder.toString());
|
||||
}
|
||||
private void outLog(String log){
|
||||
System.out.println(log);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONObject json=new JSONObject();
|
||||
JSONObject pa=new JSONObject();
|
||||
JSONObject ji=new JSONObject();
|
||||
pa.put("key","${packagename}");
|
||||
pa.put("value","com.abc.def");
|
||||
ji.put("key","${JPUSH_KEY}");
|
||||
ji.put("value","aaabbccd");
|
||||
json.put("package=",pa);
|
||||
json.put("JPUSH_APPKEY",ji);
|
||||
|
||||
Map<String,String> channel=new HashMap<>();
|
||||
channel.put("TOUTIAO_APP_ID","112345");
|
||||
AutoOutAPKTools tools=new AutoOutAPKTools(
|
||||
"123456",
|
||||
channel);
|
||||
tools.setAppPath("C:\\Users\\admin\\Documents\\游戏母包\\仙侠神域\\xianxiashenyu_29321_wozaijianghukey_xxsy_1627");
|
||||
tools.setManifestMap(json);
|
||||
tools.start(new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
System.out.println("ok:"+path);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -365,4 +365,21 @@ public class Tools {
|
||||
System.out.println(System.getProperties().getProperty("os.name"));
|
||||
return System.getProperties().getProperty("os.name").toLowerCase().contains("windows");
|
||||
}
|
||||
|
||||
public static String readFile(File manifest) {
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(manifest), StandardCharsets.UTF_8));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str.append(tmp);
|
||||
}
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(str);
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user