Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perferences #66

Merged
merged 5 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@ plugins {
dependencies {
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
// implementation 'org.ini4j:ini4j:0.5.4'
implementation 'org.apache.commons:commons-configuration2:2.9.0'
}
configurations {
all{
//exclude group: 'commons-logging', module: 'commons-logging'
//exclude group: 'org.apache.httpcomponents'
exclude module: 'httpclient'
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}

android {
lintOptions {
// Not so a good way
disable 'DuplicatePlatformClasses'
}

compileSdkVersion 33

defaultConfig {
applicationId "org.purplei2p.i2pd"
targetSdkVersion 33
// TODO: 24?
minSdkVersion 16
versionCode 2500200
versionName "2.50.2"
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
android:theme="@android:style/Theme.DeviceDefault"
android:usesCleartextTraffic="true">

<service
android:name=".I2PdQSTileService"
android:exported="true"
android:label="I2Pd"
android:icon="@drawable/ic_logo"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>

<receiver
android:enabled="true"
android:name="org.purplei2p.i2pd.receivers.BootUpReceiver"
Expand Down Expand Up @@ -64,6 +75,8 @@

<service
android:name=".ForegroundService"
android:exported="false"
android:stopWithTask="false"
android:enabled="true" />

<activity
Expand All @@ -74,5 +87,11 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.purplei2p.i2pd.I2PDPermsAskerActivity" />
</activity>
<activity
android:name=".MainPreferenceActivity"
android:label="Settings"
>
</activity>

</application>
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/java/org/purplei2p/i2pd/I2PDActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

startService(new Intent(this, ForegroundService.class));
textView = (TextView) findViewById(R.id.appStatusText);
HTTPProxyState = (CheckBox) findViewById(R.id.service_httpproxy_box);
SOCKSProxyState = (CheckBox) findViewById(R.id.service_socksproxy_box);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
} else if (requestCode == APP_STORAGE_ACCESS_REQUEST_CODE && resultCode == RESULT_OK) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Environment.isExternalStorageManager()) {
startMainActivity();
} else {
Expand All @@ -195,5 +196,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} else {
finish(); // close the app
}
}
}
}
56 changes: 56 additions & 0 deletions app/src/main/java/org/purplei2p/i2pd/I2PdQSTileService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.purplei2p.i2pd;

import android.content.Intent;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;

import android.annotation.TargetApi;
import android.os.Build;

@TargetApi(Build.VERSION_CODES.N)
public class I2PdQSTileService extends TileService {

private static final String TAG = "MyQSTileService";
@Override
public void onClick() {
super.onClick();
Log.d(TAG, "Tile clicked.");

try {
// Add the FLAG_ACTIVITY_NEW_TASK flag
Intent intent = new Intent(this, I2PDActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivityAndCollapse(intent);
} catch (Exception e) {
Log.e(TAG, "Error starting ForegroundService", e);
}
}



@Override
public void onStartListening() {
super.onStartListening();
Log.d(TAG, "Tile started listening.");
}

@Override
public void onStopListening() {
super.onStopListening();
Log.d(TAG, "Tile stopped listening.");
}

@Override
public void onTileAdded() {
super.onTileAdded();
Log.d(TAG, "Tile added.");
}

@Override
public void onTileRemoved() {
super.onTileRemoved();
Log.d(TAG, "Tile removed.");
}
}
Loading
Loading