果实APP1.0正式版

master
z15755800224@163.com 3 years ago
parent 12b5c30308
commit e6c092e971

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.ceshi">
package="com.example.Fruits">
<!--//访问电话状态-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
@ -37,7 +37,7 @@
<activity
android:name=".MainActivity"
android:name="com.example.Fruits.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@ -45,10 +45,10 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".WordSearchActivity"/>
<activity android:name=".PictureSearchActivity"/>
<activity android:name=".CollectActivity"/>
<activity android:name=".WebViewActivity"/>
<activity android:name="com.example.Fruits.WordSearchActivity"/>
<activity android:name="com.example.Fruits.PictureSearchActivity"/>
<activity android:name="com.example.Fruits.CollectActivity"/>
<activity android:name="com.example.Fruits.WebViewActivity"/>
<provider

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Context;
import android.database.Cursor;

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Intent;
import android.view.View;
@ -29,16 +29,6 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
}
});
// button2.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// //监听按钮,如果点击,就跳转
// Intent intent = new Intent();
// //前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
// intent.setClass(first.this,third.class);
// startActivity(intent);
// }
// });
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Context;
@ -21,6 +21,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import com.transfer.Ingredient;
import com.transfer.ToIngredient;
import java.io.File;
import java.io.FileNotFoundException;
@ -147,7 +148,10 @@ public class PictureSearchActivity extends AppCompatActivity {
Ingredient qw=new Ingredient(a);
String str=qw.ingredient();
t1.setText("图片保存位置:"+"\n"+a+"\n"+"识别结果:"+"\n"+str);
ToIngredient s= new ToIngredient(str);
t1.setText("识别结果:"+"\n"+s.train());//"图片保存位置:"+"\n"+a+"\n"+
}catch (FileNotFoundException e){
e.printStackTrace();
}

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Intent;
import android.os.Bundle;

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import android.content.Intent;
import android.os.Bundle;

@ -41,10 +41,10 @@ public class Ingredient {
String param = "image=" + imgParam;
// 注意这里仅为了简化编码每一次请求都去获取access_token线上环境access_token有过期时间 客户端可自行缓存,过期后重新获取。
String accessToken = "24.29d61c398f70469aa1b17124092051de.2592000.1668944414.282335-27944955";
//String accessToken = "24.29d61c398f70469aa1b17124092051de.2592000.1668944414.282335-27944955";
// AuthService auth = new AuthService();
// String accessToken = auth.getAuth();
AuthService auth = new AuthService();
String accessToken = auth.getAuth();
String result = HttpUtil.post(url, accessToken, param);
System.out.println(result);

@ -1,24 +1,25 @@
package com.transfer;
public class ToIngredient{
String name_odds="AAAAAAAAAAAA";
String aa;
public ToIngredient(String a) {
aa=a;
String name_odds;
String str;
public ToIngredient(String strin ) {
str=strin;
}
public String ingredient(){
//ImgCombination img=new ImgCombination();
//String str = img.imgCombination();
public String train(){
int a1=str.indexOf("name");
int a2=str.indexOf("\"}");
int b1=str.indexOf("score");
// String name=str.substring(str.indexOf("name"),str.indexOf("\"}"));
// String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
// name_odds="有"+odds.substring(0,4)+"的概率是"+name;
String name=str.substring(a1+7,a2); //String.valueOf(str.charAt(7));
String odds=str.substring(b1+7,a2);
Ingredient im=new Ingredient(aa);
String str = im.ingredient();
String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
name_odds="有"+odds.substring(0,4)+"的概率是"+name;
return name_odds;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@ -95,7 +95,7 @@
android:id="@+id/buttonselect"
android:layout_width="match_parent"
android:layout_height="50dp"
app:backgroundTint="#2ACD6B"
android:text="查询"></Button>
<ScrollView

@ -12,22 +12,24 @@
<TextView
android:id="@+id/one"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginStart="137dp"
android:layout_marginTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="123dp"
android:layout_marginTop="18dp"
android:gravity="center"
android:text="果识"
android:textSize="75dp" />
<Button
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="50dp"
tools:ignore="MissingConstraints"
android:text="水果鉴定"
android:layout_below="@+id/one"
android:layout_marginTop="170dp" app:backgroundTint="#4CAF50"/>
android:layout_marginTop="170dp"
app:backgroundTint="#4CAF50"/>
<Button
android:id="@+id/button"
@ -40,7 +42,9 @@
<Button
android:text="我的收藏"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/button4" app:backgroundTint="#FFB13B"
android:layout_height="wrap_content"
android:id="@+id/button4"
app:backgroundTint="#FFB13B"
android:layout_below="@+id/one"
android:layout_marginTop="240dp"/>
</RelativeLayout>

@ -25,8 +25,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_photo"
android:layout_marginTop="9dp"
android:text="no use"
android:layout_gravity="center"
android:layout_marginTop="19dp"
android:text="点击拍照,即可识别!"
android:textColor="@color/red"
app:backgroundTint="#4CAF50" />
/>

@ -6,24 +6,14 @@
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/five"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="水果百科"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.688" />
<EditText
android:id="@+id/edit_url"
android:layout_width="475dp"
android:layout_height="99dp"
android:layout_height="0dp"
android:layout_marginTop="88dp"
android:layout_marginBottom="57dp"
app:layout_constraintBottom_toTopOf="@+id/btn_open"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
@ -31,11 +21,15 @@
<Button
android:id="@+id/btn_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:text="Button"
android:layout_width="416dp"
android:layout_height="50dp"
android:layout_marginBottom="437dp"
android:text="搜索"
app:backgroundTint="#4CAF50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_url" />

@ -7,4 +7,5 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="red">#FF0000</color>
</resources>

@ -1,4 +1,4 @@
package com.example.ceshi;
package com.example.Fruits;
import org.junit.Test;
Loading…
Cancel
Save