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 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画質を設定します. 画質が高いほどファイルサイズが大きくなります. + + 保存先 + 新規ドキュメントのデフォルトタイトル + 新規フォルダのデフォルト名 + 表示 テーマ, フォントサイズ 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..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 @@ -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,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, 100, 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 new file mode 100644 index 00000000..e2695ee1 --- /dev/null +++ b/utils/src/main/java/one/nem/lacerta/utils/Store.java @@ -0,0 +1,11 @@ +package one.nem.lacerta.utils; + +import android.graphics.Bitmap; + +public class Store { + 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; + } +}