-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPickHost.java
More file actions
58 lines (47 loc) · 1.52 KB
/
PickHost.java
File metadata and controls
58 lines (47 loc) · 1.52 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
package com.shank.SambaExplorer;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.content.Intent;
public class PickHost extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pickhost);
Button btn = (Button)findViewById(R.id.Button01);
btn.setOnClickListener(mPickHostClickListener);
}
private OnClickListener mPickHostClickListener = new OnClickListener()
{
public void onClick(View v)
{
EditText ip = (EditText)findViewById(R.id.EditText01);
String text = ip.getText().toString();
if (text.startsWith("\\\\")) {
text = text.substring(2);
}
if (text.startsWith("\\")) {
text = text.substring(1);
}
if (text.startsWith("//")) {
text = text.substring(2);
}
if (text.startsWith("/")) {
text = text.substring(1);
}
if (text.endsWith("\\")) {
text = text.substring(0, text.length()-1);
}
if (text.endsWith("/")) {
text = text.substring(0, text.length()-1);
}
text = "smb://"+text+"/";
Intent intent = new Intent(v.getContext(), com.shank.SambaExplorer.SambaExplorer.class);
intent.putExtra("hostname", text);
startActivity(intent);
}
};
}