Extend Aurora Protect

This commit is contained in:
Mr. Dragon
2018-08-17 02:35:05 +05:30
parent 62d7ad2bba
commit e2df57b043
13 changed files with 1675 additions and 45 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@@ -42,6 +42,8 @@ import com.dragons.aurora.playstoreapiv2.GooglePlayAPI;
import com.percolate.caffeine.PhoneUtils;
import com.percolate.caffeine.ViewUtils;
import org.json.JSONArray;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
@@ -320,4 +322,14 @@ public class Util {
textView.setVisibility(View.GONE);
}
}
public static String[] getStringArray(JSONArray array) {
if (array == null)
return null;
String[] arr = new String[array.length()];
for (int i = 0; i < arr.length; i++) {
arr[i] = array.optString(i);
}
return arr;
}
}

View File

@@ -0,0 +1,69 @@
package com.dragons.aurora.adapters;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.dragons.aurora.R;
import com.dragons.aurora.model.ExodusTracker;
import com.percolate.caffeine.ViewUtils;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
public class ExodusAdapter extends RecyclerView.Adapter<ExodusAdapter.ViewHolder> {
private Context mContext;
private List<ExodusTracker> mExodusTrackers;
public ExodusAdapter(Context mContext, List<ExodusTracker> mExodusTrackers) {
this.mContext = mContext;
this.mExodusTrackers = mExodusTrackers;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_exodus, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
ExodusTracker mExodusTracker = mExodusTrackers.get(position);
holder.TrackerName.setText(mExodusTracker.Name);
holder.TrackerSignature.setText(mExodusTracker.Signature);
holder.TrackerDate.setText(mExodusTracker.Date);
holder.TrackerCard.setOnClickListener(v ->
mContext.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(mExodusTracker.URL)))
);
}
@Override
public int getItemCount() {
return mExodusTrackers.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
TextView TrackerName;
TextView TrackerSignature;
TextView TrackerDate;
CardView TrackerCard;
ViewHolder(View v) {
super(v);
TrackerName = ViewUtils.findViewById(v, R.id.tracker_name);
TrackerSignature = ViewUtils.findViewById(v, R.id.tracker_signature);
TrackerDate = ViewUtils.findViewById(v, R.id.tracker_date);
TrackerCard = ViewUtils.findViewById(v, R.id.tracker_card);
}
}
}

View File

