﻿B4A=true
Group=support
ModulesStructureVersion=1
Type=Activity
Version=11
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals

	Public TFsp As Int

End Sub

Sub Globals

	Dim ime As IME
 	
	Dim ed_chat As ACEditText
	Dim pan_chat As Panel
	Dim l_Send As Label
	Dim l_Peyvast As Label
  
	Dim NewHeight1 As Int
	
	Private Retrofit As Amir_Retrofit
	Private Manager_add   As Amir_RetrofitManager
	Private Builder_add   As Amir_RetrofitBuilder
	Private Jsons As Amir_Json'ignore

	Private RCver As AX_RecyclerView

	Dim listType_c As List
	Dim listMatn As List
	Dim list2Matn As List
	Dim lisDate  As List
	Dim listTf As List

	Dim panCover As Panel
	Private li4 As LoadingIndicatorView
 
	Dim heightR As Int
 
	Dim upload As classUpload
	Dim download As classDownload

	Dim picName As String
	Dim mainDir  As String
	Dim mainName As String
	
	Dim mainTxt As String
	Dim mainTf As Int
	
	Dim p_aria As AriaProgressDialog

	Dim mainID As Int
  
	Private popup1 As ACPopupMenu

	Dim mKeyboardIsVisible As Boolean

	Dim boolViPi As Boolean

	Dim cc As ContentChooser 'ignore

	Private permit As permitClass

End Sub

