This commit is contained in:
nuclearfog 2023-10-09 21:31:04 +02:00
parent a24ba241eb
commit 56f4de4eda
No known key found for this signature in database
GPG Key ID: 03488A185C476379
7 changed files with 23 additions and 16 deletions

View File

@ -269,17 +269,17 @@ public interface Connection {
Statuses getPublicTimeline(long minId, long maxId) throws ConnectionException;
/**
* get location trends
* get trending hashtags
*
* @return trend list
* @return hashtag list
*/
Hashtags getTrends() throws ConnectionException;
Hashtags getHashtags() throws ConnectionException;
/**
* search hashtags matching search string
*
* @param search text to search hashtags
* @return list of trends (Hashtags)
* @return list of hashtags
*/
Hashtags searchHashtags(String search) throws ConnectionException;

View File

@ -458,8 +458,8 @@ public class Mastodon implements Connection {
@Override
public Hashtags getTrends() throws MastodonException {
Hashtags result = getTrends(ENDPOINT_TRENDS, new ArrayList<>());
public Hashtags getHashtags() throws MastodonException {
Hashtags result = getHashtags(ENDPOINT_TRENDS, new ArrayList<>());
Collections.sort(result);
return result;
}
@ -473,7 +473,7 @@ public class Mastodon implements Connection {
else
params.add("q=" + StringUtils.encode(search));
params.add("type=hashtags");
Hashtags result = getTrends(ENDPOINT_SEARCH_TIMELINE, params);
Hashtags result = getHashtags(ENDPOINT_SEARCH_TIMELINE, params);
Collections.sort(result);
return result;
}
@ -484,19 +484,19 @@ public class Mastodon implements Connection {
List<String> params = new ArrayList<>();
if (cursor != 0L)
params.add("max_id=" + cursor);
return getTrends(ENDPOINT_HASHTAG_FOLLOWING, params);
return getHashtags(ENDPOINT_HASHTAG_FOLLOWING, params);
}
@Override
public Hashtags showHashtagFeaturing() throws ConnectionException {
return getTrends(ENDPOINT_HASHTAG_FEATURE, new ArrayList<>());
return getHashtags(ENDPOINT_HASHTAG_FEATURE, new ArrayList<>());
}
@Override
public Hashtags showHashtagSuggestions() throws ConnectionException {
return getTrends(ENDPOINT_HASHTAG_FEATURE + "/suggestions", new ArrayList<>());
return getHashtags(ENDPOINT_HASHTAG_FEATURE + "/suggestions", new ArrayList<>());
}
@ -1155,6 +1155,7 @@ public class Mastodon implements Connection {
params.add("display_name=" + StringUtils.encode(update.getName()));
params.add("note=" + StringUtils.encode(update.getDescription()));
params.add("locked=" + update.privacyEnabled());
params.add("source[sensitive]=" + update.isSensitive());
if (update.getProfileImageMedia() != null) {
streams.add(update.getProfileImageMedia().getStream());
keys.add("avatar");
@ -1461,7 +1462,7 @@ public class Mastodon implements Connection {
* @param params additional parameters
* @return trend list
*/
private Hashtags getTrends(String endpoint, List<String> params) throws MastodonException {
private Hashtags getHashtags(String endpoint, List<String> params) throws MastodonException {
try {
params.add("limit=" + settings.getListSize());
Response response = get(endpoint, params);

View File

@ -43,7 +43,7 @@ public class HashtagLoader extends AsyncExecutor<HashtagLoader.Param, HashtagLoa
// fall through
case Param.POPULAR_ONLINE:
hashtags = connection.getTrends();
hashtags = connection.getHashtags();
db.saveTrends(hashtags);
return new Result(Result.POPULAR, hashtags, param.index, null);

View File

@ -145,7 +145,7 @@ public class UserUpdate implements Closeable {
/**
* @return true if user's status should be marked as sensitive by default
*/
public boolean getContentSensitive() {
public boolean isSensitive() {
return sensitiveContent;
}

View File

@ -372,6 +372,10 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, Asy
private void setCredentials() {
if (credentials != null) {
privacy.setChecked(credentials.isLocked());
userUpdate.setPrivacy(credentials.isLocked());
userUpdate.setLanguageCode(credentials.getLanguage());
userUpdate.setStatusVisibility(credentials.getVisibility());
userUpdate.setContentSensitive(credentials.isSensitive());
}
}
}

View File

@ -20,6 +20,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.viewpager2.widget.ViewPager2;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.backend.api.ConnectionException;
import org.nuclearfog.twidda.backend.async.AsyncExecutor.AsyncCallback;
import org.nuclearfog.twidda.backend.async.HashtagAction;
import org.nuclearfog.twidda.backend.async.HashtagAction.Param;
@ -96,7 +97,7 @@ public class SearchActivity extends AppCompatActivity implements OnClickListener
search = hashtag.getName();
} else if (query != null) {
search = query;
if (search.startsWith("#") && search.matches("\\S+")) {
if (search.matches("^#\\S+") && !search.matches("^#\\d+")) {
Param param = new Param(Param.LOAD, search);
hashtagAction.execute(param, this);
}
@ -271,7 +272,8 @@ public class SearchActivity extends AppCompatActivity implements OnClickListener
break;
case Result.ERROR:
ErrorUtils.showErrorMessage(this, result.exception);
if (result.exception == null || result.exception.getErrorCode() != ConnectionException.HTTP_FORBIDDEN)
ErrorUtils.showErrorMessage(this, result.exception);
break;
}
}

View File

@ -168,7 +168,7 @@ public class StatusPreferenceDialog extends Dialog implements OnCheckedChangeLis
} else if (userUpdate.getStatusVisibility() == Status.VISIBLE_UNLISTED) {
visibilitySelector.setSelection(3, false);
}
sensitiveCheck.setCheckedImmediately(userUpdate.getContentSensitive());
sensitiveCheck.setCheckedImmediately(userUpdate.isSensitive());
if (!userUpdate.getLanguageCode().isEmpty()) {
for (int i = 0; i < languageCodes.length; i++) {
if (languageCodes[i].equals(userUpdate.getLanguageCode())) {