Compare commits
No commits in common. "ea890bfbcdce72db5f2b0842f95fe65628b0a71e" and "ecc1e4b443927b16bbd9bdeb2d894c55d73fe87f" have entirely different histories.
ea890bfbcd
...
ecc1e4b443
|
@ -7,8 +7,6 @@ import android.content.Intent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.URLUtil;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import com.blankie.unshortify.R;
|
import com.blankie.unshortify.R;
|
||||||
|
|
||||||
|
@ -33,27 +31,23 @@ public class ShareActivity extends Activity {
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final String urlString = intent.getStringExtra(Intent.EXTRA_TEXT);
|
final String urlString = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
logVariable("urlString", urlString);
|
logVariable("urlString", urlString);
|
||||||
if (urlString == null || urlString.isEmpty()) {
|
if (urlString == null || urlString == "") {
|
||||||
Toast.makeText(getApplicationContext(), R.string.empty_url,
|
Toast.makeText(getApplicationContext(), R.string.empty_url,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Uri urlParsed = Uri.parse(URLUtil.guessUrl(urlString));
|
final Uri urlParsed = Uri.parse(urlString);
|
||||||
final String scheme = urlParsed.getScheme() != null
|
final String scheme = urlParsed.getScheme();
|
||||||
? urlParsed.getScheme().toLowerCase(Locale.ROOT)
|
|
||||||
: null;
|
|
||||||
logVariable("scheme", scheme);
|
logVariable("scheme", scheme);
|
||||||
if (scheme == null || (!scheme.equals("http")
|
if (scheme != null && !scheme.equals("") && !scheme.equals("http") &&
|
||||||
&& !scheme.equals("https"))) {
|
!scheme.equals("https")) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
|
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String host = urlParsed.getHost() != null
|
final String host = urlParsed.getHost();
|
||||||
? urlParsed.getHost().toLowerCase(Locale.ROOT)
|
|
||||||
: null;
|
|
||||||
logVariable("host", host);
|
logVariable("host", host);
|
||||||
if (host == null || (!host.equals("youtube.com") &&
|
if (host == null || (!host.equals("youtube.com") &&
|
||||||
!host.endsWith(".youtube.com"))) {
|
!host.endsWith(".youtube.com"))) {
|
||||||
|
@ -69,7 +63,7 @@ public class ShareActivity extends Activity {
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!path.toLowerCase(Locale.ROOT).startsWith("/shorts/")) {
|
if (!path.startsWith("/shorts/")) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.non_shorts_url,
|
Toast.makeText(getApplicationContext(), R.string.non_shorts_url,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
@ -91,7 +85,7 @@ public class ShareActivity extends Activity {
|
||||||
|
|
||||||
final Intent unshortifiedIntent = new Intent(Intent.ACTION_VIEW, unshortifiedUrl);
|
final Intent unshortifiedIntent = new Intent(Intent.ACTION_VIEW, unshortifiedUrl);
|
||||||
try {
|
try {
|
||||||
startActivity(unshortifiedIntent);
|
startActivity(intent);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Toast.makeText(getApplicationContext(), R.string.no_activity_found,
|
Toast.makeText(getApplicationContext(), R.string.no_activity_found,
|
||||||
|
|
Loading…
Reference in New Issue