From f6b57a4b09b174714f1de70fe65a17693512b7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 11 Dec 2023 12:42:26 +0900 Subject: [PATCH] =?UTF-8?q?=E6=8C=99=E5=8B=95=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debug/DebugSharedPrefEditorFragment.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java index 88c87443..1688ff77 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugSharedPrefEditorFragment.java @@ -11,8 +11,11 @@ import android.view.ViewGroup; import android.widget.EditText; import android.widget.TextView; +import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType; import one.nem.lacerta.source.pref.repository.Common; //TODO-rca: 名前変えるべきかも +import one.nem.lacerta.data.repository.SharedPref; + import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; @@ -28,6 +31,11 @@ public class DebugSharedPrefEditorFragment extends Fragment { @Inject Common prefCommon; + @Inject + SharedPref sharedPref; + + SharedPrefType sharedPrefType = SharedPrefType.COMMON; + public DebugSharedPrefEditorFragment() { // Required empty public constructor } @@ -60,18 +68,21 @@ public class DebugSharedPrefEditorFragment extends Fragment { EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText); view.findViewById(R.id.loadButton).setOnClickListener(v -> { - String key = loadKeyEditText.getText().toString(); - String value = prefCommon.getStringValue(key); - Log.d("loadButton", "key:" + key + " value:" + value); - TextView loadValueTextView = view.findViewById(R.id.loadValueTextView); - loadValueTextView.setText(value); + String value = sharedPref.getSharedPreferencesByTag(sharedPrefType).getString(loadKeyEditText.getText().toString(), "null"); + ((TextView) view.findViewById(R.id.loadValueTextView)).setText(value); }); view.findViewById(R.id.saveButton).setOnClickListener(v -> { - String KeyValue = saveKeyEditText.getText().toString(); - String[] split = KeyValue.split(":", 2); - Log.d("saveButton", "split[0]:" + split[0] + " split[1]:" + split[1]); - prefCommon.setStringValue(split[0], split[1]); + String[] split = saveKeyEditText.getText().toString().split(":"); + sharedPref.getSharedPreferencesByTag(sharedPrefType).edit().putString(split[0], split[1]).apply(); + }); + + // ラジオボタンの変更を監視 + view.findViewById(R.id.radioButtonCommon).setOnClickListener(v -> { + sharedPrefType = SharedPrefType.COMMON; + }); + view.findViewById(R.id.radioButtonUserData).setOnClickListener(v -> { + sharedPrefType = SharedPrefType.USERDATA; }); }