MCPcopy Create free account
hub / github.com/M66B/FairEmail / isAvailable

Method isAvailable

app/src/main/java/eu/faircode/email/OpenAI.java:66–76  ·  view source on GitHub ↗
(Context context)

Source from the content-addressed store, hash-verified

64 private static final int SCALE2PIXELS = 1440; // medium
65
66 static boolean isAvailable(Context context) {
67 if (TextUtils.isEmpty(BuildConfig.OPENAI_ENDPOINT))
68 return false;
69
70 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
71 boolean enabled = prefs.getBoolean("openai_enabled", false);
72 String apikey = prefs.getString("openai_apikey", null);
73
74 return (enabled &&
75 (!TextUtils.isEmpty(apikey) || !Objects.equals(getUri(context), BuildConfig.OPENAI_ENDPOINT)));
76 }
77
78 static void checkModeration(Context context, String text) throws JSONException, IOException {
79 // https://platform.openai.com/docs/api-reference/moderations/create

Callers 6

onCreateDialogMethod · 0.95
isAvailableMethod · 0.95
completeChatMethod · 0.95
getDefaultPromptMethod · 0.95
getSummarizePromptMethod · 0.95
getSummaryTextMethod · 0.95

Calls 5

getUriMethod · 0.95
getBooleanMethod · 0.80
isEmptyMethod · 0.45
getStringMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected