-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
860 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
...n/java/com/pichillilorenzo/flutter_inappwebview_android/types/ShowFileChooserRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package com.pichillilorenzo.flutter_inappwebview_android.types; | ||
|
||
import android.annotation.TargetApi; | ||
import android.os.Build; | ||
import android.webkit.WebChromeClient; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ShowFileChooserRequest { | ||
private int mode; | ||
@NonNull | ||
private List<String> acceptTypes; | ||
private boolean isCaptureEnabled; | ||
@Nullable | ||
private String title; | ||
@Nullable | ||
private String filenameHint; | ||
|
||
public ShowFileChooserRequest(int mode, @NonNull List<String> acceptTypes, boolean isCaptureEnabled, @Nullable String title, @Nullable String filenameHint) { | ||
this.mode = mode; | ||
this.acceptTypes = acceptTypes; | ||
this.isCaptureEnabled = isCaptureEnabled; | ||
this.title = title; | ||
this.filenameHint = filenameHint; | ||
} | ||
|
||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public static ShowFileChooserRequest fromFileChooserParams(WebChromeClient.FileChooserParams fileChooserParams) { | ||
int mode = fileChooserParams.getMode(); | ||
List<String> acceptTypes = Arrays.asList(fileChooserParams.getAcceptTypes()); | ||
boolean isCaptureEnabled = fileChooserParams.isCaptureEnabled(); | ||
String title = fileChooserParams.getTitle() != null ? fileChooserParams.getTitle().toString() : null; | ||
String filenameHint = fileChooserParams.getFilenameHint(); | ||
return new ShowFileChooserRequest(mode, acceptTypes, isCaptureEnabled, title, filenameHint); | ||
} | ||
|
||
@Nullable | ||
public static ShowFileChooserRequest fromMap(@Nullable Map<String, Object> map) { | ||
if (map == null) { | ||
return null; | ||
} | ||
int mode = (int) map.get("mode"); | ||
List<String> acceptTypes = (List<String>) map.get("acceptTypes"); | ||
boolean isCaptureEnabled = (boolean) map.get("isCaptureEnabled"); | ||
String title = (String) map.get("title"); | ||
String filenameHint = (String) map.get("filenameHint"); | ||
return new ShowFileChooserRequest(mode, acceptTypes, isCaptureEnabled, title, filenameHint); | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
Map<String, Object> showFileChooserRequestMap = new HashMap<>(); | ||
showFileChooserRequestMap.put("mode", mode); | ||
showFileChooserRequestMap.put("acceptTypes", acceptTypes); | ||
showFileChooserRequestMap.put("isCaptureEnabled", isCaptureEnabled); | ||
showFileChooserRequestMap.put("title", title); | ||
showFileChooserRequestMap.put("filenameHint", filenameHint); | ||
return showFileChooserRequestMap; | ||
} | ||
|
||
|
||
public int getMode() { | ||
return mode; | ||
} | ||
|
||
public void setMode(int mode) { | ||
this.mode = mode; | ||
} | ||
|
||
public @NonNull List<String> getAcceptTypes() { | ||
return acceptTypes; | ||
} | ||
|
||
public void setAcceptTypes(@NonNull List<String> acceptTypes) { | ||
this.acceptTypes = acceptTypes; | ||
} | ||
|
||
public boolean isCaptureEnabled() { | ||
return isCaptureEnabled; | ||
} | ||
|
||
public void setCaptureEnabled(boolean captureEnabled) { | ||
isCaptureEnabled = captureEnabled; | ||
} | ||
|
||
@Nullable | ||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(@Nullable String title) { | ||
this.title = title; | ||
} | ||
|
||
@Nullable | ||
public String getFilenameHint() { | ||
return filenameHint; | ||
} | ||
|
||
public void setFilenameHint(@Nullable String filenameHint) { | ||
this.filenameHint = filenameHint; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ShowFileChooserRequest that = (ShowFileChooserRequest) o; | ||
return mode == that.mode && isCaptureEnabled == that.isCaptureEnabled && acceptTypes.equals(that.acceptTypes) && Objects.equals(title, that.title) && Objects.equals(filenameHint, that.filenameHint); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = mode; | ||
result = 31 * result + acceptTypes.hashCode(); | ||
result = 31 * result + Boolean.hashCode(isCaptureEnabled); | ||
result = 31 * result + Objects.hashCode(title); | ||
result = 31 * result + Objects.hashCode(filenameHint); | ||
return result; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String toString() { | ||
return "ShowFileChooserRequest{" + | ||
"mode=" + mode + | ||
", acceptTypes=" + acceptTypes + | ||
", isCaptureEnabled=" + isCaptureEnabled + | ||
", title='" + title + '\'' + | ||
", filenameHint='" + filenameHint + '\'' + | ||
'}'; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
.../java/com/pichillilorenzo/flutter_inappwebview_android/types/ShowFileChooserResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.pichillilorenzo.flutter_inappwebview_android.types; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ShowFileChooserResponse { | ||
private boolean handledByClient; | ||
@Nullable | ||
private List<String> filePaths; | ||
|
||
public ShowFileChooserResponse(boolean handledByClient, @Nullable List<String> filePaths) { | ||
this.handledByClient = handledByClient; | ||
this.filePaths = filePaths; | ||
} | ||
|
||
@Nullable | ||
public static ShowFileChooserResponse fromMap(@Nullable Map<String, Object> map) { | ||
if (map == null) { | ||
return null; | ||
} | ||
boolean handledByClient = (boolean) map.get("handledByClient"); | ||
List<String> filePaths = (List<String>) map.get("filePaths"); | ||
return new ShowFileChooserResponse(handledByClient, filePaths); | ||
} | ||
|
||
public boolean isHandledByClient() { | ||
return handledByClient; | ||
} | ||
|
||
public void setHandledByClient(boolean handledByClient) { | ||
this.handledByClient = handledByClient; | ||
} | ||
|
||
@Nullable | ||
public List<String> getFilePaths() { | ||
return filePaths; | ||
} | ||
|
||
public void setFilePaths(@Nullable List<String> filePaths) { | ||
this.filePaths = filePaths; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
ShowFileChooserResponse that = (ShowFileChooserResponse) o; | ||
return handledByClient == that.handledByClient && Objects.equals(filePaths, that.filePaths); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Boolean.hashCode(handledByClient); | ||
result = 31 * result + Objects.hashCode(filePaths); | ||
return result; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String toString() { | ||
return "ShowFileChooserResponse{" + | ||
"handledByClient=" + handledByClient + | ||
", filePaths=" + filePaths + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.