@@ -22,13 +22,16 @@
package com.dragons.aurora.fragment.details;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
@@ -36,18 +39,32 @@ import com.android.volley.VolleyLog;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.dragons.aurora.R;
import com.dragons.aurora.Util;
import com.dragons.aurora.adapters.ExodusAdapter;
import com.dragons.aurora.fragment.DetailsFragment;
import com.dragons.aurora.model.App;
import com.dragons.aurora.model.ExodusTracker;
import com.percolate.caffeine.ViewUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static com.android.volley.VolleyLog.TAG;
public class ExodusPrivacy extends AbstractHelper {
private String AppID;
private JSONArray trackersIDs;
public ExodusPrivacy(DetailsFragment fragment, App app) {
super(fragment, app);
}
@@ -69,10 +86,9 @@ public class ExodusPrivacy extends AbstractHelper {
JSONObject exodusReport = response.getJSONObject(app.getPackageName());
JSONArray reportsArray = exodusReport.getJSONArray("reports");
JSONObject trackersReport = reportsArray.getJSONObject(0);
JSONArray trackers = trackersReport.getJSONArray("trackers");
String appId = trackersReport.getString("id");
drawExodus(trackers, appId);
Log.i("EXODUS_PRIVACY", trackers.toString());
trackersIDs = trackersReport.getJSONArray("trackers");
AppID = trackersReport.getString("id");
drawExodus(trackersIDs, AppID);
} catch (JSONException e) {
Log.i("EXODUS_PRIVACY", "Error occurred at Exodus Privacy");
}
@@ -82,17 +98,94 @@ public class ExodusPrivacy extends AbstractHelper {
private void drawExodus(JSONArray appTrackers, String appId) {
if (fragment.getActivity() != null) {
ViewUtils.findViewById(fragment.getActivity(), R.id.exodus_card).setVisibility(View.VISIBLE);
ViewUtils.findViewById(view, R.id.exodus_card).setVisibility(View.VISIBLE);
if (appTrackers.length() > 0) {
setText(fragment.getView(), R.id.exodus_description, R.string.exodus_hasTracker, appTrackers.length());
setText(view, R.id.exodus_description, R.string.exodus_hasTracker, appTrackers.length());
} else {
setText(fragment.getView(), R.id.exodus_description, R.string.exodus_noTracker);
setText(view, R.id.exodus_description, R.string.exodus_noTracker);
}
TextView viewMore = fragment.getActivity().findViewById(R.id.viewMore);
viewMore.setPaintFlags(viewMore.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
viewMore.setOnClickListener(click -> fragment.getActivity().startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://reports.exodus-privacy.eu.org/reports/" + appId + "/"))));
Button moreButton = view.findViewById(R.id.moreButton);
if (trackersIDs.isNull(0))
moreButton.setVisibility(View.GONE);
moreButton.setOnClickListener(v -> {
showDialog();
});
}
}
private void showDialog() {
Dialog ad = new Dialog(context);
ad.setContentView(R.layout.dialog_exodus);
ad.setCancelable(true);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.copyFrom(ad.getWindow().getAttributes());
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.CENTER;
ad.getWindow().setAttributes(layoutParams);
RecyclerView mRecyclerView = ad.findViewById(R.id.exodus_recycler);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
mRecyclerView.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(context, R.anim.layout_anim));
mRecyclerView.setAdapter(new ExodusAdapter(context, getTrackerData(trackersIDs)));
Button btn_report = ad.findViewById(R.id.btn_report);
Button btn_close = ad.findViewById(R.id.btn_close);
btn_report.setOnClickListener(v -> context.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://reports.exodus-privacy.eu.org/reports/" + AppID + "/"))));
btn_close.setOnClickListener(v -> ad.dismiss());
ad.show();
}
private List<ExodusTracker> getTrackerData(JSONArray trackersIDs) {
List<ExodusTracker> mExodusTrackers = new ArrayList<>();
ArrayList<JSONObject> trackerObjects = getTrackerObjects(Util.getStringArray(trackersIDs));
for (JSONObject obj : trackerObjects) {
ExodusTracker mExodusTracker = null;
try {
mExodusTracker = new ExodusTracker(
obj.getString("name"),
obj.getString("website"),
obj.getString("code_signature"),
obj.getString("creation_date"));
} catch (JSONException e) {
Log.e("Bazinga", e.getMessage());
}
if (mExodusTracker != null)
mExodusTrackers.add(mExodusTracker);
}
return mExodusTrackers;
}
private ArrayList<JSONObject> getTrackerObjects(String[] IDs) {
ArrayList<JSONObject> trackerObjects = new ArrayList<>();
for (String ID : IDs) {
trackerObjects.add(getOfflineTrackerObj(ID));
}
return trackerObjects;
}
private JSONObject getOfflineTrackerObj(String trackerID) {
String ExodusJSON = null;
try {
InputStream mInputStream = context.getAssets().open("exodus_trackers.json");
byte[] mByte = new byte[mInputStream.available()];
mInputStream.read(mByte);
mInputStream.close();
ExodusJSON = new String(mByte, "UTF-8");
JSONArray mJsonArray = new JSONArray(ExodusJSON);
JSONObject mJsonObject = mJsonArray.getJSONObject(0);
return mJsonObject.getJSONObject(trackerID);
} catch (IOException | JSONException e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -166,6 +166,7 @@ public class GeneralDetails extends AbstractHelper {
paintButton(color, R.id.run);
paintButton(color, R.id.beta_subscribe_button);
paintButton(color, R.id.beta_submit_button);
paintButton(color, R.id.moreButton);
if (!Util.isDark(fragment.getContext())) {
paintTextView(color, R.id.beta_header);
paintTextView(color, R.id.permissions_header);

View File

@@ -0,0 +1,19 @@
package com.dragons.aurora.model;
public class ExodusTracker {
public String Name;
public String URL;
public String Date;
public String Description;
public String Signature;
public ExodusTracker(String Name, String URL, String Signature, String Date) {
this.Name = Name;
this.URL = URL;
this.Signature = Signature;
this.Date = Date;
//this.Description = Description;
}
}

View File

@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="293.04395"
android:viewportHeight="290.34396">
<path
android:fillAlpha="1"
android:fillColor="#684971"
android:pathData="M146.522,145.172m-146.522,0a145.172,146.522 90,1 1,293.044 0a145.172,146.522 90,1 1,-293.044 0"
android:strokeWidth="0.22726357"
android:strokeColor="#00000000" />
<path
android:fillAlpha="1"
android:fillColor="#ffffff"
android:pathData="m120.762,139.875c-25.533,-8.989 -38.3,-22.601 -38.3,-40.836 -0,-14.382 6.772,-25.876 20.316,-34.48 13.544,-8.604 30.361,-12.906 50.451,-12.906 18.275,0 32.791,2.986 43.549,8.957 10.757,5.971 16.136,13.131 16.136,21.478 -0,4.366 -1.685,8.187 -5.055,11.461 -3.37,3.275 -7.258,4.912 -11.665,4.912 -7.258,0 -13.22,-5.008 -17.886,-15.025 -6.481,-13.869 -16.201,-20.803 -29.162,-20.803 -10.239,0 -18.664,3.339 -25.274,10.016 -6.61,6.678 -9.915,15.988 -9.915,27.93 -0,23.5 12.248,35.25 36.744,35.25 2.592,0 5.573,-0.257 8.943,-0.77 5.832,-0.77 10.369,-1.156 13.609,-1.156 7.906,0 11.859,2.247 11.859,6.742 -0,5.008 -4.018,7.512 -12.054,7.512 -2.852,0 -7.129,-0.449 -12.831,-1.348 -4.277,-0.77 -7.582,-1.156 -9.915,-1.156 -25.922,0 -38.883,13.098 -38.883,39.295 -0,12.713 3.435,22.954 10.304,30.723 6.869,7.769 16.46,11.654 28.773,11.654 15.423,0 25.663,-7.898 30.717,-23.693 2.592,-8.347 5.476,-14.126 8.651,-17.336 3.175,-3.21 7.42,-4.816 12.734,-4.816 4.407,0 8.392,1.573 11.956,4.719 3.564,3.146 5.346,7.159 5.346,12.039 -0,11.686 -6.61,21.349 -19.83,28.99 -13.22,7.641 -29.227,11.461 -48.02,11.461 -20.608,0 -38.915,-4.88 -54.922,-14.639C81.134,214.292 73.13,201.258 73.13,184.949c-0,-20.418 15.877,-35.443 47.632,-45.074z"
android:strokeWidth="0.2500065"
android:strokeAlpha="1"
android:strokeColor="#00000000"
android:strokeLineCap="butt"
android:strokeLineJoin="miter" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?android:attr/colorForeground"
android:pathData="M12,9A3,3 0,0 0,9 12A3,3 0,0 0,12 15A3,3 0,0 0,15 12A3,3 0,0 0,12 9M12,17A5,5 0,0 1,7 12A5,5 0,0 1,12 7A5,5 0,0 1,17 12A5,5 0,0 1,12 17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z" />
</vector>

View File

@@ -0,0 +1,98 @@
<!--
~ Aurora Store
~ Copyright (C) 2018 Rahul Kumar Patel <whyorean@gmail.com>
~
~ Yalp Store
~ Copyright (C) 2018 Sergey Yeriomin <yeriomin@gmail.com>
~
~ Aurora Store (a fork of Yalp Store )is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 2 of the License, or
~ (at your option) any later version.
~
~ Aurora Store is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/exodus_head"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@color/exodusPrimaryDark">
<ImageView
android:id="@+id/exodus_img"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_exodus" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/exodus_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/action_container"
android:layout_below="@id/exodus_head"
android:layout_margin="5dp" />
<LinearLayout
android:id="@+id/action_container"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/changes_container"
android:layout_alignParentBottom="true"
android:background="@color/exodusPrimaryDark"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/btn_close"
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:maxLines="1"
android:padding="5dp"
android:text="@android:string/cancel"
android:textAllCaps="false"
android:textColor="@color/exodusTextPrimary" />
<View
android:id="@+id/div3"
android:layout_width=".5dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@color/exodusTextPrimary" />
<Button
android:id="@+id/btn_report"
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:maxLines="1"
android:padding="5dp"
android:text="@string/exodus_viewReport"
android:textAllCaps="false"
android:textColor="@color/exodusTextPrimary" />
</LinearLayout>
</RelativeLayout>
</merge>

View File

@@ -49,11 +49,11 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:src="@drawable/ic_security" />
<LinearLayout
android:id="@+id/exodus_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
@@ -70,43 +70,43 @@
android:textSize="18sp" />
<TextView
android:id="@+id/exodus_description"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:textSize="14sp" />
<TextView
android:id="@+id/exodus_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:textSize="12sp"
android:visibility="gone" />
<TextView
android:id="@+id/viewMore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:clickable="true"
android:focusable="true"
android:text="@string/exodus_viewMore"
android:text="@string/exodus_powered"
android:textAlignment="viewStart"
android:textSize="12sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/exodus_details"
android:layout_toEndOf="@id/privacy_ico"
android:orientation="horizontal">
<TextView
android:id="@+id/exodus_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/moreButton"
android:textAlignment="viewStart"
android:textSize="14sp" />
<Button
android:id="@+id/moreButton"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="5dp"
android:text="@string/exodus_viewMore"
android:textAllCaps="false" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_margin="10dp"
android:fontFamily="@font/google_sans_bold"
android:gravity="end"
android:text="@string/exodus_powered"
android:textSize="12sp" />
</LinearLayout>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Aurora Store
~ Copyright (C) 2018 Rahul Kumar Patel <whyorean@gmail.com>
~
~ Yalp Store
~ Copyright (C) 2018 Sergey Yeriomin <yeriomin@gmail.com>
~
~ Aurora Store (a fork of Yalp Store )is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 2 of the License, or
~ (at your option) any later version.
~
~ Aurora Store is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
-->
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tracker_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardBackgroundColor="?android:attr/panelBackground"
app:cardCornerRadius="5dp"
app:cardElevation="1dp"
app:cardPreventCornerOverlap="false">
<RelativeLayout
android:id="@+id/app_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:selectableItemBackgroundBorderless">
<ImageView
android:id="@+id/tracker_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:alpha=".75"
app:srcCompat="@drawable/ic_trackers" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_toEndOf="@+id/tracker_icon"
android:orientation="vertical">
<TextView
android:id="@+id/tracker_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/google_sans_bold"
android:maxLines="1"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<TextView
android:id="@+id/tracker_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1" />
<TextView
android:id="@+id/tracker_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>

View File

@@ -58,4 +58,9 @@
<color name="colorGold">#FFBF00</color>
<color name="colorPink">#F50057</color>
<color name="colorLime">#CDDC39</color>
<!--Exodus-->
<color name="exodusPrimary">#684971</color>
<color name="exodusPrimaryDark">#3D3144</color>
<color name="exodusTextPrimary">#BBB</color>
</resources>

View File

@@ -188,7 +188,8 @@
<string name="exodus_noTracker">Contains no trackers</string>
<string name="exodus_powered">Powered by Exodus</string>
<string name="exodus_title">Aurora Protect</string>
<string name="exodus_viewMore">View Details</string>
<string name="exodus_viewMore">View</string>
<string name="exodus_viewReport">View Report</string>
<string name="flagging_title">Flag as inappropriate</string>
<string name="flag_graphic_violence">Graphic violence</string>
<string name="flag_harmful_prompt">Describe the harm caused to your device or data:</string>