mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-24 12:15:12 +00:00
Java 8 migration
This commit is contained in:
parent
9b0a17ab0a
commit
cbef592f8d
14 changed files with 97 additions and 188 deletions
|
@ -78,12 +78,9 @@ public class GmsConnector<C extends ApiClient, R extends Result> {
|
||||||
final AbstractPendingResult<R> result = (AbstractPendingResult<R>) msg.obj;
|
final AbstractPendingResult<R> result = (AbstractPendingResult<R>) msg.obj;
|
||||||
try {
|
try {
|
||||||
C connection = (C) apiClient.getApiConnection(api);
|
C connection = (C) apiClient.getApiConnection(api);
|
||||||
callback.onClientAvailable(connection, new GmsConnector.Callback.ResultProvider<R>() {
|
callback.onClientAvailable(connection, realResult -> {
|
||||||
@Override
|
|
||||||
public void onResultAvailable(R realResult) {
|
|
||||||
result.deliverResult(realResult);
|
result.deliverResult(realResult);
|
||||||
apiClient.decrementUsageCounter();
|
apiClient.decrementUsageCounter();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (RemoteException ignored) {
|
} catch (RemoteException ignored) {
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,10 @@ package org.microg.gms.common.api;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
import com.google.android.gms.common.ConnectionResult;
|
||||||
import com.google.android.gms.common.api.Api;
|
import com.google.android.gms.common.api.Api;
|
||||||
import com.google.android.gms.common.api.GoogleApiClient;
|
import com.google.android.gms.common.api.GoogleApiClient;
|
||||||
|
@ -65,15 +63,11 @@ public class GoogleApiClientImpl implements GoogleApiClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final OnConnectionFailedListener baseConnectionFailedListener = new
|
private final OnConnectionFailedListener baseConnectionFailedListener = result -> {
|
||||||
OnConnectionFailedListener() {
|
|
||||||
@Override
|
|
||||||
public void onConnectionFailed(ConnectionResult result) {
|
|
||||||
Log.d(TAG, "OnConnectionFailedListener : onConnectionFailed()");
|
Log.d(TAG, "OnConnectionFailedListener : onConnectionFailed()");
|
||||||
for (OnConnectionFailedListener listener : connectionFailedListeners) {
|
for (OnConnectionFailedListener listener : connectionFailedListeners) {
|
||||||
listener.onConnectionFailed(result);
|
listener.onConnectionFailed(result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
private int usageCounter = 0;
|
private int usageCounter = 0;
|
||||||
private boolean shouldDisconnect = false;
|
private boolean shouldDisconnect = false;
|
||||||
|
|
|
@ -47,20 +47,14 @@ public abstract class AbstractDashboardActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void evaluateConditionAsync(final Condition condition) {
|
private void evaluateConditionAsync(final Condition condition) {
|
||||||
if (condition.willBeEvaluating()) {
|
if (condition.willBeEvaluating()) {
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (condition.isActive(AbstractDashboardActivity.this)) {
|
if (condition.isActive(AbstractDashboardActivity.this)) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (conditions.contains(condition) && condition.isEvaluated()) {
|
if (conditions.contains(condition) && condition.isEvaluated()) {
|
||||||
addConditionToView(condition);
|
addConditionToView(condition);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,7 @@ public class Condition {
|
||||||
}
|
}
|
||||||
final View detailGroup = view.findViewById(R.id.detail_group);
|
final View detailGroup = view.findViewById(R.id.detail_group);
|
||||||
final ImageView expandIndicator = (ImageView) view.findViewById(R.id.expand_indicator);
|
final ImageView expandIndicator = (ImageView) view.findViewById(R.id.expand_indicator);
|
||||||
View.OnClickListener expandListener = new View.OnClickListener() {
|
View.OnClickListener expandListener = v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (detailGroup.getVisibility() == View.VISIBLE) {
|
if (detailGroup.getVisibility() == View.VISIBLE) {
|
||||||
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_more, context.getTheme()));
|
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_more, context.getTheme()));
|
||||||
detailGroup.setVisibility(View.GONE);
|
detailGroup.setVisibility(View.GONE);
|
||||||
|
@ -118,7 +116,6 @@ public class Condition {
|
||||||
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_less, context.getTheme()));
|
expandIndicator.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), R.drawable.ic_expand_less, context.getTheme()));
|
||||||
detailGroup.setVisibility(View.VISIBLE);
|
detailGroup.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
view.findViewById(R.id.collapsed_group).setOnClickListener(expandListener);
|
view.findViewById(R.id.collapsed_group).setOnClickListener(expandListener);
|
||||||
expandIndicator.setOnClickListener(expandListener);
|
expandIndicator.setOnClickListener(expandListener);
|
||||||
|
|
|
@ -85,12 +85,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||||
mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
addOnSwitchChangeListener(new OnSwitchChangeListener() {
|
addOnSwitchChangeListener((switchView, isChecked) -> setTextViewLabel(isChecked));
|
||||||
@Override
|
|
||||||
public void onSwitchChanged(SwitchCompat switchView, boolean isChecked) {
|
|
||||||
setTextViewLabel(isChecked);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setOnClickListener(this);
|
setOnClickListener(this);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -39,7 +38,6 @@ import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.mgoogle.android.gms.R;
|
import com.mgoogle.android.gms.R;
|
||||||
import com.squareup.wire.Wire;
|
|
||||||
|
|
||||||
import org.microg.gms.common.PackageUtils;
|
import org.microg.gms.common.PackageUtils;
|
||||||
import org.microg.gms.people.PeopleManager;
|
import org.microg.gms.people.PeopleManager;
|
||||||
|
@ -119,18 +117,10 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||||
if (profileIcon != null) {
|
if (profileIcon != null) {
|
||||||
((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
|
((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
|
||||||
} else {
|
} else {
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
final Bitmap profileIcon1 = PeopleManager.getOwnerAvatarBitmap(AskPermissionActivity.this, account.name, true);
|
||||||
public void run() {
|
runOnUiThread(() -> ((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon1));
|
||||||
final Bitmap profileIcon = PeopleManager.getOwnerAvatarBitmap(AskPermissionActivity.this, account.name, true);
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
((ImageView) findViewById(R.id.account_photo)).setImageBitmap(profileIcon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,18 +130,8 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||||
} else {
|
} else {
|
||||||
((TextView) findViewById(R.id.title)).setText(getString(R.string.ask_service_permission_title, appLabel));
|
((TextView) findViewById(R.id.title)).setText(getString(R.string.ask_service_permission_title, appLabel));
|
||||||
}
|
}
|
||||||
findViewById(android.R.id.button1).setOnClickListener(new View.OnClickListener() {
|
findViewById(android.R.id.button1).setOnClickListener(v -> onAllow());
|
||||||
@Override
|
findViewById(android.R.id.button2).setOnClickListener(v -> onDeny());
|
||||||
public void onClick(View v) {
|
|
||||||
onAllow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
findViewById(android.R.id.button2).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
onDeny();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((ListView) findViewById(R.id.permissions)).setAdapter(new PermissionAdapter());
|
((ListView) findViewById(R.id.permissions)).setAdapter(new PermissionAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,9 +141,7 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||||
findViewById(android.R.id.button2).setEnabled(false);
|
findViewById(android.R.id.button2).setEnabled(false);
|
||||||
findViewById(R.id.progress_bar).setVisibility(VISIBLE);
|
findViewById(R.id.progress_bar).setVisibility(VISIBLE);
|
||||||
findViewById(R.id.no_progress_bar).setVisibility(GONE);
|
findViewById(R.id.no_progress_bar).setVisibility(GONE);
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
AuthResponse response = authManager.requestAuth(fromAccountManager);
|
AuthResponse response = authManager.requestAuth(fromAccountManager);
|
||||||
Bundle result = new Bundle();
|
Bundle result = new Bundle();
|
||||||
|
@ -178,7 +156,6 @@ public class AskPermissionActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.os.Bundle;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
@ -39,18 +38,8 @@ public abstract class AssistantActivity extends Activity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.login_assistant);
|
setContentView(R.layout.login_assistant);
|
||||||
formatTitle();
|
formatTitle();
|
||||||
findViewById(R.id.next_button).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.next_button).setOnClickListener(v -> onNextButtonClicked());
|
||||||
@Override
|
findViewById(R.id.back_button).setOnClickListener(v -> onBackButtonClicked());
|
||||||
public void onClick(View v) {
|
|
||||||
onNextButtonClicked();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
onBackButtonClicked();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("WrongViewCast")
|
@SuppressLint("WrongViewCast")
|
||||||
|
|
|
@ -307,12 +307,7 @@ public class CastMediaRouteProvider extends MediaRouteProvider {
|
||||||
|
|
||||||
private void publishRoutesInMainThread() {
|
private void publishRoutesInMainThread() {
|
||||||
Handler mainHandler = new Handler(this.getContext().getMainLooper());
|
Handler mainHandler = new Handler(this.getContext().getMainLooper());
|
||||||
mainHandler.post(new Runnable() {
|
mainHandler.post(this::publishRoutes);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
publishRoutes();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void publishRoutes() {
|
private void publishRoutes() {
|
||||||
|
|
|
@ -191,15 +191,12 @@ public class HttpFormClient {
|
||||||
|
|
||||||
public static <T> void requestAsync(final String url, final Request request, final Class<T> tClass,
|
public static <T> void requestAsync(final String url, final Request request, final Class<T> tClass,
|
||||||
final Callback<T> callback) {
|
final Callback<T> callback) {
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
callback.onResponse(request(url, request, tClass));
|
callback.onResponse(request(url, request, tClass));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
callback.onException(e);
|
callback.onException(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,16 +117,13 @@ public class RemoteListenerProxy<T extends IInterface> implements ServiceConnect
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
|
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
|
||||||
if (method.getDeclaringClass().equals(tClass)) {
|
if (method.getDeclaringClass().equals(tClass)) {
|
||||||
runOncePossible(new Runnable() {
|
runOncePossible(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
Object asInterface = Class.forName(tClass.getName() + "$Stub").getMethod("asInterface", IBinder.class).invoke(null, remote);
|
Object asInterface = Class.forName(tClass.getName() + "$Stub").getMethod("asInterface", IBinder.class).invoke(null, remote);
|
||||||
method.invoke(asInterface, args);
|
method.invoke(asInterface, args);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
connect();
|
connect();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -28,9 +28,7 @@ public class UnregisterReceiver extends BroadcastReceiver {
|
||||||
Log.d(TAG, "Package removed or data cleared: " + packageName);
|
Log.d(TAG, "Package removed or data cleared: " + packageName);
|
||||||
final GcmDatabase.App app = database.getApp(packageName);
|
final GcmDatabase.App app = database.getApp(packageName);
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
List<GcmDatabase.Registration> registrations = database.getRegistrationsByApp(packageName);
|
List<GcmDatabase.Registration> registrations = database.getRegistrationsByApp(packageName);
|
||||||
boolean deletedAll = true;
|
boolean deletedAll = true;
|
||||||
for (GcmDatabase.Registration registration : registrations) {
|
for (GcmDatabase.Registration registration : registrations) {
|
||||||
|
@ -40,7 +38,6 @@ public class UnregisterReceiver extends BroadcastReceiver {
|
||||||
database.removeApp(packageName);
|
database.removeApp(packageName);
|
||||||
}
|
}
|
||||||
database.close();
|
database.close();
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
database.close();
|
database.close();
|
||||||
|
|
|
@ -16,11 +16,9 @@
|
||||||
|
|
||||||
package org.microg.gms.people;
|
package org.microg.gms.people;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
@ -118,9 +116,7 @@ public class PeopleServiceImpl extends IPeopleService.Stub {
|
||||||
public ICancelToken loadOwnerAvatar(final IPeopleCallbacks callbacks, final String account, String pageId, int size, int flags) {
|
public ICancelToken loadOwnerAvatar(final IPeopleCallbacks callbacks, final String account, String pageId, int size, int flags) {
|
||||||
Log.d(TAG, "loadOwnerAvatar: " + account + ", " + pageId + ", " + size + ", " + flags);
|
Log.d(TAG, "loadOwnerAvatar: " + account + ", " + pageId + ", " + size + ", " + flags);
|
||||||
PackageUtils.assertExtendedAccess(context);
|
PackageUtils.assertExtendedAccess(context);
|
||||||
final Thread thread = new Thread(new Runnable() {
|
final Thread thread = new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putBoolean("rewindable", false);
|
extras.putBoolean("rewindable", false);
|
||||||
extras.putInt("width", 0);
|
extras.putInt("width", 0);
|
||||||
|
@ -135,7 +131,6 @@ public class PeopleServiceImpl extends IPeopleService.Stub {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
return new ICancelToken.Stub() {
|
return new ICancelToken.Stub() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
@ -58,30 +57,19 @@ public class AskPushPermission extends FragmentActivity {
|
||||||
CharSequence label = pm.getApplicationLabel(info);
|
CharSequence label = pm.getApplicationLabel(info);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.permission_message)).setText(Html.fromHtml("Allow <b>" + label + "</b> to register for push notifications?"));
|
((TextView) findViewById(R.id.permission_message)).setText(Html.fromHtml("Allow <b>" + label + "</b> to register for push notifications?"));
|
||||||
findViewById(R.id.permission_allow_button).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.permission_allow_button).setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (answered) return;
|
if (answered) return;
|
||||||
database.noteAppKnown(packageName, true);
|
database.noteAppKnown(packageName, true);
|
||||||
answered = true;
|
answered = true;
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> PushRegisterService.registerAndReply(AskPushPermission.this, database, intent, packageName, requestId)).start();
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PushRegisterService.registerAndReply(AskPushPermission.this, database, intent, packageName, requestId);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
findViewById(R.id.permission_deny_button).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.permission_deny_button).setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (answered) return;
|
if (answered) return;
|
||||||
database.noteAppKnown(packageName, false);
|
database.noteAppKnown(packageName, false);
|
||||||
answered = true;
|
answered = true;
|
||||||
PushRegisterService.replyNotAvailable(AskPushPermission.this, intent, packageName, requestId);
|
PushRegisterService.replyNotAvailable(AskPushPermission.this, intent, packageName, requestId);
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -55,14 +55,11 @@ public class Conditions {
|
||||||
return !pm.isIgnoringBatteryOptimizations(context.getPackageName());
|
return !pm.isIgnoringBatteryOptimizations(context.getPackageName());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.firstAction(R.string.cond_gcm_bat_action, new View.OnClickListener() {
|
.firstAction(R.string.cond_gcm_bat_action, v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (SDK_INT < 23) return;
|
if (SDK_INT < 23) return;
|
||||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||||
intent.setData(Uri.parse("package:" + v.getContext().getPackageName()));
|
intent.setData(Uri.parse("package:" + v.getContext().getPackageName()));
|
||||||
v.getContext().startActivity(intent);
|
v.getContext().startActivity(intent);
|
||||||
}
|
|
||||||
}).build();
|
}).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue