Skip to content

Commit

Permalink
Added contributor parser
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Nov 13, 2024
1 parent cbada52 commit e2a9c1c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.OplusRecyclerView;

import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -22,6 +24,7 @@
import it.dhd.oxygencustomizer.ui.adapters.CreditsAdapter;
import it.dhd.oxygencustomizer.ui.base.BaseFragment;
import it.dhd.oxygencustomizer.ui.models.CreditsModel;
import it.dhd.oxygencustomizer.utils.ContributorParser;
import it.dhd.oxygencustomizer.utils.TranslatorParser;

public class Credits extends BaseFragment {
Expand Down Expand Up @@ -72,7 +75,12 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "thecubed", """
Recognized Developer
For finding a fix to lag issue from recents""", "https://github.com/thecubed", R.drawable.ic_default_person));

try {
credits.addAll(new ContributorParser().parseContributors());
} catch (JSONException e) {
Log.e("Credits", "Error parsing contributors", e);
}

credits.add(new CreditsModel("Testers"));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "Max", "", "", R.drawable.ic_default_person));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "Siri00", "", "", R.drawable.ic_default_person));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package it.dhd.oxygencustomizer.utils;

import static it.dhd.oxygencustomizer.OxygenCustomizer.getAppContext;
import static it.dhd.oxygencustomizer.ui.adapters.CreditsAdapter.VIEW_TYPE_ITEM;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import it.dhd.oxygencustomizer.ui.models.CreditsModel;

public class ContributorParser {

private List<String> mExcludedContributors = new ArrayList<>(){{
addAll(Arrays.asList("DHD2280", "crowdin-bot", "github-actions[bot]"));
}};

public ArrayList<CreditsModel> parseContributors() throws JSONException {
ArrayList<CreditsModel> contributorsList = new ArrayList<>();
String jsonStr = readJsonFileFromAssets("Misc/contributors.json");
JSONArray jsonArray = new JSONArray(jsonStr);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getString("login");
if (mExcludedContributors.contains(name)) continue;
String picture = jsonObject.getString("avatar_url");
String profileUrl = jsonObject.getString("html_url");
contributorsList.add(new CreditsModel(VIEW_TYPE_ITEM, name, "GitHub Contributor", profileUrl, picture));
}
return contributorsList;
}

