Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

13:01 � ,, • CID

MainActivity.java

package com.my.newdata;

import android.app.*;
import android.os.*;
import android.view.*;
import android.view.View.*;
import android. widget.*;
import android.content.*;
import android.graphics.*;
import android.media.*;
import android.net.*;
import android.text.*;
import android.util.*; import
android.webkit.*; import
android.animation.*;
import android.view.animation.*;
import java.util.*;
import java.text.*;
import android.app.Activity;
import android. widget. ProgressBar;
import android. webkit. WebView;
import android. webkit. WebSettings;
import android.content.Intent;
import android.content.ClipData;
import android. webkit. WebViewClient;
import android.Manifest;
import android.content.pm.PackageManager;

public class MainActivity extends Activity {

public final int REQ_CD_FP = 101;

private ProgressBar progressbar1;


private WebView webview1;

private Intent fp = new lntent(lntent.ACTION_GET_CONTENT);


@Override
protected void onCreate(Bundle _savedlnstanceState) {
su per.onCreate(_saved lnstanceState);
setContentView(R. layout.main);
in itialize(_saved lnstanceState);
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) =
requestPermissions(new StringO {Manifest.permission.READ_EXTERNAL_�
}
else {
in itializelog ic();
}
}
else {
initial izelog ic ();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, StringO permissions,
super.onRequestPermissionsResult(requestCode, permissions, grantResults); if
(requestCode == 1000) {
initial izelog ic();
}
}

private void initialize(Bundle _savedlnstanceState) {

progressbar1 = (ProgressBar) frndViewByld(R.id.progressbar1 );


webview1 = (WebView) frndViewByld(R.id.webview1 );
webview1 .getSettings().setJavaScriptEnabled(true);
webview1 .getSettings().setSupportZoom(true);
fp.setType("*/*");
fp.putExtra(lntent.EXTRA_ALLOW_MULTIPLE, true);

webview1 .setWebViewClient(new WebViewClient() {


@Override
public void onPageStarted(WebView _param1, String _param2, Bitmap _para1
final String .url = _param2;
progressbar1 .setVisibility(View. VISIBLE);
super.onPageStarted(_param1, _param2, _param3);
}

@Override
public void onPageFinished(WebView _param1, String _param2) {
final String _url = _param2;
progressbar1 .setVisibility(View.GONE);
super.onPageFinished(_param1, _param2);
}
});
}
private void initializelogic() {
webview1 .setWebChromeClient(new WebChromeClient() {
II For 3.0+ Devices
protected void openFileChooser(ValueCallback uploadMsg, String accept Iyp
i.setType("image/*"); startActivityForResult(lntent.createChooser(i, "File Brc
}

II For Lollipop 5.0+ Devices


public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri
if (upload Message != null) {
uploadMessage.onReceiveValue(null);
uploadMessage =null;} upload Message = frlePathCallback; Intent intent =
startActivityForResult(intent, REQUEST_SELECT_FILE);
} catch (ActivityNotFoundException e) {
uploadMessage = null; Toast.makeText(getApplicationContext(), "Cannot

return true;}

//For Android 4.1 only


protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acce
mUploadMessage = uploadMsg; Intent intent = new lntent(lntent.ACTION_C
}

protected void openFileChooser(ValueCallback<Uri> uploadMsg)


{ mUploadMessage = uploadMsg; Intent i = new
lntent(lntent.ACTION_GET_C i. setType(" image/*"); startActivityForResu lt(I
ntent. createC h ooser(i, "File Ch
}

});
webview1 .getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NE
progressbar1 .setVisibility(View.GONE);
webview1 .loadUrl("http://36. 91. 58.183:8888/mydata/");
}

@Override
protected void onActivityResult(int _requestCode, int _resultCode, Intent _data)
super.onActivityResult(_requestCode, _resultCode, _data);

switch (_requestCode) {
case REQ_CD_FP:
if (_resultCode == Activity.RESULT_OK) {
Arraylist<String> _frlePath = new Arraylist<>();
if (_data!= null) {
if (_data.getClipData() != null) {
for (int _index = O; _index < _data.getClipData().getltemCount(); _index+-+
ClipData. Item _item = _data.getClipData().getltemAt(_index);
_fr le Path. add (FileUti I. convertUriToFi le Path (getAppl ication Context(),
_i1
}
}
else {
_frlePath.add(FileUtil.convertUriToFilePath(getApplicationContext(), _da
}
}
}
break;

case REQUEST_SELECT_FILE:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (uploadMessage == null) return; uploadMessage.onReceiveValue(WebCh1
break;

case FILECHOOSER_RESULTCODE:
if (null == mUploadMessage){
return;}
Uri result = _data == null 11 _resultCode != RESULT_OK? null : _data.getData();
mUploadMessage = null;

if (true){
}
else {

} break;
default:
break;
}
}

private void _extracodes () {


}

private ValueCallback<Uri> mUploadMessage;


public Valuecallback-Urijl> uploadMessage;
public static final int REQUEST_SELECT_FILE= 100;

private final static int FILECHOOSER_RESULTCODE = 1;


{
}

@Deprecated
public void showMessage(String _s) { Toast.
makeText(getApplicationContext(), _s, Toast. LENGTH_SHO RT).show();
}

@Deprecated
public int getlocationX(View .v) {
int _locationO = new int[2];
_v. get Location In Window(_location);
return _location[O];
}

@Deprecated
public int getlocationY(View _v) {
int .Iocationll = new int[2];
_v.getlocation I nWindow(_location);
return _location[1 ];
}

@Deprecated
public int getRandom(int _min, int _max) {
Random random = new Random();
return random.nextlnt(_max - _min+ 1) + _min;
}

@Deprecated

public Arraylist<Double> getCheckedltemPositionsToArray(ListView _list) {


Arraylist<Double> _result= new Arraylist<Double>();
SparseBooleanArray _arr= _list.getCheckedltemPositions();
for (int _ildx = O; _ildx < _arr.size(); _ildx++) {
if (_arr.valueAt(_ildx))
_result. add((double)_arr. keyAt(_i ldx));
}
return .result:
}

@Deprecated
public float getDip(int _input){
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, g
}

@Deprecated
public int getDisplayWidthPixels(){
return getResources().getDisplayMetrics().widthPixels;
}

@Deprecated
public int getDisplayHeightPixels(){
return getResources().getDisplayMetrics().heightPixels;
}

}
13:oo V ,,1 • OD

AndroidManifest.xm
l

<manifest
xmlns:android=11http://schemas.android.com/apk/res/androi
d11 packaqe=rcom.mynewdata">
<uses-permission android:name="android.permission.lNTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STA-
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORA
<application
android:allowBackup="true"
android.label=Torm Input Data"
android:icon="@drawable/app_icon
" android :larg eHeap ="true"
android .name=" .SketchApplication"
android.therne=Ypstyle/AppTheme"
>
<activity
android.name=". MainActivity"
android:conflgChanges orientationlscreenSize
11

=
11
11

android:theme= @style/NoActionBar >


11

<intent-fl lter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<zintent-f lter>
</activity>
<activity
android.narne=". DebugActivity"
android:screenOrientation="portrait"/
>
</application>
</man ifest>
13:oo V ,,1 • OD

main.xml

<Linearlayout
xmlns:android=11http://schemas.android.com/apk/res/android1
1

xmlns:app= http://schemas.android.com/apk/res-auto
11 11

xmlns:tools=11http://schemas.android.com/tools1
1 android:layout_width =rnatch.parent"

android.layout heiqht=rmatch.parent"
and raid :orientation =vertica 1 >
11

<ProgressBar
android:id=11@+id/progressbar111
android:layout_width=11match_parent1
1 android.layout.heiqht=Bdp"
android.scalev=" S.011
and raid :in determ in ate=true" style="?
11
android:progressBarStyleHorizontal />
<WebView
android:id=11@+id/webview111
android:layout_width=11match_parent11
android:layout_height=11match_parent11/
>
</Linearlayout>

You might also like