Skip to content

Commit

Permalink
Swipe up test (#63)
Browse files Browse the repository at this point in the history
* Update build.gradle

* Update activity_main.xml

* Update MainActivity.java

* add swipy for swipe up

* add swipy for swipe up

* Update build.gradle
  • Loading branch information
KFMDMSolutions committed Mar 13, 2022
1 parent cae9699 commit 169d596
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Expand Up @@ -13,8 +13,8 @@ android {
minSdkVersion 24
//noinspection OldTargetApi
targetSdkVersion 31
versionCode 11
versionName "3.1-beta2"
versionCode 12
versionName "3.2-alpha.1"

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand Down Expand Up @@ -53,6 +53,7 @@ android {
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])

}
}
Expand Down
Binary file added app/libs/swipy.aar
Binary file not shown.
40 changes: 28 additions & 12 deletions app/src/main/java/com/kfmdmsolutions/ivelt/MainActivity.java
Expand Up @@ -60,6 +60,9 @@
import com.kfmdmsolutions.ivelt.Utilities.Logger;
import com.kfmdmsolutions.ivelt.Utilities.Utils;
import com.kfmdmsolutions.ivelt.Utilities.WebkitCookieManagerProxy;
import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout;
import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
Expand All @@ -72,11 +75,11 @@
import static android.webkit.WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE;


public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements SwipyRefreshLayout.OnRefreshListener {
private static Bundle webviewBundle;
WebView mywebView;
String sURL, sFileName, sUserAgent;
SwipeRefreshLayout swipeRefreshLayout;
private SwipyRefreshLayout mSwipyRefreshLayout;
String currentUrl = "https://www.ivelt.com/";
String url = null;
Logger logger;
Expand All @@ -93,6 +96,8 @@ public class MainActivity extends AppCompatActivity {

private String mCameraPhotoPath;

// private ActivityMainBinding mBinding;

public int getBundleSizeInBytes(Bundle bundle ) {
Parcel parcel = Parcel.obtain();
parcel.writeValue(bundle);
Expand Down Expand Up @@ -188,8 +193,9 @@ protected void onCreate(Bundle savedInstanceState) {

}
mywebView = findViewById(R.id.webview);
swipeRefreshLayout = findViewById(R.id.swipeContainer);
swipeRefreshLayout.setNestedScrollingEnabled(true);
mSwipyRefreshLayout = (SwipyRefreshLayout) findViewById(R.id.swipeContainer);
// SwipyRefreshLayoutDirection = findViewById(R.id.swipeContainer);
// SwipyRefreshLayoutDirection.setNestedScrollingEnabled(true);
WebViewAssetLoader.AssetsPathHandler assetsHandler = new WebViewAssetLoader.AssetsPathHandler(this);
WebViewAssetLoader loader = new WebViewAssetLoader.Builder()
.setDomain("www.ivelt.com")
Expand Down Expand Up @@ -280,7 +286,8 @@ protected void onCreate(Bundle savedInstanceState) {

});

swipeRefreshLayout.setOnRefreshListener(() -> mywebView.reload());
// mywebView.swipe
mSwipyRefreshLayout.setOnRefreshListener(this);

}

Expand Down Expand Up @@ -359,6 +366,8 @@ public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGest
android.util.Log.d("OCW", "is dialog " + isDialog);
view.getOriginalUrl();
url = view.getHitTestResult().getExtra();


android.util.Log.d("OCW", "url " + view.getOriginalUrl());
if(url != null && href.getData() != null && shouldOverrideUrlLoading(mywebView, Uri.parse(url))){
return false;
Expand Down Expand Up @@ -400,7 +409,7 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request

@Override
public void onPageFinished(WebView view, String url) {
swipeRefreshLayout.setRefreshing(false);
mSwipyRefreshLayout.setRefreshing(false);
super.onPageFinished(view, url);
}
});
Expand Down Expand Up @@ -428,7 +437,7 @@ public boolean onConsoleMessage(ConsoleMessage consoleMessage) {

resultMsg.sendToTarget();

swipeRefreshLayout.setRefreshing(true);
mSwipyRefreshLayout.setRefreshing(true);
alertDialog.show();
return true;
}
Expand Down Expand Up @@ -528,6 +537,7 @@ public void onActivityResult (int requestCode, int resultCode, Intent data) {
}
private void downloadFile(String fileName, String url, String userAgent) {
try {
logger.log("mimatype = " +getMimeType(fileName));
String mimeType = getMimeType(fileName);
DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
Expand All @@ -542,7 +552,7 @@ private void downloadFile(String fileName, String url, String userAgent) {
.setAllowedOverRoaming(true)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE | DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);

downloadManager.enqueue(request);
sURL = "";
sFileName = "";
Expand Down Expand Up @@ -670,7 +680,7 @@ private boolean handleIvelt(String url, WebView view){
startActivity(intent);
return true;
}
swipeRefreshLayout.setRefreshing(true);
// swipeRefreshLayout.setRefreshing(true);
return false;
}

Expand Down Expand Up @@ -767,6 +777,12 @@ public void like() {
animatorSet.start();
}

@Override
public void onRefresh(SwipyRefreshLayoutDirection direction) {
mywebView.reload();

}


public class CustomWebViewClient extends WebViewClient {

Expand Down Expand Up @@ -827,7 +843,7 @@ public void onScaleChanged(WebView view, float oldScale,

@Override
public void onPageFinished(WebView view, String url) {
swipeRefreshLayout.setRefreshing(false);
mSwipyRefreshLayout.setRefreshing(false);

FirebaseCrashlytics.getInstance().log("current url " + currentUrl);
logger.log("Page finished for url " + url);
Expand Down Expand Up @@ -898,11 +914,11 @@ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebRes
}

private void showProgress() {
swipeRefreshLayout.setRefreshing(true);
mSwipyRefreshLayout.setRefreshing(true);
}

private void hideProgress() {
swipeRefreshLayout.setRefreshing(false);
mSwipyRefreshLayout.setRefreshing(false);

}
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/layout/activity_main.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipeContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:srl_direction="both"
android:nextFocusForward="@+id/webview">

<!--androidx.core.widget.NestedScrollView
Expand All @@ -15,4 +18,4 @@
android:layout_height="match_parent"/>
<!--/androidx.core.widget.NestedScrollView-->

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout>

0 comments on commit 169d596

Please sign in to comment.