diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bafc4abd..90d2ef9b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
index 77f72416..d5e7f59a 100644
--- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
@@ -201,7 +201,11 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
floatingBtn.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
- boolean b = saveTheToot(textEditor.getText().toString());
+ String contentWarning = null;
+ if (statusHideText) {
+ contentWarning = contentWarningEditor.getText().toString();
+ }
+ boolean b = saveTheToot(textEditor.getText().toString(), contentWarning);
if (b) {
Toast.makeText(ComposeActivity.this, R.string.action_save_one_toot, Toast.LENGTH_SHORT).show();
}
@@ -269,6 +273,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
Intent intent = getIntent();
String[] mentionedUsernames = null;
+ ArrayList loadedDraftMediaUris = null;
inReplyToId = null;
if (intent != null) {
inReplyToId = intent.getStringExtra("in_reply_to_id");
@@ -294,10 +299,15 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
if (startingHideText) {
startingContentWarning = intent.getStringExtra("content_warning");
}
+ } else {
+ String contentWarning = intent.getStringExtra("saved_toot_content_warning");
+ startingHideText = !TextUtils.isEmpty(contentWarning);
+ if (startingHideText) {
+ startingContentWarning = contentWarning;
+ }
}
- /* If come from SavedTootActivity
- * */
+ // If come from SavedTootActivity
String savedTootText = intent.getStringExtra("saved_toot_text");
if (!TextUtils.isEmpty(savedTootText)) {
textEditor.append(savedTootText);
@@ -306,7 +316,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
String savedJsonUrls = intent.getStringExtra("saved_json_urls");
if (!TextUtils.isEmpty(savedJsonUrls)) {
// try to redo a list of media
- ArrayList playersList = new Gson().fromJson(savedJsonUrls,
+ loadedDraftMediaUris = new Gson().fromJson(savedJsonUrls,
new TypeToken>() {
}.getType());
}
@@ -398,6 +408,13 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
statusAlreadyInFlight = false;
// These can only be added after everything affected by the media queue is initialized.
+ /* if (loadedDraftMediaUris != null && !loadedDraftMediaUris.isEmpty()) {
+ for (String uriString : loadedDraftMediaUris) {
+ Uri uri = Uri.parse(uriString);
+ long mediaSize = MediaUtils.getMediaSize(getContentResolver(), uri);
+ pickMedia(uri, mediaSize);
+ }
+ } else */
if (savedMediaQueued != null) {
for (SavedQueuedMedia item : savedMediaQueued) {
addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize);
@@ -530,16 +547,16 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
}
}
- public boolean saveTheToot(String s) {
+ public boolean saveTheToot(String s, @Nullable String contentWarning) {
if (TextUtils.isEmpty(s)) {
return false;
} else {
final TootEntity toot = new TootEntity();
toot.setText(s);
+ toot.setContentWarning(contentWarning);
if (mediaQueued != null && mediaQueued.size() > 0) {
List list = new ArrayList<>();
- for (QueuedMedia q :
- mediaQueued) {
+ for (QueuedMedia q : mediaQueued) {
list.add(q.uri.toString());
}
String json = new Gson().toJson(list);
@@ -679,7 +696,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
}
private boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags,
- String[] mimeTypes) {
+ String[] mimeTypes) {
try {
if (currentInputContentInfo != null) {
currentInputContentInfo.releasePermission();
@@ -741,7 +758,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
}
private void sendStatus(String content, String visibility, boolean sensitive,
- String spoilerText) {
+ String spoilerText) {
ArrayList mediaIds = new ArrayList<>();
for (QueuedMedia item : mediaQueued) {
@@ -1240,7 +1257,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
}
}
- void showMarkSensitive(boolean show) {
+ private void showMarkSensitive(boolean show) {
showMarkSensitive = show;
if (!showMarkSensitive) {
@@ -1256,7 +1273,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
}
}
- void showContentWarning(boolean show) {
+ private void showContentWarning(boolean show) {
statusHideText = show;
if (show) {
contentWarningBar.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
index 385fa52e..10507d68 100644
--- a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java
@@ -137,6 +137,7 @@ public class SavedTootActivity extends BaseActivity implements SavedTootAdapter.
Intent intent = new Intent(this, ComposeActivity.class);
intent.putExtra("saved_toot_uid", item.getUid());
intent.putExtra("saved_toot_text", item.getText());
+ intent.putExtra("saved_toot_content_warning", item.getContentWarning());
intent.putExtra("saved_json_urls", item.getUrls());
startActivity(intent);
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
index 8480d27e..c4bea594 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
+++ b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
@@ -7,7 +7,7 @@ import android.arch.persistence.room.RoomDatabase;
* DB version & declare DAO
*/
-@Database(entities = {TootEntity.class}, version = 1, exportSchema = false)
+@Database(entities = {TootEntity.class}, version = 2, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
public abstract TootDao tootDao();
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java b/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java
index b3779af5..3c792bce 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java
+++ b/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java
@@ -3,7 +3,6 @@ package com.keylesspalace.tusky.db;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
-import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java
index 760379e8..fb00afa8 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java
@@ -19,6 +19,9 @@ public class TootEntity {
@ColumnInfo(name = "urls")
private String urls;
+ @ColumnInfo(name = "contentWarning")
+ private String contentWarning;
+
// getter setter
public String getText() {
return text;
@@ -28,6 +31,14 @@ public class TootEntity {
this.text = text;
}
+ public String getContentWarning() {
+ return contentWarning;
+ }
+
+ public void setContentWarning(String contentWarning) {
+ this.contentWarning = contentWarning;
+ }
+
public int getUid() {
return uid;
}