Sub Activity_Create(FirstTime As Boolean)
	 
	cc.Initialize("CC")
	permit.Initialize(Me,Activity)

	Dim bd As BitmapDrawable
	bd.Initialize(LoadBitmap(File.DirAssets, "bg_chat.jpg"))
	bd.Gravity = Gravity.FILL
	Activity.Background = bd
 	
	ime.Initialize("ime")
 	
 	upload.Initialize(Me,"upload")
	download.Initialize(Me,"download",Activity)
	
	listType_c.Initialize
	listMatn.Initialize
	list2Matn.Initialize
	lisDate.Initialize
	listTf.Initialize
	

	Dim Label1 As Label
	Dim labPosht As Label
	Dim lab_back As Label
	
	labPosht.Initialize("")
	Activity.AddView(labPosht,0,0,100%x,4%y+35dip)
	labPosht.Color = 0xFF4C9A7B

	Label1.Initialize("")
	Activity.AddView(Label1,8%x+35dip,0,100%x-2*(8%x+35dip),4%y+35dip)
	Label1.Typeface=Typeface.CreateNew(Typeface.LoadFromAssets(func.font3),Typeface.STYLE_BOLD)
	Label1.Gravity=Bit.Or(Gravity.CENTER,Gravity.CENTER_VERTICAL)
	Label1.Padding = Array As Int (0,0,0,4dip)
	Label1.textColor =  Colors.White
	Label1.TextSize = 14
	Label1.Text = func.gland(375)
	
	lab_back.Initialize("lab_back")
	Activity.AddView(lab_back,7%x,2%y,35dip,35dip)
	lab_back.Typeface = Typeface.MATERIALICONS
	lab_back.Text = Chr(0xE314)
	lab_back.TextColor = Colors.White
	lab_back.TextSize = 20
	lab_back.Gravity = Bit.Or(Gravity.CENTER,Gravity.CENTER_VERTICAL)
	func.SetRipple(lab_back ,0x337FD3B1,0x884C9A7B,16)

 	''	**********************************************************

	heightR = Activity.Height-(labPosht.Top+labPosht.Height+1%y)-1%y
	
	Dim pan As Panel
	pan.Initialize("pan")
	Activity.AddView(pan,0,labPosht.Top+labPosht.Height+1%y,100%x,heightR-55dip)
	
	pan.LoadLayout("agahi_layout")
	
	RCver.Color = Colors.Transparent
	RCver.Adapter=RCver.DefaultAdapter

	'***********************************************************************************
	
	p_aria.initialize("p_aria")
	p_aria.setTitle(func.gland(376))
	p_aria.STYLE_Horizontal
	p_aria.setCanceledOnTouchOutside(False)
	p_aria.setCancelable(False)
	p_aria.setMax(100)
	p_aria.setIndeterminate(False)

 	'***********************************************************************************
	 

	pan_chat.Initialize("")
	Activity.AddView(pan_chat,0,100%y-55dip,100%x,55dip)
	pan_chat.Color = Colors.Transparent
	
	
	ed_chat.Initialize("ed_chat")
	pan_chat.AddView(ed_chat,105dip,2.5dip,100%x-110dip,45dip)
	ed_chat.Typeface=Typeface.CreateNew( Typeface.LoadFromAssets(func.font3),Typeface.STYLE_NORMAL)
	ed_chat.Gravity=Bit.Or(Gravity.RIGHT,Gravity.CENTER)
	ed_chat.TextSize=14
	ed_chat.Padding=Array As Int(5dip,0,10dip,0)
	ed_chat.Wrap=True
	ed_chat.hint=func.gland(377)
	ed_chat.HintColor=Colors.DarkGray
	ed_chat.TextColor=Colors.Black
	func.color_border(ed_chat,Colors.White,10)

	l_Send.Initialize("l_Send")
	pan_chat.AddView(l_Send,5dip,pan_chat.Height-52.5dip,45dip,45dip)
	l_Send.Typeface = Typeface.MATERIALICONS
	l_Send.Text = Chr(0xE163)
	l_Send.TextColor = Colors.Black
	l_Send.TextSize = 23
	l_Send.Gravity = Bit.Or(Gravity.CENTER,Gravity.CENTER_VERTICAL)
	func.color_border(l_Send,0xFFFFA500,1000)
	func.setRotation(l_Send,180)
	
	l_Peyvast.Initialize("l_Peyvast")
	pan_chat.AddView(l_Peyvast,55dip,pan_chat.Height-52.5dip,45dip,45dip)
	l_Peyvast.Typeface = Typeface.LoadFromAssets("fonticon.otf")
	l_Peyvast.Text = Chr(0xf0c6)
	l_Peyvast.TextColor = Colors.Black
	l_Peyvast.TextSize = 22
	l_Peyvast.Gravity = Bit.Or(Gravity.CENTER,Gravity.CENTER_VERTICAL)
	func.color_border(l_Peyvast,0xFFFFA500,1000)
	
	popup1.Initialize("popup1",l_Peyvast)
	popup1.AddMenuItem(1,func.gland(378),Null)
	popup1.AddMenuItem(2,func.gland(379),Null)


	panCover.Initialize("panCover")
	pan_chat.AddView(panCover,105dip,2.5dip,100%x-110dip,45dip)
	panCover.Color = 0xaaeeeeee

	
	li4.Initialize(0)
	panCover.AddView(li4,(panCover.Width/2)-17.5dip,(panCover.Height/2)-17.5dip,35dip,35dip)
	li4.IndicatorColor=0xFF6A5EF0

	panCover.Visible = False

	'***********************************************************************************

	ime.AddHeightChangedEvent
   
	''	**********************************************************

	Builder_add.Initialize
	Builder_add.baseUrl(urls.baseUrl).WithManager
	Jsons = Builder_add.addGsonConverterFactory
	Builder_add.addHeader(CreateMap("Content-Type":"application/json"))
	Retrofit.Initialize(Builder_add)
	Manager_add = Retrofit.Utils.GetRetrofitManager(Retrofit)
 

	checkUser

End Sub


Sub checkUser
  	
	ProgressDialogShow2(func.gland(2),False)
  	
	Dim params As Map
	Dim params1 As Map
	params.Initialize
	params1.Initialize
    	 
	params.Put("user",func.Android_Id)
 	params1.Put("request_params",params)
  	
	Retrofit.Json("skill",urls.chats,Retrofit.toJson(params1))

End Sub

