Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 16c80a4

Browse files
master
1 parent a5f4deb commit 16c80a4

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

‎app/build.gradle‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ android {
2121
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2222
}
2323
}
24+
buildFeatures {
25+
viewBinding true
26+
}
2427
compileOptions {
2528
sourceCompatibility JavaVersion.VERSION_1_8
2629
targetCompatibility JavaVersion.VERSION_1_8

‎app/src/main/AndroidManifest.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.aniketjain.textscanner">
44

5+
<uses-permission android:name="android.permission.CAMERA" />
6+
57
<application
68
android:allowBackup="true"
79
android:icon="@mipmap/ic_launcher"
Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
11
package com.aniketjain.textscanner;
22

3+
import android.Manifest;
4+
import android.content.pm.PackageManager;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
38
import androidx.appcompat.app.AppCompatActivity;
9+
import androidx.core.app.ActivityCompat;
10+
import androidx.core.content.ContextCompat;
411

5-
import android.os.Bundle;
12+
import com.aniketjain.textscanner.databinding.ActivityMainBinding;
613

714
public class MainActivity extends AppCompatActivity {
815

16+
private ActivityMainBinding binding;
17+
private static final int REQUEST_CAMERA_CODE = 100;
18+
919
@Override
1020
protected void onCreate(Bundle savedInstanceState) {
1121
super.onCreate(savedInstanceState);
12-
setContentView(R.layout.activity_main);
22+
// Binding SetUp
23+
binding = ActivityMainBinding.inflate(getLayoutInflater());
24+
View view = binding.getRoot();
25+
setContentView(view);
26+
27+
// we are checking permission for CAMERA Access.
28+
checkPermissions();
29+
30+
onClickListeners();
31+
}
32+
33+
private void checkPermissions() {
34+
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
35+
ActivityCompat.requestPermissions(MainActivity.this, new String[]{
36+
Manifest.permission.CAMERA
37+
}, REQUEST_CAMERA_CODE);
38+
}
39+
}
40+
41+
42+
private void onClickListeners() {
43+
binding.captureBtn.setOnClickListener(view -> {
44+
45+
});
1346
}
1447
}

‎app/src/main/res/layout/activity_main.xml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ScrollView
99
android:layout_width="match_parent"
1010
android:layout_height="match_parent"
11+
android:layout_above="@id/buttons_LL"
1112
android:layout_alignParentTop="true"
1213
android:layout_margin="8dp">
1314

@@ -19,4 +20,30 @@
1920
android:textSize="22sp" />
2021
</ScrollView>
2122

23+
<LinearLayout
24+
android:id="@+id/buttons_LL"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:layout_alignParentBottom="true"
28+
android:layout_margin="8dp"
29+
android:orientation="horizontal"
30+
android:weightSum="2">
31+
32+
<Button
33+
android:id="@+id/capture_btn"
34+
android:layout_width="0dp"
35+
android:layout_height="wrap_content"
36+
android:layout_marginHorizontal="8dp"
37+
android:layout_weight="1"
38+
android:text="Capture" />
39+
40+
<Button
41+
android:id="@+id/copy_btn"
42+
android:layout_width="0dp"
43+
android:layout_height="wrap_content"
44+
android:layout_marginHorizontal="8dp"
45+
android:layout_weight="1"
46+
android:text="Copy Text" />
47+
</LinearLayout>
48+
2249
</RelativeLayout>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /