mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
スキャナ実装いろいろ
This commit is contained in:
parent
d780e57e39
commit
aefe5d1001
|
@ -1,15 +1,45 @@
|
|||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.AnimatorRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
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 {
|
||||
|
||||
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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -20,5 +50,10 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
|||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
documentScanner.startScan();
|
||||
// Init
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -9,6 +10,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||
import com.websitebeaver.documentscanner.DocumentScannerActivity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -31,8 +33,6 @@ public class ScannerManagerFragment extends Fragment {
|
|||
@Inject
|
||||
LacertaVcsFactory vcsFactory;
|
||||
|
||||
DocumentScanner documentScanner;
|
||||
|
||||
private static final boolean DEFAULT_SINGLE_PAGE = false;
|
||||
private boolean singlePage;
|
||||
|
||||
|
@ -62,25 +62,6 @@ public class ScannerManagerFragment extends Fragment {
|
|||
if (getArguments() != null) {
|
||||
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
|
||||
|
@ -105,10 +86,10 @@ public class ScannerManagerFragment extends Fragment {
|
|||
// Init
|
||||
logger.debug(TAG, "called");
|
||||
|
||||
view.findViewById(R.id.button_start_scan).setOnClickListener(v -> {
|
||||
if (documentScanner != null) {
|
||||
documentScanner.startScan();
|
||||
}
|
||||
view.findViewById(R.id.button_intent_scanner_manager_activity).setOnClickListener(v -> {
|
||||
// DocumentScannerActivityを起動する
|
||||
Intent intent = new Intent(requireActivity().getApplicationContext(), ScannerManagerActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -7,4 +7,12 @@
|
|||
android:layout_height="match_parent"
|
||||
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>
|
|
@ -7,7 +7,7 @@
|
|||
tools:context=".ScannerManagerFragment">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_start_scan"
|
||||
android:id="@+id/button_intent_scanner_manager_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
|
|
Loading…
Reference in New Issue
Block a user