Skip to content

Commit cf5fe2e

Browse files
Perferences (#66)
1 parent 938a85b commit cf5fe2e

13 files changed

+653
-1235
lines changed

app/build.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@ plugins {
55
dependencies {
66
implementation 'androidx.core:core:1.9.0'
77
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
8+
// implementation 'org.ini4j:ini4j:0.5.4'
9+
implementation 'org.apache.commons:commons-configuration2:2.9.0'
10+
}
11+
configurations {
12+
all{
13+
//exclude group: 'commons-logging', module: 'commons-logging'
14+
//exclude group: 'org.apache.httpcomponents'
15+
exclude module: 'httpclient'
16+
}
817
}
918

1019
android {
20+
lintOptions {
21+
// Not so a good way
22+
disable 'DuplicatePlatformClasses'
23+
}
24+
1125
compileSdkVersion 33
1226

1327
defaultConfig {
1428
applicationId "org.purplei2p.i2pd"
1529
targetSdkVersion 33
30+
// TODO: 24?
1631
minSdkVersion 16
1732
versionCode 2500200
1833
versionName "2.50.2"

app/src/main/AndroidManifest.xml

+19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
android:theme="@android:style/Theme.DeviceDefault"
2424
android:usesCleartextTraffic="true">
2525

26+
<service
27+
android:name=".I2PdQSTileService"
28+
android:exported="true"
29+
android:label="I2Pd"
30+
android:icon="@drawable/ic_logo"
31+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
32+
<intent-filter>
33+
<action android:name="android.service.quicksettings.action.QS_TILE" />
34+
</intent-filter>
35+
</service>
36+
2637
<receiver
2738
android:enabled="true"
2839
android:name="org.purplei2p.i2pd.receivers.BootUpReceiver"
@@ -64,6 +75,8 @@
6475

6576
<service
6677
android:name=".ForegroundService"
78+
android:exported="false"
79+
android:stopWithTask="false"
6780
android:enabled="true" />
6881

6982
<activity
@@ -74,5 +87,11 @@
7487
android:name="android.support.PARENT_ACTIVITY"
7588
android:value="org.purplei2p.i2pd.I2PDPermsAskerActivity" />
7689
</activity>
90+
<activity
91+
android:name=".MainPreferenceActivity"
92+
android:label="Settings"
93+
>
94+
</activity>
95+
7796
</application>
7897
</manifest>

app/src/main/java/org/purplei2p/i2pd/I2PDActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void onCreate(Bundle savedInstanceState) {
111111
Log.d(TAG, "onCreate");
112112
super.onCreate(savedInstanceState);
113113
setContentView(R.layout.activity_main);
114-
114+
startService(new Intent(this, ForegroundService.class));
115115
textView = (TextView) findViewById(R.id.appStatusText);
116116
HTTPProxyState = (CheckBox) findViewById(R.id.service_httpproxy_box);
117117
SOCKSProxyState = (CheckBox) findViewById(R.id.service_socksproxy_box);

app/src/main/java/org/purplei2p/i2pd/I2PDPermsAskerActivity.java

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
183183
}
184184
}
185185
} else if (requestCode == APP_STORAGE_ACCESS_REQUEST_CODE && resultCode == RESULT_OK) {
186+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
186187
if (Environment.isExternalStorageManager()) {
187188
startMainActivity();
188189
} else {
@@ -195,5 +196,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
195196
} else {
196197
finish(); // close the app
197198
}
199+
}
198200
}
199201
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.purplei2p.i2pd;
2+
3+
import android.content.Intent;
4+
import android.service.quicksettings.Tile;
5+
import android.service.quicksettings.TileService;
6+
import android.util.Log;
7+
8+
import android.annotation.TargetApi;
9+
import android.os.Build;
10+
11+
@TargetApi(Build.VERSION_CODES.N)
12+
public class I2PdQSTileService extends TileService {
13+
14+
private static final String TAG = "MyQSTileService";
15+
@Override
16+
public void onClick() {
17+
super.onClick();
18+
Log.d(TAG, "Tile clicked.");
19+
20+
try {
21+
// Add the FLAG_ACTIVITY_NEW_TASK flag
22+
Intent intent = new Intent(this, I2PDActivity.class);
23+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
24+
25+
startActivityAndCollapse(intent);
26+
} catch (Exception e) {
27+
Log.e(TAG, "Error starting ForegroundService", e);
28+
}
29+
}
30+
31+
32+
33+
@Override
34+
public void onStartListening() {
35+
super.onStartListening();
36+
Log.d(TAG, "Tile started listening.");
37+
}
38+
39+
@Override
40+
public void onStopListening() {
41+
super.onStopListening();
42+
Log.d(TAG, "Tile stopped listening.");
43+
}
44+
45+
@Override
46+
public void onTileAdded() {
47+
super.onTileAdded();
48+
Log.d(TAG, "Tile added.");
49+
}
50+
51+
@Override
52+
public void onTileRemoved() {
53+
super.onTileRemoved();
54+
Log.d(TAG, "Tile removed.");
55+
}
56+
}

0 commit comments

Comments
 (0)