Skip to content

Commit

Permalink
Happy Lambda & other lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Apr 21, 2017
1 parent 151c43a commit 059f373
Show file tree
Hide file tree
Showing 16 changed files with 373 additions and 575 deletions.
20 changes: 6 additions & 14 deletions app/src/main/java/de/Maxr1998/xposed/maxlock/MLImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,13 @@ public ImplementationDialog() {

group.check(getImplementation(MLPreferences.getPreferences(c)) == DEFAULT ? R.id.implementation_item_default : R.id.implementation_item_no_xposed);

group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
updateView();
}
});
group.setOnCheckedChangeListener((radioGroup, i) -> updateView());

accessibilityError.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
c.startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
accessibilityError.setOnClickListener(v -> {
try {
c.startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
});

Expand Down
85 changes: 29 additions & 56 deletions app/src/main/java/de/Maxr1998/xposed/maxlock/ui/LockActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package de.Maxr1998.xposed.maxlock.ui;

import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -113,63 +112,37 @@ private void fakeDieSetup() {
String requestPkgFullName = (String) (requestPkgInfo != null ? pm.getApplicationLabel(requestPkgInfo) : "(unknown)");
AlertDialog.Builder fakeDieDialogBuilder = new AlertDialog.Builder(this);
fakeDieDialog = fakeDieDialogBuilder.setMessage(String.format(getResources().getString(R.string.dialog_text_fake_die_stopped), requestPkgFullName))
.setNeutralButton(R.string.dialog_button_report, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (prefs.getBoolean(Common.ENABLE_DIRECT_UNLOCK, false)) {
fakeDieDialog.dismiss();
launchLockView();
finish();
} else {
fakeDieDialog.dismiss();
final EditText input = new EditText(LockActivity.this);
input.setMinLines(2);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
AlertDialog.Builder reportDialogBuilder = new AlertDialog.Builder(LockActivity.this);
reportDialog = reportDialogBuilder.setView(input)
.setTitle(R.string.dialog_title_report_problem)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (input.getText().toString().equals(prefs.getString(Common.FAKE_CRASH_INPUT, "start"))) {
reportDialog.dismiss();
launchLockView();
finish();
} else {
Toast.makeText(LockActivity.this, "Thanks for your feedback", Toast.LENGTH_SHORT).show();
onBackPressed();
}
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
onBackPressed();
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
onBackPressed();
}
})
.create();
reportDialog.show();
}
}
})
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
onBackPressed();
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
onBackPressed();
.setNeutralButton(R.string.dialog_button_report, (dialogInterface, i) -> {
if (prefs.getBoolean(Common.ENABLE_DIRECT_UNLOCK, false)) {
fakeDieDialog.dismiss();
launchLockView();
finish();
} else {
fakeDieDialog.dismiss();
final EditText input = new EditText(LockActivity.this);
input.setMinLines(2);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
AlertDialog.Builder reportDialogBuilder = new AlertDialog.Builder(LockActivity.this);
reportDialog = reportDialogBuilder.setView(input)
.setTitle(R.string.dialog_title_report_problem)
.setPositiveButton(android.R.string.ok, (dialogInterface1, i1) -> {
if (input.getText().toString().equals(prefs.getString(Common.FAKE_CRASH_INPUT, "start"))) {
reportDialog.dismiss();
launchLockView();
finish();
} else {
Toast.makeText(LockActivity.this, "Thanks for your feedback", Toast.LENGTH_SHORT).show();
onBackPressed();
}
})
.setNegativeButton(android.R.string.cancel, (dialogInterface12, i12) -> onBackPressed())
.setOnCancelListener(dialogInterface13 -> onBackPressed())
.create();
reportDialog.show();
}
})
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> onBackPressed())
.setOnCancelListener(dialogInterface -> onBackPressed())
.create();
fakeDieDialog.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
Expand Down Expand Up @@ -50,7 +49,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;

import java.util.Arrays;

