From 29737303af1242c8d10215f0f552492c87bb7b3e Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 02:35:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/setting/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/feature/setting/build.gradle b/feature/setting/build.gradle index b3a0014c..31595be7 100644 --- a/feature/setting/build.gradle +++ b/feature/setting/build.gradle @@ -45,4 +45,8 @@ dependencies { // shared implementation project(':shared:ui') + // https://mvnrepository.com/artifact/androidx.preference/preference + implementation 'androidx.preference:preference:1.2.1' + + } \ No newline at end of file From ed5e6994935c66b9a77f8a81c0120076225eaf65 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 02:53:53 +0900 Subject: [PATCH 2/4] WIP --- .../setting/SettingScanPageFragment.java | 23 ++++----- .../res/layout/fragment_setting_scan_page.xml | 50 ++++++++++++++++--- .../main/res/values/scan_setting_array.xml | 11 ++++ .../src/main/res/values/setting_integers.xml | 6 +++ .../src/main/res/xml/scan_preferences.xml | 29 +++++++++++ shared/ui/src/main/res/values/strings.xml | 8 +++ 6 files changed, 107 insertions(+), 20 deletions(-) create mode 100644 feature/setting/src/main/res/values/scan_setting_array.xml create mode 100644 feature/setting/src/main/res/values/setting_integers.xml create mode 100644 feature/setting/src/main/res/xml/scan_preferences.xml diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingScanPageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingScanPageFragment.java index 27352225..cad410b9 100644 --- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingScanPageFragment.java +++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingScanPageFragment.java @@ -2,8 +2,12 @@ package one.nem.lacerta.setting; import android.os.Bundle; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; +import androidx.preference.PreferenceFragmentCompat; +import android.preference.PreferenceFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,12 +17,17 @@ import android.view.ViewGroup; * Use the {@link SettingScanPageFragment#newInstance} factory method to * create an instance of this fragment. */ -public class SettingScanPageFragment extends Fragment { +public class SettingScanPageFragment extends PreferenceFragmentCompat { public SettingScanPageFragment() { // Required empty public constructor } + @Override + public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) { + addPreferencesFromResource(R.xml.scan_preferences); + } + public static SettingScanPageFragment newInstance() { SettingScanPageFragment fragment = new SettingScanPageFragment(); Bundle args = new Bundle(); @@ -26,16 +35,4 @@ public class SettingScanPageFragment extends Fragment { return fragment; } - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_setting_scan_page, container, false); - } } \ No newline at end of file diff --git a/feature/setting/src/main/res/layout/fragment_setting_scan_page.xml b/feature/setting/src/main/res/layout/fragment_setting_scan_page.xml index 422566e7..916f5abe 100644 --- a/feature/setting/src/main/res/layout/fragment_setting_scan_page.xml +++ b/feature/setting/src/main/res/layout/fragment_setting_scan_page.xml @@ -1,14 +1,50 @@ - + android:background="@color/colorSurface"> - - + android:layout_height="match_parent"> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/feature/setting/src/main/res/values/scan_setting_array.xml b/feature/setting/src/main/res/values/scan_setting_array.xml new file mode 100644 index 00000000..3e4f226f --- /dev/null +++ b/feature/setting/src/main/res/values/scan_setting_array.xml @@ -0,0 +1,11 @@ + + + + 5 + 6 + 7 + 8 + 9 + + + \ No newline at end of file diff --git a/feature/setting/src/main/res/values/setting_integers.xml b/feature/setting/src/main/res/values/setting_integers.xml new file mode 100644 index 00000000..4e21ed5f --- /dev/null +++ b/feature/setting/src/main/res/values/setting_integers.xml @@ -0,0 +1,6 @@ + + + 70 + 5 + 100 + \ No newline at end of file diff --git a/feature/setting/src/main/res/xml/scan_preferences.xml b/feature/setting/src/main/res/xml/scan_preferences.xml new file mode 100644 index 00000000..b5c0cc16 --- /dev/null +++ b/feature/setting/src/main/res/xml/scan_preferences.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/shared/ui/src/main/res/values/strings.xml b/shared/ui/src/main/res/values/strings.xml index d7832d4a..2a35d080 100644 --- a/shared/ui/src/main/res/values/strings.xml +++ b/shared/ui/src/main/res/values/strings.xml @@ -19,6 +19,14 @@ スキャン 画質, 保存先 + 画質 + PNG画質 + PNG画質を設定します. 画質が高いほどファイルサイズが大きくなります. + + 保存先 + 新規ドキュメントのデフォルトタイトル + 新規フォルダのデフォルト名 + 表示 テーマ, フォントサイズ From 0b2d58470bdb3c1fd45748f786b7f169547a22b5 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 02:57:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6Store=E3=81=A7=E7=AE=A1=E7=90=86=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/file/impl/FileManagerImpl.java | 3 ++- utils/src/main/java/one/nem/lacerta/utils/Store.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 utils/src/main/java/one/nem/lacerta/utils/Store.java diff --git a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java index b8f5226c..03f9332b 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java @@ -22,6 +22,7 @@ import dagger.assisted.AssistedInject; import one.nem.lacerta.source.file.FileManager; import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.utils.Store; public class FileManagerImpl implements FileManager { @@ -303,7 +304,7 @@ public class FileManagerImpl implements FileManager { private void saveBitmapInternal(Bitmap bitmap, Path path) throws IOException { try { logger.debug("saveBitmapInternal", "path: " + path); - bitmap.compress(Bitmap.CompressFormat.PNG, 100, Files.newOutputStream(path)); + bitmap.compress(Bitmap.CompressFormat.PNG, Store.Scan.PNG_QUALITY, Files.newOutputStream(path)); } catch (Exception e) { logger.error("saveBitmapInternal", e.getMessage()); throw new IOException("Failed to save bitmap"); diff --git a/utils/src/main/java/one/nem/lacerta/utils/Store.java b/utils/src/main/java/one/nem/lacerta/utils/Store.java new file mode 100644 index 00000000..78bc2511 --- /dev/null +++ b/utils/src/main/java/one/nem/lacerta/utils/Store.java @@ -0,0 +1,7 @@ +package one.nem.lacerta.utils; + +public class Store { + public class Scan { + public static final int PNG_QUALITY = 60; + } +} From da9cd9be8ec1a1a5d794846293fc10f89166a093 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 03:04:55 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6Store=E3=81=A7=E7=AE=A1=E7=90=86=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/file/impl/FileManagerImpl.java | 11 ++++++++++- .../java/one/nem/lacerta/utils/FeatureSwitch.java | 2 +- utils/src/main/java/one/nem/lacerta/utils/Store.java | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java index 03f9332b..6077bf4e 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java @@ -304,7 +304,16 @@ public class FileManagerImpl implements FileManager { private void saveBitmapInternal(Bitmap bitmap, Path path) throws IOException { try { logger.debug("saveBitmapInternal", "path: " + path); - bitmap.compress(Bitmap.CompressFormat.PNG, Store.Scan.PNG_QUALITY, Files.newOutputStream(path)); + // Bitmapの長辺を1024pxにする + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + float scale = 1.0f; + if (width > height) { + scale = Store.Scan.MAX_RESOLUTION_LONG / width; + } else { + scale = Store.Scan.MAX_RESOLUTION_LONG / height; + } + bitmap.compress(new Store.Scan().COMPRESS_FORMAT, Store.Scan.QUALITY, Files.newOutputStream(path)); } catch (Exception e) { logger.error("saveBitmapInternal", e.getMessage()); throw new IOException("Failed to save bitmap"); diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 718c1aa8..91aab3eb 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -8,7 +8,7 @@ public class FeatureSwitch { public static class FeatureMaster { public static boolean enableSearch = false; - public static boolean enableDebugMenu = false; + public static boolean enableDebugMenu = true; } public static class Vcs { diff --git a/utils/src/main/java/one/nem/lacerta/utils/Store.java b/utils/src/main/java/one/nem/lacerta/utils/Store.java index 78bc2511..e2695ee1 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/Store.java +++ b/utils/src/main/java/one/nem/lacerta/utils/Store.java @@ -1,7 +1,11 @@ package one.nem.lacerta.utils; +import android.graphics.Bitmap; + public class Store { - public class Scan { - public static final int PNG_QUALITY = 60; + public static class Scan { + public Bitmap.CompressFormat COMPRESS_FORMAT = Bitmap.CompressFormat.JPEG; + public static final int QUALITY = 60; + public static final float MAX_RESOLUTION_LONG = 2048; } }