diff --git a/.idea/.gitignore b/.idea/.gitignore index 35410ca..359bb53 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,8 +1,3 @@ # 默认忽略的文件 /shelf/ /workspace.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name index b3405b3..baaea39 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -My Application \ No newline at end of file +Fruit \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..c3c32a8 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 900e5e4..a2d7c21 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,8 +4,15 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index a3ccf56..2a4d5b5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index f4ce9bb..3a9f38b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,12 +3,12 @@ plugins { } android { - compileSdk 32 + compileSdk 33 defaultConfig { - applicationId "com.example.myapplication" - minSdk 21 - targetSdk 32 + applicationId "com.example.ceshi" + minSdk 23 + targetSdk 33 versionCode 1 versionName "1.0" @@ -29,10 +29,10 @@ android { dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..7749c52 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..9b578b9 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.example.ceshi", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/ceshi/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/ceshi/ExampleInstrumentedTest.java new file mode 100644 index 0000000..095c030 --- /dev/null +++ b/app/src/androidTest/java/com/example/ceshi/ExampleInstrumentedTest.java @@ -0,0 +1,25 @@ +package com.example.ceshi; + +import android.content.Context; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.ceshi", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8ab9183..12e1eaf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,16 +1,20 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.example.ceshi"> + android:theme="@style/Theme.Ceshi" + tools:targetApi="31"> @@ -18,6 +22,23 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/ceshi/Main_activity.java b/app/src/main/java/com/example/ceshi/Main_activity.java new file mode 100644 index 0000000..efdf145 --- /dev/null +++ b/app/src/main/java/com/example/ceshi/Main_activity.java @@ -0,0 +1,63 @@ +package com.example.ceshi; + +import android.content.Intent; +import android.view.View; +import android.widget.Button; +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; + +public class Main_activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main_view); + + //获取按钮 + Button button = findViewById(R.id.button); + Button button2 = findViewById(R.id.button2); + Button button3 = findViewById(R.id.button3); + Button button4 = findViewById(R.id.button4); + //按钮进行监听 + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //监听按钮,如果点击,就跳转 + Intent intent = new Intent(); + //前一个(MainActivity.this)是目前页面,后面一个是要跳转的下一个页面 + intent.setClass(Main_activity.this,second.class); + startActivity(intent); + } + }); + button2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //监听按钮,如果点击,就跳转 + Intent intent = new Intent(); + //前一个(MainActivity.this)是目前页面,后面一个是要跳转的下一个页面 + intent.setClass(Main_activity.this,third.class); + startActivity(intent); + } + }); + button3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //监听按钮,如果点击,就跳转 + Intent intent = new Intent(); + //前一个(MainActivity.this)是目前页面,后面一个是要跳转的下一个页面 + intent.setClass(Main_activity.this, Shoot_activity.class); + startActivity(intent); + } + }); + button4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //监听按钮,如果点击,就跳转 + Intent intent = new Intent(); + //前一个(MainActivity.this)是目前页面,后面一个是要跳转的下一个页面 + intent.setClass(Main_activity.this, collection.class); + startActivity(intent); + } + }); + } +} diff --git a/app/src/main/java/com/example/ceshi/Shoot_activity.java b/app/src/main/java/com/example/ceshi/Shoot_activity.java new file mode 100644 index 0000000..37c989c --- /dev/null +++ b/app/src/main/java/com/example/ceshi/Shoot_activity.java @@ -0,0 +1,73 @@ +package com.example.ceshi; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.FileProvider; + +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.provider.MediaStore; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +public class Shoot_activity extends AppCompatActivity { + final int TAKE_PHOTO=1; + ImageView iv_photo; + Uri imageUri; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fourview); + Button btn_1=findViewById(R.id.btn_takephoto); + iv_photo=findViewById(R.id.img_photo); + btn_1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + File output=new File(getExternalCacheDir(),"output_image.jpg"); + try { + if (output.exists()){ + output.delete(); + } + output.createNewFile(); + }catch (IOException e){ + e.printStackTrace(); + } + if (Build.VERSION.SDK_INT>=24){ +//图片的保存路径 + imageUri= FileProvider.getUriForFile(Shoot_activity.this,"com.example.takephoto.fileprovider",output); + } + else { imageUri=Uri.fromFile(output);} + //跳转界面到系统自带的拍照界面 + Intent intent=new Intent("android.media.action.IMAGE_CAPTURE"); + intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri); + startActivityForResult(intent,TAKE_PHOTO); + } + }); + } + protected void onActivityResult(int requestCode,int resultCode,Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode){ + case TAKE_PHOTO: + if (resultCode==RESULT_OK){ + // 使用try让程序运行在内报错 + try { + //将图片保存 + Bitmap bitmap= BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri)); + iv_photo.setImageBitmap(bitmap); + }catch (FileNotFoundException e){ + e.printStackTrace(); + } + } + break; + default:break; + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/ceshi/collection.java b/app/src/main/java/com/example/ceshi/collection.java new file mode 100644 index 0000000..82ec4aa --- /dev/null +++ b/app/src/main/java/com/example/ceshi/collection.java @@ -0,0 +1,12 @@ +package com.example.ceshi; + +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +public class collection extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.collview); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/ceshi/second.java b/app/src/main/java/com/example/ceshi/second.java new file mode 100644 index 0000000..fec8f44 --- /dev/null +++ b/app/src/main/java/com/example/ceshi/second.java @@ -0,0 +1,13 @@ +package com.example.ceshi; + +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; + +public class second extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.secondview); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/ceshi/third.java b/app/src/main/java/com/example/ceshi/third.java new file mode 100644 index 0000000..5a81459 --- /dev/null +++ b/app/src/main/java/com/example/ceshi/third.java @@ -0,0 +1,13 @@ +package com.example.ceshi; + +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; + +public class third extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.thirdview); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1ee1493 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/green.jpg b/app/src/main/res/drawable/green.jpg new file mode 100644 index 0000000..a4b67ff Binary files /dev/null and b/app/src/main/res/drawable/green.jpg differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..956b344 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/search.png b/app/src/main/res/drawable/search.png new file mode 100644 index 0000000..caef6a6 Binary files /dev/null and b/app/src/main/res/drawable/search.png differ diff --git a/app/src/main/res/layout/collview.xml b/app/src/main/res/layout/collview.xml new file mode 100644 index 0000000..f320485 --- /dev/null +++ b/app/src/main/res/layout/collview.xml @@ -0,0 +1,27 @@ + + + + + + + diff --git a/app/src/main/res/layout/fourview.xml b/app/src/main/res/layout/fourview.xml new file mode 100644 index 0000000..b2aab43 --- /dev/null +++ b/app/src/main/res/layout/fourview.xml @@ -0,0 +1,26 @@ + + + +