This commit is contained in:
ろむねこ 2023-12-11 11:24:45 +09:00
parent d6d4998f3a
commit afe92c04e0
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
4 changed files with 73 additions and 18 deletions

View File

@ -3,6 +3,7 @@ package one.nem.lacerta.feature.debug;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.navigation.ui.NavigationUI;
import android.view.LayoutInflater;
import android.view.View;
@ -86,13 +87,11 @@ public class DebugMenuFragment extends Fragment {
});
view.findViewById(R.id.btn_debug_menu_shared_pref_editor).setOnClickListener( v -> {
// SharedPrefEditor機能呼び出し
Toast.makeText(getContext(), "textMessage", Toast.LENGTH_SHORT).show();
// Fragment移動
});
view.findViewById(R.id.btn_debug_menu_clear_pref).setOnClickListener( v -> {
// SharedPrefClear
Toast.makeText(getContext(), "textMessage", Toast.LENGTH_SHORT).show();
});
}
}

View File

@ -7,14 +7,25 @@ import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import one.nem.lacerta.source.pref.repository.Common; //TODO-rca: 名前変えるべきかも
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
/**
* A simple {@link Fragment} subclass.
* Use the {@link DebugSharedPrefEditorFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class DebugSharedPrefEditorFragment extends Fragment {
@Inject
Common prefCommon;
public DebugSharedPrefEditorFragment() {
// Required empty public constructor
}
@ -38,4 +49,25 @@ public class DebugSharedPrefEditorFragment extends Fragment {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_debug_shared_pref_editor, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
EditText loadKeyEditText = view.findViewById(R.id.loadKeyEditText);
EditText saveKeyEditText = view.findViewById(R.id.saveKeyEditText);
view.findViewById(R.id.loadButton).setOnClickListener(v -> {
String key = loadKeyEditText.getText().toString();
String value = prefCommon.getStringValue(key);
view.findViewById(R.id.loadValueTextView).setContentDescription(value);
});
view.findViewById(R.id.saveButton).setOnClickListener(v -> {
String KeyValue = saveKeyEditText.getText().toString();
String[] split = KeyValue.split(":", 2);
prefCommon.setStringValue(split[0], split[1]);
});
}
}

View File

@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="2"
android:hint="Key" />
android:hint="Key:Value" />
<com.google.android.material.button.MaterialButton
android:id="@+id/saveButton"
@ -43,26 +43,41 @@
android:text="Load pref" />
<LinearLayout
android:id="@+id/LoadLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
android:orientation="vertical">
<EditText
android:id="@+id/loadKeyEditText"
android:layout_width="0dp"
<LinearLayout
android:id="@+id/LoadLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="Key" />
android:orientation="horizontal"
android:weightSum="3">
<com.google.android.material.button.MaterialButton
android:id="@+id/loadButton"
android:layout_width="0dp"
<EditText
android:id="@+id/loadKeyEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="Key" />
<com.google.android.material.button.MaterialButton
android:id="@+id/loadButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lauout_weight="1"
android:text="Load" />
</LinearLayout>
<TextView
android:id="@+id/loadValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:lauout_weight="1"
android:text="Load" />
android:text="No value..."
android:textSize="24sp" />
</LinearLayout>

View File

@ -8,5 +8,14 @@
android:id="@+id/debugMenuFragment"
android:name="one.nem.lacerta.feature.debug.DebugMenuFragment"
android:label="fragment_debug_menu"
tools:layout="@layout/fragment_debug_menu" />
tools:layout="@layout/fragment_debug_menu" >
<action
android:id="@+id/action_debugMenuFragment_to_debugSharedPrefEditorFragment"
app:destination="@id/debugSharedPrefEditorFragment" />
</fragment>
<fragment
android:id="@+id/debugSharedPrefEditorFragment"
android:name="one.nem.lacerta.feature.debug.DebugSharedPrefEditorFragment"
android:label="fragment_debug_shared_pref_editor"
tools:layout="@layout/fragment_debug_shared_pref_editor" />
</navigation>