bug fix, layout fix, code cleanup, removed unused resources

This commit is contained in:
nuclearfog 2023-01-22 20:40:41 +01:00
parent d41a762ba3
commit 1dc5e532a8
No known key found for this signature in database
GPG Key ID: 03488A185C476379
17 changed files with 87 additions and 48 deletions

View File

@ -57,6 +57,12 @@ public class IconHolder extends ViewHolder implements OnClickListener {
this.settings = settings;
this.listener = listener;
int size = parent.getLayoutParams().height;
if (size == 0)
size = parent.getMeasuredHeight();
itemView.getLayoutParams().height = size;
itemView.getLayoutParams().width = size;
button.setOnClickListener(this);
}

View File

@ -135,10 +135,10 @@ public class MessageHolder extends ViewHolder implements OnClickListener, OnTagC
*/
public void setContent(Message message) {
User sender = message.getSender();
username.setText(sender.getUsername());
screenname.setText(sender.getScreenname());
time.setText(StringTools.formatCreationTime(itemView.getResources(), message.getTimestamp()));
iconList.setVisibility(View.VISIBLE);
adapter.addItems(message);
if (!message.getText().trim().isEmpty()) {
@ -160,8 +160,6 @@ public class MessageHolder extends ViewHolder implements OnClickListener, OnTagC
}
if (adapter.isEmpty()) {
iconList.setVisibility(View.GONE);
} else {
iconList.setVisibility(View.VISIBLE);
}
String profileImageUrl = sender.getProfileImageThumbnailUrl();
if (settings.imagesEnabled() && !profileImageUrl.isEmpty()) {

View File

@ -175,6 +175,8 @@ public class StatusHolder extends ViewHolder implements OnClickListener {
replyname.setVisibility(View.GONE);
}
if (settings.statusIndicatorsEnabled()) {
// set visibility first so iconholder can measure the listview height
iconList.setVisibility(View.VISIBLE);
adapter.addItems(status);
if (adapter.isEmpty()) {
iconList.setVisibility(View.GONE);

View File

@ -10,7 +10,7 @@ import org.nuclearfog.twidda.model.UserList;
/**
* userlist implementation
* https://docs.joinmastodon.org/entities/List/
* <a href="https://docs.joinmastodon.org/entities/List/">Mastodon documentation</a>
*
* @author nuclearfog
*/

View File

@ -1357,7 +1357,7 @@ public class Twitter implements Connection {
*/
private Users getUsers1(long[] ids) throws TwitterException {
List<String> params = new ArrayList<>();
if (ids.length > 0) {
if (ids.length > 1) {
StringBuilder idBuf = new StringBuilder("user_id=");
for (int i = 0 ; i < ids.length - 1 ; i++) {
idBuf.append(ids[i]).append("%2C");

View File

@ -26,7 +26,7 @@ import java.util.List;
/**
* This class handles deep links and starts activities to show the content
* When the user clicks on a link (e.g. https://twitter.com/Twitter/status/1480571976414543875)
* When the user clicks on a link (e.g. "twitter.com/Twitter/status/1480571976414543875")
* this class extracts information of the link and open an activity tp show the content
* When a link type isn't supported, the {@link MainActivity} will be opened instead
*

View File

@ -39,7 +39,7 @@ public final class StringTools {
/**
* regex pattern used to get user mentions
*/
private static final Pattern MENTION = Pattern.compile("[@][\\w_]+");
private static final Pattern MENTION = Pattern.compile("@[\\w_]+");
/**
* oauth 1.0 signature algorithm

View File

@ -204,7 +204,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener,
}
// generate Mastodon login
else if (hostSelector.getSelectedItemId() == NetworkAdapter.ID_MASTODON) {
if (hostname == null || Patterns.WEB_URL.matcher(hostname).matches()){
if (hostname == null || Patterns.WEB_URL.matcher(hostname).matches()) {
Toast.makeText(getApplicationContext(), R.string.info_open_mastodon_login, LENGTH_LONG).show();
loginAsync = new LoginAction(this, LoginAction.LOGIN_MASTODON, LoginAction.MODE_REQUEST);
if (hostname != null) {

View File

@ -207,6 +207,7 @@ public abstract class MediaActivity extends AppCompatActivity implements Locatio
/**
* save image to external storage
*/
@SuppressWarnings("IOStreamConstructor")
private void saveImage() {
try {
if (imageTask == null || imageTask.getStatus() != RUNNING) {

View File

@ -62,7 +62,7 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
api1 = findViewById(R.id.dialog_connection_api1);
api2 = findViewById(R.id.dialog_connection_api2);
int width = (int)(context.getResources().getDisplayMetrics().widthPixels*0.9);
int width = (int) (context.getResources().getDisplayMetrics().widthPixels * 0.9);
getWindow().setLayout(width, WRAP_CONTENT);
AppStyles.setTheme(root);
enableApi.setOnCheckedChangeListener(this);
@ -95,7 +95,12 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
}
dismiss();
} else {
// todo error message
if (api1Text.trim().isEmpty()) {
api1.setError(getContext().getString(R.string.info_missing_key));
}
if (api2Text.trim().isEmpty()) {
api2.setError(getContext().getString(R.string.info_missing_key));
}
}
break;
@ -107,7 +112,7 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
callback.onConnectionSet(null, null, null);
dismiss();
} else {
// todo error message
host.setError(getContext().getString(R.string.info_missing_host));
}
break;
}
@ -132,8 +137,7 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
api1.setVisibility(View.INVISIBLE);
api2.setVisibility(View.INVISIBLE);
}
}
else if (buttonView.getId() == R.id.dialog_connection_custom_host) {
} else if (buttonView.getId() == R.id.dialog_connection_custom_host) {
if (isChecked) {
host.setVisibility(View.VISIBLE);
} else {
@ -150,9 +154,10 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
public void show(int type) {
switch(type) {
switch (type) {
case TYPE_TWITTER:
enableHost.setCheckedImmediately(false);
enableApi.setCheckedImmediately(false);
enableV2.setCheckedImmediately(false);
enableApi.setVisibility(View.VISIBLE);
apiLabel.setVisibility(View.VISIBLE);
api1.setVisibility(View.INVISIBLE);
@ -163,8 +168,7 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
break;
case TYPE_MASTODON:
enableApi.setCheckedImmediately(false);
enableV2.setCheckedImmediately(false);
enableHost.setCheckedImmediately(false);
hostLabel.setVisibility(View.VISIBLE);
enableHost.setVisibility(View.VISIBLE);
host.setVisibility(View.INVISIBLE);
@ -176,6 +180,12 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
api2.setVisibility(View.GONE);
break;
}
if (api1.getError() != null)
api1.setError(null);
if (api2.getError() != null)
api2.setError(null);
if (host.getError() != null)
host.setError(null);
this.type = type;
super.show();
}
@ -190,8 +200,8 @@ public class ConnectionDialog extends Dialog implements OnCheckedChangeListener,
String TWITTER_V2 = "api-v2";
/**
* @param key1 first API key
* @param key2 second API key
* @param key1 first API key
* @param key2 second API key
* @param hostname hostname or type of API {@link #TWITTER_V1,#TWITTER_V2}
*/
void onConnectionSet(@Nullable String key1, @Nullable String key2, @Nullable String hostname);

View File

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M16.783,10c0,-1.049 0.646,-1.875 1.617,-2.443c-0.176,-0.584 -0.407,-1.145 -0.692,-1.672c-1.089,0.285 -1.97,-0.141 -2.711,-0.883c-0.741,-0.74 -0.968,-1.621 -0.683,-2.711c-0.527,-0.285 -1.088,-0.518 -1.672,-0.691C12.074,2.57 11.047,3.215 10,3.215c-1.048,0 -2.074,-0.645 -2.643,-1.615C6.772,1.773 6.213,2.006 5.686,2.291c0.285,1.09 0.059,1.971 -0.684,2.711C4.262,5.744 3.381,6.17 2.291,5.885C2.006,6.412 1.774,6.973 1.6,7.557C2.57,8.125 3.215,8.951 3.215,10c0,1.047 -0.645,2.074 -1.615,2.643c0.175,0.584 0.406,1.144 0.691,1.672c1.09,-0.285 1.971,-0.059 2.711,0.682c0.741,0.742 0.969,1.623 0.684,2.711c0.527,0.285 1.087,0.518 1.672,0.693c0.568,-0.973 1.595,-1.617 2.643,-1.617c1.047,0 2.074,0.645 2.643,1.617c0.584,-0.176 1.144,-0.408 1.672,-0.693c-0.285,-1.088 -0.059,-1.969 0.683,-2.711c0.741,-0.74 1.622,-1.166 2.711,-0.883c0.285,-0.527 0.517,-1.086 0.692,-1.672C17.429,11.873 16.783,11.047 16.783,10zM10,13.652c-2.018,0 -3.653,-1.635 -3.653,-3.652c0,-2.018 1.636,-3.654 3.653,-3.654c2.018,0 3.652,1.637 3.652,3.654C13.652,12.018 12.018,13.652 10,13.652z"
android:fillColor="#FFFFFF"/>
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M16.783,10c0,-1.049 0.646,-1.875 1.617,-2.443c-0.176,-0.584 -0.407,-1.145 -0.692,-1.672c-1.089,0.285 -1.97,-0.141 -2.711,-0.883c-0.741,-0.74 -0.968,-1.621 -0.683,-2.711c-0.527,-0.285 -1.088,-0.518 -1.672,-0.691C12.074,2.57 11.047,3.215 10,3.215c-1.048,0 -2.074,-0.645 -2.643,-1.615C6.772,1.773 6.213,2.006 5.686,2.291c0.285,1.09 0.059,1.971 -0.684,2.711C4.262,5.744 3.381,6.17 2.291,5.885C2.006,6.412 1.774,6.973 1.6,7.557C2.57,8.125 3.215,8.951 3.215,10c0,1.047 -0.645,2.074 -1.615,2.643c0.175,0.584 0.406,1.144 0.691,1.672c1.09,-0.285 1.971,-0.059 2.711,0.682c0.741,0.742 0.969,1.623 0.684,2.711c0.527,0.285 1.087,0.518 1.672,0.693c0.568,-0.973 1.595,-1.617 2.643,-1.617c1.047,0 2.074,0.645 2.643,1.617c0.584,-0.176 1.144,-0.408 1.672,-0.693c-0.285,-1.088 -0.059,-1.969 0.683,-2.711c0.741,-0.74 1.622,-1.166 2.711,-0.883c0.285,-0.527 0.517,-1.086 0.692,-1.672C17.429,11.873 16.783,11.047 16.783,10zM10,13.652c-2.018,0 -3.653,-1.635 -3.653,-3.652c0,-2.018 1.636,-3.654 3.653,-3.654c2.018,0 3.652,1.637 3.652,3.654C13.652,12.018 12.018,13.652 10,13.652z"
android:fillColor="#FFFFFF" />
</vector>

View File

@ -5,6 +5,7 @@
android:id="@+id/dialog_connection_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dialog_connection_root_padding"
tools:ignore="UseSwitchCompatOrMaterialXml">
<com.kyleduo.switchbutton.SwitchButton
@ -14,7 +15,7 @@
android:layout_margin="@dimen/dialog_connection_layout_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@id/dialog_connection_custom_api_label"/>
app:layout_constraintEnd_toStartOf="@id/dialog_connection_custom_api_label" />
<TextView
android:id="@+id/dialog_connection_custom_api_label"
@ -37,7 +38,7 @@
android:visibility="invisible"
app:layout_constraintStart_toEndOf="@id/dialog_connection_custom_api_label"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@id/dialog_connection_use_v2_label"/>
app:layout_constraintEnd_toStartOf="@id/dialog_connection_use_v2_label" />
<TextView
android:id="@+id/dialog_connection_use_v2_label"
@ -51,7 +52,7 @@
app:layout_constraintStart_toEndOf="@id/dialog_connection_use_v2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/dialog_connection_use_v2"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/dialog_connection_api1"
@ -63,9 +64,11 @@
android:layout_weight="1"
android:layout_margin="@dimen/dialog_connection_layout_margin"
android:visibility="invisible"
android:inputType="textPassword"
android:importantForAutofill="no"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/dialog_connection_custom_api"
app:layout_constraintEnd_toStartOf="@id/dialog_connection_api2"/>
app:layout_constraintEnd_toStartOf="@id/dialog_connection_api2" />
<EditText
android:id="@+id/dialog_connection_api2"
@ -77,9 +80,11 @@
android:layout_weight="1"
android:layout_margin="@dimen/dialog_connection_layout_margin"
android:visibility="invisible"
android:inputType="textPassword"
android:importantForAutofill="no"
app:layout_constraintStart_toEndOf="@id/dialog_connection_api1"
app:layout_constraintTop_toBottomOf="@id/dialog_connection_custom_api"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />
<com.kyleduo.switchbutton.SwitchButton
android:id="@+id/dialog_connection_custom_host"
@ -88,7 +93,7 @@
android:layout_margin="@dimen/dialog_connection_layout_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/dialog_connection_api1"
app:layout_constraintEnd_toStartOf="@id/dialog_connection_custom_host_label"/>
app:layout_constraintEnd_toStartOf="@id/dialog_connection_custom_host_label" />
<TextView
android:id="@+id/dialog_connection_custom_host_label"
@ -101,7 +106,7 @@
app:layout_constraintStart_toEndOf="@id/dialog_connection_custom_host"
app:layout_constraintTop_toTopOf="@id/dialog_connection_custom_host"
app:layout_constraintBottom_toBottomOf="@id/dialog_connection_custom_host"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/dialog_connection_hostname"
@ -113,6 +118,8 @@
android:layout_weight="1"
android:layout_margin="@dimen/dialog_connection_layout_margin"
android:visibility="invisible"
android:inputType="textUri"
android:importantForAutofill="no"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/dialog_connection_custom_host"
app:layout_constraintEnd_toEndOf="parent" />
@ -129,7 +136,7 @@
app:layout_constraintTop_toBottomOf="@id/dialog_connection_hostname"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/dialog_connection_discard"
style="@style/FeedbackButton"/>
style="@style/FeedbackButton" />
<Button
android:id="@+id/dialog_connection_discard"
@ -143,6 +150,6 @@
app:layout_constraintTop_toBottomOf="@id/dialog_connection_hostname"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
style="@style/FeedbackButton"/>
style="@style/FeedbackButton" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/item_icon_indicator_size"
android:layout_height="@dimen/item_icon_indicator_size"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/item_icon_indicator_margin"
android:layout_marginEnd="@dimen/item_icon_indicator_margin">

View File

@ -36,7 +36,7 @@
android:text="@string/login_network_selector_label"
app:layout_constraintStart_toStartOf="@id/login_network_selector"
app:layout_constraintBottom_toTopOf="@id/login_network_selector"
app:layout_constraintEnd_toEndOf="@id/login_network_selector"/>
app:layout_constraintEnd_toEndOf="@id/login_network_selector" />
<Spinner
android:id="@+id/login_network_selector"
@ -46,7 +46,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/login_toolbar"
app:layout_constraintBottom_toTopOf="@id/login_get_link"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/login_network_settings"
@ -111,7 +111,8 @@
app:layout_constraintTop_toTopOf="@id/login_enter_code"
app:layout_constraintBottom_toBottomOf="@id/login_enter_code"
app:layout_constraintEnd_toStartOf="@id/login_enter_code"
app:layout_constraintHorizontal_chainStyle="packed"/>
app:layout_constraintHorizontal_chainStyle="packed"
tools:ignore="ContentDescription" />
<EditText
android:id="@+id/login_enter_code"

View File

@ -19,6 +19,11 @@
<string name="confirm_delete_database">App Daten Löschen?</string>
<string name="error_limit_exceeded">"Anfragelimit erreicht! Entsperrung nach:"</string>
<string name="info_tweet_sent">Status gesendet</string>
<string name="info_user_favorited">%1$s hat deinen Status favorisiert</string>
<string name="info_user_follow">%1$s folgt dir</string>
<string name="info_user_follow_request">Follow-Anfrage von %1$s</string>
<string name="info_user_mention">%1$s hat dich erwähnt</string>
<string name="info_user_repost">%1$s hat deinen Status geteilt</string>
<string name="info_error">Fehler!</string>
<string name="menu_tweet_delete">löschen</string>
<string name="menu_tweet_open_browser">Im Browser öffnen</string>
@ -70,6 +75,7 @@
<string name="menu_edit_save">speichern</string>
<string name="info_profile_updated">Profile aktualisiert!</string>
<string name="error_empty_name">Name leer!</string>
<string name="connection_discard">verwerfen</string>
<string name="confirm_discard">Änderungen verwerfen?</string>
<string name="user_data">Nutzerdaten</string>
<string name="follows_you">folgt dir</string>
@ -88,6 +94,8 @@
<string name="edit_proxy_user">Nutzername</string>
<string name="proxy_password">Passwort</string>
<string name="error_dm_send">Direktnachricht konnte nicht an diesen Nutzer gesendet werden!</string>
<string name="dialog_connection_custom_host">Benutzerdefinierter Hostname</string>
<string name="dialog_connection_apply">anwenden</string>
<string name="confirm_mute">Nutzer stummschalten?</string>
<string name="info_gps_attached">GPS Position hinzugefügt</string>
<string name="error_gps">GPS lokalisierung fehlgeschlagen!</string>
@ -166,6 +174,7 @@
<string name="settings_icon_color">Symbolfarbe</string>
<string name="settings_key1_hint">Consumer Key</string>
<string name="settings_key2_hint">Consumer Secret</string>
<string name="error_acc_loading">Fehler während des Abruf</string>
<string name="error_api_access_denied">Fehler, API Zugang wurde abgelehnt! Bitte API Schlüssel überprüfen!</string>
<string name="error_mention_exceed">Zu viele Nutzer Erwähnungen!</string>
<string name="error_api_key_expired">Fehler, API Schlüssel veraltet, bitte App aktualisieren!</string>
@ -247,7 +256,15 @@
<string name="status_metrics_title">Statusmetriken</string>
<string name="error_empty_text">Text ist leer!</string>
<string name="error_api_access_limited">Fehler! API Zugang wurde von Twitter beschränkt.</string>
<string name="status_media_preview">Medienvorschau</string>
<string name="status_media_preview_button">Videovorschau Button</string>
<string name="poll_total_votes">"Anzahl:\u0020"</string>
<string name="description_poll_vote_icon">abgestimmt</string>
<string name="poll_finished">Abstimmung beendet:\u0020</string>
<string name="description_attachment_icon">Status/Nachricht Anhang</string>
<string name="notification_status_poll">Umfrage abgeschlossen</string>
<string name="login_network_selector_label">Netzwerk auswählen</string>
<string name="login_network_settings">Verbindungseinstellungen</string>
<string name="info_missing_key">bitte Schlüssel eingeben</string>
<string name="info_missing_host">bitte gültigen Hostnamen eingeben</string>
</resources>

View File

@ -146,15 +146,11 @@
<!--dimens of page_login.xml-->
<dimen name="loginpage_toolbar_height">@dimen/toolbar_height</dimen>
<dimen name="loginpage_layout_margin">8dp</dimen>
<dimen name="loginpage_dropdown_margin">5dp</dimen>
<dimen name="loginpage_button_padding">24dp</dimen>
<dimen name="loginpage_textsize_button">14sp</dimen>
<dimen name="loginpage_padding_drawable">5dp</dimen>
<dimen name="loginpage_textsize_switch">12sp</dimen>
<dimen name="loginpage_textsize_api_key">16sp</dimen>
<dimen name="loginpage_textsize_login_key">20sp</dimen>
<dimen name="loginpage_number_margin">10dp</dimen>
<dimen name="loginpage_label_max_width">110dp</dimen>
<!--dimens of popup_status.xml-->
<dimen name="popup_status_margin_layout">10dp</dimen>
@ -237,6 +233,7 @@
<dimen name="dialog_connection_button_height">24sp</dimen>
<dimen name="dialog_connection_button_padding">5dp</dimen>
<dimen name="dialog_connection_layout_margin">5dp</dimen>
<dimen name="dialog_connection_root_padding">8dp</dimen>
<dimen name="dialog_connection_textsizte_normal">13sp</dimen>
<!--dimens of tabitem.xml-->
@ -265,8 +262,6 @@
<!-- dimens of item_icon.xml -->
<dimen name="item_icon_indicator_margin">2dp</dimen>
<dimen name="item_icon_indicator_size">@dimen/item_status_indicator_size</dimen>
<!-- dimens of item_option -->
<dimen name="item_option_icon_size">12sp</dimen>

View File

@ -59,9 +59,11 @@
<string name="info_account_selected">%1$s selected</string>
<string name="info_user_favorited">%1$s favorited your status</string>
<string name="info_user_follow">%1$s followed you</string>
<string name="info_user_follow_request">%1$s request to follow you</string>
<string name="info_user_follow_request">follow request from %1$s</string>
<string name="info_user_mention">%1$s mentioned you</string>
<string name="info_user_repost">%1$s reposted your status</string>
<string name="info_missing_key">please enter key</string>
<string name="info_missing_host">please enter correct hostname</string>
<string name="info_error">Error</string>
<!-- toast messages for error information -->
@ -294,6 +296,6 @@
<string name="description_attachment_icon">Status/Message attachment</string>
<string name="notification_status_poll">vote finished</string>
<string name="login_network_selector_label">select network</string>
<string name="login_network_settings">network settings</string>
<string name="login_network_settings">connection settings</string>
</resources>