forked from cory/tildefriends
		
	Android pull refresh fixes. Sigh.
This commit is contained in:
		| @@ -26,7 +26,7 @@ import android.webkit.URLUtil; | ||||
| import android.webkit.ValueCallback; | ||||
| import android.webkit.WebChromeClient; | ||||
| import android.webkit.WebResourceRequest; | ||||
| import android.webkit.WebView; | ||||
| //import android.webkit.WebView; | ||||
| import android.webkit.WebViewClient; | ||||
| import android.widget.Button; | ||||
| import android.widget.TextView; | ||||
| @@ -182,7 +182,6 @@ public class MainActivity extends Activity { | ||||
| 		}); | ||||
|  | ||||
| 		web_view.setWebChromeClient(new WebChromeClient() { | ||||
| 			@Override | ||||
| 			public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { | ||||
| 				new AlertDialog.Builder(view.getContext()) | ||||
| 					.setTitle("Tilde Friends") | ||||
| @@ -211,7 +210,6 @@ public class MainActivity extends Activity { | ||||
| 			** https://stackoverflow.com/questions/8586691/how-to-open-file-save-dialog-in-android | ||||
| 			*/ | ||||
|  | ||||
| 			@Override | ||||
| 			public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> message, WebChromeClient.FileChooserParams params) { | ||||
| 				upload_message = message; | ||||
| 				Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | ||||
| @@ -221,7 +219,6 @@ public class MainActivity extends Activity { | ||||
| 				return true; | ||||
| 			} | ||||
|  | ||||
| 			@Override | ||||
| 			public boolean onConsoleMessage(android.webkit.ConsoleMessage consoleMessage) { | ||||
| 				Log.d("tildefriends", consoleMessage.message() + " -- From line " + consoleMessage.lineNumber() + " of " + consoleMessage.sourceId()); | ||||
| 				return true; | ||||
| @@ -229,7 +226,6 @@ public class MainActivity extends Activity { | ||||
| 		}); | ||||
|  | ||||
| 		web_view.setWebViewClient(new WebViewClient() { | ||||
| 			@Override | ||||
| 			public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) | ||||
| 			{ | ||||
| 				if (request.getUrl() != null && request.getUrl().toString().startsWith(base_url)) { | ||||
| @@ -304,10 +300,11 @@ public class MainActivity extends Activity { | ||||
| 		switch (event.getActionMasked()) { | ||||
| 		case MotionEvent.ACTION_DOWN: | ||||
| 			touch_down_y = event.getY(); | ||||
| 			web_view.clearOverscrolledY(); | ||||
| 			break; | ||||
| 		case MotionEvent.ACTION_MOVE: | ||||
| 			{ | ||||
| 				float delta = event.getY() - touch_down_y; | ||||
| 				float delta = web_view.getOverscrolledY() ? event.getY() - touch_down_y : 0.0f; | ||||
| 				TextView refresh = (TextView)findViewById(R.id.refresh); | ||||
| 				LayoutParams layout = refresh.getLayoutParams(); | ||||
| 				layout.height = | ||||
| @@ -319,7 +316,7 @@ public class MainActivity extends Activity { | ||||
| 			break; | ||||
| 		case MotionEvent.ACTION_UP: | ||||
| 			{ | ||||
| 				float delta = event.getY() - touch_down_y; | ||||
| 				float delta = web_view.getOverscrolledY() ? event.getY() - touch_down_y : 0.0f; | ||||
| 				if (delta > getWindow().getDecorView().getHeight() / 4) { | ||||
| 					web_view.reload(); | ||||
| 				} | ||||
|   | ||||
							
								
								
									
										31
									
								
								src/android/com/unprompted/tildefriends/WebView.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/android/com/unprompted/tildefriends/WebView.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| package com.unprompted.tildefriends; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.util.AttributeSet; | ||||
| import android.util.Log; | ||||
|  | ||||
| public class WebView extends android.webkit.WebView { | ||||
| 	boolean overscrolledY = false; | ||||
|  | ||||
| 	public WebView(final Context context) { | ||||
| 		super(context); | ||||
| 	} | ||||
|  | ||||
| 	public WebView(final Context context, final AttributeSet attrs) { | ||||
| 		super(context, attrs); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { | ||||
| 		super.onOverScrolled(scrollX, scrollY, clampedX, clampedY); | ||||
| 		overscrolledY = true; | ||||
| 	} | ||||
|  | ||||
| 	public boolean getOverscrolledY() { | ||||
| 		return overscrolledY; | ||||
| 	} | ||||
|  | ||||
| 	public void clearOverscrolledY() { | ||||
| 		overscrolledY = false; | ||||
| 	} | ||||
| } | ||||
| @@ -4,7 +4,7 @@ | ||||
| 	android:layout_width="match_parent" | ||||
| 	android:layout_height="match_parent" | ||||
| 	android:orientation="vertical"> | ||||
| 	<WebView | ||||
| 	<com.unprompted.tildefriends.WebView | ||||
| 		android:id="@+id/web" | ||||
| 		android:layout_width="match_parent" | ||||
| 		android:layout_height="match_parent"/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user