Loading app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +40 −16 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.vanniktech.emoji.EmojiManager; Loading Loading @@ -1705,7 +1706,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder * @param position - int position */ private void displayPollPopup(ComposeViewHolder holder, Status statusDraft, int position) { AlertDialog.Builder alertPoll = new AlertDialog.Builder(context, Helper.dialogStyle()); AlertDialog.Builder alertPoll = new MaterialAlertDialogBuilder(context, Helper.dialogStyle()); alertPoll.setTitle(R.string.create_poll); ComposePollBinding composePollBinding = ComposePollBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); alertPoll.setView(composePollBinding.getRoot()); Loading @@ -1723,17 +1724,19 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(max_length); composePollBinding.option1.text.setFilters(fArray); composePollBinding.option1.text.setHint(context.getString(R.string.poll_choice_s, 1)); composePollBinding.option1.textLayout.setHint(context.getString(R.string.poll_choice_s, 1)); composePollBinding.option2.text.setFilters(fArray); composePollBinding.option2.text.setHint(context.getString(R.string.poll_choice_s, 2)); composePollBinding.option2.textLayout.setHint(context.getString(R.string.poll_choice_s, 2)); composePollBinding.option1.buttonRemove.setVisibility(View.GONE); composePollBinding.option2.buttonRemove.setVisibility(View.GONE); int finalMax_entry = max_entry; composePollBinding.buttonAddOption.setOnClickListener(v -> { if (pollCountItem[0] < finalMax_entry) { ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(composePollBinding.optionsList.getContext()), composePollBinding.optionsList, false); if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple) composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); composePollItemBinding.text.setFilters(fArray); composePollItemBinding.text.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.textLayout.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); LinearLayoutCompat viewItem = composePollItemBinding.getRoot(); composePollBinding.optionsList.addView(composePollItemBinding.getRoot()); composePollItemBinding.buttonRemove.setOnClickListener(view -> { Loading Loading @@ -1764,27 +1767,31 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder ArrayAdapter<CharSequence> pollduration = ArrayAdapter.createFromResource(context, R.array.poll_duration, android.R.layout.simple_spinner_dropdown_item); ArrayAdapter<CharSequence> pollchoice = ArrayAdapter.createFromResource(context, R.array.poll_choice_type, android.R.layout.simple_spinner_dropdown_item); composePollBinding.pollType.setAdapter(pollchoice); composePollBinding.pollDuration.setAdapter(pollduration); composePollBinding.pollDuration.setSelection(4); composePollBinding.pollType.setSelection(0); if (statusDraft != null && statusDraft.poll != null && statusDraft.poll.options != null) { int i = 1; for (Poll.PollItem pollItem : statusDraft.poll.options) { if (i == 1) { if (statusDraft.poll.multiple) composePollBinding.option1.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); if (pollItem.title != null) composePollBinding.option1.text.setText(pollItem.title); } else if (i == 2) { if (statusDraft.poll.multiple) composePollBinding.option2.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); if (pollItem.title != null) composePollBinding.option2.text.setText(pollItem.title); } else { ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple) composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); else composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single); composePollItemBinding.text.setFilters(fArray); composePollItemBinding.text.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.textLayout.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.text.setText(pollItem.title); composePollBinding.optionsList.addView(composePollItemBinding.getRoot()); composePollItemBinding.buttonRemove.setOnClickListener(view -> { Loading Loading @@ -1822,9 +1829,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder break; } if (statusDraft.poll.multiple) composePollBinding.pollType.setSelection(1); composePollBinding.pollType.check(R.id.poll_type_multiple); else composePollBinding.pollType.setSelection(0); composePollBinding.pollType.check(R.id.poll_type_single); } Loading @@ -1834,15 +1841,32 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder dialog.dismiss(); notifyItemChanged(position); }); alertPoll.setPositiveButton(R.string.validate, null); alertPoll.setPositiveButton(R.string.save, null); final AlertDialog alertPollDiaslog = alertPoll.create(); alertPollDiaslog.setOnShowListener(dialog -> { composePollBinding.pollType.addOnButtonCheckedListener((group, checkedId, isChecked) -> { if (isChecked) { if (checkedId == R.id.poll_type_single) { if (statusDraft != null && statusDraft.poll != null) statusDraft.poll.multiple = false; for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) { ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i)); child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single); } } else if (checkedId == R.id.poll_type_multiple) { if (statusDraft != null && statusDraft.poll != null) statusDraft.poll.multiple = true; for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) { ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i)); child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); } } } }); Button b = alertPollDiaslog.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(view1 -> { int poll_duration_pos = composePollBinding.pollDuration.getSelectedItemPosition(); int poll_choice_pos = composePollBinding.pollType.getSelectedItemPosition(); int selected_poll_type_id = composePollBinding.pollType.getCheckedButtonId(); String choice1 = composePollBinding.option1.text.getText().toString().trim(); String choice2 = composePollBinding.option2.text.getText().toString().trim(); Loading @@ -1850,7 +1874,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder Toasty.error(context, context.getString(R.string.poll_invalid_choices), Toasty.LENGTH_SHORT).show(); } else if (statusDraft != null) { statusDraft.poll = new Poll(); statusDraft.poll.multiple = (poll_choice_pos != 0); statusDraft.poll.multiple = selected_poll_type_id == R.id.poll_type_multiple; int expire; switch (poll_duration_pos) { case 0: Loading app/src/main/res/drawable/ic_compose_poll_option_mark_multiple.xml +2 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,6 @@ android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="#808080" android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" /> android:fillColor="@android:color/white" android:pathData="M18,19L6,19c-0.55,0 -1,-0.45 -1,-1L5,6c0,-0.55 0.45,-1 1,-1h12c0.55,0 1,0.45 1,1v12c0,0.55 -0.45,1 -1,1zM19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2z" /> </vector> app/src/main/res/drawable/ic_compose_poll_option_mark_single.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" /> </vector> app/src/main/res/layout/compose_poll.xml +70 −71 Original line number Diff line number Diff line Loading @@ -14,29 +14,22 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see <http://www.gnu.org/licenses> --> <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="6dp" app:cardElevation="2dp"> <ScrollView android:id="@+id/options_list_container" android:layout_width="match_parent" android:layout_height="wrap_content"> <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="6dp"> android:paddingHorizontal="24dp" android:paddingVertical="12dp"> <androidx.appcompat.widget.LinearLayoutCompat android:id="@+id/options_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:orientation="vertical"> <include Loading @@ -52,59 +45,65 @@ </androidx.appcompat.widget.LinearLayoutCompat> <androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.button.MaterialButton android:id="@+id/button_add_option" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginTop="6dp" android:contentDescription="@string/add_poll_item" android:src="@drawable/ic_baseline_add_24" /> <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" style="@style/Widget.Material3.Button.OutlinedButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical"> android:layout_gravity="center_horizontal" android:layout_marginTop="12dp" android:text="@string/add_poll_item" app:icon="@drawable/ic_baseline_add_24" /> <com.google.android.material.textview.MaterialTextView android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginTop="24dp" android:text="@string/poll_type" android:textAlignment="viewEnd" /> android:textAppearance="@style/TextAppearance.Material3.LabelLarge" /> <androidx.appcompat.widget.AppCompatSpinner <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/poll_type" android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" /> android:layout_marginTop="6dp" android:orientation="vertical" app:checkedButton="@id/poll_type_single" app:selectionRequired="true" app:singleSelection="true"> </androidx.appcompat.widget.LinearLayoutCompat> <com.google.android.material.button.MaterialButton android:id="@+id/poll_type_single" style="@style/Fedilab.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/poll_type_single" android:textAlignment="textStart" app:icon="@drawable/ic_compose_poll_option_mark_single" /> <androidx.appcompat.widget.LinearLayoutCompat <com.google.android.material.button.MaterialButton android:id="@+id/poll_type_multiple" style="@style/Fedilab.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical"> android:text="@string/poll_type_multiple" android:textAlignment="textStart" app:icon="@drawable/ic_compose_poll_option_mark_multiple" /> </com.google.android.material.button.MaterialButtonToggleGroup> <com.google.android.material.textview.MaterialTextView android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginTop="24dp" android:text="@string/poll_duration" android:textAlignment="viewEnd" /> android:textAppearance="@style/TextAppearance.Material3.LabelLarge" /> <androidx.appcompat.widget.AppCompatSpinner android:id="@+id/poll_duration" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" /> </androidx.appcompat.widget.LinearLayoutCompat> android:layout_width="match_parent" android:layout_height="wrap_content" /> </androidx.appcompat.widget.LinearLayoutCompat> </ScrollView> </com.google.android.material.card.MaterialCardView> app/src/main/res/layout/compose_poll_item.xml +21 −13 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ see <http://www.gnu.org/licenses> --> <androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp" Loading @@ -23,23 +24,30 @@ <androidx.appcompat.widget.AppCompatImageView android:id="@+id/type_indicator" android:layout_width="36dp" android:layout_height="36dp" android:padding="4dp" android:src="@drawable/ic_compose_poll_option_mark_multiple" /> android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_compose_poll_option_mark_single" /> <androidx.appcompat.widget.AppCompatEditText android:id="@+id/text" <com.google.android.material.textfield.TextInputLayout android:id="@+id/textLayout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> android:layout_marginHorizontal="6dp" android:layout_weight="1"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/text" style="@style/Widget.Material3.TextInputEditText.OutlinedBox.Dense" android:layout_width="match_parent" android:layout_height="wrap_content" /> </com.google.android.material.textfield.TextInputLayout> <androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.button.MaterialButton android:id="@+id/button_remove" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="48dp" android:layout_height="48dp" android:backgroundTint="@color/errorColor" android:src="@drawable/ic_baseline_close_24" /> style="@style/Widget.Material3.Button.IconButton" android:layout_width="wrap_content" android:layout_height="wrap_content" app:icon="@drawable/ic_baseline_close_24" /> </androidx.appcompat.widget.LinearLayoutCompat> Loading
app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +40 −16 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.vanniktech.emoji.EmojiManager; Loading Loading @@ -1705,7 +1706,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder * @param position - int position */ private void displayPollPopup(ComposeViewHolder holder, Status statusDraft, int position) { AlertDialog.Builder alertPoll = new AlertDialog.Builder(context, Helper.dialogStyle()); AlertDialog.Builder alertPoll = new MaterialAlertDialogBuilder(context, Helper.dialogStyle()); alertPoll.setTitle(R.string.create_poll); ComposePollBinding composePollBinding = ComposePollBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); alertPoll.setView(composePollBinding.getRoot()); Loading @@ -1723,17 +1724,19 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(max_length); composePollBinding.option1.text.setFilters(fArray); composePollBinding.option1.text.setHint(context.getString(R.string.poll_choice_s, 1)); composePollBinding.option1.textLayout.setHint(context.getString(R.string.poll_choice_s, 1)); composePollBinding.option2.text.setFilters(fArray); composePollBinding.option2.text.setHint(context.getString(R.string.poll_choice_s, 2)); composePollBinding.option2.textLayout.setHint(context.getString(R.string.poll_choice_s, 2)); composePollBinding.option1.buttonRemove.setVisibility(View.GONE); composePollBinding.option2.buttonRemove.setVisibility(View.GONE); int finalMax_entry = max_entry; composePollBinding.buttonAddOption.setOnClickListener(v -> { if (pollCountItem[0] < finalMax_entry) { ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(composePollBinding.optionsList.getContext()), composePollBinding.optionsList, false); if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple) composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); composePollItemBinding.text.setFilters(fArray); composePollItemBinding.text.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.textLayout.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); LinearLayoutCompat viewItem = composePollItemBinding.getRoot(); composePollBinding.optionsList.addView(composePollItemBinding.getRoot()); composePollItemBinding.buttonRemove.setOnClickListener(view -> { Loading Loading @@ -1764,27 +1767,31 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder ArrayAdapter<CharSequence> pollduration = ArrayAdapter.createFromResource(context, R.array.poll_duration, android.R.layout.simple_spinner_dropdown_item); ArrayAdapter<CharSequence> pollchoice = ArrayAdapter.createFromResource(context, R.array.poll_choice_type, android.R.layout.simple_spinner_dropdown_item); composePollBinding.pollType.setAdapter(pollchoice); composePollBinding.pollDuration.setAdapter(pollduration); composePollBinding.pollDuration.setSelection(4); composePollBinding.pollType.setSelection(0); if (statusDraft != null && statusDraft.poll != null && statusDraft.poll.options != null) { int i = 1; for (Poll.PollItem pollItem : statusDraft.poll.options) { if (i == 1) { if (statusDraft.poll.multiple) composePollBinding.option1.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); if (pollItem.title != null) composePollBinding.option1.text.setText(pollItem.title); } else if (i == 2) { if (statusDraft.poll.multiple) composePollBinding.option2.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); if (pollItem.title != null) composePollBinding.option2.text.setText(pollItem.title); } else { ComposePollItemBinding composePollItemBinding = ComposePollItemBinding.inflate(LayoutInflater.from(context), new LinearLayout(context), false); if (composePollBinding.pollType.getCheckedButtonId() == R.id.poll_type_multiple) composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); else composePollItemBinding.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single); composePollItemBinding.text.setFilters(fArray); composePollItemBinding.text.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.textLayout.setHint(context.getString(R.string.poll_choice_s, (pollCountItem[0] + 1))); composePollItemBinding.text.setText(pollItem.title); composePollBinding.optionsList.addView(composePollItemBinding.getRoot()); composePollItemBinding.buttonRemove.setOnClickListener(view -> { Loading Loading @@ -1822,9 +1829,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder break; } if (statusDraft.poll.multiple) composePollBinding.pollType.setSelection(1); composePollBinding.pollType.check(R.id.poll_type_multiple); else composePollBinding.pollType.setSelection(0); composePollBinding.pollType.check(R.id.poll_type_single); } Loading @@ -1834,15 +1841,32 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder dialog.dismiss(); notifyItemChanged(position); }); alertPoll.setPositiveButton(R.string.validate, null); alertPoll.setPositiveButton(R.string.save, null); final AlertDialog alertPollDiaslog = alertPoll.create(); alertPollDiaslog.setOnShowListener(dialog -> { composePollBinding.pollType.addOnButtonCheckedListener((group, checkedId, isChecked) -> { if (isChecked) { if (checkedId == R.id.poll_type_single) { if (statusDraft != null && statusDraft.poll != null) statusDraft.poll.multiple = false; for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) { ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i)); child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_single); } } else if (checkedId == R.id.poll_type_multiple) { if (statusDraft != null && statusDraft.poll != null) statusDraft.poll.multiple = true; for (int i = 0; i < composePollBinding.optionsList.getChildCount(); i++) { ComposePollItemBinding child = ComposePollItemBinding.bind(composePollBinding.optionsList.getChildAt(i)); child.typeIndicator.setImageResource(R.drawable.ic_compose_poll_option_mark_multiple); } } } }); Button b = alertPollDiaslog.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(view1 -> { int poll_duration_pos = composePollBinding.pollDuration.getSelectedItemPosition(); int poll_choice_pos = composePollBinding.pollType.getSelectedItemPosition(); int selected_poll_type_id = composePollBinding.pollType.getCheckedButtonId(); String choice1 = composePollBinding.option1.text.getText().toString().trim(); String choice2 = composePollBinding.option2.text.getText().toString().trim(); Loading @@ -1850,7 +1874,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder Toasty.error(context, context.getString(R.string.poll_invalid_choices), Toasty.LENGTH_SHORT).show(); } else if (statusDraft != null) { statusDraft.poll = new Poll(); statusDraft.poll.multiple = (poll_choice_pos != 0); statusDraft.poll.multiple = selected_poll_type_id == R.id.poll_type_multiple; int expire; switch (poll_duration_pos) { case 0: Loading
app/src/main/res/drawable/ic_compose_poll_option_mark_multiple.xml +2 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,6 @@ android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="#808080" android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" /> android:fillColor="@android:color/white" android:pathData="M18,19L6,19c-0.55,0 -1,-0.45 -1,-1L5,6c0,-0.55 0.45,-1 1,-1h12c0.55,0 1,0.45 1,1v12c0,0.55 -0.45,1 -1,1zM19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2z" /> </vector>
app/src/main/res/drawable/ic_compose_poll_option_mark_single.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" /> </vector>
app/src/main/res/layout/compose_poll.xml +70 −71 Original line number Diff line number Diff line Loading @@ -14,29 +14,22 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see <http://www.gnu.org/licenses> --> <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="6dp" app:cardElevation="2dp"> <ScrollView android:id="@+id/options_list_container" android:layout_width="match_parent" android:layout_height="wrap_content"> <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="6dp"> android:paddingHorizontal="24dp" android:paddingVertical="12dp"> <androidx.appcompat.widget.LinearLayoutCompat android:id="@+id/options_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:orientation="vertical"> <include Loading @@ -52,59 +45,65 @@ </androidx.appcompat.widget.LinearLayoutCompat> <androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.button.MaterialButton android:id="@+id/button_add_option" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginTop="6dp" android:contentDescription="@string/add_poll_item" android:src="@drawable/ic_baseline_add_24" /> <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" style="@style/Widget.Material3.Button.OutlinedButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical"> android:layout_gravity="center_horizontal" android:layout_marginTop="12dp" android:text="@string/add_poll_item" app:icon="@drawable/ic_baseline_add_24" /> <com.google.android.material.textview.MaterialTextView android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginTop="24dp" android:text="@string/poll_type" android:textAlignment="viewEnd" /> android:textAppearance="@style/TextAppearance.Material3.LabelLarge" /> <androidx.appcompat.widget.AppCompatSpinner <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/poll_type" android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" /> android:layout_marginTop="6dp" android:orientation="vertical" app:checkedButton="@id/poll_type_single" app:selectionRequired="true" app:singleSelection="true"> </androidx.appcompat.widget.LinearLayoutCompat> <com.google.android.material.button.MaterialButton android:id="@+id/poll_type_single" style="@style/Fedilab.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/poll_type_single" android:textAlignment="textStart" app:icon="@drawable/ic_compose_poll_option_mark_single" /> <androidx.appcompat.widget.LinearLayoutCompat <com.google.android.material.button.MaterialButton android:id="@+id/poll_type_multiple" style="@style/Fedilab.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical"> android:text="@string/poll_type_multiple" android:textAlignment="textStart" app:icon="@drawable/ic_compose_poll_option_mark_multiple" /> </com.google.android.material.button.MaterialButtonToggleGroup> <com.google.android.material.textview.MaterialTextView android:layout_width="0dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginTop="24dp" android:text="@string/poll_duration" android:textAlignment="viewEnd" /> android:textAppearance="@style/TextAppearance.Material3.LabelLarge" /> <androidx.appcompat.widget.AppCompatSpinner android:id="@+id/poll_duration" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" /> </androidx.appcompat.widget.LinearLayoutCompat> android:layout_width="match_parent" android:layout_height="wrap_content" /> </androidx.appcompat.widget.LinearLayoutCompat> </ScrollView> </com.google.android.material.card.MaterialCardView>
app/src/main/res/layout/compose_poll_item.xml +21 −13 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ see <http://www.gnu.org/licenses> --> <androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp" Loading @@ -23,23 +24,30 @@ <androidx.appcompat.widget.AppCompatImageView android:id="@+id/type_indicator" android:layout_width="36dp" android:layout_height="36dp" android:padding="4dp" android:src="@drawable/ic_compose_poll_option_mark_multiple" /> android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_compose_poll_option_mark_single" /> <androidx.appcompat.widget.AppCompatEditText android:id="@+id/text" <com.google.android.material.textfield.TextInputLayout android:id="@+id/textLayout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> android:layout_marginHorizontal="6dp" android:layout_weight="1"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/text" style="@style/Widget.Material3.TextInputEditText.OutlinedBox.Dense" android:layout_width="match_parent" android:layout_height="wrap_content" /> </com.google.android.material.textfield.TextInputLayout> <androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.button.MaterialButton android:id="@+id/button_remove" style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="48dp" android:layout_height="48dp" android:backgroundTint="@color/errorColor" android:src="@drawable/ic_baseline_close_24" /> style="@style/Widget.Material3.Button.IconButton" android:layout_width="wrap_content" android:layout_height="wrap_content" app:icon="@drawable/ic_baseline_close_24" /> </androidx.appcompat.widget.LinearLayoutCompat>