Sub skill_onNext(ResponseBody As Amir_ResponseBody)
 
	ProgressDialogHide
 
	Try
		
		Dim parser As JSONParser
		parser.Initialize(ResponseBody.String)
		Dim root As Map = parser.NextObject
		Dim response As Map = root.Get("response")
		Dim code As Int = response.Get("code")
		
		If code = 200 Then
			
			listType_c.Clear
			listMatn.Clear
			list2Matn.Clear
			lisDate.Clear
			listTf.Clear

			Dim components() As String
			
			Dim message As Object = response.Get("message")

			If func.IsList(message) Then
				
				Dim kk As List = message
				For Each colmessage As Map In kk
					
					Dim text_or_file As String = colmessage.Get("text_or_file")
					Dim date_fa As String = colmessage.Get("date_fa")
					Dim typec As String = colmessage.Get("type")
					Dim matn As String = colmessage.Get("matn")
					Dim id As Int = colmessage.Get("id")
 					
					list2Matn.Add(matn)

					If text_or_file<>3 Then
 						components = Regex.Split("/", matn)  
						matn = components(components.Length-1)
					End If
					
					listTf.Add(text_or_file)
					lisDate.Add(date_fa)
					listType_c.Add(typec)
					listMatn.Add(matn)
			
					mainID = id

				Next
				
    			
			End If
  			
			CallSubDelayed(Me,"RefUlv1")
  			
		Else
			func.ToastERROR(func.gland(3))
		End If
  		 
	Catch
		func.ToastERROR(func.gland(3))
		Log(LastException)
	End Try
 
End Sub

Sub skill_onError(Error As String)
 
	ProgressDialogHide

	Log(Error)
	func.ToastERROR(func.gland(3))
  
End Sub
 
 Sub Ptar_Touch (Action As Int, X As Float, Y As Float)
 	
End Sub

 
Private Sub RefUlv1
	
	RCver.Adapter2.NotifyDataSetChanged
	RCver.Adapter2.NotifyItemRemoved(0)
  
	RCver.ScrollToPosition(listType_c.Size-1)
	
End Sub
  
Sub RCver_GetItemCount As Int
	
	Return listType_c.Size
	
End Sub


Private Sub RCver_onCreateViewHolder (Parent As Panel,ViewType As Int)

	Dim pan As Panel
	pan.Initialize("pan")
	Parent.AddView(pan,5%x,10dip,60%x,50dip)
 
	Dim lab As Label
	lab.Initialize("")
	pan.AddView(lab,5%x,2dip,50%x,35dip)

	Dim lab1 As Label
	lab1.Initialize("")
	pan.AddView(lab1,4%x+35dip,lab.Top+lab.Height+2dip,50%x,35dip)
  
	Dim lab2 As Label
	lab2.Initialize("")
	pan.AddView(lab2,2%x,lab.Top+lab.Height+2dip,35dip,35dip)

End Sub

Private Sub RCver_onBindViewHolder (Parent As Panel,Position As Int)
	
	Dim pan As Panel = Parent.GetView(0)
 	
	Dim lab   As Label = pan.GetView(0)
	Dim lab1  As Label = pan.GetView(1)
	Dim lab2  As Label = pan.GetView(2)
 
	pan.Tag = Position
 
	If 1 = listType_c.Get(Position) Or  "1" = listType_c.Get(Position) Then
		pan.Left = 35%x
		func.SetRipple(pan,0xFF00FFA1,0xFF07C47E,5)
	Else
		pan.Left = 5%x
		func.SetRipple(pan,Colors.White,0xFFD3D3D3,5)
	End If
 
 
	Dim dddL As String = listMatn.Get(Position)
	
	
	lab.Typeface=Typeface.LoadFromAssets(func.font3)
	lab.Gravity=Bit.Or(Gravity.CENTER_VERTICAL,Gravity.RIGHT)
	lab.TextSize=14
	
	If dddL.StartsWith("http") Or dddL.StartsWith("www") Then
		lab.TextColor=Colors.Blue
		lab.Text=dddL
	Else
		lab.TextColor=Colors.Black
 		lab.Text = func.setThing3(dddL,"Ꞵ")
	End If
		
	lab.Height = func.heightLabel(lab,lab.Text) + 5dip

	lab1.Top = lab.Top+lab.Height+5dip
	lab2.Top = lab1.Top
	
 
	lab1.Typeface=Typeface.LoadFromAssets(func.font3)
	lab1.Gravity=Bit.Or(Gravity.CENTER_VERTICAL,Gravity.LEFT)
	lab1.Text=lisDate.Get(Position)
	lab1.TextSize=12
	lab1.TextColor=Colors.DarkGray
	
	lab2.Typeface = Typeface.LoadFromAssets("fonticon.otf")
	lab2.Gravity = Bit.Or(Gravity.CENTER,Gravity.CENTER_VERTICAL)
	lab2.TextSize = 18
	lab2.TextColor = Colors.White
  
	Dim kk As Int = listTf.Get(Position)
	
	If kk =1 Then
		lab2.Text = Chr(0xf130)
		func.color_border(lab2,0xFF18D2A0,10dip)
	Else If kk =2 Then
		lab2.Text = Chr(0xf03d)
		func.color_border(lab2,0xFF35A70C,10dip)
	Else If kk =3 Then
		lab2.Text = Chr(0xf15c)
		func.color_border(lab2,0xFF3AA7DE,10dip)
	Else If kk =4 Then
		lab2.Text = Chr(0xf03e)
		func.color_border(lab2,0xFFCC2AA0,10dip)
	Else
		lab2.Text = Chr(0xE037)
		func.color_border(lab2,Colors.Red,10dip)
	End If
 
	pan.Height=lab1.Top+lab1.Height+5dip

	If Position = listType_c.Size-1 Then
		If mKeyboardIsVisible Then
			Parent.Height=pan.Top+pan.Height + 50%y
		Else
			Parent.Height=pan.Top+pan.Height
		End If
	Else
		Parent.Height=pan.Top+pan.Height
	End If

	Parent.Width=100%x
	
