Skip to content

Commit

Permalink
Material Design 3-style command text field
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiascode committed Mar 22, 2024
1 parent 39d040e commit 88bae4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ android {
}
buildTypes {
release {
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.textfield.TextInputLayout;

import org.cuberite.android.R;
import org.cuberite.android.helpers.CuberiteHelper;
Expand Down Expand Up @@ -55,13 +56,12 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
return false;
});

ImageView sendCommandButton = view.findViewById(R.id.executeLine);
sendCommandButton.setOnClickListener(v -> {
final TextInputLayout textInputLayout = view.findViewById(R.id.inputWrapper);
textInputLayout.setEndIconOnClickListener(v -> {
String command = inputLine.getText().toString();
sendExecuteCommand(command);
inputLine.setText("");
});
TooltipCompat.setTooltipText(sendCommandButton, getString(R.string.do_execute_line));
}

private void sendExecuteCommand(String command) {
Expand Down
31 changes: 12 additions & 19 deletions app/src/main/res/layout/fragment_console.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,30 @@
android:textIsSelectable="true" />
</ScrollView>

<RelativeLayout
<com.google.android.material.textfield.TextInputLayout
style="?attr/textInputFilledStyle"
android:id="@+id/inputWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/inputLine_hint"
android:layout_alignParentBottom="true"
android:background="?attr/colorSurface"
android:elevation="8dp" tools:targetApi="lollipop">
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="6dp"
android:paddingBottom="12dp"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_execute"
app:endIconContentDescription="@string/do_execute_line">

<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:padding="12dp"
android:hint="@string/inputLine_hint"
android:layout_toStartOf="@+id/executeLine"
android:layout_toLeftOf="@+id/executeLine"
android:singleLine="true"
tools:ignore="Autofill"
android:inputType="textNoSuggestions" />

<ImageView
style="@style/Widget.AppCompat.ActionButton"
android:id="@+id/executeLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/do_execute_line"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
app:srcCompat="@drawable/ic_execute" />
</RelativeLayout>
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>

0 comments on commit 88bae4f

Please sign in to comment.