summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-01-27 16:30:45 +0100
committerThomas <tschneider.ac@gmail.com>2023-01-27 16:30:45 +0100
commit654f7850deaec90a4d393af37b75217ada1395ad (patch)
treee608e4d7b27523b2eb0765a6f93f01d5a030e421
parentb52ab37aede6402b53c38a9667383bcc8843c4ca (diff)
Fixes and improvements
-rw-r--r--app/src/debug/res/xml/compose_shortcuts.xml19
-rw-r--r--app/src/fdroid/res/xml/compose_shortcuts.xml19
-rw-r--r--app/src/main/AndroidManifest.xml20
-rw-r--r--app/src/main/java/app/fedilab/android/BaseMainActivity.java12
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/helper/CrossActionHelper.java12
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/worker/NotificationsWorker.java19
-rw-r--r--app/src/main/res/drawable/ic_baseline_add_comment_24.xml10
-rw-r--r--app/src/main/res/layouts/mastodon/values/strings.xml4
-rw-r--r--app/src/playstore/res/xml/compose_shortcuts.xml19
-rw-r--r--src/fdroid/fastlane/metadata/android/en/changelogs/472.txt2
10 files changed, 129 insertions, 7 deletions
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 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
+ <shortcut
+ android:enabled="true"
+ android:icon="@drawable/ic_baseline_add_comment_24"
+ android:shortcutId="compose"
+ android:shortcutShortLabel="@string/compose_shortcut_short_label1"
+ tools:targetApi="n_mr1">
+ <intent
+ android:action="app.fedilab.android.shorcut.compose"
+ android:targetClass="app.fedilab.android.activities.MainActivity"
+ android:targetPackage="fr.gouv.etalab.mastodon.debug" />
+
+ <categories android:name="android.shortcut.conversation" />
+ <capability-binding android:key="actions.intent.CREATE_MESSAGE" />
+ </shortcut>
+
+
+</shortcuts> \ 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 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
+ <shortcut
+ android:enabled="true"
+ android:icon="@drawable/ic_baseline_add_comment_24"
+ android:shortcutId="compose"
+ android:shortcutShortLabel="@string/compose_shortcut_short_label1"
+ tools:targetApi="n_mr1">
+ <intent
+ android:action="app.fedilab.android.shorcut.compose"
+ android:targetClass="app.fedilab.android.activities.MainActivity"
+ android:targetPackage="fr.gouv.etalab.mastodon" />
+
+ <categories android:name="android.shortcut.conversation" />
+ <capability-binding android:key="actions.intent.CREATE_MESSAGE" />
+ </shortcut>
+
+
+</shortcuts> \ 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">
<intent-filter>
+ <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
<activity-alias
@@ -96,6 +101,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
<activity-alias
@@ -109,6 +117,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
<activity-alias
@@ -122,6 +133,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
<activity-alias
@@ -135,6 +149,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
<activity-alias
@@ -148,6 +165,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <meta-data
+ android:name="android.app.shortcuts"
+ android:resource="@xml/compose_shortcuts" />
</activity-alias>
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 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:tint="?attr/colorControlNormal"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="?attr/colorControlNormal"
+ android:pathData="M21.99,4c0,-1.1 -0.89,-2 -1.99,-2H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4 -0.01,-18zM17,11h-4v4h-2v-4H7V9h4V5h2v4h4v2z" />
+</vector>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="compose_shortcut_short_label1">Compose</string>
+</resources> \ 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 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
+ <shortcut
+ android:enabled="true"
+ android:icon="@drawable/ic_baseline_add_comment_24"
+ android:shortcutId="compose"
+ android:shortcutShortLabel="@string/compose_shortcut_short_label1"
+ tools:targetApi="n_mr1">
+ <intent
+ android:action="app.fedilab.android.shorcut.compose"
+ android:targetClass="app.fedilab.android.activities.MainActivity"
+ android:targetPackage="app.fedilab.android" />
+
+ <categories android:name="android.shortcut.conversation" />
+ <capability-binding android:key="actions.intent.CREATE_MESSAGE" />
+ </shortcut>
+
+
+</shortcuts> \ 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