public String readJsonFileFromAssets(String fileName) {
StringBuilder stringBuilder = new StringBuilder();
try {
InputStream inputStream = getAppContext().getAssets().open(fileName);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
bufferedReader.close();
} catch (Exception e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_crdroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?colorOnSurface">
android:tint="@color/oplusColorControls">
<path
android:fillColor="#FF000000"
android:pathData="m14.951,19.206c-0.0227-0.07025-0.03004-0.41881-0.01976-0.94056,0.005-0.2549,0.0129-0.5199,0.01751-0.58887,0.04255-0.63662,0.13888-1.2172,0.50713-3.0567,0.06407-0.32002,0.12942-0.65509,0.14522-0.74459,0.14583-0.82575,0.16896-1.4355,0.06269-1.6524-0.03433-0.07008-0.08241-0.10078-0.16592-0.10593-0.07602-0.0047-0.12854,0.01813-0.21817,0.09486-0.08838,0.07565-0.18701,0.20295-0.38183,0.49286-0.26412,0.39303-0.38333,0.55842-0.72299,1.003-1.0074,1.3186-2.0717,2.4527-3.0309,3.2295-1.4784,1.1972-2.9789,1.8964-4.304,2.0054-0.19195,0.01578-0.60064,0.0067-0.76589-0.01681-0.7477-0.105-1.2982-0.418-1.7275-0.98-0.6769-0.887-0.9181-2.249-0.6073-3.431,0.20756-0.78941,0.72205-1.3506,1.3859-1.5117,0.11567-0.02806,0.44543-0.02785,0.56193,0.000371,0.31078,0.07528,0.58564,0.25334,0.79442,0.51464,0.18182,0.22755,0.26972,0.5134,0.2561,0.83284-0.00657,0.15431-0.031153,0.27617-0.084821,0.42066-0.0941,0.254-0.2671,0.461-0.454,0.546-0.3333,0.151-0.7378-0.184-0.7826-0.647-0.00886-0.09154-0.00105-0.18024,0.026335-0.29866,0.022341-0.09664,0.019086-0.13328-0.012256-0.13798-0.03699-0.0054-0.23012,0.08015-0.32852,0.14576-0.30528,0.20358-0.5012,0.56091-0.55529,1.0127-0.019479,0.16274-0.013957,0.44282,0.012053,0.61133,0.089727,0.58128,0.37982,1.1045,0.78965,1.4243,0.44742,0.34912,1.132,0.48536,1.8831,0.37474,1.3507-0.19893,2.9807-1.168,4.5745-2.7197,0.51654-0.5029,1.14-1.2375,1.5568-1.8345,0.30134-0.43152,0.45099-0.71794,0.41364-0.7917-0.02701-0.05334-0.45255-0.04742-1.0131,0.01412-0.39559,0.04342-0.57877,0.05227-0.93655,0.04522-0.44239-0.0087-0.77193-0.04181-1.2236-0.12282-0.8801-0.156-1.8172-0.454-2.8614-0.906-0.1227-0.054-0.4569-0.204-0.7428-0.334-0.6435-0.292-0.8619-0.379-1.37-0.544-0.3308-0.108-0.5999-0.184-0.9699-0.274-0.4362-0.107-0.4-0.094-0.3955-0.151,0.00204-0.02529,0.00572-0.32536,0.00822-0.6668s0.00572-0.62237,0.00718-0.62428c0.00145-0.00191,0.14658-0.047332,0.32249-0.10094,0.91967-0.28025,2.0584-0.65706,3.4288-1.1346,1.9767-0.6888,2.3519-0.81066,2.7892-0.90598,0.96326-0.20996,1.6228-0.21388,2.4642-0.014648,0.77373,0.18322,1.7684,0.56611,3.5006,1.3476,0.54364,0.24525,0.7219,0.31058,1.0198,0.37373,0.4674,0.099089,0.8953,0.094183,1.3629-0.015623,0.22004-0.051672,0.34652-0.069199,0.42234-0.058528l0.06616,0.00931,0.0905,0.26172c0.16326,0.47216,0.33662,0.981,0.34241,1.005,0.0051,0.021026,0.0013,0.024805-0.0342,0.035107-0.02192,0.00641-0.12041,0.026482-0.21885,0.044745-0.54251,0.10065-0.8368,0.17033-1.1239,0.26608-0.72004,0.24019-1.2024,0.58688-1.5191,1.0918-0.21333,0.34012-0.34613,0.61773-0.41139,0.85995-0.08317,0.30867-0.13927,0.81614-0.11919,1.0781,0.01238,0.16152,0.02715,0.23325,0.07267,0.35268,0.09932,0.2606,0.29798,0.45275,0.73229,0.70829,0.14916,0.08777,0.16248,0.09762,0.16248,0.12029,0,0.01651-0.01953,0.02552-0.15185,0.06989-0.4995,0.16756-0.76056,0.51256-1.008,1.3321-0.0207,0.06855-0.08697,0.31592-0.14729,0.54972-0.23088,0.89498-0.38812,1.415-0.58192,1.9245-0.09576,0.25176-0.13789,0.34975-0.23211,0.5398-0.16689,0.33665-0.32396,0.537-0.46606,0.59449-0.07152,0.02894-0.07551,0.02808-0.0908-0.01925zm-1.9548-8.0283c0.49146-0.02201,0.67189-0.04328,1.0323-0.1218,1.0988-0.2393,2.2532-0.78599,2.9498-1.3969l0.06772-0.059417-0.21424-0.13733c-0.291-0.1867-0.529-0.3173-0.906-0.4973-0.357-0.1705-0.983-0.435-1.227-0.519-0.227-0.0778-0.8-0.2394-1.145-0.3227-0.10073-0.024355-0.19401-0.047113-0.20729-0.050572-0.02003-0.00522-0.02324-0.00322-0.01887,0.011697,0.0029,0.00989,0.01304,0.087732,0.02254,0.17298,0.06143,0.55077-0.02994,1.0075-0.26627,1.3312-0.145,0.1979-0.36,0.3449-0.601,0.4098-0.328,0.0885-0.731,0.0405-1.013-0.121-0.24-0.1376-0.402-0.3341-0.506-0.6144-0.05326-0.14288-0.08189-0.28043-0.09522-0.45765-0.01049-0.1395-0.0076-0.21572,0.01658-0.46382,0.0086-0.086969,0.01762-0.18186,0.0202-0.21087l0.0046-0.052743-0.03532,0.00728c-0.208,0.0426-1.2768,0.3742-2.1971,0.6814-0.9402,0.3137-1.6956,0.556-2.2664,0.7267-0.13619,0.040739-0.24483,0.077108-0.24142,0.080839,0.00339,0.00375,0.053022,0.025436,0.11026,0.048258,0.18441,0.073517,0.55634,0.23076,1.1655,0.49274,1.0977,0.47206,1.5767,0.65344,2.126,0.80504,0.47632,0.13144,1.0728,0.23966,1.4995,0.27206,0.10784,0.0082,1.6799-0.0038,1.923-0.01482zm-8.6201-3.0518c0.0000576-0.17378,0.027645-0.92837,0.04236-1.1587,0.00784-0.12256,0.034149-0.3812,0.045218-0.44438l0.0043-0.024536,0.33492-0.0000217c0.5183,0,0.7338-0.0301,1.1374-0.1585,0.4185-0.1333,0.8154-0.299,2.3194-0.9682,1.1825-0.5261,2.2665-0.8214,3.3545-0.914,0.23634-0.020088,0.7687-0.01713,0.98561,0.00548,0.29857,0.031117,0.59691,0.090531,1.0477,0.20866,0.91923,0.24086,1.8094,0.55926,2.9991,1.0727,0.57214,0.24694,0.81292,0.33913,1.1297,0.43253,0.66922,0.19734,1.181,0.2054,1.7299,0.027252,0.12089-0.039234,0.13468-0.04169,0.15176-0.027033,0.08254,0.070838,0.36671,0.6961,0.43178,0.95002,0.02883,0.11254,0.02562,0.11997-0.08159,0.188-0.16695,0.10594-0.37206,0.18557-0.548,0.21276-0.38396,0.05934-1.1,0.064919-1.3816,0.010765-0.226-0.0436-1.108-0.3668-1.886-0.6915-0.457-0.191-0.698-0.2817-1.066-0.4024-1.426-0.4681-2.901-0.6783-3.868-0.5512-0.15,0.0197-0.515,0.088-0.76,0.1423-0.352,0.0779-0.701,0.1793-1.0283,0.2983-0.2975,0.1081-0.549,0.211-1.3111,0.5364-1.5758,0.6727-2.8304,1.1133-3.6146,1.2692-0.1772,0.0353-0.1691,0.036-0.1691-0.0141z" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_matrixx_logo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?colorOnSurface">
android:tint="@color/oplusColorControls">
<path
android:pathData="M3.36,20.883C2.707,20.038 2.175,19.095 1.789,18.08L8.986,9.162L11.999,13.228L12,13.226L12.001,13.228L15.014,9.162L22.211,18.08C21.779,19.218 21.162,20.265 20.397,21.184L14.882,13.812L12,17.193L9.117,13.812L3.36,20.883Z"
android:fillColor="#fff"/>
Expand Down

0 comments on commit e2a9c1c

Please sign in to comment.