diff --git a/src/androidTest/java/de/blau/android/FeedbackTest.java b/src/androidTest/java/de/blau/android/FeedbackTest.java index c8d690f7e2..a7266a0cc0 100644 --- a/src/androidTest/java/de/blau/android/FeedbackTest.java +++ b/src/androidTest/java/de/blau/android/FeedbackTest.java @@ -21,6 +21,8 @@ import androidx.test.uiautomator.UiDevice; import de.blau.android.prefs.AdvancedPrefDatabase; import de.blau.android.prefs.Preferences; +import de.blau.android.resources.KeyDatabaseHelper; +import de.blau.android.resources.KeyDatabaseHelper.EntryType; import okhttp3.HttpUrl; @RunWith(AndroidJUnit4.class) @@ -46,6 +48,7 @@ public void setup() { device = UiDevice.getInstance(instrumentation); context = instrumentation.getTargetContext(); main = mActivityRule.getActivity(); + KeyDatabaseHelper.replaceOrDeleteKey(new KeyDatabaseHelper(main).getWritableDatabase(), Feedback.VESPUCCI_REPORTER_ENTRY, EntryType.API_KEY, "123", false, false, null, null);; mockServer = new MockWebServerPlus(); HttpUrl mockBaseUrl = mockServer.server().url("/api/0.6/"); prefDB = new AdvancedPrefDatabase(context); diff --git a/src/main/java/de/blau/android/Feedback.java b/src/main/java/de/blau/android/Feedback.java index 43cae8a1f4..b38d2b9de1 100644 --- a/src/main/java/de/blau/android/Feedback.java +++ b/src/main/java/de/blau/android/Feedback.java @@ -54,9 +54,10 @@ public class Feedback extends IssueReporterActivity implements ActivityResultHan private static final String DEBUG_TAG = "Feedback"; - private static final String REPO_USER_KEY = "repo_user"; - private static final String REPO_NAME_KEY = "repo_name"; - private static final String GITHUB_API_KEY = "github_api_key"; + static final String VESPUCCI_REPORTER_ENTRY = "VESPUCCI_REPORTER"; + private static final String REPO_USER_KEY = "repo_user"; + private static final String REPO_NAME_KEY = "repo_name"; + private static final String GITHUB_API_KEY = "github_api_key"; private static final String EMPTY_BUG_REPORT = "bug_report_empty.md"; @@ -88,7 +89,7 @@ public static void start(@NonNull Context context, boolean useUrl) { */ public static void start(@NonNull Context context, @NonNull String repoUser, @NonNull String repoName, boolean useUrl) { try (KeyDatabaseHelper keys = new KeyDatabaseHelper(context); SQLiteDatabase db = keys.getReadableDatabase()) { - String apiKey = KeyDatabaseHelper.getKey(db, "VESPUCCI_REPORTER", EntryType.API_KEY); + String apiKey = KeyDatabaseHelper.getKey(db, VESPUCCI_REPORTER_ENTRY, EntryType.API_KEY); if (useUrl || Util.isPackageInstalled(Github.APP, context.getPackageManager()) || Util.isEmpty(apiKey)) { reportViaUrl(context, repoUser, repoName); } else { diff --git a/src/main/java/de/blau/android/resources/KeyDatabaseHelper.java b/src/main/java/de/blau/android/resources/KeyDatabaseHelper.java index e3285bcbbe..e11029d603 100644 --- a/src/main/java/de/blau/android/resources/KeyDatabaseHelper.java +++ b/src/main/java/de/blau/android/resources/KeyDatabaseHelper.java @@ -90,7 +90,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { * @param add1 1st additional value to store * @param add2 2nd additional value to store */ - static void replaceOrDeleteKey(@NonNull SQLiteDatabase db, @NonNull String name, @NonNull EntryType type, @Nullable String key, boolean custom, + public static void replaceOrDeleteKey(@NonNull SQLiteDatabase db, @NonNull String name, @NonNull EntryType type, @Nullable String key, boolean custom, boolean overwrite, @Nullable String add1, @Nullable String add2) { if ("".equals(key) && overwrite) { Log.i(DEBUG_TAG, "Deleting key " + name);