version upgrade, bug fix, added poll dialog remove button

This commit is contained in:
nuclearfog 2023-09-19 23:13:20 +02:00
parent d304ea58a5
commit bdce4ad09c
No known key found for this signature in database
GPG Key ID: 03488A185C476379
10 changed files with 71 additions and 44 deletions

View File

@ -11,8 +11,8 @@ android {
applicationId 'org.nuclearfog.twidda'
minSdkVersion 21
targetSdkVersion 34
versionCode 97
versionName '3.4.1'
versionCode 98
versionName '3.4.2'
resConfigs 'en', 'es', 'de-rDE', 'zh-rCN'
}

View File

@ -1,6 +1,5 @@
package org.nuclearfog.twidda.backend.api.mastodon;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONException;

View File

@ -349,7 +349,7 @@ public class StatusUpdate implements Serializable, Closeable {
}
/**
* @return time to post the status
* @return datetime to post the status
*/
public long getScheduleTime() {
return scheduleTime;

View File

@ -29,7 +29,7 @@ import java.io.Serializable;
import java.util.List;
/**
* Dialog class used to show poll editor
* Dialog class used to create/edit a poll
*
* @author nuclearfog
*/
@ -70,6 +70,7 @@ public class PollDialog extends Dialog implements OnClickListener {
ViewGroup root = findViewById(R.id.dialog_poll_root);
RecyclerView optionsList = findViewById(R.id.dialog_poll_option_list);
Button confirm = findViewById(R.id.dialog_poll_create);
Button remove = findViewById(R.id.dialog_poll_remove);
View close = findViewById(R.id.dialog_poll_close);
durationInput = findViewById(R.id.dialog_poll_duration_input);
timeUnitSelector = findViewById(R.id.dialog_poll_duration_timeunit);
@ -82,6 +83,7 @@ public class PollDialog extends Dialog implements OnClickListener {
AppStyles.setTheme(root, settings.getPopupColor());
confirm.setOnClickListener(this);
remove.setOnClickListener(this);
close.setOnClickListener(this);
}
@ -92,14 +94,14 @@ public class PollDialog extends Dialog implements OnClickListener {
optionAdapter.replaceItems(poll.getOptions());
multiple_choice.setCheckedImmediately(poll.multipleChoiceEnabled());
hide_votes.setCheckedImmediately(poll.hideTotalVotes());
if (poll.getDuration() > 86400000L) {
durationInput.setText(Long.toString(Math.round(poll.getDuration() / 86400000d)));
if (poll.getDuration() >= 86400) {
durationInput.setText(Integer.toString(Math.round(poll.getDuration() / 86400.0f)));
timeUnitSelector.setSelection(2);
} else if (poll.getDuration() > 3600000L) {
durationInput.setText(Long.toString(Math.round(poll.getDuration() / 3600000d)));
} else if (poll.getDuration() >= 3600) {
durationInput.setText(Integer.toString(Math.round(poll.getDuration() / 3600.0f)));
timeUnitSelector.setSelection(1);
} else if (poll.getDuration() > 60000L) {
durationInput.setText(Long.toString(Math.round(poll.getDuration() / 60000d)));
} else if (poll.getDuration() >= 60) {
durationInput.setText(Integer.toString(Math.round(poll.getDuration() / 60.0f)));
timeUnitSelector.setSelection(0);
}
}
@ -159,6 +161,9 @@ public class PollDialog extends Dialog implements OnClickListener {
callback.onPollUpdate(poll);
dismiss();
}
} else if (v.getId() == R.id.dialog_poll_remove) {
callback.onPollUpdate(null);
dismiss();
} else if (v.getId() == R.id.dialog_poll_close) {
dismiss();
}
@ -185,11 +190,13 @@ public class PollDialog extends Dialog implements OnClickListener {
*/
public void show(@Nullable PollUpdate poll) {
if (!isShowing()) {
if (poll != null) {
this.poll = poll;
} else {
this.poll = new PollUpdate();
if (poll == null) {
poll = new PollUpdate();
if (instance != null) {
poll.setDuration(instance.getMinPollDuration());
}
}
this.poll = poll;
super.show();
}
}

View File

@ -112,13 +112,32 @@
android:layout_weight="2"
android:layout_marginEnd="@dimen/dialog_poll_layout_margins" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dialog_poll_layout_margins"
android:gravity="end">
<Button
android:id="@+id/dialog_poll_remove"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_poll_button_height"
android:text="@string/dialog_poll_button_remove"
android:layout_margin="@dimen/dialog_poll_layout_margins"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@id/dialog_poll_duration_timeunit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
style="@style/FeedbackButton" />
<Button
android:id="@+id/dialog_poll_create"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_poll_button_height"
android:layout_weight="1"
android:text="@string/dialog_poll_button"
android:lines="1"
android:text="@string/dialog_poll_button_create"
android:layout_marginTop="@dimen/dialog_poll_layout_margins"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@id/dialog_poll_duration_timeunit"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -67,7 +67,7 @@
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_add_location"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
<ProgressBar
@ -94,7 +94,7 @@
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_add_poll"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
<ImageButton
@ -108,9 +108,25 @@
android:src="@drawable/poll"
android:contentDescription="@string/status_add_poll"
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_emoji"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
<ImageButton
android:id="@+id/popup_status_emoji"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="@dimen/popup_status_button_padding"
android:layout_marginBottom="@dimen/popup_status_margin_layout"
android:layout_marginEnd="@dimen/popup_status_button_margin"
android:contentDescription="@string/status_close"
android:scaleType="fitCenter"
android:src="@drawable/emoji"
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_pref"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
<ImageButton
@ -124,25 +140,9 @@
android:scaleType="fitCenter"
android:src="@drawable/cog"
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_emoji"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
style="@style/RoundButton" />
<ImageButton
android:id="@+id/popup_status_emoji"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="@dimen/popup_status_button_padding"
android:layout_marginBottom="@dimen/popup_status_margin_layout"
android:layout_marginEnd="@dimen/popup_status_margin_layout"
android:contentDescription="@string/status_close"
android:scaleType="fitCenter"
android:src="@drawable/emoji"
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toStartOf="@id/popup_status_send"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
<ImageButton
@ -157,7 +157,7 @@
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
app:layout_constraintEnd_toEndOf="@id/popup_status_input"
app:layout_constraintDimensionRatio="1.0"
app:layout_constraintWidth_percent="@dimen/popup_status_button_size"
app:layout_constraintWidth_percent="@dimen/popup_status_button_width_ratio"
style="@style/RoundButton" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -280,7 +280,8 @@
<string name="menu_bookmark_remove">Lesezeichen entfernen</string>
<string name="notification_dismiss">Benachrichtigung verwerfen</string>
<string name="dialog_poll_title">Umfrage erstellen</string>
<string name="dialog_poll_button">erstellen</string>
<string name="dialog_poll_button_create">erstellen</string>
<string name="dialog_poll_button_remove">entfernen</string>
<string name="dialog_poll_mc">Mehrfachauswahl</string>
<string name="dialog_poll_hide">Stimmen verstecken</string>
<string name="dialog_poll_option_edit_hint">%1$d. Option</string>

View File

@ -206,7 +206,7 @@
<string name="profile_bio">Biografía</string>
<string name="connection_discard">Descartar</string>
<string name="dialog_poll_title">Crear encuesta</string>
<string name="dialog_poll_button">Crear</string>
<string name="dialog_poll_button_create">Crear</string>
<string name="dialog_poll_mc">Opción múltiple</string>
<string name="dialog_poll_hide">Ocultar votos</string>
<string name="dialog_poll_option_edit_hint">Opción %1$d</string>

View File

@ -153,7 +153,7 @@
<dimen name="popup_status_button_margin">7dp</dimen>
<dimen name="popup_status_icon_list_margin">7dp</dimen>
<dimen name="popup_status_button_padding">7dp</dimen>
<dimen name="popup_status_button_size">0.09</dimen>
<item name="popup_status_button_width_ratio" format="float" type="dimen">0.09</item>
<!--dimen of popup_userlist.xml-->
<dimen name="popup_userlist_background_margin">10dp</dimen>

View File

@ -235,7 +235,8 @@
<string name="profile_bio">Bio</string>
<string name="connection_discard">discard</string>
<string name="dialog_poll_title">create poll</string>
<string name="dialog_poll_button">create</string>
<string name="dialog_poll_button_create">create</string>
<string name="dialog_poll_button_remove">remove</string>
<string name="dialog_poll_mc">multiple choice</string>
<string name="dialog_poll_hide">hide votes</string>
<string name="dialog_poll_option_edit_hint">Option %1$d</string>