This commit is contained in:
r-ca 2024-01-23 02:53:53 +09:00
parent 29737303af
commit ed5e699493
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
6 changed files with 107 additions and 20 deletions

View File

@ -2,8 +2,12 @@ package one.nem.lacerta.setting;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; 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.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -13,12 +17,17 @@ import android.view.ViewGroup;
* Use the {@link SettingScanPageFragment#newInstance} factory method to * Use the {@link SettingScanPageFragment#newInstance} factory method to
* create an instance of this fragment. * create an instance of this fragment.
*/ */
public class SettingScanPageFragment extends Fragment { public class SettingScanPageFragment extends PreferenceFragmentCompat {
public SettingScanPageFragment() { public SettingScanPageFragment() {
// Required empty public constructor // Required empty public constructor
} }
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
addPreferencesFromResource(R.xml.scan_preferences);
}
public static SettingScanPageFragment newInstance() { public static SettingScanPageFragment newInstance() {
SettingScanPageFragment fragment = new SettingScanPageFragment(); SettingScanPageFragment fragment = new SettingScanPageFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -26,16 +35,4 @@ public class SettingScanPageFragment extends Fragment {
return 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);
}
} }

View File

@ -1,14 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SettingScanPageFragment"> android:background="@color/colorSurface">
<!-- TODO: Update blank fragment layout --> <androidx.coordinatorlayout.widget.CoordinatorLayout
<TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:text="@string/hello_blank_fragment" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
android:layout_width="match_parent"
android:layout_height="160dp"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:collapsedTitleGravity="start|center_vertical"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="16dp"
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="@string/setting_top_scan_title" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/setting_scan_page_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout> </FrameLayout>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="png_quality_array">
<item name="5">5</item>
<item name="6">6</item>
<item name="7">7</item>
<item name="8">8</item>
<item name="9">9</item>
</array>
</resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="png_quality_default">70</integer>
<integer name="png_quality_min">5</integer>
<integer name="png_quality_max">100</integer>
</resources>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/setting_scan_quality_title">
<SeekBarPreference
android:defaultValue="@integer/png_quality_default"
android:key="png_quality"
android:max="@integer/png_quality_max"
android:min="@integer/png_quality_min"
android:summary="@string/setting_scan_quality_png_quality_description"
android:title="@string/setting_scan_quality_png_quality_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/setting_scan_default_title">
<EditTextPreference
android:defaultValue="Untitled"
android:key="new_doc_default_title"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/setting_scan_default_document_name" />
<EditTextPreference
android:defaultValue="NewFolder"
android:key="new_dir_default_title"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/setting_scan_default_folder_name" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -19,6 +19,14 @@
<string name="setting_top_scan_title">スキャン</string> <string name="setting_top_scan_title">スキャン</string>
<string name="setting_top_scan_description">画質, 保存先</string> <string name="setting_top_scan_description">画質, 保存先</string>
<string name="setting_scan_quality_title">画質</string>
<string name="setting_scan_quality_png_quality_title">PNG画質</string>
<string name="setting_scan_quality_png_quality_description">PNG画質を設定します. 画質が高いほどファイルサイズが大きくなります.</string>
<string name="setting_scan_default_title">保存先</string>
<string name="setting_scan_default_document_name">新規ドキュメントのデフォルトタイトル</string>
<string name="setting_scan_default_folder_name">新規フォルダのデフォルト名</string>
<string name="setting_top_display_title">表示</string> <string name="setting_top_display_title">表示</string>
<string name="setting_top_display_description">テーマ, フォントサイズ</string> <string name="setting_top_display_description">テーマ, フォントサイズ</string>