mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-08 11:34:07 +08:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user