-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit a9a9cb9
Showing
38 changed files
with
1,467 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,83 @@ | ||
# Built application files | ||
*.apk | ||
*.aar | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
/bin/ | ||
/gen/ | ||
/out/ | ||
# Uncomment the following line in case you need and you don't have the release build type files in your app | ||
# Gradle files | ||
.gradle/ | ||
/build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
# Android Studio 3 in .gitignore file. | ||
.idea/caches | ||
.idea/modules.xml | ||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you | ||
.idea/navEditor.xml | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
.cxx/ | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ |
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 @@ | ||
/build |
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,48 @@ | ||
|
||
plugins { | ||
id("com.android.application") | ||
|
||
} | ||
|
||
android { | ||
namespace = "com.dypho.roughdict" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
applicationId = "com.dypho.roughdict" | ||
minSdk = 21 | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
|
||
buildFeatures { | ||
viewBinding = true | ||
|
||
} | ||
|
||
} | ||
|
||
dependencies { | ||
|
||
|
||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.9.0") | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<application | ||
android:usesCleartextTraffic="true" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:roundIcon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"> | ||
<activity | ||
android:name="MainActivity" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action | ||
android:name="android.intent.action.MAIN" /> | ||
<category | ||
android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
89 changes: 89 additions & 0 deletions
89
roughdict/app/src/main/java/com/dypho/roughdict/HttpsUtils.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,89 @@ | ||
package com.dypho.roughdict; | ||
|
||
import com.dypho.roughdict.Utils; | ||
import java.io.BufferedReader; | ||
import java.io.InputStream; | ||
import java.io.UnsupportedEncodingException; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.Reader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.stream.Collectors; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
public class HttpsUtils { | ||
//private static String apiUrl = "https://aidemo.youdao.com/ocrapi1"; // 替换为您的目标 API URL | ||
// private static String langParam = "lang=auto"; | ||
private static HttpURLConnection conn; | ||
private static BufferedReader reader; | ||
private static String jsonResponse; | ||
//private static String wordsString; | ||
//private static StringBuilder wordsBuilder; | ||
|
||
//状态控制符 | ||
public static boolean ifsend=false; | ||
public static boolean ifdetect=false; | ||
|
||
public static String sendOnce(String word){ | ||
word=word.toLowerCase(); | ||
connect(word); | ||
String result=send(); | ||
disconnect(); | ||
return result; | ||
|
||
|
||
} | ||
public static String send(/*String base64Param*/) { | ||
String result="null"; | ||
//String params = langParam + "&" + "imgBase=base64," + base64Param; | ||
try { | ||
//conn.getOutputStream().write(params.getBytes()); | ||
//conn.getOutputStream().flush(); | ||
//System.out.println("don1"); | ||
|
||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); | ||
jsonResponse = reader.lines().collect(Collectors.joining()); | ||
//System.out.println("原始"+jsonResponse); | ||
result=Utils.jsonProcess(jsonResponse); | ||
//System.out.println(result); | ||
|
||
} catch(Exception err) { | ||
|
||
} | ||
return result; | ||
|
||
} | ||
|
||
public static void connect(String word){ | ||
try { | ||
// 创建 URL 对象 | ||
URL url = new URL("https://dict.youdao.com/jsonapi?q="+word+"&dicts=%7B%22count%22%3A99%2C%22dicts%22%3A%5B%5B%22ec%22%2C%22ce%22%2C%22rel_word%22%2C%22phrs%22%2C%22fanyi%22%2C%22blng_sents_part%22%%22%5D%5D%7D"); | ||
conn = (HttpURLConnection) url.openConnection(); | ||
conn.setRequestMethod("POST"); | ||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); | ||
conn.setConnectTimeout(3000); | ||
conn.setReadTimeout(3000); | ||
// conn.setRequestProperty("Connection","keep-Alive"); | ||
//conn.setDoOutput(true); | ||
//conn.setDoInput(true); | ||
conn.connect(); | ||
//System.out.println("don0"); | ||
|
||
} catch(Exception err) { | ||
err.printStackTrace(); | ||
} | ||
} | ||
public static void disconnect(){ | ||
// 关闭连接 | ||
try { | ||
reader.close(); | ||
} catch(Exception err) { | ||
|
||
} | ||
conn.disconnect(); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.