Skip to content

Commit da8cd01

Browse files
committed
Evs Projects
0 parents  commit da8cd01

File tree

1,358 files changed

+30266
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,358 files changed

+30266
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GameLecture-recording/GameLecture-recording.mp4

CameraProject/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

CameraProject/.idea/compiler.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/.idea/gradle.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/.idea/misc.xml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/.idea/modules.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CameraProject/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

CameraProject/app/build.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "26.0.1"
6+
defaultConfig {
7+
applicationId "com.example.aqibjaved.cameraproject"
8+
minSdkVersion 19
9+
targetSdkVersion 25
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:25.3.1'
28+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
29+
testCompile 'junit:junit:4.12'
30+
}

CameraProject/app/proguard-rules.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in D:\Android\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.aqibjaved.cameraproject;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.example.aqibjaved.cameraproject", appContext.getPackageName());
25+
}
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.aqibjaved.cameraproject">
4+
<uses-permission android:name="android.permission.CAMERA">
5+
6+
</uses-permission>
7+
<uses-feature android:name="android.hardware.Camera"></uses-feature>
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
android:theme="@style/AppTheme">
15+
<activity android:name=".MainActivity">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
</manifest>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.aqibjaved.cameraproject;
2+
3+
import android.Manifest;
4+
5+
/**
6+
* Created by AQIB JAVED on 10/22/2017.
7+
*/
8+
9+
public interface AppConst {
10+
int requestCodeForPermission=0;
11+
String permissions[]={Manifest.permission.CAMERA};
12+
13+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.example.aqibjaved.cameraproject;
2+
3+
import android.app.Activity;
4+
import android.content.pm.PackageManager;
5+
import android.hardware.Camera;
6+
import android.os.Build;
7+
import android.os.Bundle;
8+
import android.support.annotation.NonNull;
9+
import android.widget.CompoundButton;
10+
import android.widget.Toast;
11+
import android.widget.ToggleButton;
12+
13+
public class MainActivity extends Activity {
14+
private ToggleButton tb;
15+
private Camera camera;
16+
private Camera.Parameters parameters;
17+
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_main);
22+
requestRunTimePermissions();
23+
24+
}
25+
26+
private void requestRunTimePermissions() {
27+
if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.M){
28+
if(checkSelfPermission(AppConst.permissions[0])!= PackageManager.PERMISSION_GRANTED){
29+
requestPermissions(AppConst.permissions,AppConst.requestCodeForPermission);
30+
}else{
31+
initComponents();
32+
}
33+
}else{
34+
initComponents();
35+
}
36+
}
37+
38+
@Override
39+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
40+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
41+
switch (requestCode){
42+
case AppConst.requestCodeForPermission:
43+
if(grantResults[0]== PackageManager.PERMISSION_GRANTED){
44+
initComponents();
45+
}else{
46+
Toast.makeText(this, "Cannot use application without camera permission", Toast.LENGTH_SHORT).show();
47+
finish();
48+
}
49+
50+
break;
51+
}
52+
}
53+
54+
@Override
55+
protected void onStart() {
56+
super.onStart();
57+
}
58+
private void cameraStart(){
59+
camera= Camera.open();
60+
parameters= camera.getParameters();
61+
}
62+
63+
private void cameraOff(){
64+
if(camera!=null && parameters!=null) {
65+
torchOff();
66+
camera.release();
67+
}
68+
}
69+
@Override
70+
protected void onStop() {
71+
super.onStop();
72+
cameraOff();
73+
}
74+
75+
private void torchOn(){
76+
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
77+
camera.setParameters(parameters);
78+
camera.startPreview();
79+
80+
}
81+
private void torchOff(){
82+
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
83+
camera.setParameters(parameters);
84+
camera.stopPreview();
85+
}
86+
private void initComponents() {
87+
tb=(ToggleButton)findViewById(R.id.tb);
88+
cameraStart();
89+
tb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
90+
@Override
91+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
92+
if(isChecked){
93+
torchOn();
94+
}else{
95+
torchOff();
96+
}
97+
}
98+
});
99+
}
100+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context="com.example.aqibjaved.cameraproject.MainActivity">
8+
9+
<ToggleButton
10+
android:id="@+id/tb"
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:layout_alignParentEnd="true"
14+
android:layout_centerVertical="true"
15+
android:layout_marginEnd="128dp"
16+
android:text="ToggleButton" />
17+
</RelativeLayout>
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">CameraProject</string>
3+
</resources>

0 commit comments

Comments
 (0)