Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sk22 committed Nov 27, 2023
1 parent f7dfebc commit 93624a5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
11 changes: 0 additions & 11 deletions .github/FUNDING.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.joinmastodon.android.api.session.AccountLocalPreferences.ColorPreference;
import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.ContentType;
import org.joinmastodon.android.model.Instance;
import org.joinmastodon.android.model.TimelineDefinition;
Expand Down Expand Up @@ -66,6 +67,10 @@ private static SharedPreferences getPrefs(){
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
}

private static SharedPreferences getPreReplyPrefs(){
return MastodonApp.context.getSharedPreferences("pre_reply_sheets", Context.MODE_PRIVATE);
}

public static <T> T fromJson(String json, Type type, T orElse){
if(json==null) return orElse;
try{
Expand Down Expand Up @@ -182,12 +187,45 @@ public static void save(){
.apply();
}

public static boolean isOptedOutOfPreReplySheet(PreReplySheetType type, Account account, String accountID){
if(getPreReplyPrefs().getBoolean("opt_out_"+type, false))
return true;
if(account==null)
return false;
String accountKey=account.acct;
if(!accountKey.contains("@"))
accountKey+="@"+AccountSessionManager.get(accountID).domain;
return getPreReplyPrefs().getBoolean("opt_out_"+type+"_"+accountKey.toLowerCase(), false);
}

public static void optOutOfPreReplySheet(PreReplySheetType type, Account account, String accountID){
String key;
if(account==null){
key="opt_out_"+type;
}else{
String accountKey=account.acct;
if(!accountKey.contains("@"))
accountKey+="@"+AccountSessionManager.get(accountID).domain;
key="opt_out_"+type+"_"+accountKey.toLowerCase();
}
getPreReplyPrefs().edit().putBoolean(key, true).apply();
}

public static void resetPreReplySheets(){
getPreReplyPrefs().edit().clear().apply();
}

public enum ThemePreference{
AUTO,
LIGHT,
DARK
}

public enum PreReplySheetType{
OLD_POST,
NON_MUTUAL
}

public enum AutoRevealMode {
NEVER,
THREADS,
Expand Down
17 changes: 12 additions & 5 deletions mastodon/src/main/java/org/joinmastodon/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.BadParcelableException;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
Expand Down Expand Up @@ -91,8 +92,14 @@ else if (intent.getBooleanExtra("fromNotification", false)) {
return;
}
if(intent.hasExtra("notification")){
Notification notification=Parcels.unwrap(intent.getParcelableExtra("notification"));
showFragmentForNotification(notification, accountID);
// Parcelables might not be compatible across app versions so this protects against possible crashes
// when a notification was received, then the app was updated, and then the user opened the notification
try{
Notification notification=Parcels.unwrap(intent.getParcelableExtra("notification"));
showFragmentForNotification(notification, accountID);
}catch(BadParcelableException x){
Log.w(TAG, x);
}
}else{
AccountSessionManager.getInstance().setLastActiveAccountID(accountID);
Bundle args=new Bundle();
Expand Down Expand Up @@ -123,11 +130,11 @@ public void handleURL(Uri uri, String accountID){
session=AccountSessionManager.get(accountID);
if(session==null || !session.activated)
return;
openSearchQuery(uri.toString(), session.getID(), R.string.opening_link, false);
openSearchQuery(uri.toString(), session.getID(), R.string.opening_link, false, null);
}

public void openSearchQuery(String q, String accountID, int progressText, boolean fromSearch){
new GetSearchResults(q, null, true, null, 0, 0)
public void openSearchQuery(String q, String accountID, int progressText, boolean fromSearch, GetSearchResults.Type type){
new GetSearchResults(q, type, true, null, 0, 0)
.setCallback(new Callback<>(){
@Override
public void onSuccess(SearchResults result){
Expand Down

0 comments on commit 93624a5

Please sign in to comment.