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