@@ -38,6 +38,6 @@ For reporting issues, visit [Framagit](https://framagit.org/tom79/fedilab/issues | |||
<img src="./images/device-2019-02-02-114910.png" width="250"> | |||
Lead developer: [toot.fedilab.app/@fedilab](https://toot.fedilab.app/@fedilab) | |||
Lead developer: [toot.fedilab.app/@apps](https://toot.fedilab.app/@apps) | |||
@@ -162,6 +162,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt | |||
private ScheduledExecutorService scheduledExecutorService; | |||
private action doAction; | |||
private API.StatusAction doActionAccount; | |||
ImageButton account_notification; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
@@ -191,6 +192,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt | |||
account_dn = findViewById(R.id.account_dn); | |||
account_un = findViewById(R.id.account_un); | |||
account_bot = findViewById(R.id.account_bot); | |||
account_notification = findViewById(R.id.account_notification); | |||
addToList = null; | |||
account_pp.setBackgroundResource(R.drawable.account_pp_border); | |||
if (b != null) { | |||
@@ -740,11 +742,17 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt | |||
startActivity(intent); | |||
} | |||
}); | |||
//Follow button | |||
String target = account.getId(); | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) | |||
target = account.getAcct(); | |||
String finalTarget = target; | |||
account_notification.setOnClickListener(v -> { | |||
if (relationship != null) { | |||
new PostActionAsyncTask(ShowAccountActivity.this, relationship.isNotifying() ? API.StatusAction.UNNOTIFY_FOR_ACCOUNT : API.StatusAction.NOTIFY_FOR_ACCOUNT, finalTarget, ShowAccountActivity.this); | |||
} | |||
}); | |||
account_follow.setOnClickListener(v -> { | |||
if (doAction == action.NOTHING) { | |||
Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show(); | |||
@@ -951,6 +959,17 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt | |||
account_follow.setVisibility(View.GONE); | |||
doAction = action.NOTHING; | |||
} | |||
if (!relationship.isFollowing()) { | |||
account_notification.setVisibility(View.GONE); | |||
} else { | |||
account_notification.setVisibility(View.VISIBLE); | |||
} | |||
if (relationship.isNotifying()) { | |||
account_notification.setImageResource(R.drawable.ic_baseline_notifications_account_yes); | |||
} else { | |||
account_notification.setImageResource(R.drawable.ic_baseline_notifications_account_none); | |||
} | |||
} | |||
@Override | |||
@@ -1520,24 +1539,21 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt | |||
return displayStatusFragment; | |||
} | |||
case 1: | |||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); | |||
if (peertubeAccount) { | |||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); | |||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.CHANNELS); | |||
bundle.putString("targetedid", account.getId()); | |||
bundle.putString("instance", Helper.getLiveInstance(ShowAccountActivity.this)); | |||
bundle.putString("name", account.getAcct()); | |||
displayAccountsFragment.setArguments(bundle); | |||
return displayAccountsFragment; | |||
} else { | |||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); | |||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWING); | |||
bundle.putString("targetedid", account.getId()); | |||
displayAccountsFragment.setArguments(bundle); | |||
return displayAccountsFragment; | |||
} | |||
displayAccountsFragment.setArguments(bundle); | |||
return displayAccountsFragment; | |||
default: | |||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment(); | |||
displayAccountsFragment = new DisplayAccountsFragment(); | |||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWERS); | |||
bundle.putString("targetedid", account.getId()); | |||
displayAccountsFragment.setArguments(bundle); | |||
@@ -264,9 +264,11 @@ public class PostActionAsyncTask { | |||
statusCode = gnuapi.postAction(apiAction, targetedId); | |||
error = gnuapi.getError(); | |||
} | |||
Handler mainHandler = new Handler(Looper.getMainLooper()); | |||
Runnable myRunnable = () -> listener.onPostAction(statusCode, apiAction, targetedId, error); | |||
mainHandler.post(myRunnable); | |||
if (listener != null) { | |||
Handler mainHandler = new Handler(Looper.getMainLooper()); | |||
Runnable myRunnable = () -> listener.onPostAction(statusCode, apiAction, targetedId, error); | |||
mainHandler.post(myRunnable); | |||
} | |||
}).start(); | |||
} | |||
@@ -3642,7 +3642,7 @@ public class API { | |||
List<Status> tmp_status = parseStatuses(context, new JSONArray(response)); | |||
if (tmp_status.size() > 0) { | |||
for (Status status : tmp_status) { | |||
if (status.getAccount().getAcct().equals("fedilab")) { | |||
if (status.getAccount().getAcct().equals("apps")) { | |||
statuses.add(status); | |||
} | |||
} | |||
@@ -4274,6 +4274,16 @@ public class API { | |||
case FOLLOW: | |||
action = String.format("/accounts/%s/follow", targetedId); | |||
break; | |||
case NOTIFY_FOR_ACCOUNT: | |||
params = new HashMap<>(); | |||
params.put("notify", "true"); | |||
action = String.format("/accounts/%s/follow", targetedId); | |||
break; | |||
case UNNOTIFY_FOR_ACCOUNT: | |||
params = new HashMap<>(); | |||
params.put("notify", "false"); | |||
action = String.format("/accounts/%s/follow", targetedId); | |||
break; | |||
case REMOTE_FOLLOW: | |||
action = "/follows"; | |||
params = new HashMap<>(); | |||
@@ -4801,7 +4811,7 @@ public class API { | |||
return apiResponse; | |||
} | |||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); | |||
boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll; | |||
boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll, notif_status; | |||
StringBuilder parameters = new StringBuilder(); | |||
//TODO: If pixelfed supports exclude_types this condition needs to be changed | |||
if (type == DisplayNotificationsFragment.Type.ALL && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) { | |||
@@ -4811,12 +4821,14 @@ public class API { | |||
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true); | |||
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true); | |||
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL_FILTER, true); | |||
notif_status = sharedpreferences.getBoolean(Helper.SET_NOTIF_STATUS_FILTER, true); | |||
} else { | |||
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); | |||
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); | |||
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); | |||
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); | |||
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true); | |||
notif_status = sharedpreferences.getBoolean(Helper.SET_NOTIF_STATUS, true); | |||
} | |||
@@ -4828,6 +4840,8 @@ public class API { | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
if (!notif_share) | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
if (!notif_status) | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
if (!notif_mention) | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
if (!notif_poll) | |||
@@ -4841,6 +4855,7 @@ public class API { | |||
parameters.append("exclude_types[]=").append("follow_request").append("&"); | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
parameters.append("exclude_types[]=").append("poll").append("&"); | |||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); | |||
params.put("exclude_types[]", parameters.toString()); | |||
@@ -4848,6 +4863,7 @@ public class API { | |||
parameters.append("exclude_types[]=").append("follow").append("&"); | |||
parameters.append("exclude_types[]=").append("follow_request").append("&"); | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
parameters.append("exclude_types[]=").append("poll").append("&"); | |||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); | |||
@@ -4855,6 +4871,7 @@ public class API { | |||
} else if (type == DisplayNotificationsFragment.Type.BOOST) { | |||
parameters.append("exclude_types[]=").append("follow").append("&"); | |||
parameters.append("exclude_types[]=").append("follow_request").append("&"); | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
parameters.append("exclude_types[]=").append("poll").append("&"); | |||
@@ -4863,12 +4880,22 @@ public class API { | |||
} else if (type == DisplayNotificationsFragment.Type.POLL) { | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
parameters.append("exclude_types[]=").append("follow").append("&"); | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
parameters.append("exclude_types[]=").append("follow_request").append("&"); | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); | |||
params.put("exclude_types[]", parameters.toString()); | |||
} else if (type == DisplayNotificationsFragment.Type.FOLLOW) { | |||
parameters.append("exclude_types[]=").append("status").append("&"); | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
parameters.append("exclude_types[]=").append("poll").append("&"); | |||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); | |||
params.put("exclude_types[]", parameters.toString()); | |||
} else if (type == DisplayNotificationsFragment.Type.STATUS) { | |||
parameters.append("exclude_types[]=").append("follow").append("&"); | |||
parameters.append("exclude_types[]=").append("reblog").append("&"); | |||
parameters.append("exclude_types[]=").append("mention").append("&"); | |||
parameters.append("exclude_types[]=").append("favourite").append("&"); | |||
@@ -6081,6 +6108,17 @@ public class API { | |||
} catch (Exception ignored) { | |||
relationship.setBlocked_by(false); | |||
} | |||
try { | |||
relationship.setDomain_blocking(resobj.getBoolean("domain_blocking")); | |||
} catch (Exception ignored) { | |||
relationship.setDomain_blocking(false); | |||
} | |||
relationship.setNote(resobj.getString("note")); | |||
try { | |||
relationship.setNotifying(resobj.getBoolean("notifying")); | |||
} catch (Exception ignored) { | |||
relationship.setNotifying(false); | |||
} | |||
relationship.setRequested(resobj.getBoolean("requested")); | |||
} catch (JSONException e) { | |||
setDefaultError(e); | |||
@@ -6257,6 +6295,8 @@ public class API { | |||
UNBLOCK, | |||
FOLLOW, | |||
UNFOLLOW, | |||
NOTIFY_FOR_ACCOUNT, | |||
UNNOTIFY_FOR_ACCOUNT, | |||
CREATESTATUS, | |||
UNSTATUS, | |||
AUTHORIZE, | |||
@@ -76,7 +76,7 @@ public class ManageTimelines { | |||
private String currentFilter; | |||
private boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll; | |||
private boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll, notif_status; | |||
public static Type typeFromDb(String value) { | |||
switch (value) { | |||
@@ -387,18 +387,21 @@ public class ManageTimelines { | |||
final MenuItem itemMention = menu.findItem(R.id.action_mention); | |||
final MenuItem itemBoost = menu.findItem(R.id.action_boost); | |||
final MenuItem itemPoll = menu.findItem(R.id.action_poll); | |||
final MenuItem itemStatus = menu.findItem(R.id.action_status); | |||
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, true); | |||
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true); | |||
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true); | |||
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true); | |||
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL_FILTER, true); | |||
notif_status = sharedpreferences.getBoolean(Helper.SET_NOTIF_STATUS_FILTER, true); | |||
itemFavourite.setChecked(notif_add); | |||
itemFollow.setChecked(notif_follow); | |||
itemMention.setChecked(notif_mention); | |||
itemBoost.setChecked(notif_share); | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) { | |||
itemPoll.setChecked(notif_poll); | |||
else | |||
itemStatus.setChecked(notif_status); | |||
} else | |||
itemPoll.setVisible(false); | |||
popup.setOnDismissListener(menu1 -> { | |||
@@ -423,42 +426,48 @@ public class ManageTimelines { | |||
return false; | |||
} | |||
}); | |||
switch (item.getItemId()) { | |||
case R.id.action_favorite: | |||
SharedPreferences.Editor editor = sharedpreferences.edit(); | |||
notif_add = !notif_add; | |||
editor.putBoolean(Helper.SET_NOTIF_ADD_FILTER, notif_add); | |||
itemFavourite.setChecked(notif_add); | |||
editor.apply(); | |||
break; | |||
case R.id.action_follow: | |||
editor = sharedpreferences.edit(); | |||
notif_follow = !notif_follow; | |||
editor.putBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, notif_follow); | |||
itemFollow.setChecked(notif_follow); | |||
editor.apply(); | |||
break; | |||
case R.id.action_mention: | |||
editor = sharedpreferences.edit(); | |||
notif_mention = !notif_mention; | |||
editor.putBoolean(Helper.SET_NOTIF_MENTION_FILTER, notif_mention); | |||
itemMention.setChecked(notif_mention); | |||
editor.apply(); | |||
break; | |||
case R.id.action_boost: | |||
editor = sharedpreferences.edit(); | |||
notif_share = !notif_share; | |||
editor.putBoolean(Helper.SET_NOTIF_SHARE_FILTER, notif_share); | |||
itemBoost.setChecked(notif_share); | |||
editor.apply(); | |||
break; | |||
case R.id.action_poll: | |||
editor = sharedpreferences.edit(); | |||
notif_poll = !notif_poll; | |||
editor.putBoolean(Helper.SET_NOTIF_POLL_FILTER, notif_poll); | |||
itemPoll.setChecked(notif_poll); | |||
editor.apply(); | |||
break; | |||
int itemId = item.getItemId(); | |||
if (itemId == R.id.action_favorite) { | |||
SharedPreferences.Editor editor = sharedpreferences.edit(); | |||
notif_add = !notif_add; | |||
editor.putBoolean(Helper.SET_NOTIF_ADD_FILTER, notif_add); | |||
itemFavourite.setChecked(notif_add); | |||
editor.apply(); | |||
} else if (itemId == R.id.action_follow) { | |||
SharedPreferences.Editor editor; | |||
editor = sharedpreferences.edit(); | |||
notif_follow = !notif_follow; | |||
editor.putBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, notif_follow); | |||
itemFollow.setChecked(notif_follow); | |||
editor.apply(); | |||
} else if (itemId == R.id.action_mention) { | |||
SharedPreferences.Editor editor; | |||
editor = sharedpreferences.edit(); | |||
notif_mention = !notif_mention; | |||
editor.putBoolean(Helper.SET_NOTIF_MENTION_FILTER, notif_mention); | |||
itemMention.setChecked(notif_mention); | |||
editor.apply(); | |||
} else if (itemId == R.id.action_boost) { | |||
SharedPreferences.Editor editor; | |||
editor = sharedpreferences.edit(); | |||
notif_share = !notif_share; | |||
editor.putBoolean(Helper.SET_NOTIF_SHARE_FILTER, notif_share); | |||
itemBoost.setChecked(notif_share); | |||
editor.apply(); | |||
} else if (itemId == R.id.action_poll) { | |||
SharedPreferences.Editor editor; | |||
editor = sharedpreferences.edit(); | |||
notif_poll = !notif_poll; | |||
editor.putBoolean(Helper.SET_NOTIF_POLL_FILTER, notif_poll); | |||
itemPoll.setChecked(notif_poll); | |||
editor.apply(); | |||
} else if (itemId == R.id.action_status) { | |||
SharedPreferences.Editor editor; | |||
editor = sharedpreferences.edit(); | |||
notif_status = !notif_status; | |||
editor.putBoolean(Helper.SET_NOTIF_STATUS_FILTER, notif_status); | |||
itemStatus.setChecked(notif_status); | |||
editor.apply(); | |||
} | |||
return false; | |||
}); | |||
@@ -25,12 +25,15 @@ public class Relationship { | |||
private boolean following; | |||
private boolean followed_by; | |||
private boolean blocking; | |||
private boolean domain_blocking; | |||
private boolean muting; | |||
private boolean requested; | |||
private boolean muting_notifications; | |||
private boolean endorsed; | |||
private boolean showing_reblogs; | |||
private boolean blocked_by; | |||
private String note; | |||
private boolean notifying; | |||
public String getId() { | |||
@@ -112,4 +115,28 @@ public class Relationship { | |||
public void setBlocked_by(boolean blocked_by) { | |||
this.blocked_by = blocked_by; | |||
} | |||
public boolean isDomain_blocking() { | |||
return domain_blocking; | |||
} | |||
public void setDomain_blocking(boolean domain_blocking) { | |||
this.domain_blocking = domain_blocking; | |||
} | |||
public String getNote() { | |||
return note; | |||
} | |||
public void setNote(String note) { | |||
this.note = note; | |||
} | |||
public boolean isNotifying() { | |||
return notifying; | |||
} | |||
public void setNotifying(boolean notifying) { | |||
this.notifying = notifying; | |||
} | |||
} |
@@ -607,6 +607,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); | |||
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); | |||
boolean notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true); | |||
boolean notif_status = sharedpreferences.getBoolean(Helper.SET_NOTIF_STATUS, true); | |||
boolean notif_wifi = sharedpreferences.getBoolean(Helper.SET_WIFI_ONLY, false); | |||
boolean notif_silent = sharedpreferences.getBoolean(Helper.SET_NOTIF_SILENT, false); | |||
@@ -621,7 +622,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
final SwitchCompat set_notif_follow_mention = rootView.findViewById(R.id.set_notif_follow_mention); | |||
final SwitchCompat set_notif_follow_share = rootView.findViewById(R.id.set_notif_follow_share); | |||
final SwitchCompat set_notif_follow_poll = rootView.findViewById(R.id.set_notif_follow_poll); | |||
final SwitchCompat set_notif_status = rootView.findViewById(R.id.set_notif_status); | |||
final SwitchCompat switchCompatWIFI = rootView.findViewById(R.id.set_wifi_only); | |||
final SwitchCompat switchCompatSilent = rootView.findViewById(R.id.set_silence); | |||
@@ -637,6 +638,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
final Button sound_poll = rootView.findViewById(R.id.sound_poll); | |||
final Button sound_backup = rootView.findViewById(R.id.sound_backup); | |||
final Button sound_media = rootView.findViewById(R.id.sound_media); | |||
final Button sound_status = rootView.findViewById(R.id.sound_status); | |||
final ImageButton set_hide_status_bar = rootView.findViewById(R.id.set_hide_status_bar); | |||
Button set_notif_sound = rootView.findViewById(R.id.set_notif_sound); | |||
@@ -703,6 +706,12 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, "channel_store"); | |||
startActivity(intent); | |||
}); | |||
sound_status.setOnClickListener(v -> { | |||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS); | |||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName()); | |||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, "channel_status"); | |||
startActivity(intent); | |||
}); | |||
} else { | |||
set_notif_sound.setVisibility(View.VISIBLE); | |||
channels_container.setVisibility(View.GONE); | |||
@@ -817,7 +826,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
set_notif_follow_mention.setChecked(notif_mention); | |||
set_notif_follow_share.setChecked(notif_share); | |||
set_notif_follow_poll.setChecked(notif_poll); | |||
set_notif_status.setChecked(notif_status); | |||
switchCompatWIFI.setChecked(notif_wifi); | |||
switchCompatSilent.setChecked(notif_silent); | |||
@@ -848,7 +857,11 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
editor.putBoolean(Helper.SET_NOTIF_POLL, set_notif_follow_poll.isChecked()); | |||
editor.apply(); | |||
}); | |||
set_notif_status.setOnClickListener(v -> { | |||
SharedPreferences.Editor editor = sharedpreferences.edit(); | |||
editor.putBoolean(Helper.SET_NOTIF_STATUS, set_notif_status.isChecked()); | |||
editor.apply(); | |||
}); | |||
switchCompatWIFI.setOnCheckedChangeListener((buttonView, isChecked) -> { | |||
// Save the state here | |||
@@ -2112,7 +2125,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot | |||
update_tracking_domains.setOnClickListener(v -> { | |||
update_tracking_domains.setEnabled(false); | |||
Intent scriptIntent = new Intent(context, DownloadTrackingDBScriptsService.class); | |||
((Activity) context).startService(scriptIntent); | |||
context.startService(scriptIntent); | |||
} | |||
); | |||
@@ -501,6 +501,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve | |||
MENTION, | |||
FAVORITE, | |||
BOOST, | |||
STATUS, | |||
POLL, | |||
FOLLOW | |||
} | |||
@@ -33,6 +33,8 @@ import androidx.viewpager.widget.ViewPager; | |||
import com.google.android.material.tabs.TabLayout; | |||
import org.jetbrains.annotations.NotNull; | |||
import java.util.Objects; | |||
import app.fedilab.android.R; | |||
@@ -67,6 +69,7 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
TabLayout.Tab tabMention = tabLayout.newTab(); | |||
TabLayout.Tab tabFav = tabLayout.newTab(); | |||
TabLayout.Tab tabBoost = tabLayout.newTab(); | |||
TabLayout.Tab tabStatus = tabLayout.newTab(); | |||
TabLayout.Tab tabPoll = tabLayout.newTab(); | |||
TabLayout.Tab tabFollow = tabLayout.newTab(); | |||
@@ -75,8 +78,10 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
tabFav.setCustomView(R.layout.tab_badge); | |||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) | |||
tabBoost.setCustomView(R.layout.tab_badge); | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) { | |||
tabPoll.setCustomView(R.layout.tab_badge); | |||
tabStatus.setCustomView(R.layout.tab_badge); | |||
} | |||
tabFollow.setCustomView(R.layout.tab_badge); | |||
@@ -100,13 +105,19 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
iconBoost.setImageResource(R.drawable.ic_repeat_notif_tab); | |||
} | |||
ImageView iconStatus = null; | |||
if (tabStatus.getCustomView() != null) { | |||
iconStatus = tabStatus.getCustomView().findViewById(R.id.tab_icon); | |||
iconStatus.setImageResource(R.drawable.ic_baseline_home_notif); | |||
} | |||
ImageView iconPoll = null; | |||
if (tabPoll.getCustomView() != null) { | |||
iconPoll = tabPoll.getCustomView().findViewById(R.id.tab_icon); | |||
iconPoll.setImageResource(R.drawable.ic_view_list_poll_notif); | |||
} | |||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") | |||
@SuppressLint("CutPasteId") | |||
ImageView iconFollow = tabFollow.getCustomView().findViewById(R.id.tab_icon); | |||
iconFollow.setImageResource(R.drawable.ic_follow_notif_tab); | |||
@@ -118,6 +129,8 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
tabLayout.addTab(tabBoost); | |||
if (tabPoll.getCustomView() != null) | |||
tabLayout.addTab(tabPoll); | |||
if (tabStatus.getCustomView() != null) | |||
tabLayout.addTab(tabStatus); | |||
tabLayout.addTab(tabFollow); | |||
if (theme == Helper.THEME_BLACK) | |||
@@ -133,6 +146,8 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
iconBoost.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); | |||
if (iconPoll != null) | |||
iconPoll.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); | |||
if (iconStatus != null) | |||
iconStatus.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); | |||
iconFollow.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); | |||
} else { | |||
iconMention.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); | |||
@@ -142,14 +157,15 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
iconBoost.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); | |||
if (iconPoll != null) | |||
iconPoll.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); | |||
if (iconStatus != null) | |||
iconStatus.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); | |||
iconFollow.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); | |||
} | |||
viewPager = inflatedView.findViewById(R.id.viewpager); | |||
viewPager.setEnableSwipe(false); | |||
viewPager.setAdapter(new PagerAdapter | |||
(getChildFragmentManager(), tabLayout.getTabCount())); | |||
viewPager.setAdapter(new PagerAdapter(getChildFragmentManager(), tabLayout.getTabCount())); | |||
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); | |||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { | |||
@Override | |||
@@ -206,7 +222,7 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
/** | |||
* Page Adapter for settings | |||
*/ | |||
private class PagerAdapter extends FragmentStatePagerAdapter { | |||
private static class PagerAdapter extends FragmentStatePagerAdapter { | |||
int mNumOfTabs; | |||
private PagerAdapter(FragmentManager fm, int NumOfTabs) { | |||
@@ -215,7 +231,7 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
} | |||
@Override | |||
public Fragment getItem(int position) { | |||
public @NotNull Fragment getItem(int position) { | |||
DisplayNotificationsFragment displayNotificationsFragment = new DisplayNotificationsFragment(); | |||
DisplayNotificationsFragment.Type type = null; | |||
String tag = ""; | |||
@@ -244,12 +260,15 @@ public class TabLayoutNotificationsFragment extends Fragment { | |||
type = DisplayNotificationsFragment.Type.BOOST; | |||
break; | |||
case 4: | |||
type = DisplayNotificationsFragment.Type.STATUS; | |||
break; | |||
case 5: | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) | |||
type = DisplayNotificationsFragment.Type.POLL; | |||
else | |||
type = DisplayNotificationsFragment.Type.FOLLOW; | |||
break; | |||
case 5: | |||
case 6: | |||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) | |||
type = DisplayNotificationsFragment.Type.FOLLOW; | |||
default: | |||
@@ -426,11 +426,13 @@ public class BaseHelper { | |||
public static final String SET_NOTIF_MENTION = "set_notif_follow_mention"; | |||
public static final String SET_NOTIF_SHARE = "set_notif_follow_share"; | |||
public static final String SET_NOTIF_POLL = "set_notif_follow_poll"; | |||
public static final String SET_NOTIF_STATUS = "set_notif_follow_status"; | |||
public static final String SET_NOTIF_FOLLOW_FILTER = "set_notif_follow_filter"; | |||
public static final String SET_NOTIF_ADD_FILTER = "set_notif_follow_add_filter"; | |||
public static final String SET_NOTIF_MENTION_FILTER = "set_notif_follow_mention_filter"; | |||
public static final String SET_NOTIF_SHARE_FILTER = "set_notif_follow_share_filter"; | |||
public static final String SET_NOTIF_POLL_FILTER = "set_notif_follow_poll_filter"; | |||
public static final String SET_NOTIF_STATUS_FILTER = "set_notif_follow_status_filter"; | |||
public static final String SET_FILTER_REGEX_HOME = "set_filter_regex_home"; | |||
public static final String SET_FILTER_REGEX_LOCAL = "set_filter_regex_local"; | |||
public static final String SET_FILTER_REGEX_PUBLIC = "set_filter_regex_public"; | |||
@@ -4482,6 +4484,7 @@ public class BaseHelper { | |||
BOOST, | |||
FAV, | |||
POLL, | |||
STATUS, | |||
BACKUP, | |||
STORE, | |||
TOOT | |||
@@ -56,8 +56,6 @@ import com.koushikdutta.async.http.WebSocket; | |||
import org.json.JSONException; | |||
import org.json.JSONObject; | |||
import java.security.KeyManagementException; | |||
import java.security.NoSuchAlgorithmException; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Objects; | |||
@@ -67,7 +65,6 @@ import app.fedilab.android.activities.MainActivity; | |||
import app.fedilab.android.client.API; | |||
import app.fedilab.android.client.Entities.Account; | |||
import app.fedilab.android.client.Entities.Notification; | |||
import app.fedilab.android.client.TLSSocketFactory; | |||
import app.fedilab.android.helper.Helper; | |||
import app.fedilab.android.sqlite.AccountDAO; | |||
import app.fedilab.android.sqlite.Sqlite; | |||
@@ -231,14 +228,6 @@ public abstract class BaseLiveNotificationService extends Service implements Net | |||
String urlKey = "wss://" + account.getInstance() + "/api/v1/streaming/?stream=" + notif_url + "&access_token=" + account.getToken(); | |||
Uri url = Uri.parse(urlKey); | |||
AsyncHttpRequest.setDefaultHeaders(headers, url); | |||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { | |||
try { | |||
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(account.getInstance()).getSSLContext()); | |||
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true); | |||
} catch (KeyManagementException | NoSuchAlgorithmException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
String key = account.getAcct() + "@" + account.getInstance(); | |||
if (webSocketFutures.get(key) == null || !Objects.requireNonNull(webSocketFutures.get(key)).isOpen()) { | |||
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream=" + notif_url + "&access_token=" + account.getToken(), "wss", (ex, webSocket) -> { | |||
@@ -382,6 +371,30 @@ public abstract class BaseLiveNotificationService extends Service implements Net | |||
canSendBroadCast = false; | |||
} | |||
break; | |||
case "status": | |||
notifType = Helper.NotifType.STATUS; | |||
if (notif_mention) { | |||
if (notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0) | |||
message = String.format("%s %s", notification.getAccount().getDisplay_name(), getString(R.string.notif_status)); | |||
else | |||
message = String.format("@%s %s", notification.getAccount().getAcct(), getString(R.string.notif_status)); | |||
if (notification.getStatus() != null) { | |||
if (notification.getStatus().getSpoiler_text() != null && notification.getStatus().getSpoiler_text().length() > 0) { | |||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) | |||
message = "\n" + new SpannableString(Html.fromHtml(notification.getStatus().getSpoiler_text(), FROM_HTML_MODE_LEGACY)); | |||
else | |||
message = "\n" + new SpannableString(Html.fromHtml(notification.getStatus().getSpoiler_text())); | |||
} else { | |||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) | |||
message = "\n" + new SpannableString(Html.fromHtml(notification.getStatus().getContent(), FROM_HTML_MODE_LEGACY)); | |||
else | |||
message = "\n" + new SpannableString(Html.fromHtml(notification.getStatus().getContent())); | |||
} | |||
} | |||
} else { | |||
canSendBroadCast = false; | |||
} | |||
break; | |||
case "reblog": | |||
notifType = Helper.NotifType.BOOST; | |||
if (notif_share) { | |||
@@ -77,6 +77,7 @@ | |||
android:layout_height="45dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginTop="10dp" | |||
android:contentDescription="@string/make_an_action" | |||
android:scaleType="fitCenter" | |||
android:visibility="gone" | |||
app:layout_constraintStart_toEndOf="@id/account_pp" | |||
@@ -90,6 +91,7 @@ | |||
android:layout_marginStart="10dp" | |||
android:layout_marginTop="10dp" | |||
android:scaleType="fitCenter" | |||
android:contentDescription="@string/edit_profile" | |||
android:src="@drawable/ic_edit" | |||
android:visibility="gone" | |||
app:layout_constraintStart_toEndOf="@id/account_pp" | |||
@@ -104,10 +106,25 @@ | |||
android:layout_marginTop="10dp" | |||
android:scaleType="fitCenter" | |||
android:src="@drawable/ic_note" | |||
android:contentDescription="@string/action_add_notes" | |||
android:visibility="gone" | |||
app:layout_constraintStart_toEndOf="@id/account_follow" | |||
app:layout_constraintTop_toBottomOf="@id/banner_pp" /> | |||
<ImageButton | |||
android:id="@+id/account_notification" | |||
style="@style/Widget.AppCompat.Button.Colored" | |||
android:layout_width="45dp" | |||
android:layout_height="45dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginTop="10dp" | |||
android:contentDescription="@string/set_notify" | |||
android:scaleType="fitCenter" | |||
android:src="@drawable/ic_baseline_notifications_account_none" | |||
android:visibility="gone" | |||
app:layout_constraintStart_toEndOf="@id/account_personal_note" | |||
app:layout_constraintTop_toBottomOf="@id/banner_pp" /> | |||
<View | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
@@ -192,7 +209,8 @@ | |||
android:background="@drawable/red_border" | |||
android:text="Peertube" | |||
android:textColor="@color/red_1" | |||
android:visibility="gone" /> | |||
android:visibility="gone" | |||
tools:ignore="HardcodedText" /> | |||
<TextView | |||
android:id="@+id/account_bot" | |||
@@ -112,6 +112,21 @@ | |||
app:layout_constraintStart_toEndOf="@id/account_follow" | |||
app:layout_constraintTop_toBottomOf="@id/banner_pp" /> | |||
<ImageButton | |||
android:id="@+id/account_notification" | |||
style="@style/Widget.AppCompat.Button.Colored" | |||
android:layout_width="45dp" | |||
android:layout_height="45dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginTop="10dp" | |||
android:contentDescription="@string/set_notify" | |||
android:scaleType="fitCenter" | |||
android:src="@drawable/ic_baseline_notifications_account_none" | |||
android:visibility="gone" | |||
app:layout_constraintStart_toEndOf="@id/account_personal_note" | |||
app:layout_constraintTop_toBottomOf="@id/banner_pp" /> | |||
<View | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
@@ -341,10 +341,15 @@ | |||
android:tint="@android:color/white" /> | |||
<Button | |||
android:id="@+id/sound_status" | |||
style="@style/colored_button" | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:visibility="invisible" /> | |||
android:gravity="center" | |||
android:singleLine="true" | |||
android:text="@string/channel_notif_status" | |||
android:tint="@android:color/white" /> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -492,6 +497,30 @@ | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="@dimen/settings_option_margin" | |||
android:layout_marginBottom="@dimen/settings_option_margin" | |||
android:gravity="center_vertical" | |||
android:orientation="horizontal"> | |||
<TextView | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginEnd="10dp" | |||
android:layout_weight="1" | |||
android:text="@string/set_notif_status" | |||
android:textSize="16sp" /> | |||
<androidx.appcompat.widget.SwitchCompat | |||
android:id="@+id/set_notif_status" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" /> | |||
</LinearLayout> | |||
<!-- END NOTIFICATIONS SETTINGS --> | |||
<LinearLayout | |||
@@ -28,6 +28,12 @@ | |||
app:actionViewClass="android.widget.CheckBox" | |||
app:showAsAction="always" /> | |||
<item | |||
android:id="@+id/action_status" | |||
android:checkable="true" | |||
android:title="@string/new_toot" | |||
app:actionViewClass="android.widget.CheckBox" | |||
app:showAsAction="always" /> | |||
<item | |||
android:id="@+id/action_poll" | |||
android:checkable="true" | |||
android:title="@string/polls" | |||
@@ -236,6 +236,7 @@ | |||
<!-- Notifications --> | |||
<string name="no_notifications">No notification to display</string> | |||
<string name="notif_mention">mentioned you</string> | |||
<string name="notif_status">wrote a new message</string> | |||
<string name="notif_reblog">boosted your status</string> | |||
<string name="notif_favourite">favourited your status</string> | |||
<string name="notif_follow">followed you</string> | |||
@@ -306,6 +307,7 @@ | |||
<string name="set_notif_follow_add">Notify when someone favourites your status</string> | |||
<string name="set_notif_follow_mention">Notify when someone mentions you</string> | |||
<string name="set_notif_follow_poll">Notify when a poll ended</string> | |||
<string name="set_notif_status">Notify for new posts</string> | |||
<string name="set_share_validation">Show confirmation dialog before boosting</string> | |||
<string name="set_share_validation_fav">Show confirmation dialog before adding to favourites</string> | |||
<string name="set_wifi_only">Notify in WIFI only</string> | |||
@@ -589,6 +591,7 @@ | |||
<string name="channel_notif_poll">Poll Ended</string> | |||
<string name="channel_notif_toot">New Toot</string> | |||
<string name="channel_notif_backup">Toots Backup</string> | |||
<string name="channel_notif_status">New post</string> | |||
<string name="channel_notif_media">Media Download</string> | |||
<string name="set_notif_sound">Change notification sound</string> | |||
<string name="select_sound">Select Tone</string> | |||