End Sub
   
Sub pan_LongClick
	
	Dim pan As Panel = Sender
	Dim pos As Int = pan.Tag

	Dim cops As BClipboard
	cops.setText(func.PersianNumbers(listMatn.Get(pos)).Replace("Ꞵ",""))

	func.ToastERROR(func.gland(88))

End Sub

Sub pan_Click
	Dim pan As Panel = Sender
	Dim pos As Int = pan.Tag
	
	Dim kk As Int = listTf.Get(pos)

	If kk = 3 Then
		
		Dim urlss As String = listMatn.Get(pos)

		If urlss.StartsWith("http") Or urlss.StartsWith("www") Then
			csClick(urlss )
		Else If urlss.Contains("Ꞵ") Then
			
			Dim strtI As Int=urlss.IndexOf2("Ꞵ",0)
			Dim strtI2 As Int=urlss.IndexOf2("Ꞵ",strtI+1)
 			
 			If strtI <> -1 And strtI2 <> -1 Then
				csClick(urlss.SubString2(strtI+1,strtI2).Trim)
 			End If
		End If

	Else
		 	
		Dim urlss As String = listMatn.Get(pos)
		Dim ur2lss As String = list2Matn.Get(pos)
	
		If 1 = listType_c.Get(pos) Or  "1" = listType_c.Get(pos) Then
		
			If File.Exists(File.DirInternal&"/abtahi/support",urlss) Then
				Intent_OpenFile(File.DirInternal&"/abtahi/support",urlss)
			Else
				Log("notFound")
				download.download(ur2lss,urlss)
			End If
		
		Else
  		
			If File.Exists(File.DirInternal&"/abtahi/support",urlss) Then
				Intent_OpenFile(File.DirInternal&"/abtahi/support",urlss)
			Else
				download.download(ur2lss,urlss)
			End If
 		
		End If

	End If

End Sub

Sub csClick (url1 As String)
	Dim int1 As PhoneIntents
	StartActivity(int1.OpenBrowser(url1))
End Sub

Sub download_pakhsh(filename As String)
 
 	If File.Exists(File.DirInternal&"/abtahi/support",filename) Then
		Intent_OpenFile(File.DirInternal&"/abtahi/support",filename)
	Else
		Log("notFound")
	End If
End Sub
 
 Sub ime_HeightChanged (NewHeight As Int, OldHeight As Int)
	
	mKeyboardIsVisible = (NewHeight < OldHeight)
 	CallSubDelayed(Me,"RefUlv1")
   	
	chH(NewHeight)
	
End Sub

Sub chH(NewHeight As Int)
	NewHeight1 = NewHeight
	pan_chat.Top=NewHeight-pan_chat.Height
