admin
2021-03-26 998b6bd2a1dc25ec8350f5a691c3cd44a23d6d14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package com.tencent.xinge;
 
import org.json.JSONObject;
 
public class ClickAction {
    public static final int TYPE_ACTIVITY = 1;
    public static final int TYPE_URL = 2;
    public static final int TYPE_INTENT = 3;
    
    public void setActionType(int actionType)
    {
        this.m_actionType = actionType;
    }
    public void setActivity(String activity)
    {
        this.m_activity = activity;
    }
    public void setUrl(String url)
    {
        this.m_url = url;
    }
    public void setConfirmOnUrl(int confirmOnUrl)
    {
        this.m_confirmOnUrl = confirmOnUrl;
    }
    public void setIntent(String intent)
    {
        this.m_intent = intent;
    }
    public void setAtyAttrIntentFlag(int atyAttrIntentFlag) 
    {
        this.m_atyAttrIntentFlag = atyAttrIntentFlag;
    }
    public void setAtyAttrPendingIntentFlag(int atyAttrPendingIntentFlag)
    {
        this.m_atyAttrPendingIntentFlag = atyAttrPendingIntentFlag;
    }
    public void setPackageDownloadUrl(String packageDownloadUrl)
    {
        this.m_packageDownloadUrl = packageDownloadUrl;
    }
    public void setConfirmOnPackageDownloadUrl(int confirmOnPackageDownloadUrl)
    {
        this.m_confirmOnPackageDownloadUrl = confirmOnPackageDownloadUrl;
    }
    public void setPackageName(String packageName)
    {
        this.m_packageName = packageName;
    }
    
    public String toJson()
    {
        JSONObject json = new JSONObject();
        json.put("action_type", m_actionType);
        JSONObject browser = new JSONObject();
        browser.put("url", m_url);
        browser.put("confirm", m_confirmOnUrl);
        json.put("browser", browser);
        json.put("activity", m_activity);
        json.put("intent", m_intent);
        
        JSONObject aty_attr = new JSONObject();
        aty_attr.put("if", m_atyAttrIntentFlag);
        aty_attr.put("pf", m_atyAttrPendingIntentFlag);
        json.put("aty_attr", aty_attr);
        
        return json.toString();
    }
    
    public JSONObject toJsonObject()
    {
        JSONObject json = new JSONObject();
        json.put("action_type", m_actionType);
        JSONObject browser = new JSONObject();
        browser.put("url", m_url);
        browser.put("confirm", m_confirmOnUrl);
        json.put("browser", browser);
        json.put("activity", m_activity);
        json.put("intent", m_intent);
        
        JSONObject aty_attr = new JSONObject();
        aty_attr.put("if", m_atyAttrIntentFlag);
        aty_attr.put("pf", m_atyAttrPendingIntentFlag);
        json.put("aty_attr", aty_attr);
        
        return json;
    }
    
    public boolean isValid()
    {
        if (m_actionType<TYPE_ACTIVITY || m_actionType>TYPE_INTENT) return false;
 
        if (m_actionType == TYPE_URL)
        {
            if (m_url.isEmpty() || m_confirmOnUrl<0 || m_confirmOnUrl>1) return false;
            return true;
        }
        if(m_actionType == TYPE_INTENT)
        {
            if(m_intent.isEmpty()) return false;
            return true;
        }
        return true;
    }
    
    public ClickAction()
    {
        m_url = "";
        m_actionType = 1;
        m_activity = "";
        
        m_atyAttrIntentFlag = 0;
        m_atyAttrPendingIntentFlag = 0;
        
        m_packageDownloadUrl = "";
        m_confirmOnPackageDownloadUrl = 1;
        m_packageName = "";
    }
    
    private int m_actionType;
    private String m_url;
    private int m_confirmOnUrl;
    private String m_activity;
    private String m_intent;
    private int m_atyAttrIntentFlag;
    private int m_atyAttrPendingIntentFlag;
    private String m_packageDownloadUrl;
    private int m_confirmOnPackageDownloadUrl;
    private String m_packageName;
}