Skip to content

Commit

Permalink
Fix permissions, Fix ForegroundService on Android>=34, remove all Tit…
Browse files Browse the repository at this point in the history
…lePageIndicators.
  • Loading branch information
eyedeekay committed Oct 16, 2024
1 parent 128f1df commit a06b449
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 24 deletions.
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<!-- following two are for UPnP -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
Expand All @@ -29,7 +30,10 @@
android:icon="@drawable/ic_launcher_itoopie"
android:enabled="true"
android:exported="true"
android:label="@string/app_name">
android:label="@string/app_name"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="i2p_router_background_process_required_network_operation"/>
<intent-filter>
<action android:name="net.i2p.android.router.service.IRouterState" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import android.widget.ImageButton;
import android.widget.Toast;

import com.viewpagerindicator.TitlePageIndicator;
//import com.viewpagerindicator.TitlePageIndicator;

import net.i2p.android.i2ptunnel.preferences.EditTunnelContainerFragment;
import net.i2p.android.i2ptunnel.util.TunnelUtil;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class TunnelsContainer extends Fragment implements
private boolean mTwoPane;

ViewPager mViewPager;
TitlePageIndicator mPageIndicator;
//TitlePageIndicator mPageIndicator;
FragmentPagerAdapter mFragPagerAdapter;

private static final String FRAGMENT_CLIENT = "client_fragment";
Expand Down Expand Up @@ -82,7 +82,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View v = inflater.inflate(R.layout.container_tunnels, container, false);

mViewPager = (ViewPager) v.findViewById(R.id.pager);
mPageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
//mPageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
mNewTunnel = (ImageButton) v.findViewById(R.id.promoted_action);
mNewTunnel.setVisibility(showActions() ? View.VISIBLE : View.GONE);

Expand Down Expand Up @@ -111,7 +111,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
mViewPager.setAdapter(mFragPagerAdapter);

// Bind the page indicator to the pager.
mPageIndicator.setViewPager(mViewPager);
//mPageIndicator.setViewPager(mViewPager);

mNewTunnel.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import android.view.View;
import android.view.ViewGroup;

import com.viewpagerindicator.TitlePageIndicator;
//import com.viewpagerindicator.TitlePageIndicator;

import net.i2p.android.router.R;
import net.i2p.android.router.util.NamingServiceUtil;
Expand Down Expand Up @@ -92,10 +92,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

if (!mTwoPane) {
mViewPager = (ViewPager) v.findViewById(R.id.pager);
TitlePageIndicator pageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
//TitlePageIndicator pageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
mFragPagerAdapter = new AddressbookPagerAdapter(getActivity(), getChildFragmentManager());
mViewPager.setAdapter(mFragPagerAdapter);
pageIndicator.setViewPager(mViewPager);
//pageIndicator.setViewPager(mViewPager);
}

return v;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.i2p.android.router.service;

import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -173,11 +175,18 @@ public int onStartCommand(Intent intent, int flags, int startId) {
// We need to *not* check if we're restarting on Android greater than Oreo due to
// changes in how notifications work and the use of NotificationChannels.
if(!restart) {
startForeground(1337, _statusBar.getNote());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(1337, _statusBar.getNote(), FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
startForeground(1337, _statusBar.getNote());
}
} else {
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
startForeground(1337, _statusBar.getNote());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(1337, _statusBar.getNote(), FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void update(String title, String text) {
mNotificationManager.createNotificationChannel(mNotificationChannel);
mNotificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
mNotifyBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
//
}
mNotif = mNotifyBuilder.build();
mNotificationManager.notify(ID, mNotif);
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/layout/container_addressbook_onepane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
android:layout_height="match_parent"
android:orientation="vertical">

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/page_indicator"
style="@style/PagerIndicator" />

<!-- The main content view -->
<android.support.v4.view.ViewPager
android:id="@+id/pager"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/layout/container_tunnels_twopane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
android:layout_weight="2"
android:orientation="vertical">

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/page_indicator"
style="@style/PagerIndicator" />

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/res/layout/container_with_add_onepane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/page_indicator"
style="@style/PagerIndicator" />

<!-- The main content view -->
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/page_indicator" />
android:layout_alignParentBottom="true" />

<net.i2p.android.ext.floatingactionbutton.AddFloatingActionButton
android:id="@+id/promoted_action"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ANDROID_BUILD_SDK_VERSION=34

I2P_VERSION=2.7.0
I2P_ANDROID_VERSION=2.7.0
I2P_ANDROID_VERSION_CODE=4745286
I2P_ANDROID_VERSION_CODE=4745288
android.disableAutomaticComponentCreation=true
android.useAndroidX=true
#android.enableJetifier=true

0 comments on commit a06b449

Please sign in to comment.