mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Test PROPFIND with new endpoind and new network library
This commit is contained in:
parent
ede34920c2
commit
d79bdb7893
@ -15,7 +15,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.9.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -22,24 +22,29 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.owncloud.android.lib.sampleclient"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
package="com.owncloud.android.lib.sampleclient"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="26" />
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
<activity android:name="MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="26"/>
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar">
|
||||
<activity
|
||||
android:name="MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
@ -22,26 +22,27 @@
|
||||
THE SOFTWARE.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_refresh"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
<EditText
|
||||
android:id="@+id/server_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:enabled="false"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/refresh"
|
||||
android:visibility="invisible"/>
|
||||
android:layout_toLeftOf="@+id/button_check_server"
|
||||
android:layout_toStartOf="@+id/button_check_server"
|
||||
android:ems="10"
|
||||
android:hint="Server address (with http or https)"
|
||||
android:inputType="textPersonName"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_check_server"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/server_address"
|
||||
@ -51,105 +52,103 @@
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/check_server"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/server_address"
|
||||
android:layout_marginTop="10dp"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/refresh"
|
||||
android:visibility="visible"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/button_upload"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/button_refresh"
|
||||
android:visibility="invisible">
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_upload"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_above="@+id/frame"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:enabled="false"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/upload"
|
||||
android:visibility="invisible"/>
|
||||
<!--<Button-->
|
||||
<!--android:id="@+id/button_upload"-->
|
||||
<!--style="@style/ButtonStyle"-->
|
||||
<!--android:layout_above="@+id/frame"-->
|
||||
<!--android:layout_alignParentLeft="true"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:onClick="onClickHandler"-->
|
||||
<!--android:text="@string/upload"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/upload_progress"
|
||||
style="@style/ProgressStyle"
|
||||
android:layout_above="@id/frame"
|
||||
android:layout_below="@id/list_view"
|
||||
android:layout_toLeftOf="@+id/button_delete_remote"
|
||||
android:layout_toRightOf="@id/button_upload"
|
||||
android:enabled="false"
|
||||
android:gravity="center"
|
||||
android:text="0%"
|
||||
android:textSize="14sp"
|
||||
android:visibility="invisible"/>
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/upload_progress"-->
|
||||
<!--style="@style/ProgressStyle"-->
|
||||
<!--android:layout_above="@id/frame"-->
|
||||
<!--android:layout_below="@id/list_view"-->
|
||||
<!--android:layout_toLeftOf="@+id/button_delete_remote"-->
|
||||
<!--android:layout_toRightOf="@id/button_upload"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:gravity="center"-->
|
||||
<!--android:text="0%"-->
|
||||
<!--android:textSize="14sp"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
<Button
|
||||
android:id="@id/button_delete_remote"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_above="@id/frame"
|
||||
android:layout_alignParentRight="true"
|
||||
android:enabled="false"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/delete_remote_file"
|
||||
android:visibility="invisible"/>
|
||||
<!--<Button-->
|
||||
<!--android:id="@id/button_delete_remote"-->
|
||||
<!--style="@style/ButtonStyle"-->
|
||||
<!--android:layout_above="@id/frame"-->
|
||||
<!--android:layout_alignParentRight="true"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:onClick="onClickHandler"-->
|
||||
<!--android:text="@string/delete_remote_file"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/frame_height"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_above="@+id/button_download"
|
||||
>
|
||||
</FrameLayout>
|
||||
<!--<FrameLayout-->
|
||||
<!--android:id="@id/frame"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="@dimen/frame_height"-->
|
||||
<!--android:layout_alignParentLeft="true"-->
|
||||
<!--android:layout_alignParentRight="true"-->
|
||||
<!--android:layout_above="@+id/button_download"-->
|
||||
<!-->-->
|
||||
<!--</FrameLayout>-->
|
||||
|
||||
<Button
|
||||
android:id="@id/button_download"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:enabled="false"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/download"
|
||||
android:visibility="invisible"/>
|
||||
<!--<Button-->
|
||||
<!--android:id="@id/button_download"-->
|
||||
<!--style="@style/ButtonStyle"-->
|
||||
<!--android:layout_alignParentBottom="true"-->
|
||||
<!--android:layout_alignParentLeft="true"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:onClick="onClickHandler"-->
|
||||
<!--android:text="@string/download"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_progress"
|
||||
style="@style/ProgressStyle"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/frame"
|
||||
android:layout_toLeftOf="@+id/button_delete_local"
|
||||
android:layout_toRightOf="@id/button_download"
|
||||
android:enabled="false"
|
||||
android:gravity="center"
|
||||
android:text="0%"
|
||||
android:textSize="14sp"
|
||||
android:visibility="invisible"/>
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/download_progress"-->
|
||||
<!--style="@style/ProgressStyle"-->
|
||||
<!--android:layout_alignParentBottom="true"-->
|
||||
<!--android:layout_below="@id/frame"-->
|
||||
<!--android:layout_toLeftOf="@+id/button_delete_local"-->
|
||||
<!--android:layout_toRightOf="@id/button_download"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:gravity="center"-->
|
||||
<!--android:text="0%"-->
|
||||
<!--android:textSize="14sp"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
<Button
|
||||
android:id="@id/button_delete_local"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:enabled="false"
|
||||
android:onClick="onClickHandler"
|
||||
android:text="@string/delete_local_file"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/server_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/list_view"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/button_check_server"
|
||||
android:layout_toStartOf="@+id/button_check_server"
|
||||
android:ems="10"
|
||||
android:hint="Server address (with http or https)"
|
||||
android:inputType="textPersonName"/>
|
||||
<!--<Button-->
|
||||
<!--android:id="@id/button_delete_local"-->
|
||||
<!--style="@style/ButtonStyle"-->
|
||||
<!--android:layout_alignParentBottom="true"-->
|
||||
<!--android:layout_alignParentRight="true"-->
|
||||
<!--android:enabled="false"-->
|
||||
<!--android:onClick="onClickHandler"-->
|
||||
<!--android:text="@string/delete_local_file"-->
|
||||
<!--android:visibility="invisible"/>-->
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -83,6 +83,16 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
private View mFrame;
|
||||
|
||||
private static final String NODE_VERSION = "version";
|
||||
|
||||
private static final String URL = "TO COMPLETE";
|
||||
|
||||
private static final String WEBDAV_PATH_4_0 = "/remote.php/webdav/";
|
||||
|
||||
private static final String NEW_WEBDAV_PATH = "/remote.php/dav/files/";
|
||||
|
||||
private static final String USERNAME = "TO COMPLETE";
|
||||
|
||||
private static final String PASSWORD = "TO COMPLETE";
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
@ -125,7 +135,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
Log.e(LOG_TAG, getString(R.string.error_copying_sample_file), e);
|
||||
}
|
||||
|
||||
mFrame = findViewById(R.id.frame);
|
||||
// mFrame = findViewById(R.id.frame);
|
||||
}
|
||||
|
||||
|
||||
@ -147,18 +157,18 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
case R.id.button_refresh:
|
||||
startRefresh();
|
||||
break;
|
||||
case R.id.button_upload:
|
||||
startUpload();
|
||||
break;
|
||||
case R.id.button_delete_remote:
|
||||
startRemoteDeletion();
|
||||
break;
|
||||
case R.id.button_download:
|
||||
startDownload();
|
||||
break;
|
||||
case R.id.button_delete_local:
|
||||
startLocalDeletion();
|
||||
break;
|
||||
// case R.id.button_upload:
|
||||
// startUpload();
|
||||
// break;
|
||||
// case R.id.button_delete_remote:
|
||||
// startRemoteDeletion();
|
||||
// break;
|
||||
// case R.id.button_download:
|
||||
// startDownload();
|
||||
// break;
|
||||
// case R.id.button_delete_local:
|
||||
// startLocalDeletion();
|
||||
// break;
|
||||
default:
|
||||
Toast.makeText(this, R.string.youre_doing_it_wrong, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@ -168,16 +178,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
|
||||
String serverAddress = ((TextView) findViewById(R.id.server_address)).getText().toString();
|
||||
|
||||
if (serverAddress.equals("")) {
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
"Introduce a server address", Toast.LENGTH_LONG);
|
||||
|
||||
toast.setGravity(Gravity.CENTER,0,0);
|
||||
|
||||
toast.show();
|
||||
|
||||
return;
|
||||
}
|
||||
if (!validServerAddress(serverAddress)) return;
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
@ -188,6 +189,47 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
|
||||
@Override public void onResponse(Call call, final Response response) throws IOException {
|
||||
|
||||
if (!response.isSuccessful()) {
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
showToastMessage("Response not successful with code " + response.code());
|
||||
}
|
||||
});
|
||||
|
||||
throw new IOException("Unexpected code " + response);
|
||||
}
|
||||
|
||||
try { // Successful response
|
||||
|
||||
String jsonData = response.body().string();
|
||||
|
||||
JSONObject Jobject = new JSONObject(jsonData);
|
||||
|
||||
final String serverVersion = Jobject.get("version").toString();
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
showToastMessage("Server with version " + serverVersion + " detected");
|
||||
}
|
||||
});
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Headers responseHeaders = response.headers();
|
||||
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
|
||||
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFailure(Call call, final IOException e) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -203,6 +245,31 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
});
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startRefresh() {
|
||||
|
||||
// Let's first use OKHttp with the new endpoint without depending on our library operations
|
||||
|
||||
// ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
|
||||
// refreshOperation.execute(mClient, this, mHandler);
|
||||
|
||||
String serverAddress = ((TextView) findViewById(R.id.server_address)).getText().toString();
|
||||
|
||||
if (!validServerAddress(serverAddress)) return;
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
String credentials = Credentials.basic(USERNAME, PASSWORD);
|
||||
|
||||
final Request request = new Request.Builder()
|
||||
.url(URL + NEW_WEBDAV_PATH + USERNAME)
|
||||
.addHeader("Authorization", credentials)
|
||||
.method("PROPFIND", null)
|
||||
.build();
|
||||
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
|
||||
@Override public void onResponse(Call call, final Response response) throws IOException {
|
||||
|
||||
@ -212,81 +279,33 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
"Response not successful with code " + response.code(), Toast.LENGTH_LONG);
|
||||
|
||||
toast.setGravity(Gravity.CENTER,0,0);
|
||||
|
||||
toast.show();
|
||||
showToastMessage("Response not successful with code " + response.code());
|
||||
}
|
||||
});
|
||||
|
||||
throw new IOException("Unexpected code " + response);
|
||||
}
|
||||
|
||||
try { // Response successful
|
||||
} else { // Successful response
|
||||
|
||||
String jsonData = response.body().string();
|
||||
|
||||
JSONObject Jobject = new JSONObject(jsonData);
|
||||
|
||||
final String serverVersion = Jobject.get("version").toString();
|
||||
final String propFindResult = response.body().string();
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
"Server with version " + serverVersion + " detected", Toast.LENGTH_LONG);
|
||||
|
||||
toast.setGravity(Gravity.CENTER,0,0);
|
||||
|
||||
toast.show();
|
||||
showToastMessage(propFindResult);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Headers responseHeaders = response.headers();
|
||||
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
|
||||
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
|
||||
Headers responseHeaders = response.headers();
|
||||
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
|
||||
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startRefresh() {
|
||||
// ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
|
||||
// refreshOperation.execute(mClient, this, mHandler);
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
String credentials = Credentials.basic("", "");
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("")
|
||||
.addHeader("Authorization", credentials)
|
||||
.method("PROPFIND", null)
|
||||
.build();
|
||||
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override public void onResponse(Call call, Response response) throws IOException {
|
||||
|
||||
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
||||
|
||||
Headers responseHeaders = response.headers();
|
||||
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
|
||||
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
|
||||
}
|
||||
|
||||
System.out.println(response.body().string());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -331,8 +350,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
if (!downloadedFile.delete() && downloadedFile.exists()) {
|
||||
Toast.makeText(this, R.string.error_deleting_local_file, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
((TextView) findViewById(R.id.download_progress)).setText("0%");
|
||||
findViewById(R.id.frame).setBackgroundDrawable(null);
|
||||
// ((TextView) findViewById(R.id.download_progress)).setText("0%");
|
||||
// findViewById(R.id.frame).setBackgroundDrawable(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,10 +400,10 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
|
||||
private void onSuccessfulRemoteDeletion(RemoveRemoteFileOperation operation, RemoteOperationResult result) {
|
||||
startRefresh();
|
||||
TextView progressView = (TextView) findViewById(R.id.upload_progress);
|
||||
if (progressView != null) {
|
||||
progressView.setText("0%");
|
||||
}
|
||||
// TextView progressView = (TextView) findViewById(R.id.upload_progress);
|
||||
// if (progressView != null) {
|
||||
// progressView.setText("0%");
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -404,11 +423,11 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
@Override
|
||||
public void run() {
|
||||
TextView progressView = null;
|
||||
if (upload) {
|
||||
progressView = (TextView) findViewById(R.id.upload_progress);
|
||||
} else {
|
||||
progressView = (TextView) findViewById(R.id.download_progress);
|
||||
}
|
||||
// if (upload) {
|
||||
// progressView = (TextView) findViewById(R.id.upload_progress);
|
||||
// } else {
|
||||
// progressView = (TextView) findViewById(R.id.download_progress);
|
||||
// }
|
||||
if (progressView != null) {
|
||||
progressView.setText(Long.toString(percentage) + "%");
|
||||
}
|
||||
@ -416,4 +435,19 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validServerAddress(String serverAddress) {
|
||||
if (serverAddress.equals("") || (!serverAddress.contains("http://") && !serverAddress.contains("https://"))) {
|
||||
showToastMessage("Introduce a proper server address with http/https");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showToastMessage(String message) {
|
||||
Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
|
||||
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user