mirror of
https://github.com/nuclearfog/Shitter.git
synced 2024-12-27 10:03:44 +01:00
version upgrade, bug fix
This commit is contained in:
parent
dba43be464
commit
104e9515ea
@ -11,8 +11,8 @@ android {
|
||||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 85
|
||||
versionName '3.1.5'
|
||||
versionCode 86
|
||||
versionName '3.1.6'
|
||||
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
||||
}
|
||||
|
||||
|
@ -281,6 +281,13 @@ public interface Connection {
|
||||
*/
|
||||
Trends showHashtagFollowing(long cursor) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* show information of a single hashtag
|
||||
* @param name hashtag name
|
||||
* @return hashtag information
|
||||
*/
|
||||
Trend showHashtag(String name) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* follow hashtag by name
|
||||
*
|
||||
|
@ -456,6 +456,18 @@ public class Mastodon implements Connection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Trend showHashtag(String name) throws ConnectionException {
|
||||
try {
|
||||
if (name.startsWith("#"))
|
||||
name = name.substring(1);
|
||||
return createTrend(get(ENDPOINT_HASHTAG_GET + StringUtils.encode(name), new ArrayList<>()));
|
||||
} catch (IOException e) {
|
||||
throw new MastodonException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Trend followHashtag(String name) throws ConnectionException {
|
||||
try {
|
||||
|
@ -574,6 +574,12 @@ public class TwitterV1 implements Connection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Trend showHashtag(String name) throws ConnectionException {
|
||||
throw new TwitterException("not supported!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Trend followHashtag(String name) throws ConnectionException {
|
||||
throw new TwitterException("not supported!");
|
||||
|
@ -31,8 +31,12 @@ public class HashtagAction extends AsyncExecutor<HashtagAction.HashtagParam, Has
|
||||
protected HashtagResult doInBackground(@NonNull HashtagParam param) {
|
||||
try {
|
||||
switch (param.mode) {
|
||||
case HashtagParam.LOAD:
|
||||
Trend result = connection.showHashtag(param.name);
|
||||
return new HashtagResult(HashtagResult.LOAD, result, null);
|
||||
|
||||
case HashtagParam.FOLLOW:
|
||||
Trend result = connection.followHashtag(param.name);
|
||||
result = connection.followHashtag(param.name);
|
||||
return new HashtagResult(HashtagResult.FOLLOW, result, null);
|
||||
|
||||
case HashtagParam.UNFOLLOW:
|
||||
@ -52,8 +56,9 @@ public class HashtagAction extends AsyncExecutor<HashtagAction.HashtagParam, Has
|
||||
*/
|
||||
public static class HashtagParam {
|
||||
|
||||
public static final int FOLLOW = 1;
|
||||
public static final int UNFOLLOW = 2;
|
||||
public static final int LOAD = 1;
|
||||
public static final int FOLLOW = 2;
|
||||
public static final int UNFOLLOW = 3;
|
||||
|
||||
final String name;
|
||||
final int mode;
|
||||
@ -70,8 +75,9 @@ public class HashtagAction extends AsyncExecutor<HashtagAction.HashtagParam, Has
|
||||
public static class HashtagResult {
|
||||
|
||||
public static final int ERROR = -1;
|
||||
public static final int FOLLOW = 3;
|
||||
public static final int UNFOLLOW = 4;
|
||||
public static final int LOAD = 4;
|
||||
public static final int FOLLOW = 5;
|
||||
public static final int UNFOLLOW = 6;
|
||||
|
||||
@Nullable
|
||||
public final ConnectionException exception;
|
||||
|
@ -101,6 +101,10 @@ public class SearchActivity extends AppCompatActivity implements OnTabSelectedLi
|
||||
search = trend.getName();
|
||||
} else if (query != null) {
|
||||
search = query;
|
||||
if (search.startsWith("#") && search.matches("\\S+")) {
|
||||
HashtagParam param = new HashtagParam(search, HashtagParam.LOAD);
|
||||
hashtagAction.execute(param, this);
|
||||
}
|
||||
}
|
||||
boolean enableHashtags = !search.startsWith("#") && settings.getLogin().getConfiguration() == Configuration.MASTODON;
|
||||
adapter.setupSearchPage(search, enableHashtags);
|
||||
@ -143,8 +147,9 @@ public class SearchActivity extends AppCompatActivity implements OnTabSelectedLi
|
||||
searchFilter.setVisible(enableSearchFilter);
|
||||
searchFilter.setChecked(settings.filterResults() & enableSearchFilter);
|
||||
searchView.setQueryHint(search);
|
||||
hashtag.setVisible(trend != null);
|
||||
|
||||
if (trend != null && trend.getName().startsWith("#")) {
|
||||
hashtag.setVisible(true);
|
||||
}
|
||||
// set theme
|
||||
AppStyles.setTheme(searchView, Color.TRANSPARENT);
|
||||
AppStyles.setMenuIconColor(menu, settings.getIconColor());
|
||||
@ -158,6 +163,7 @@ public class SearchActivity extends AppCompatActivity implements OnTabSelectedLi
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem hashtag = menu.findItem(R.id.search_hashtag);
|
||||
// set menu option depending on trend follow status
|
||||
if (trend != null) {
|
||||
if (trend.following()) {
|
||||
hashtag.setTitle(R.string.menu_hashtag_unfollow);
|
||||
@ -236,17 +242,17 @@ public class SearchActivity extends AppCompatActivity implements OnTabSelectedLi
|
||||
|
||||
@Override
|
||||
public void onResult(@NonNull HashtagResult result) {
|
||||
if (result.trend != null)
|
||||
if (result.trend != null) {
|
||||
this.trend = result.trend;
|
||||
invalidateMenu();
|
||||
}
|
||||
switch(result.mode) {
|
||||
case HashtagResult.FOLLOW:
|
||||
Toast.makeText(getApplicationContext(), R.string.info_hashtag_followed, Toast.LENGTH_SHORT).show();
|
||||
invalidateMenu();
|
||||
break;
|
||||
|
||||
case HashtagResult.UNFOLLOW:
|
||||
Toast.makeText(getApplicationContext(), R.string.info_hashtag_unfollowed, Toast.LENGTH_SHORT).show();
|
||||
invalidateMenu();
|
||||
break;
|
||||
|
||||
case HashtagResult.ERROR:
|
||||
|
@ -1,9 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
wrapper {
|
||||
gradleVersion = '7.6' //version required
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
1
gradle/wrapper/gradle-wrapper.properties
vendored
1
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
# note: run 'gradle wrapper' after upgrading gradle version
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
Loading…
Reference in New Issue
Block a user