Expand Down Expand Up @@ -176,13 +174,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
SwitchCompat master_switch = (SwitchCompat) MenuItemCompat.getActionView(menu.findItem(R.id.toolbar_master_switch));
//noinspection deprecation
master_switch.setChecked(MLPreferences.getPrefsApps(this).getBoolean(Common.MASTER_SWITCH_ON, true));
master_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@SuppressLint({"CommitPrefEdits"})
@Override
public void onCheckedChanged(CompoundButton button, boolean b) {
MLPreferences.getPrefsApps(SettingsActivity.this).edit().putBoolean(Common.MASTER_SWITCH_ON, b).commit();
}
});
master_switch.setOnCheckedChangeListener((button, b) -> MLPreferences.getPrefsApps(SettingsActivity.this).edit().putBoolean(Common.MASTER_SWITCH_ON, b).commit());
Fragment lockScreen = getSupportFragmentManager().findFragmentByTag(TAG_LOCK_FRAGMENT);
if (getSupportActionBar() != null && !getSupportActionBar().isShowing() && (lockScreen == null || !lockScreen.isVisible())) {
getSupportActionBar().show();
Expand Down Expand Up @@ -253,15 +245,12 @@ public void updateXposedStatusAlert() {
//noinspection ConstantConditions
findViewById(R.id.xposed_active).setVisibility(showWarning ? View.VISIBLE : View.GONE);
//noinspection ConstantConditions
findViewById(R.id.xposed_active_message).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog help = new AlertDialog.Builder(SettingsActivity.this)
.setTitle(R.string.maxlock_inactive)
.setMessage(R.string.dialog_message_not_active)
.create();
help.show();
}
findViewById(R.id.xposed_active_message).setOnClickListener(v -> {
AlertDialog help = new AlertDialog.Builder(SettingsActivity.this)
.setTitle(R.string.maxlock_inactive)
.setMessage(R.string.dialog_message_not_active)
.create();
help.show();
});
}
}
Expand Down Expand Up @@ -300,14 +289,11 @@ public void restart() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_text_restart_required);
builder.setTitle(R.string.app_name)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = getIntent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
finish();
startActivity(intent);
}
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
Intent intent = getIntent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
finish();
startActivity(intent);
}).create().show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,22 @@ protected void onCreate(Bundle savedInstanceState) {

final RadioGroup options = (RadioGroup) findViewById(R.id.tasker_config_options);
final Button apply = (Button) findViewById(R.id.tasker_apply_button);
apply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int checked = options.getCheckedRadioButtonId();
result = new Intent();
if (taskerMode) {
Bundle resultBundle = new Bundle();
resultBundle.putInt(ACTION_EXTRA_KEY, ActionsHelper.getKey(checked));
result.putExtra(EXTRA_BUNDLE, resultBundle);
result.putExtra(EXTRA_STRING_BLURB, ((RadioButton) findViewById(checked)).getText().toString());
} else {
Intent shortcut = new Intent(ActionConfigActivity.this, ActionActivity.class);
shortcut.putExtra(ACTION_EXTRA_KEY, getKey(checked));
result.putExtra(Intent.EXTRA_SHORTCUT_NAME, ((RadioButton) findViewById(checked)).getText().toString());
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher));
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut);
}
finish();
apply.setOnClickListener(view -> {
int checked = options.getCheckedRadioButtonId();
result = new Intent();
if (taskerMode) {
Bundle resultBundle = new Bundle();
resultBundle.putInt(ACTION_EXTRA_KEY, ActionsHelper.getKey(checked));
result.putExtra(EXTRA_BUNDLE, resultBundle);
result.putExtra(EXTRA_STRING_BLURB, ((RadioButton) findViewById(checked)).getText().toString());
} else {
Intent shortcut = new Intent(ActionConfigActivity.this, ActionActivity.class);
shortcut.putExtra(ACTION_EXTRA_KEY, getKey(checked));
result.putExtra(Intent.EXTRA_SHORTCUT_NAME, ((RadioButton) findViewById(checked)).getText().toString());
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher));
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut);
}
finish();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import android.support.annotation.DrawableRes;
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
import android.support.v4.os.CancellationSignal;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

Expand All @@ -42,12 +41,7 @@
public final class FingerprintView extends ImageView {

private final LockView mLockView;
private final OnClickListener mNotAllowedToast = new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), R.string.message_fingerprint_disabled, Toast.LENGTH_SHORT).show();
}
};
private final OnClickListener mNotAllowedToast = v -> Toast.makeText(getContext(), R.string.message_fingerprint_disabled, Toast.LENGTH_SHORT).show();
private CancellationSignal mCancelFingerprint = new CancellationSignal();
private final FingerprintManagerCompat.AuthenticationCallback mFPAuthenticationCallback = new FingerprintManagerCompat.AuthenticationCallback() {
@Override
Expand All @@ -65,12 +59,7 @@ public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationRes
public void onAuthenticationFailed() {
handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_fp_to_error_state_animation);
if (mLockView.allowFingerprint()) {
postDelayed(new Runnable() {
@Override
public void run() {
handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_error_state_to_fp_animation);
}
}, 800);
postDelayed(() -> handleFingerprintIndicator(R.drawable.lockscreen_fingerprint_error_state_to_fp_animation), 800);
} else {
mCancelFingerprint.cancel();
setOnClickListener(mNotAllowedToast);
Expand Down
Loading

0 comments on commit 059f373

Please sign in to comment.