bug fix, layout fix

This commit is contained in:
nuclearfog 2023-03-15 21:04:37 +01:00
parent 79c64b8e5b
commit 33eae0dba2
No known key found for this signature in database
GPG Key ID: 03488A185C476379
6 changed files with 49 additions and 34 deletions

View File

@ -847,7 +847,11 @@ public class AppDatabase {
result.ensureCapacity(cursor.getCount());
do {
DatabaseAccount account = new DatabaseAccount(cursor);
account.addUser(getUser(account.getId()));
DatabaseUser user = getUser(account.getId());
if (user != null) {
user.setAsCurrentUser();
account.addUser(user);
}
result.add(account);
} while (cursor.moveToNext());
}
@ -883,12 +887,12 @@ public class AppDatabase {
* @return user information or null if not found
*/
@Nullable
public User getUser(long userId) {
public DatabaseUser getUser(long userId) {
synchronized (LOCK) {
String[] args = {Long.toString(userId)};
SQLiteDatabase db = adapter.getDbRead();
Cursor cursor = db.rawQuery(SINGLE_USER_QUERY, args);
User user = null;
DatabaseUser user = null;
if (cursor.moveToFirst())
user = new DatabaseUser(cursor, settings.getLogin());
cursor.close();

View File

@ -246,4 +246,11 @@ public class DatabaseUser implements User {
public String toString() {
return "name=\"" + screenName + "\"";
}
/**
* set this user as current user
*/
public void setAsCurrentUser() {
isCurrentUser = true;
}
}

View File

@ -54,7 +54,7 @@ public class PollDialog extends Dialog implements OnClickListener {
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, R.array.timeunits, android.R.layout.simple_spinner_dropdown_item);
timeUnitSelector.setAdapter(adapter);
timeUnitSelector.setSelected(true);
timeUnitSelector.setSelection(2);
optionAdapter = new EditOptionsAdapter();
optionsList.setAdapter(optionAdapter);
@ -69,27 +69,27 @@ public class PollDialog extends Dialog implements OnClickListener {
public void onClick(View v) {
if (v.getId() == R.id.dialog_poll_create) {
String durationStr = durationInput.getText().toString();
int secondsDuration;
if (durationStr.matches("\\d{1,3}")) {
int duration = Integer.parseInt(durationStr);
switch (timeUnitSelector.getSelectedItemPosition()) {
// minutes
case 0:
poll.setDuration(duration * 60);
break;
// hours
case 1:
poll.setDuration(duration * 3600);
break;
// days
case 2:
poll.setDuration(duration * 86400);
break;
}
secondsDuration = Integer.parseInt(durationStr);
} else {
// default 24h
poll.setDuration(86400);
secondsDuration = 1;
}
switch (timeUnitSelector.getSelectedItemPosition()) {
// minutes
case 0:
poll.setDuration(secondsDuration * 60);
break;
// hours
case 1:
poll.setDuration(secondsDuration * 3600);
break;
// days
case 2:
poll.setDuration(secondsDuration * 86400);
break;
}
poll.setMultipleChoice(multiple_choice.isChecked());
poll.hideVotes(hide_votes.isChecked());

View File

@ -126,13 +126,15 @@
android:id="@+id/item_status_reply"
android:layout_width="@dimen/item_status_icon_size"
android:layout_height="@dimen/item_status_icon_size"
android:layout_marginStart="@dimen/item_status_text_margin"
android:layout_marginStart="@dimen/item_status_layout_margin"
android:src="@drawable/back"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/item_status_reply_name"
app:layout_constraintBottom_toBottomOf="@id/item_status_reply_name"
app:layout_constraintEnd_toStartOf="@id/item_status_reply_name"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintHorizontal_bias="0"
tools:ignore="ContentDescription" />
<TextView
@ -145,7 +147,7 @@
android:textSize="@dimen/item_status_textsize_button"
app:layout_constraintStart_toEndOf="@id/item_status_reply"
app:layout_constraintTop_toBottomOf="@id/item_status_user_barrier"
app:layout_constraintEnd_toStartOf="@id/item_status_reposter_icon" />
app:layout_constraintEnd_toStartOf="@id/item_status_reposter_icon"/>
<ImageView
android:id="@+id/item_status_reposter_icon"
@ -157,7 +159,7 @@
app:layout_constraintTop_toTopOf="@id/item_status_reposter_name"
app:layout_constraintBottom_toBottomOf="@id/item_status_reposter_name"
app:layout_constraintEnd_toStartOf="@id/item_status_reposter_name"
tools:ignore="ContentDescription" />
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/item_status_reposter_name"
@ -168,7 +170,8 @@
android:lines="1"
android:textSize="@dimen/item_status_textsize_button"
app:layout_constraintStart_toEndOf="@id/item_status_reposter_icon"
app:layout_constraintTop_toBottomOf="@id/item_status_user_barrier" />
app:layout_constraintTop_toBottomOf="@id/item_status_user_barrier"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/item_status_text_barrier"
@ -200,10 +203,10 @@
android:id="@+id/item_status_indicator_placeholder"
android:layout_width="0dp"
android:layout_height="@dimen/item_status_icon_size"
android:layout_marginTop="@dimen/item_status_layout_margin"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/item_status_attachment_list"
app:layout_constraintTop_toTopOf="@id/item_status_reply_icon"
app:layout_constraintBottom_toBottomOf="@id/item_status_reply_icon"
app:layout_constraintEnd_toStartOf="@id/item_status_reply_icon" />
<ImageView
@ -227,7 +230,7 @@
android:textSize="@dimen/item_status_textsize_button"
app:layout_constraintHorizontal_weight="3"
app:layout_constraintStart_toEndOf="@id/item_status_reply_icon"
app:layout_constraintTop_toBottomOf="@id/item_status_attachment_list"
app:layout_constraintTop_toTopOf="@id/item_status_reply_icon"
app:layout_constraintBottom_toBottomOf="@id/item_status_reply_icon"
app:layout_constraintEnd_toStartOf="@id/item_status_repost_icon" />
@ -252,7 +255,7 @@
android:textSize="@dimen/item_status_textsize_button"
app:layout_constraintHorizontal_weight="3"
app:layout_constraintStart_toEndOf="@id/item_status_repost_icon"
app:layout_constraintTop_toBottomOf="@id/item_status_attachment_list"
app:layout_constraintTop_toTopOf="@id/item_status_repost_icon"
app:layout_constraintBottom_toBottomOf="@id/item_status_repost_icon"
app:layout_constraintEnd_toStartOf="@id/item_status_favorite_icon" />
@ -277,7 +280,8 @@
android:textSize="@dimen/item_status_textsize_button"
app:layout_constraintHorizontal_weight="3"
app:layout_constraintStart_toEndOf="@id/item_status_favorite_icon"
app:layout_constraintTop_toBottomOf="@id/item_status_attachment_list"
app:layout_constraintTop_toTopOf="@id/item_status_favorite_icon"
app:layout_constraintBottom_toBottomOf="@id/item_status_favorite_icon"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -281,7 +281,7 @@
<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>
<string name="dialog_poll_duration_hint">Dauer</string>
<string name="dialog_poll_duration_hint">Dauer: 1</string>
<string name="poll_option_edit_button">hinzufügen/entfernen</string>
<string name="status_add_poll">Umfrage hinzufügen</string>
<string name="status_pref">Statuseinstellungen</string>

View File

@ -226,7 +226,7 @@
<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>
<string name="dialog_poll_duration_hint">Duration</string>
<string name="dialog_poll_duration_hint">Duration: 1</string>
<string name="confirm_discard">discard changes?</string>
<string name="user_data">User data</string>
<string name="follows_you">follows you</string>