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
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
GPLAY_KEYSTORE_PASSWORD: ${{ secrets.GPLAY_KEYSTORE_PASSWORD }}
|
GPLAY_KEYSTORE_PASSWORD: ${{ secrets.GPLAY_KEYSTORE_PASSWORD }}
|
||||||
|
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ local.properties
|
|||||||
.idea/
|
.idea/
|
||||||
app_pojavlauncher/.cxx/
|
app_pojavlauncher/.cxx/
|
||||||
.vs/
|
.vs/
|
||||||
|
/curseforge_key.txt
|
||||||
|
@ -69,6 +69,12 @@ def getVersionName = {
|
|||||||
return TAG_STRING.trim().replace("-g", "-") + "-" + BRANCH.toString().trim()
|
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 {
|
configurations {
|
||||||
instrumentedClasspath {
|
instrumentedClasspath {
|
||||||
canBeConsumed = false
|
canBeConsumed = false
|
||||||
@ -107,6 +113,7 @@ android {
|
|||||||
versionCode getDateSeconds()
|
versionCode getDateSeconds()
|
||||||
versionName getVersionName()
|
versionName getVersionName()
|
||||||
multiDexEnabled true //important
|
multiDexEnabled true //important
|
||||||
|
resValue 'string', 'curseforge_api_key', getCFApiKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.kdt.pojavlaunch.fragments;
|
package net.kdt.pojavlaunch.fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -55,11 +56,16 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
|
|
||||||
public SearchModFragment(){
|
public SearchModFragment(){
|
||||||
super(R.layout.fragment_mod_search);
|
super(R.layout.fragment_mod_search);
|
||||||
modpackApi = new CommonApi();
|
|
||||||
mSearchFilters = new SearchFilters();
|
mSearchFilters = new SearchFilters();
|
||||||
mSearchFilters.isModpack = true;
|
mSearchFilters.isModpack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
modpackApi = new CommonApi(context.getString(R.string.curseforge_api_key));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
// You can only access resources after attaching to current context
|
// You can only access resources after attaching to current context
|
||||||
|
@ -18,9 +18,16 @@ import java.util.concurrent.Future;
|
|||||||
*/
|
*/
|
||||||
public class CommonApi implements ModpackApi {
|
public class CommonApi implements ModpackApi {
|
||||||
|
|
||||||
private final ModpackApi mCurseforgeApi = new CurseforgeApi();
|
private final ModpackApi mCurseforgeApi;
|
||||||
private final ModpackApi mModrinthApi = new ModrinthApi();
|
private final ModpackApi mModrinthApi;
|
||||||
private final ModpackApi[] mModpackApis = new ModpackApi[]{mModrinthApi, mCurseforgeApi};
|
private final ModpackApi[] mModpackApis;
|
||||||
|
|
||||||
|
public CommonApi(String curseforgeApiKey) {
|
||||||
|
mCurseforgeApi = new CurseforgeApi(curseforgeApiKey);
|
||||||
|
mModrinthApi = new ModrinthApi();
|
||||||
|
mModpackApis = new ModpackApi[]{mModrinthApi, mCurseforgeApi};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
||||||
CommonApiSearchResult commonApiSearchResult = (CommonApiSearchResult) previousPageResult;
|
CommonApiSearchResult commonApiSearchResult = (CommonApiSearchResult) previousPageResult;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.kdt.pojavlaunch.modloaders.modpacks.api;
|
package net.kdt.pojavlaunch.modloaders.modpacks.api;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
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_END_REACHED = -1;
|
||||||
private static final int CURSEFORGE_PAGINATION_ERROR = -2;
|
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
|
@Override
|
||||||
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
public SearchResult searchMod(SearchFilters searchFilters, SearchResult previousPageResult) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user