OpenAI: build config

pull/212/head
M66B 2 years ago
parent 239330e7ad
commit 7b88e4c46f

@ -176,6 +176,8 @@ android {
buildConfigField "String", "ANNOUNCEMENT_URI", "\"\""
buildConfigField "String", "CLOUD_URI", "\"https://api.fairemail.net/sync\""
buildConfigField "String", "CLOUD_EMAIL", "\"cloud@in.faircode.eu\""
buildConfigField "String", "OPENAI_ENDPOINT", "\"https://api.openai.com/\""
buildConfigField "String", "OPENAI_PRIVACY", "\"https://openai.com/policies/privacy-policy\""
buildConfigField "String", "TX_URI", localProperties.getProperty("paypal.uri", "\"\"")
buildConfigField "String", "GPA_URI", localProperties.getProperty("gpa.uri", "\"\"")
buildConfigField "String", "INFO_URI", localProperties.getProperty("info.uri", "\"\"")
@ -199,6 +201,8 @@ android {
buildConfigField "String", "ANNOUNCEMENT_URI", "\"\""
buildConfigField "String", "CLOUD_URI", "\"https://api.fairemail.net/sync\""
buildConfigField "String", "CLOUD_EMAIL", "\"cloud@in.faircode.eu\""
buildConfigField "String", "OPENAI_ENDPOINT", "\"https://api.openai.com/\""
buildConfigField "String", "OPENAI_PRIVACY", "\"https://openai.com/policies/privacy-policy\""
buildConfigField "String", "TX_URI", localProperties.getProperty("paypal.uri", "\"\"")
buildConfigField "String", "GPA_URI", localProperties.getProperty("gpa.uri", "\"\"")
buildConfigField "String", "INFO_URI", localProperties.getProperty("info.uri", "\"\"")
@ -222,6 +226,8 @@ android {
buildConfigField "String", "ANNOUNCEMENT_URI", "\"\""
buildConfigField "String", "CLOUD_URI", "\"https://api.fairemail.net/sync\""
buildConfigField "String", "CLOUD_EMAIL", "\"cloud@in.faircode.eu\""
buildConfigField "String", "OPENAI_ENDPOINT", "\"https://api.openai.com/\""
buildConfigField "String", "OPENAI_PRIVACY", "\"https://openai.com/policies/privacy-policy\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""
@ -246,6 +252,8 @@ android {
buildConfigField "String", "ANNOUNCEMENT_URI", "\"\""
buildConfigField "String", "CLOUD_URI", "\"\""
buildConfigField "String", "CLOUD_EMAIL", "\"\""
buildConfigField "String", "OPENAI_ENDPOINT", "\"\""
buildConfigField "String", "OPENAI_PRIVACY", "\"\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""
@ -270,6 +278,8 @@ android {
buildConfigField "String", "ANNOUNCEMENT_URI", "\"\""
buildConfigField "String", "CLOUD_URI", "\"\""
buildConfigField "String", "CLOUD_EMAIL", "\"\""
buildConfigField "String", "OPENAI_ENDPOINT", "\"\""
buildConfigField "String", "OPENAI_PRIVACY", "\"\""
buildConfigField "String", "TX_URI", "\"\""
buildConfigField "String", "GPA_URI", "\"\""
buildConfigField "String", "INFO_URI", "\"\""

@ -1020,7 +1020,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvOpenAiPrivacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse(OpenAI.URI_PRIVACY), true);
Helper.view(v.getContext(), Uri.parse(BuildConfig.OPENAI_PRIVACY), true);
}
});
@ -2074,7 +2074,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
? View.GONE : View.VISIBLE);
grpVirusTotal.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
grpSend.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
grpOpenAi.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
grpOpenAi.setVisibility(TextUtils.isEmpty(BuildConfig.OPENAI_ENDPOINT) ? View.GONE : View.VISIBLE);
grpTest.setVisibility(BuildConfig.TEST_RELEASE ? View.VISIBLE : View.GONE);
setLastCleanup(prefs.getLong("last_cleanup", -1));

@ -42,13 +42,10 @@ import java.util.Iterator;
import java.util.List;
public class OpenAI {
static final String URI_ENDPOINT = "https://api.openai.com/";
static final String URI_PRIVACY = "https://openai.com/policies/privacy-policy";
private static final int TIMEOUT = 30; // seconds
static boolean isAvailable(Context context) {
if (BuildConfig.PLAY_STORE_RELEASE)
if (TextUtils.isEmpty(BuildConfig.OPENAI_ENDPOINT))
return false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -152,7 +149,7 @@ public class OpenAI {
String apikey = prefs.getString("openai_apikey", null);
// https://platform.openai.com/docs/api-reference/introduction
Uri uri = Uri.parse(URI_ENDPOINT).buildUpon().appendEncodedPath(path).build();
Uri uri = Uri.parse(BuildConfig.OPENAI_ENDPOINT).buildUpon().appendEncodedPath(path).build();
Log.i("OpenAI uri=" + uri);
long start = new Date().getTime();

Loading…
Cancel
Save