version upgrade, bug fix
This commit is contained in:
parent
883bd8246f
commit
d902704c09
|
@ -11,8 +11,8 @@ android {
|
|||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 87
|
||||
versionName '3.2'
|
||||
versionCode 88
|
||||
versionName '3.2.1'
|
||||
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package org.nuclearfog.twidda;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.os.Build;
|
||||
|
||||
import org.nuclearfog.twidda.backend.image.ImageCache;
|
||||
import org.nuclearfog.twidda.backend.image.PicassoBuilder;
|
||||
import org.nuclearfog.twidda.config.GlobalSettings;
|
||||
import org.nuclearfog.twidda.notification.PushNotification;
|
||||
import org.nuclearfog.twidda.notification.PushSubscription;
|
||||
|
||||
/**
|
||||
|
@ -24,12 +20,6 @@ public class ClientApplication extends Application {
|
|||
super.onCreate();
|
||||
// setup push receiver
|
||||
settings = GlobalSettings.getInstance(getApplicationContext());
|
||||
// setup notification channel
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||
NotificationChannel channel = new NotificationChannel(PushNotification.NOTIFICATION_ID_STR, PushNotification.NOTIFICATION_NAME, NotificationManager.IMPORTANCE_HIGH);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
if (settings.isLoggedIn() && settings.pushEnabled()) {
|
||||
PushSubscription.subscripe(getApplicationContext());
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class MastodonStatus implements Status {
|
|||
jsoupDoc.select("p").before("\\n");
|
||||
String str = jsoupDoc.html().replace("\\n", "\n");
|
||||
text = Jsoup.clean(str, "", Safelist.none(), OUTPUT_SETTINGS);
|
||||
text = text.replace("<", "<").replace(">", ">").replace("&", "&");
|
||||
text = text.replace("<", "<").replace(">", ">").replace("&", "&").replace(" ", "\u00A0");
|
||||
if (text.startsWith("\n")) {
|
||||
text = text.substring(1);
|
||||
}
|
||||
|
|
|
@ -27,11 +27,6 @@ public enum Configuration {
|
|||
*/
|
||||
MASTODON(Account.API_MASTODON);
|
||||
|
||||
/**
|
||||
* fallback configuration to use when there is no network selected
|
||||
*/
|
||||
public static final Configuration FALLBACK_CONFIG = MASTODON;
|
||||
|
||||
private final String name;
|
||||
private final int accountType;
|
||||
private final boolean userlistExtended;
|
||||
|
@ -73,7 +68,7 @@ public enum Configuration {
|
|||
emojiSupported = false;
|
||||
statusEditSupported = false;
|
||||
webpushSupported = false;
|
||||
arrayResHome = R.array.home_twitter_icons;
|
||||
arrayResHome = R.array.home_twitter_tab_icons;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -93,7 +88,7 @@ public enum Configuration {
|
|||
emojiSupported = true;
|
||||
statusEditSupported = true;
|
||||
webpushSupported = true;
|
||||
arrayResHome = R.array.home_mastodon_icons;
|
||||
arrayResHome = R.array.home_mastodon_tab_icons;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ConfigAccount implements Account {
|
|||
|
||||
private long id;
|
||||
private long timestamp;
|
||||
private int type;
|
||||
private int apiType;
|
||||
private String oauthToken, tokenSecret, bearerToken;
|
||||
private String consumerToken, consumerSecret, hostname;
|
||||
|
||||
|
@ -36,15 +36,15 @@ public class ConfigAccount implements Account {
|
|||
|
||||
switch (account.getConfiguration()) {
|
||||
case TWITTER1:
|
||||
type = API_TWITTER_1;
|
||||
apiType = API_TWITTER_1;
|
||||
break;
|
||||
|
||||
case TWITTER2:
|
||||
type = API_TWITTER_2;
|
||||
apiType = API_TWITTER_2;
|
||||
break;
|
||||
|
||||
case MASTODON:
|
||||
type = API_MASTODON;
|
||||
apiType = API_MASTODON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class ConfigAccount implements Account {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public ConfigAccount(long id, String oauthToken, String tokenSecret, String consumerToken, String consumerSecret, String bearerToken, String hostname, int type) {
|
||||
public ConfigAccount(long id, String oauthToken, String tokenSecret, String consumerToken, String consumerSecret, String bearerToken, String hostname, int apiType) {
|
||||
this.id = id;
|
||||
this.oauthToken = oauthToken;
|
||||
this.tokenSecret = tokenSecret;
|
||||
|
@ -60,7 +60,7 @@ public class ConfigAccount implements Account {
|
|||
this.consumerSecret = consumerSecret;
|
||||
this.bearerToken = bearerToken;
|
||||
this.hostname = hostname;
|
||||
this.type = type;
|
||||
this.apiType = apiType;
|
||||
timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class ConfigAccount implements Account {
|
|||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
switch (type) {
|
||||
switch (apiType) {
|
||||
case API_TWITTER_1:
|
||||
return Configuration.TWITTER1;
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class ConfigAccount implements Account {
|
|||
return Configuration.MASTODON;
|
||||
|
||||
default:
|
||||
return Configuration.FALLBACK_CONFIG;
|
||||
throw new RuntimeException("wrong API type: " + apiType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class DatabaseAccount implements Account, AccountTable {
|
|||
return Configuration.MASTODON;
|
||||
|
||||
default:
|
||||
return Configuration.FALLBACK_CONFIG;
|
||||
throw new RuntimeException("wrong API type: " + apiType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.nuclearfog.twidda.notification;
|
|||
|
||||
import static android.Manifest.permission.POST_NOTIFICATIONS;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -39,10 +41,16 @@ public class PushNotification {
|
|||
*
|
||||
*/
|
||||
public PushNotification(Context context) {
|
||||
this.context = context;
|
||||
notificationManager = NotificationManagerCompat.from(context);
|
||||
notificationBuilder = new NotificationCompat.Builder(context, NOTIFICATION_ID_STR);
|
||||
settings = GlobalSettings.getInstance(context);
|
||||
this.context = context;
|
||||
// setup notification channel
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager manager = context.getSystemService(NotificationManager.class);
|
||||
NotificationChannel channel = new NotificationChannel(PushNotification.NOTIFICATION_ID_STR, PushNotification.NOTIFICATION_NAME, NotificationManager.IMPORTANCE_HIGH);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
// Open MainActivity and select notification tab, if notification view is clicked
|
||||
Intent notificationIntent = new Intent(context.getApplicationContext(), MainActivity.class);
|
||||
notificationIntent.putExtra(MainActivity.KEY_SELECT_NOTIFICATION, true);
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PushNotificationReceiver extends MessagingReceiver implements Async
|
|||
@Override
|
||||
public void onMessage(@NonNull Context context, @NonNull byte[] message, @NonNull String instance) {
|
||||
GlobalSettings settings = GlobalSettings.getInstance(context);
|
||||
if (settings.pushEnabled()) {
|
||||
if (settings.isLoggedIn() && settings.getLogin().getConfiguration().isWebpushSupported() && settings.pushEnabled()) {
|
||||
NotificationLoader loader = new NotificationLoader(context);
|
||||
NotificationLoaderParam param = new NotificationLoaderParam(NotificationLoaderParam.LOAD_UNREAD, 0, 0L, 0L);
|
||||
notificationManager = new PushNotification(context);
|
||||
|
|
|
@ -210,6 +210,10 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
|||
enableLocalTl.setVisibility(View.VISIBLE);
|
||||
trend_card.setVisibility(View.GONE);
|
||||
}
|
||||
if (!configuration.isWebpushSupported()) {
|
||||
push_label.setVisibility(View.GONE);
|
||||
enablePush.setVisibility(View.GONE);
|
||||
}
|
||||
if (!settings.isLoggedIn()) {
|
||||
user_card.setVisibility(View.GONE);
|
||||
push_label.setVisibility(View.GONE);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<integer-array name="home_twitter_icons">
|
||||
<integer-array name="home_twitter_tab_icons">
|
||||
<item>@drawable/home</item>
|
||||
<item>@drawable/hash</item>
|
||||
<item>@drawable/bell</item>
|
||||
<item>@drawable/message</item>
|
||||
</integer-array>
|
||||
|
||||
<integer-array name="home_mastodon_icons">
|
||||
<integer-array name="home_mastodon_tab_icons">
|
||||
<item>@drawable/home</item>
|
||||
<item>@drawable/hash</item>
|
||||
<item>@drawable/global</item>
|
||||
|
|
Loading…
Reference in New Issue