Add in-app Donation link in Termux Settings for non google playstore releases

The `TermuxConstants` class has been updated to `v0.22.0`. Check its Changelog sections for info on changes.
This commit is contained in:
agnostic-apollo
2021-05-14 05:19:18 +05:00
parent 79df863b75
commit 6de3713049
5 changed files with 105 additions and 29 deletions

View File

@@ -4,6 +4,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import androidx.core.content.ContextCompat;
@@ -13,6 +14,8 @@ import com.termux.shared.logger.Logger;
public class ShareUtils {
private static final String LOG_TAG = "ShareUtils";
/**
* Open the system app chooser that allows the user to select which app to send the intent.
*
@@ -68,4 +71,21 @@ public class ShareUtils {
}
}
/**
* Open a url.
*
* @param context The context for operations.
* @param url The url to open.
*/
public static void openURL(final Context context, final String url) {
if (context == null || url == null || url.isEmpty()) return;
try {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(intent);
} catch (Exception e) {
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to open the url \"" + url + "\"", e);
}
}
}