diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c4e03e5..0a46b65 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,23 +7,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -60,12 +48,44 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -94,11 +114,34 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1388,7 +1431,7 @@
@@ -1690,10 +1735,7 @@
-
-
-
@@ -1716,21 +1758,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
@@ -1971,7 +2035,7 @@
-
+
@@ -1985,7 +2049,7 @@
-
+
@@ -2006,7 +2070,7 @@
-
+
@@ -2046,6 +2110,14 @@
1488265773247
+
+ 1488472281606
+
+
+
+ 1488472281606
+
+
@@ -2054,7 +2126,7 @@
-
+
@@ -2063,11 +2135,11 @@
-
+
-
+
@@ -2112,36 +2184,138 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2153,6 +2327,246 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2182,8 +2596,38 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/app.iml b/app/app.iml
index 2b962e7..db2a0f0 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -66,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -82,19 +74,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 4d9b5ea..c1ebca1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 19
- buildToolsVersion "19.1.0"
+ compileSdkVersion 25
+ buildToolsVersion '23.0.3'
defaultConfig {
applicationId "jonas.tool.saveForOffline"
@@ -27,5 +27,5 @@ android {
dependencies {
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.squareup.okhttp:okhttp:2.7.2'
- compile 'com.squareup.picasso:picasso:2.5.2'
+ compile 'com.squareup.picasso:picasso:2.5.2'
}
diff --git a/app/src/main/java/jonas/tool/saveForOffline/AddActivity.java b/app/src/main/java/jonas/tool/saveForOffline/AddActivity.java
index c81e4c3..c91c31f 100644
--- a/app/src/main/java/jonas/tool/saveForOffline/AddActivity.java
+++ b/app/src/main/java/jonas/tool/saveForOffline/AddActivity.java
@@ -64,19 +64,21 @@ Written by Jonas Czech (JonasCz, stackoverflow.com/users/4428462/JonasCz and git
public class AddActivity extends Activity {
private Button btn_save;
private EditText edit_origurl;
+ private TextView tipText;
private String origurl ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setTitle("Enter URL to save");
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setTitle("Enter URL to save");
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
setContentView(R.layout.add_activity);
btn_save = (Button)findViewById(R.id.save_btn);
- btn_save.setEnabled(false);
+ tipText = (TextView) findViewById(R.id.tipText);
edit_origurl = (EditText)findViewById(R.id.frst_editTxt);
edit_origurl.setText(getIntent().getStringExtra(Intent.EXTRA_TEXT));
@@ -86,22 +88,6 @@ public void onCreate(Bundle savedInstanceState) {
if (origurl.length() > 0) {
startSave(origurl);
}
-
- edit_origurl.addTextChangedListener(new TextWatcher(){
- public void afterTextChanged(Editable text) {
- if (edit_origurl.length() == 0) {
- btn_save.setEnabled(false);
- } else {
- btn_save.setEnabled(true);
- }
- }
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
- public void onTextChanged(CharSequence s, int start, int before, int count) {}
- });
- }
-
- public void cancelButtonClick(View view) {
- finish();
}
public void btn_paste(View view) {
@@ -109,24 +95,32 @@ public void btn_paste(View view) {
if (edit_origurl.getText().length() == 0) {
edit_origurl.append(clipboard.getText());
} else {
- edit_origurl.append(System.lineSeparator() + clipboard.getText());
- }
+ edit_origurl.append(System.getProperty("line.separator") + clipboard.getText());
+ }
}
// saveButton click event
public void okButtonClick(View view) {
origurl = edit_origurl.getText().toString().trim();
- String[] urls = origurl.split("[\\r\\n]+");
- for (String url : urls) {
- if (url.length() > 0 && (url.startsWith("http"))) {
- startSave(url);
- } else if (url.length() > 0) {
- url = "http://" + url;
- startSave(url);
+ if (isValidUrlText(origurl)) {
+ String[] urls = origurl.split("[\\r\\n]+");
+ for (String url : urls) {
+ startSave(url);
}
- }
-
- }
+ } else {
+ Toast.makeText(this, "Oops, that doesn't look like a valid URL. Make sure you included the 'http://' part.", Toast.LENGTH_LONG).show();
+ }
+ }
+
+ private boolean isValidUrlText(String urltext) {
+ String[] urls = urltext.split("[\\r\\n]+");
+ for (String url : urls) {
+ if (url.length() == 0 || (!url.startsWith("http"))) {
+ return false;
+ }
+ }
+ return true;
+ }
private void startSave(String url) {
diff --git a/app/src/main/res/layout/add_activity.xml b/app/src/main/res/layout/add_activity.xml
index 1807aff..ced2772 100644
--- a/app/src/main/res/layout/add_activity.xml
+++ b/app/src/main/res/layout/add_activity.xml
@@ -19,23 +19,12 @@
android:orientation="vertical">
-
-
+
+ android:id="@+id/pasteButton" />