diff --git a/README.md b/README.md
index 72de7ff..fba760e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# Party UP!
-upload files and links to a copyparty server by sharing them to this app
+ '' ''
+
+upload files and links to a [copyparty](https://github.com/9001/copyparty) server by sharing them to this app
primarily made for this year's meadup, letting a room full of nerds throw memes onto the big screen
diff --git a/app/build.gradle b/app/build.gradle
index 97e7ae4..470b7cd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,8 +17,8 @@ android {
applicationId "me.ocv.partyup"
minSdk 28
targetSdk 28
- versionCode 10201
- versionName "1.2.1"
+ versionCode 10300
+ versionName "1.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.release
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
index 2692be4..26261f8 100644
--- a/app/release/output-metadata.json
+++ b/app/release/output-metadata.json
@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
- "versionCode": 10201,
- "versionName": "1.2.1",
+ "versionCode": 10300,
+ "versionName": "1.3.0",
"outputFile": "app-release.apk"
}
],
diff --git a/app/src/main/java/me/ocv/partyup/XferActivity.java b/app/src/main/java/me/ocv/partyup/XferActivity.java
index c06474f..2ab12f9 100644
--- a/app/src/main/java/me/ocv/partyup/XferActivity.java
+++ b/app/src/main/java/me/ocv/partyup/XferActivity.java
@@ -1,5 +1,8 @@
package me.ocv.partyup;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
@@ -11,10 +14,13 @@
import androidx.appcompat.app.AppCompatActivity;
import android.provider.OpenableColumns;
+import android.view.Gravity;
import android.view.View;
+import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.preference.PreferenceManager;
+import android.widget.Toast;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -25,20 +31,23 @@
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
+import java.util.stream.Collectors;
import me.ocv.partyup.databinding.ActivityXferBinding;
+import me.ocv.partyup.databinding.ContentXferBinding;
public class XferActivity extends AppCompatActivity {
- private ActivityXferBinding binding;
- private Intent the_intent;
- private String the_msg;
- private String base_url, full_url;
- private Uri file_uri;
- private String file_name;
- private long file_size;
- private String the_desc;
- private boolean upping;
+ ActivityXferBinding binding;
+ SharedPreferences prefs;
+ Intent the_intent;
+ String the_msg;
+ String base_url, full_url, share_url;
+ Uri file_uri;
+ String file_name;
+ long file_size;
+ String the_desc;
+ boolean upping;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -49,6 +58,8 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(binding.toolbar);
+ prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
@@ -70,7 +81,7 @@ protected void onCreate(Bundle savedInstanceState) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- fab.setVisibility(View.INVISIBLE);
+ fab.setVisibility(View.GONE);
do_up();
}
});
@@ -143,7 +154,6 @@ private void do_up() {
upping = true;
try {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
base_url = full_url = prefs.getString("server_url", "");
show_msg("Sending to " + base_url + " ...\n\n" + the_desc);
@@ -196,8 +206,22 @@ private void do_textmsg(HttpURLConnection conn) throws Exception {
OutputStream os = conn.getOutputStream();
os.write(body);
os.flush();
+ int rc = conn.getResponseCode();
+ share_url = "HTTP " + rc;
+ if (rc >= 300) {
+ byte[] buf = new byte[1024];
+ int n = Math.max(0, conn.getErrorStream().read(buf));
+ tshow_msg("Server error " + rc + ":\n" + new String(buf, 0, n, "UTF-8"));
+ conn.disconnect();
+ return;
+ }
conn.disconnect();
- finishAndRemoveTask();
+ findViewById(R.id.upper_info).post(new Runnable() {
+ @Override
+ public void run() {
+ onsuccess(false);
+ }
+ });
}
private void do_fileput(HttpURLConnection conn) throws Exception {
@@ -205,7 +229,7 @@ private void do_fileput(HttpURLConnection conn) throws Exception {
conn.setFixedLengthStreamingMode(file_size);
conn.setRequestProperty("Content-Type", "application/octet-stream");
conn.connect();
- final TextView tv = (TextView)findViewById(R.id.upper_info);
+ final TextView tv = (TextView) findViewById(R.id.upper_info);
OutputStream os = conn.getOutputStream();
InputStream ins = getContentResolver().openInputStream(file_uri);
MessageDigest md = MessageDigest.getInstance("SHA-512");
@@ -232,14 +256,14 @@ public void run() {
file_size - meme,
perc
));
- ((ProgressBar)findViewById(R.id.progbar)).setProgress((int)Math.round(perc));
+ ((ProgressBar) findViewById(R.id.progbar)).setProgress((int) Math.round(perc));
}
});
}
os.flush();
int rc = conn.getResponseCode();
if (rc >= 300) {
- int n = conn.getErrorStream().read(buf);
+ int n = Math.max(0, conn.getErrorStream().read(buf));
tshow_msg("Server error " + rc + ":\n" + new String(buf, 0, n, "UTF-8"));
conn.disconnect();
return;
@@ -249,20 +273,85 @@ public void run() {
for (int a = 0; a < 28; a++)
sha += String.format("%02x", bsha[a]);
- String line, line2 = "";
- boolean ok = false;
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- while ((line = br.readLine()) != null)
- if (line.indexOf(sha) >= 0)
- ok = true;
- else
- line2 = line;
-
+ String[] lines = br.lines().collect(Collectors.toList()).toArray(new String[0]);
conn.disconnect();
- if (ok) {
+
+ if (lines.length < 3) {
+ tshow_msg("SERVER ERROR:\n" + lines[0]);
+ return;
+ }
+ if (lines[2].indexOf(sha) != 0) {
+ tshow_msg("ERROR:\nFile got corrupted during the upload;\n\n" + lines[2] + " expected\n" + sha + " from server");
+ return;
+ }
+ if (lines.length > 3 && !lines[3].isEmpty())
+ share_url = lines[3];
+ else
+ share_url = full_url.split("\\?")[0];
+
+ tv.post(new Runnable() {
+ @Override
+ public void run() {
+ onsuccess(true);
+ }
+ });
+ }
+
+ void onsuccess(Boolean upload) {
+ show_msg("✅ 👍\n\nCompleted successfully\n\n" + share_url);
+ ((TextView)findViewById(R.id.upper_info)).setGravity(Gravity.CENTER);
+
+ if (prefs.getBoolean("autoclose", false)) {
finishAndRemoveTask();
return;
}
- tshow_msg("ERROR:\nFile got corrupted during the upload;\n\n" + line2 + " expected\n" + sha + " from server");
+
+ findViewById(R.id.progbar).setVisibility(View.GONE);
+ findViewById(R.id.successbuttons).setVisibility(View.VISIBLE);
+
+ Button btn = (Button)findViewById(R.id.btnExit);
+ btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finishAndRemoveTask();
+ }
+ });
+
+ if (!upload) {
+ findViewById(R.id.btnCopyLink).setVisibility(View.GONE);
+ findViewById(R.id.btnShareLink).setVisibility(View.GONE);
+ return;
+ }
+
+ btn = (Button)findViewById(R.id.btnCopyLink);
+ btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ClipboardManager cb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData cd = ClipData.newPlainText("copyparty upload", share_url);
+ Toast.makeText(getApplicationContext(), "Link copied", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ btn = (Button)findViewById(R.id.btnShareLink);
+ btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent send = new Intent(Intent.ACTION_SEND);
+ send.setType("text/plain");
+ send.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ send.putExtra(Intent.EXTRA_SUBJECT, "Uploaded file");
+ send.putExtra(Intent.EXTRA_TEXT, share_url);
+ //startActivity(Intent.createChooser(send, "Share file link"));
+
+ Intent view = new Intent(Intent.ACTION_VIEW);
+ view.setData(Uri.parse(share_url));
+
+ Intent i = Intent.createChooser(send, "Share file link");
+ i.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { view });
+ startActivity(i);
+ }
+ });
}
}
diff --git a/app/src/main/res/layout/activity_xfer.xml b/app/src/main/res/layout/activity_xfer.xml
index 3d3b4fc..b46c981 100644
--- a/app/src/main/res/layout/activity_xfer.xml
+++ b/app/src/main/res/layout/activity_xfer.xml
@@ -69,11 +69,46 @@
android:layout_height="wrap_content"
android:layout_weight="1" />
+
+
+
+
+
+
+
+
+
+ android:layout_height="wrap_content"
+ android:scaleY="5" />
+
- #FFBB86FC
- #FF6200EE
- #FF3700B3
+
+ #FFFFCC80
+ #FFFF9800
+ #FFF57C00#FF03DAC5#FF018786#FF000000
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index 78603a1..c646a32 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -19,13 +19,21 @@
app:useSimpleSummaryProvider="true" />
+
+
+
+
+
-
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3798992..c36c3f1 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -4,3 +4,4 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
+distributionSha256Sum=0e46229820205440b48a5501122002842b82886e76af35f0f3a069243dca4b3c
diff --git a/metadata/en-US/changelogs/10300.txt b/metadata/en-US/changelogs/10300.txt
new file mode 100644
index 0000000..c974291
--- /dev/null
+++ b/metadata/en-US/changelogs/10300.txt
@@ -0,0 +1 @@
+• new: copy/share link after upload
\ No newline at end of file
diff --git a/metadata/en-US/full_description.txt b/metadata/en-US/full_description.txt
index 4ae1c07..7187a29 100644
--- a/metadata/en-US/full_description.txt
+++ b/metadata/en-US/full_description.txt
@@ -1,12 +1,12 @@
Send files and links to a copyparty server by sharing them to this app
-Features:
-
sha512-verified uploads
-
stash links and plaintext
-
supports HTTP and HTTPS
+Features:
+• sha512-verified uploads
+• stash links and plaintext
+• display/copy link to the uploaded files
+• supports HTTP and HTTPS
-Future ideas:
-
upload slicing (resumable + usually faster)
-
display/copy link to the uploaded files
+Future ideas:
+• upload slicing (resumable + usually faster)
This can be used to turn a raspi into a very flexible chromecast clone; see the readme for details
\ No newline at end of file
diff --git a/metadata/nb-NO/full_description.txt b/metadata/nb-NO/full_description.txt
index 9e184e7..1c290ea 100644
--- a/metadata/nb-NO/full_description.txt
+++ b/metadata/nb-NO/full_description.txt
@@ -1,12 +1,12 @@
Send filer og lenker til en copyparty-server ved å dele dem til denne appen
-Funksjoner per nu:
-
sha512 garanterer at ting kommer helskinnet frem
-
arkivering av linker og annen klartekst
-
tar både HTTP og HTTPS
+Funksjoner per nu:
+• sha512 garanterer at ting kommer helskinnet frem
+• arkivering av linker og annen klartekst
+• vise/kopiere link til det som er lastet opp
+• tar både HTTP og HTTPS
-Én gang i fremtiden:
-
oppdeling av filer (ofte raskere, samt mulighet for å gjenoppta avbrutte opplastninger)
-
vise/kopiere link til det som er lastet opp
+Én gang i fremtiden:
+• oppdeling av filer (ofte raskere, samt mulighet for å gjenoppta avbrutte opplastninger)
-Kan forøvrig brukes for å gjøre en raspi om til en særdeles fleksibel chromecast-aktig sak; se readme'n for litt mer info
+Kan forøvrig brukes for å gjøre en raspi om til en særdeles fleksibel chromecast-aktig sak; se readme'n for litt mer info
\ No newline at end of file