diff --git a/app/src/debug/res/xml/compose_shortcuts.xml b/app/src/debug/res/xml/compose_shortcuts.xml new file mode 100644 index 000000000..19ed0e0ab --- /dev/null +++ b/app/src/debug/res/xml/compose_shortcuts.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/fdroid/res/xml/compose_shortcuts.xml b/app/src/fdroid/res/xml/compose_shortcuts.xml new file mode 100644 index 000000000..fa439bd24 --- /dev/null +++ b/app/src/fdroid/res/xml/compose_shortcuts.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 704ea4a43..b9ccf5806 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -80,9 +80,14 @@ android:roundIcon="@mipmap/ic_launcher_bubbles_round" android:targetActivity=".activities.MainActivity"> + + + + + + + + diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 9f6fea70e..34ad53a53 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -850,6 +850,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt rateThisApp(); binding.compose.setOnClickListener(v -> startActivity(new Intent(this, ComposeActivity.class))); + binding.compose.setOnLongClickListener(view -> { + CrossActionHelper.doCrossAction(BaseMainActivity.this, CrossActionHelper.TypeOfCrossAction.COMPOSE, null, null); + return false; + }); headerMenuOpen = false; PushHelper.startStreaming(BaseMainActivity.this); @@ -1094,6 +1098,14 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt String type = intent.getType(); Bundle extras = intent.getExtras(); String userIdIntent, instanceIntent, urlOfMessage; + if (action != null && action.equalsIgnoreCase("app.fedilab.android.shorcut.compose")) { + CrossActionHelper.doCrossAction(BaseMainActivity.this, CrossActionHelper.TypeOfCrossAction.COMPOSE, null, null); + intent.replaceExtras(new Bundle()); + intent.setAction(""); + intent.setData(null); + intent.setFlags(0); + return; + } if (extras != null && extras.containsKey(Helper.INTENT_ACTION)) { userIdIntent = extras.getString(Helper.PREF_USER_ID); //Id of the account in the intent instanceIntent = extras.getString(Helper.PREF_USER_INSTANCE); diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java index cd6e94219..08386025f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java @@ -135,7 +135,9 @@ public class CrossActionHelper { private static void fetchRemote(@NonNull Context context, @NonNull TypeOfCrossAction actionType, @NonNull BaseAccount ownerAccount, app.fedilab.android.mastodon.client.entities.api.Account targetedAccount, Status targetedStatus) { SearchVM searchVM = new ViewModelProvider((ViewModelStoreOwner) context).get("crossactions", SearchVM.class); - if (targetedAccount != null) { + if (actionType == TypeOfCrossAction.COMPOSE) { + applyAction(context, actionType, ownerAccount, null, null); + } else if (targetedAccount != null) { String search; if (targetedAccount.acct.contains("@")) { //Not from same instance search = targetedAccount.acct; @@ -247,6 +249,11 @@ public class CrossActionHelper { intent.putExtra(Helper.ARG_ACCOUNT, ownerAccount); context.startActivity(intent); break; + case COMPOSE: + Intent intentCompose = new Intent(context, ComposeActivity.class); + intentCompose.putExtra(Helper.ARG_ACCOUNT, ownerAccount); + context.startActivity(intentCompose); + break; } } @@ -530,7 +537,8 @@ public class CrossActionHelper { UNBOOKMARK_ACTION, REBLOG_ACTION, UNREBLOG_ACTION, - REPLY_ACTION + REPLY_ACTION, + COMPOSE } diff --git a/app/src/main/java/app/fedilab/android/peertube/worker/NotificationsWorker.java b/app/src/main/java/app/fedilab/android/peertube/worker/NotificationsWorker.java index a1401d7bc..7aaea5edb 100644 --- a/app/src/main/java/app/fedilab/android/peertube/worker/NotificationsWorker.java +++ b/app/src/main/java/app/fedilab/android/peertube/worker/NotificationsWorker.java @@ -306,11 +306,20 @@ public class NotificationsWorker extends Worker { notificationManager.createNotificationChannel(channel); } Intent myIntent = new Intent(getApplicationContext(), PeertubeMainActivity.class); - PendingIntent pendingIntent = PendingIntent.getActivity( - getApplicationContext(), - 0, - myIntent, - PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + pendingIntent = PendingIntent.getActivity( + getApplicationContext(), + 0, + myIntent, + PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); + } else { + pendingIntent = PendingIntent.getActivity( + getApplicationContext(), + 0, + myIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + } NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), FETCH_NOTIFICATION_CHANNEL_ID) .setContentTitle(title) .setTicker(title) diff --git a/app/src/main/res/drawable/ic_baseline_add_comment_24.xml b/app/src/main/res/drawable/ic_baseline_add_comment_24.xml new file mode 100644 index 000000000..e1b7c6888 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_add_comment_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layouts/mastodon/values/strings.xml b/app/src/main/res/layouts/mastodon/values/strings.xml new file mode 100644 index 000000000..1c0897ec8 --- /dev/null +++ b/app/src/main/res/layouts/mastodon/values/strings.xml @@ -0,0 +1,4 @@ + + + Compose + \ No newline at end of file diff --git a/app/src/playstore/res/xml/compose_shortcuts.xml b/app/src/playstore/res/xml/compose_shortcuts.xml new file mode 100644 index 000000000..1357bfe79 --- /dev/null +++ b/app/src/playstore/res/xml/compose_shortcuts.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/472.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/472.txt index 41188591d..acb89789c 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/472.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/472.txt @@ -1,5 +1,7 @@ Changed: - Peertube support +- Compose shortcut +- Long press compose button to write with another account Changed: - Cross actions with two accounts display a dialog