Log variables

This commit is contained in:
blank X 2022-07-12 13:05:35 +07:00
parent 3209f036d0
commit 42ca1a016c
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 15 additions and 0 deletions

View File

@ -6,12 +6,23 @@ import android.widget.Toast;
import android.content.Intent;
import android.content.ActivityNotFoundException;
import android.net.Uri;
import android.util.Log;
import com.blankie.unshortify.R;
public class ShareActivity extends Activity {
public static final String TAG = "unshortify";
private void logVariable(final String name, final String value) {
String msg = name + " = ";
if (value != null) {
msg += "[" + value + "]";
} else {
msg += "null";
}
Log.d(TAG, msg);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -19,6 +30,7 @@ public class ShareActivity extends Activity {
try {
final Intent intent = getIntent();
final String urlString = intent.getStringExtra(Intent.EXTRA_TEXT);
logVariable("urlString", urlString);
if (urlString == null || urlString == "") {
Toast.makeText(getApplicationContext(), R.string.empty_url,
Toast.LENGTH_SHORT).show();
@ -26,6 +38,7 @@ public class ShareActivity extends Activity {
}
final Uri urlParsed = Uri.parse(urlString);
logVariable("scheme", urlParsed.getScheme());
if (urlParsed.getScheme() != "http" && urlParsed.getScheme() != "https" &&
urlParsed.getScheme() != "") {
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
@ -33,6 +46,7 @@ public class ShareActivity extends Activity {
return;
}
logVariable("host", urlParsed.getHost());
if (urlParsed.getHost() == null || (urlParsed.getHost() != "youtube.com" &&
urlParsed.getHost().endsWith(".youtube.com"))) {
Toast.makeText(getApplicationContext(), R.string.non_youtube_url,
@ -40,6 +54,7 @@ public class ShareActivity extends Activity {
return;
}
logVariable("path", urlParsed.getPath());
if (urlParsed.getPath() == null) {
Toast.makeText(getApplicationContext(), R.string.null_path,
Toast.LENGTH_SHORT).show();