mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-08-03 23:56:52 -04:00
Feat[modpack]: move CF API key into a string resource
This commit is contained in:
parent
6ef2b1f7a4
commit
d00565ebac
1
.github/workflows/android.yml
vendored
1
.github/workflows/android.yml
vendored
@ -15,6 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
GPLAY_KEYSTORE_PASSWORD: ${{ secrets.GPLAY_KEYSTORE_PASSWORD }}
|
||||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@ app_pojavlauncher/src/main/assets/components/jre
|
||||
local.properties
|
||||
.idea/
|
||||
app_pojavlauncher/.cxx/
|
||||
.vs/
|
||||
.vs/
|
||||
/curseforge_key.txt
|
||||
|
@ -69,6 +69,12 @@ def getVersionName = {
|
||||
return TAG_STRING.trim().replace("-g", "-") + "-" + BRANCH.toString().trim()
|
||||
}
|
||||
|
||||
def getCFApiKey = {
|
||||
String key = System.getenv("CURSEFORGE_API_KEY");
|
||||
if(key == null) key = new File("./curseforge_key.txt").text;
|
||||
return key;
|
||||
}
|
||||
|
||||
configurations {
|
||||
instrumentedClasspath {
|
||||
canBeConsumed = false
|
||||
@ -107,6 +113,7 @@ android {
|
||||
versionCode getDateSeconds()
|
||||
versionName getVersionName()
|
||||
multiDexEnabled true //important
|
||||
resValue 'string', 'curseforge_api_key', getCFApiKey()
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.kdt.pojavlaunch.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
@ -55,11 +56,16 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
||||
|
||||
public SearchModFragment(){
|
||||
super(R.layout.fragment_mod_search);
|
||||
modpackApi = new CommonApi();
|
||||
mSearchFilters = new SearchFilters();
|
||||
mSearchFilters.isModpack = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
modpackApi = new CommonApi(context.getString(R.string.curseforge_api_key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
// You can only access resources after attaching to current context
|
||||
|
@ -18,9 +18,16 @@ import java.util.concurrent.Future;
|
||||
*/
|
||||
public class CommonApi implements ModpackApi {
|
||||
|
||||
private final ModpackApi mCurseforgeApi = new CurseforgeApi();
|
||||
private final ModpackApi mModrinthApi = new ModrinthApi();
|
||||
private final ModpackApi[] mModpackApis = new ModpackApi[]{mModrinthApi, mCurseforgeApi};
|
||||
private final ModpackApi mCurseforgeApi;
|
||||
private final ModpackApi mModrinthApi;
|
||||
private final ModpackApi[] mModpackApis;
|
||||
|
||||
public CommonApi(String curseforgeApiKey) {
|
||||
mCurseforgeApi = new CurseforgeApi(curseforgeApiKey);
|
||||
mModrinthApi = new ModrinthApi();
|
||||
mModpackApis = new ModpackApi[]{mModrinthApi, mCurseforgeApi};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
||||
CommonApiSearchResult commonApiSearchResult = (CommonApiSearchResult) previousPageResult;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.kdt.pojavlaunch.modloaders.modpacks.api;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
@ -38,7 +39,10 @@ public class CurseforgeApi implements ModpackApi{
|
||||
private static final int CURSEFORGE_PAGINATION_END_REACHED = -1;
|
||||
private static final int CURSEFORGE_PAGINATION_ERROR = -2;
|
||||
|
||||
private final ApiHandler mApiHandler = new ApiHandler("https://api.curseforge.com/v1", "$2a$10$Vxkj4kH1Ekf8EsS4Mx8b2eVTHsht107Lk2erVEUtnbqvojsLy.jYq");
|
||||
private final ApiHandler mApiHandler;
|
||||
public CurseforgeApi(String apiKey) {
|
||||
mApiHandler = new ApiHandler("https://api.curseforge.com/v1", apiKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user