Skip to content

Commit

Permalink
Add support to Android version 13 and remove firebase and crashlytics
Browse files Browse the repository at this point in the history
  • Loading branch information
bongtrop committed May 8, 2023
1 parent 4538e90 commit 057338f
Show file tree
Hide file tree
Showing 14 changed files with 521 additions and 689 deletions.
11 changes: 4 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
compileSdkVersion 33
buildToolsVersion "33.0.0"
ndkVersion "20.0.5594570"
defaultConfig {
applicationId "org.proxydroid"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 33
versionCode 72
versionName "3.2.0"

Expand Down Expand Up @@ -47,8 +48,4 @@ dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'org.mozilla:rhino:1.7.11'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-ads:18.3.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
15 changes: 6 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.proxydroid">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Expand All @@ -19,14 +20,10 @@
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-9097031975646651~9376680322" />

<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />

<activity
android:name="ProxyDroid"
android:label="@string/app_name">
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -48,12 +45,12 @@
android:name=".ProxyDroidService"
android:enabled="true" />

<receiver android:name=".ConnectivityBroadcastReceiver">
<receiver android:name=".ConnectivityBroadcastReceiver" android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<receiver android:name=".ProxyDroidWidgetProvider">
<receiver android:name=".ProxyDroidWidgetProvider" android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="org.proxydroid.ProxyDroidWidgetProvider.PROXY_SWITCH_ACTION" />
Expand Down
87 changes: 30 additions & 57 deletions app/src/main/java/org/proxydroid/AppManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import org.proxydroid.utils.ImageLoaderFactory;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.Vector;

Expand All @@ -68,9 +68,9 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList

private boolean appsLoaded = false;

final Handler handler = new Handler() {
final Handler handler = new Handler(new Handler.Callback() {
@Override
public void handleMessage(Message msg) {
public boolean handleMessage(Message msg) {
switch (msg.what) {
case MSG_LOAD_START:
pd = ProgressDialog.show(AppManager.this, "",
Expand All @@ -88,7 +88,7 @@ public void handleMessage(Message msg) {
public void onScrollStateChanged(AbsListView view,
int scrollState) {
visible = true;
if (scrollState == ListView.OnScrollListener.SCROLL_STATE_IDLE) {
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
overlay.setVisibility(View.INVISIBLE);
}
}
Expand All @@ -115,33 +115,24 @@ public void onScroll(AbsListView view,
}
break;
}
super.handleMessage(msg);
return true;
}
};
});

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// app icon in action bar clicked; go home
// Intent intent = new Intent(this, ProxyDroid.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(intent);
if (item.getItemId() == android.R.id.home) {
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

((ProxyDroidApplication)getApplication())
.firebaseAnalytics.setCurrentScreen(this, "app_manager", null);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);

this.setContentView(R.layout.layout_apps);

Expand Down Expand Up @@ -175,9 +166,7 @@ public void onDestroy() {
@Override
protected void onResume() {
super.onResume();

new Thread() {

@Override
public void run() {
handler.sendEmptyMessage(MSG_LOAD_START);
Expand All @@ -189,24 +178,20 @@ public void run() {
handler.sendEmptyMessage(MSG_LOAD_FINISH);
}
}.start();

}

private void loadApps() {
getApps(this);

Arrays.sort(apps, new Comparator<ProxyedApp>() {
@Override
public int compare(ProxyedApp o1, ProxyedApp o2) {
if (o1 == null || o2 == null || o1.getName() == null
|| o2.getName() == null)
return 1;
if (o1.isProxyed() == o2.isProxyed())
return o1.getName().compareTo(o2.getName());
if (o1.isProxyed())
return -1;
Arrays.sort(apps, (o1, o2) -> {
if (o1 == null || o2 == null || o1.getName() == null
|| o2.getName() == null)
return 1;
}
if (o1.isProxyed() == o2.isProxyed())
return o1.getName().compareTo(o2.getName());
if (o1.isProxyed())
return -1;
return 1;
});

final LayoutInflater inflater = getLayoutInflater();
Expand Down Expand Up @@ -303,11 +288,10 @@ public static ProxyedApp[] getProxyedApps(Context context, boolean self) {

Iterator<ApplicationInfo> itAppInfo = lAppInfo.iterator();

Vector<ProxyedApp> vectorApps = new Vector<ProxyedApp>();
Vector<ProxyedApp> vectorApps = new Vector<>();

ApplicationInfo aInfo = null;
ApplicationInfo aInfo;

int appIdx = 0;

while (itAppInfo.hasNext()) {
aInfo = itAppInfo.next();
Expand All @@ -327,11 +311,7 @@ public static ProxyedApp[] getProxyedApps(Context context, boolean self) {
&& aInfo.packageName.equals("org.proxydroid")) {
if (self)
app.setProxyed(true);
} else if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {
app.setProxyed(true);
} else {
app.setProxyed(false);
}
} else app.setProxyed(Arrays.binarySearch(tordApps, app.getUsername()) >= 0);

if (app.isProxyed())
vectorApps.add(app);
Expand Down Expand Up @@ -360,7 +340,7 @@ public void getApps(Context context) {

Arrays.sort(tordApps);

Vector<ProxyedApp> vectorApps = new Vector<ProxyedApp>();
Vector<ProxyedApp> vectorApps = new Vector<>();

// else load the apps up
PackageManager pMgr = context.getPackageManager();
Expand All @@ -369,7 +349,7 @@ public void getApps(Context context) {

Iterator<ApplicationInfo> itAppInfo = lAppInfo.iterator();

ApplicationInfo aInfo = null;
ApplicationInfo aInfo;

while (itAppInfo.hasNext()) {
aInfo = itAppInfo.next();
Expand All @@ -395,11 +375,7 @@ public void getApps(Context context) {
tApp.setName(pMgr.getApplicationLabel(aInfo).toString());

// check if this application is allowed
if (Arrays.binarySearch(tordApps, tApp.getUsername()) >= 0) {
tApp.setProxyed(true);
} else {
tApp.setProxyed(false);
}
tApp.setProxyed(Arrays.binarySearch(tordApps, tApp.getUsername()) >= 0);

vectorApps.add(tApp);
}
Expand All @@ -409,28 +385,25 @@ public void getApps(Context context) {

}

public void saveAppSettings(Context context) {
public void saveAppSettings() {
if (apps == null)
return;

SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);

// final SharedPreferences prefs =
// context.getSharedPreferences(PREFS_KEY, 0);

StringBuilder tordApps = new StringBuilder();

for (int i = 0; i < apps.length; i++) {
if (apps[i].isProxyed()) {
tordApps.append(apps[i].getUsername());
for (ProxyedApp app : apps) {
if (app.isProxyed()) {
tordApps.append(app.getUsername());
tordApps.append("|");
}
}

Editor edit = prefs.edit();
edit.putString(PREFS_KEY_PROXYED, tordApps.toString());
edit.commit();
edit.apply();

}

Expand All @@ -444,7 +417,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
app.setProxyed(isChecked);
}

saveAppSettings(this);
saveAppSettings();

}

Expand All @@ -459,7 +432,7 @@ public void onClick(View v) {
cbox.setChecked(app.isProxyed());
}

saveAppSettings(this);
saveAppSettings();

}

Expand Down
Loading

0 comments on commit 057338f

Please sign in to comment.