-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodehub_android.b4a
More file actions
141 lines (125 loc) · 4.12 KB
/
Copy pathcodehub_android.b4a
File metadata and controls
141 lines (125 loc) · 4.12 KB
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
131
132
133
134
135
136
137
138
139
140
141
Build1=Default,b4a.example
File1=Artboard 1.png
File10=Vazir-Bold.ttf
File11=Vazir-Bold-FD.ttf
File12=Vazir-FD.ttf
File13=Vazir-Light.ttf
File14=Vazir-Light-FD.ttf
File15=Vazir-Medium.ttf
File16=Vazir-Medium-FD.ttf
File17=Vazir-Thin.ttf
File18=Vazir-Thin-FD.ttf
File2=consola.ttf
File3=consolab.ttf
File4=consolai.ttf
File5=consolaz.ttf
File6=light_layout_v05.bal
File7=Vazir.ttf
File8=Vazir-Black.ttf
File9=Vazir-Black-FD.ttf
FileGroup1=Images
FileGroup10=Fonts
FileGroup11=Fonts
FileGroup12=Fonts
FileGroup13=Fonts
FileGroup14=Fonts
FileGroup15=Fonts
FileGroup16=Fonts
FileGroup17=Fonts
FileGroup18=Fonts
FileGroup2=Default Group
FileGroup3=Default Group
FileGroup4=Default Group
FileGroup5=Default Group
FileGroup6=Default Group
FileGroup7=Fonts
FileGroup8=Fonts
FileGroup9=Fonts
Group=Default Group
Library1=core
Library2=clipboard
Library3=okhttputils2
Library4=json
Library5=phone
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.DarkTheme)~\n~'End of default text.~\n~
Module1=Starter
NumberOfFiles=18
NumberOfLibraries=5
NumberOfModules=1
Version=9.9
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: کد هاب
#VersionCode: 1
#VersionName: v1.0
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#BridgeLogger: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
' all global vars should be here..
End Sub
Sub Globals
Private edt_detail As EditText
Private edt_script As EditText
Private edt_title As EditText
Private ac_language As AutoCompleteEditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
' layout v0.5
Activity.LoadLayout("light_layout_v05")
' available languages on AutoCompleteEditText(ac_language)
Dim languages () As String
languages = Array As String ("python", "php", "go", "html", "java")
ac_language.SetItems(languages)
' v0.1 fixed orientation
Dim orientation As Phone
orientation.SetScreenOrientation(1)
End Sub
Sub btn_submit_Click
If edt_title.Text == "" Or edt_script.Text == "" Or ac_language.Text == "" Then
ToastMessageShow("تمام فیلد ها را پر کنید", False)
Else
ToastMessageShow("درخواست شما در حال انجام است", False)
Dim snippet_clip As BClipboard
Dim data As Map = CreateMap("title": edt_title.Text, "detail": edt_detail.Text, "script": edt_script.Text, "language": ac_language.Text)
Dim json As JSONGenerator
json.Initialize(data)
Dim connection As HttpJob
connection.Initialize("Connection", Me)
connection.PostString("http://codehub.pythonanywhere.com/api/v1/snippet/", json.ToString)
connection.GetRequest.SetContentType("application/json")
Wait For (connection) JobDone(connection As HttpJob)
If connection.Success Then
Dim response As String = connection.GetString
Dim jsn_response As JSONParser
jsn_response.Initialize(response)
Dim dta As Map
dta = jsn_response.NextObject
Dim link As String = dta.Get("link")
Dim SID As String = dta.Get("SID")
snippet_clip.setText(link)
ToastMessageShow("درخواست انجام شد. اسنیپ آیدی "&SID&" در کلیپبورد ذخیره شد", True)
Else
ToastMessageShow("خطا در برقراری ارتباط", False)
End If
End If
End Sub
Sub Clearify
edt_title.Text = ""
edt_detail.Text = ""
edt_script.Text = ""
ac_language.Text = ""
End Sub
Sub btn_clear_Click
Clearify
ToastMessageShow("فیلد ها خالی شد", False)
End Sub
Sub btn_github_Click
Dim phone As PhoneIntents
StartActivity(phone.OpenBrowser("https://github.com/lnxpy/codehub-android"))
End Sub