mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
スキャナ実装いろいろ
This commit is contained in:
parent
d780e57e39
commit
aefe5d1001
|
@ -1,15 +1,45 @@
|
||||||
package one.nem.lacerta.component.scanner;
|
package one.nem.lacerta.component.scanner;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.annotation.AnimatorRes;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
public class ScannerManagerActivity extends AppCompatActivity {
|
public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
DocumentScanner documentScanner = new DocumentScanner(
|
||||||
|
this,
|
||||||
|
(croppedImageResults) -> {
|
||||||
|
// display the first cropped image
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
(errorMessage) -> {
|
||||||
|
// an error happened
|
||||||
|
Log.v("documentscannerlogs", errorMessage);
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
() -> {
|
||||||
|
// user canceled document scan
|
||||||
|
Log.v("documentscannerlogs", "User canceled document scan");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
5
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -20,5 +50,10 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
documentScanner.startScan();
|
||||||
|
// Init
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package one.nem.lacerta.component.scanner;
|
package one.nem.lacerta.component.scanner;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -9,6 +10,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.websitebeaver.documentscanner.DocumentScanner;
|
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||||
|
import com.websitebeaver.documentscanner.DocumentScannerActivity;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -31,8 +33,6 @@ public class ScannerManagerFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaVcsFactory vcsFactory;
|
LacertaVcsFactory vcsFactory;
|
||||||
|
|
||||||
DocumentScanner documentScanner;
|
|
||||||
|
|
||||||
private static final boolean DEFAULT_SINGLE_PAGE = false;
|
private static final boolean DEFAULT_SINGLE_PAGE = false;
|
||||||
private boolean singlePage;
|
private boolean singlePage;
|
||||||
|
|
||||||
|
@ -62,25 +62,6 @@ public class ScannerManagerFragment extends Fragment {
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
singlePage = getArguments().getBoolean("singlePage", DEFAULT_SINGLE_PAGE);
|
singlePage = getArguments().getBoolean("singlePage", DEFAULT_SINGLE_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
documentScanner = new DocumentScanner(
|
|
||||||
requireActivity(),
|
|
||||||
(croppedImage) -> {
|
|
||||||
// TODO-rca: 画像を保存する
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
(error) -> {
|
|
||||||
// TODO-rca: エラー処理
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
// TODO-rca: キャンセル処理
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,10 +86,10 @@ public class ScannerManagerFragment extends Fragment {
|
||||||
// Init
|
// Init
|
||||||
logger.debug(TAG, "called");
|
logger.debug(TAG, "called");
|
||||||
|
|
||||||
view.findViewById(R.id.button_start_scan).setOnClickListener(v -> {
|
view.findViewById(R.id.button_intent_scanner_manager_activity).setOnClickListener(v -> {
|
||||||
if (documentScanner != null) {
|
// DocumentScannerActivityを起動する
|
||||||
documentScanner.startScan();
|
Intent intent = new Intent(requireActivity().getApplicationContext(), ScannerManagerActivity.class);
|
||||||
}
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,4 +7,12 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ScannerManagerActivity">
|
tools:context=".ScannerManagerActivity">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_start_scan"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -7,7 +7,7 @@
|
||||||
tools:context=".ScannerManagerFragment">
|
tools:context=".ScannerManagerFragment">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_start_scan"
|
android:id="@+id/button_intent_scanner_manager_activity"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Button"
|
android:text="Button"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user