End Sub

Sub ed_chat_TextChanged (Old As String, New As String)
	
	Dim su As StringUtils
	Dim inth As Int = su.MeasureMultilineTextHeight(ed_chat,New)
	
	If inth<45dip Then
		pan_chat.Top = 100%y - (45dip + 10dip)
		ed_chat.Top = 2.5dip
		pan_chat.Height = 45dip + 10dip
		ed_chat.Height = 45dip
	Else
		
		If inth > 150dip Then inth = 150dip
		
		pan_chat.Top = 100%y - (inth + 10dip)
		ed_chat.Top = 2.5dip
		pan_chat.Height = inth + 10dip
		ed_chat.Height = inth
		
	End If
	
	panCover.Top = ed_chat.Top
	panCover.Height = ed_chat.Height
 	
	l_Peyvast.Top = pan_chat.Height-52.5dip
	l_Send.Top = pan_chat.Height-52.5dip
 
	chH(NewHeight1)
 	
End Sub

Sub l_Peyvast_Click
 	popup1.Show
End Sub

Sub popup1_ItemClicked (Item As ACMenuItem)
  	
	If Item.Id = 1 Then
		boolViPi = False
		TFsp = 4
 	Else
		boolViPi = True
		TFsp = 2
 	End If
	
	permit.PermissionRequest

End Sub
  
Sub permit_ref
 	If boolViPi Then
		cc.Show("video/*", "Choose video")
	Else
		cc.Show("image/*", "Choose image")
	End If
End Sub
 
Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
 	
	Log("SuccessFile: "&Success)

	If Not(Success) Then
	
		func.ToastERROR(func.gland(229))

	Else
		
		If File.Exists(File.DirInternal,"anvarvahy2")=False Then
			File.MakeDir(File.DirInternal,"anvarvahy2")
		End If

		Dim myType As String = GetFileInfoByIndex("mime_type",FileName)
		Dim myType1() As String = Regex.Split("/",myType)
		
		Log("myType: "&myType)
		myType = myType1(1)
		Log("myType: "&myType)
		
		Dim folder As String = File.DirInternal&"/anvarvahy2"
		Dim newFileName As String
		
		newFileName =  "mmm."&myType

 
		Dim out As OutputStream
		Dim input As InputStream
		input = File.OpenInput(Dir,FileName)
		out = File.OpenOutput(folder,newFileName,False )
		Wait For (File.Copy2Async(input, out)) Complete (Success As Boolean)
		out.Close
		
		AksGallery_result(folder,newFileName,myType)
		
	End If

End Sub


Sub AksGallery_result( Dir As String, FileName As String,myType As String)
 		
 	p_aria.Show
   
 	mainDir  = Dir
	mainName = FileName
 
	Log("Dir: "&Dir)
	Log("FileName: "&FileName)

	If boolViPi Then
		picName =  "video_"&DateTime.Now&"_"&mainID&"."&myType
	Else
		picName =  "picture_"&DateTime.Now&"_"&mainID&"."&myType
	End If
 		
	upload.uploadFile(Dir,FileName,myType,picName)
  
End Sub
  
Sub GetFileInfoByIndex(column As String, uri As String) As String
	
	Dim results As String
	Dim Cur As Cursor
	Dim Uri1 As Uri
	Dim cr As ContentResolver
	cr.Initialize("")

	'if viewing by gallery
	If uri.StartsWith("content://media/") Then
		Dim i As Int = uri.LastIndexOf("/")
		Dim id As String = uri.SubString(i + 1)
		Uri1.Parse(uri)
		Cur = cr.Query(Uri1, Null, "_id = ?", Array As String(id), Null)
		Cur.Position = 0
		If Cur.RowCount <> 0 Then
			For i = 0 To Cur.ColumnCount - 1
				If Cur.GetColumnName(i) <> Null Then
					If Cur.GetColumnName(i) = column Then
						results = Cur.GetString2(i)
						Exit
					End If
				End If
			Next
		End If
	Else
		Uri1.Parse(uri)
		Cur = cr.Query(Uri1, Null, Null, Null, Null)
		Cur.Position = 0
		If Cur.RowCount <> 0 Then
			For i = 0 To Cur.ColumnCount - 1
				If Cur.GetColumnName(i) <> Null Then
					If Cur.GetColumnName(i) = column Then
						results = Cur.GetString2(i)
						Exit
					End If
				End If
			Next
		End If
	End If
	
	Cur.Close
	
	Return results
	
End Sub

Sub upload_completed(s1 As String)
	If s1 = "successfull" Then
		
		If File.Exists(File.DirInternal,"abtahi/support")=False Then
			File.MakeDir(File.DirInternal,"abtahi/support")
		End If
		
		Wait For (File.CopyAsync(mainDir,mainName,File.DirInternal&"/abtahi/support",picName)) Complete (Success As Boolean)
		Log("Success: " & Success)

		sendKol(TFsp,picName)

	Else
		func.ToastERROR(func.gland(380))
	End If
	
	p_aria.Dismiss

End Sub

Sub upload_onProgressUpdate(s1 As String)
	p_aria.setProgress(s1)
End Sub

 
Sub Intent_OpenFile(Dir As String,Filename As String)
  
	Try
		Dim ext As String
		ext = Filename.SubString(Filename.LastIndexOf(".")+1)
      
		Log(ext)
		
		File.copy(Dir, Filename, Starter.Provider.SharedFolder, Filename)

		Dim i As Intent
		
		Dim phone As Phone
		
		If phone.SdkVersion >= 24 Then
			i.Initialize(i.ACTION_VIEW, Starter.Provider.GetFileUri(Filename))
			i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
		Else
			i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(Starter.Provider.SharedFolder, Filename))
			i.SetType("application/vnd.android.package-archive")

			Dim types As Map
			types.Initialize

			types.Put("apk","application/vnd.android.package-archive")
			types.Put("au","audio/basic")
			types.Put("avi","video/msvideo, video/avi, video/x-msvideo")
			types.Put("bmp","image/bmp")
			types.Put("bz2","Application/x-bzip2")
			types.Put("css","text/css")
			types.Put("dtd","Application/xml-dtd")
			types.Put("doc","Application/msword")
			types.Put("docx","Application/vnd.openxmlformats-officedocument.wordprocessingml.document")
			types.Put("dotx","Application/vnd.openxmlformats-officedocument.wordprocessingml.template")
			types.Put("es","Application/ecmascript")
			types.Put("exe","Application/octet-stream")
			types.Put("gif","image/gif")
			types.Put("gz","Application/x-gzip")
			types.Put("hqx","Application/mac-binhex40")
			types.Put("html","text/html")
			types.Put("jar","Application/java-archive")
			types.Put("jpg","image/jpeg")
			types.Put("js","Application/x-javascript")
			types.Put("midi","audio/x-midi")
			types.Put("mp3","audio/mpeg")
			types.Put("mpeg","video/mpeg")
			types.Put("ogg","audio/vorbis, Application/ogg")
			types.Put("pdf","Application/pdf")
			types.Put("pl","Application/x-perl")
			types.Put("png","image/png")
			types.Put("potx","Application/vnd.openxmlformats-officedocument.presentationml.template")
			types.Put("ppsx","Application/vnd.openxmlformats-officedocument.presentationml.slideshow")
			types.Put("ppt","Application/vnd.ms-powerpointtd>")
			types.Put("pptx","Application/vnd.openxmlformats-officedocument.presentationml.presentation")
			types.Put("psv","Application/postscript")
			types.Put("qt","video/quicktime")
			types.Put("ra","audio/x-pn-realaudio, audio/vnd.rn-realaudio")
			types.Put("ram","audio/x-pn-realaudio, audio/vnd.rn-realaudio")
			types.Put("rdf","Application/rdf, Application/rdf+xml")
			types.Put("rtf","Application/rtf")
			types.Put("sgml","text/sgml")
			types.Put("sit","Application/x-stuffit")
			types.Put("sldx","Application/vnd.openxmlformats-officedocument.presentationml.slide")
			types.Put("svg","image/svg+xml")
			types.Put("swf","Application/x-shockwave-flash")
			types.Put("tar.gz","Application/x-tar")
			types.Put("tgz","Application/x-tar")
			types.Put("tiff","image/tiff")
			types.Put("tsv","text/TAB-separated-values")
			types.Put("txt","text/plain")
			types.Put("wav","audio/wav, audio/x-wav")
			types.Put("xlam","Application/vnd.ms-excel.addin.macroEnabled.12")
			types.Put("xls","Application/vnd.ms-excel")
			types.Put("xlsb","Application/vnd.ms-excel.sheet.binary.macroEnabled.12")
			types.Put("xlsx","Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
			types.Put("xltx","Application/vnd.openxmlformats-officedocument.spreadsheetml.template")
			types.Put("xml","Application/xml")
			types.Put("zip","Application/zip, Application/x-compressed-zip")
      
			If types.ContainsKey(ext) Then
				i.SetType(types.Get(ext))
			Else
				i.SetType("application/vnd.android.package-archive")
			End If

		End If

		Dim jo As JavaObject = I
		StartActivity(jo.RunMethod("createChooser", Array As Object(I, "")))
        
	Catch
		Log(LastException)
	End Try
  
End Sub
 
Sub panCover_Touch (Action As Int, X As Float, Y As Float)
End Sub

Sub l_Send_Click
 
	If ed_chat.Text.Trim.Length > 0 Then
		
		sendKol(3,ed_chat.Text)

	Else
		func.ToastERROR(func.gland(381))
	End If

End Sub

Sub sendKol(tf As Int,txt As String)
	
	li4.Top = (panCover.Height/2)-17.5dip
	panCover.Visible = True
		
	Dim params As Map
	Dim params1 As Map
	params.Initialize
	params1.Initialize
   
	mainTf = tf
	mainTxt = txt
		
	Dim phone As Phone

	params.Put("user",func.Android_Id)
	params.Put("matn",mainTxt)
	params.Put("text_or_file",mainTf)
	params.Put("info_mobile",phone.Manufacturer&";;"&phone.Model&";;"&phone.Product&";;"&phone.SdkVersion)
	params.Put("version_app",Application.VersionCode&";;"&Application.VersionName)
 	
	params1.Put("request_params",params)
  	
	Retrofit.Json("skill1",urls.send_chats,Retrofit.toJson(params1))
	
End Sub

Sub skill1_onNext(ResponseBody As Amir_ResponseBody)
 
	panCover.Visible = False
	
'	Log(ResponseBody.String)
	
	Try
		Dim parser As JSONParser
		parser.Initialize(ResponseBody.String)
		Dim root As Map = parser.NextObject
		Dim response As Map = root.Get("response")
		Dim code As Int = response.Get("code")
 		
		If code = 200 Then
			Dim message As String = response.Get("message")
  
			listTf.Add(mainTf)
			listType_c.Add(1)
			listMatn.Add(mainTxt)
			list2Matn.Add(mainTxt)
			lisDate.Add(message)
			
			ime.HideKeyboard
			
			ed_chat.Text = ""
			
'			ed_chat_TextChanged("","")

			pan_chat.Top = 100%y - (45dip + 10dip)
			ed_chat.Top = 2.5dip
			pan_chat.Height = 45dip + 10dip
			ed_chat.Height = 45dip
			
			panCover.Top = ed_chat.Top
			panCover.Height = ed_chat.Height
 	
			l_Peyvast.Top = pan_chat.Height-52.5dip
			l_Send.Top = pan_chat.Height-52.5dip

 			
			CallSubDelayed(Me,"RefUlv1")

		Else
			func.ToastERROR(func.gland(3))
		End If
  		 
	Catch
		func.ToastERROR(func.gland(3))
		Log(LastException)
	End Try
 
End Sub

Sub skill1_onError(Error As String)
  
	panCover.Visible = False

	Log(Error)
	func.ToastERROR(func.gland(3))
  
End Sub
 
  
Sub lab_back_Click
	close
End Sub

Sub close
	
	Manager_add.CancelAll
	ime.HideKeyboard
	
	Activity.Finish
 	
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


 Sub Activity_KeyPress (KeyCode As Int) As Boolean
 	
	If KeyCode = KeyCodes.KEYCODE_BACK Then
		close
	End If
 	
	Return True
	
End Sub
  
  
