Skip to content
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
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand All @@ -24,7 +24,7 @@ dependencies {
android {
publishNonDefault true
compileSdkVersion 25
buildToolsVersion "24.0.3"
buildToolsVersion "25.0.0"

defaultConfig {
versionName "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion library/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<item name="android:textColor">@color/passcodelock_button_text_color</item>
<item name="android:textSize">@dimen/passcodelock_button_text_size</item>
<item name="android:clickable">true</item>
<item name="android:background">?android:attr/selectableItemBackground</item>
<item name="android:background">?attr/selectableItemBackground</item>
</style>

<style name="PasscodeEditTextStyle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.SwitchPreference;

public class PasscodePreferenceFragment extends PreferenceFragment
implements Preference.OnPreferenceClickListener {
implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
public static final String KEY_SHOULD_INFLATE = "should-inflate";
public static final int ENABLE_PASSLOCK = 0;
public static final int DISABLE_PASSLOCK = 1;
Expand Down Expand Up @@ -34,15 +35,38 @@ public void onCreate(Bundle savedInstanceState) {
public boolean onPreferenceClick(Preference preference) {
String preferenceKey = preference.getKey() != null ? preference.getKey() : "";

if (preferenceKey.equals(getString(R.string.pref_key_passcode_toggle))) {
return handlePasscodeToggleClick();
} else if (preferenceKey.equals(getString(R.string.pref_key_change_passcode))) {
if (preferenceKey.equals(getString(R.string.pref_key_change_passcode))) {
return handleChangePasscodeClick();
}

return false;
}

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (newValue == null) return false;
String preferenceKey = preference.getKey() != null ? preference.getKey() : "";
if (!preferenceKey.equals(getString(R.string.pref_key_passcode_toggle))) {
// Make sure we're updating the correct preference item.
// Actually this check is not even required, since we've one item only that has set the
// OnPreferenceChangeListener.
return false;
}

Boolean newValueBool = (Boolean) newValue;
boolean oldValue = ((SwitchPreference)mTogglePasscodePreference).isChecked();
if (newValueBool == oldValue) {
// Already updated. Do not call the setup activity.
// This method get called twice if the click is on the row (not on the toggle visual item)
// on devices Pre-Lollip.
return true;
}

handlePasscodeToggleClick();

return true;
}

/**
* When the preferences are nested in a parent apps xml layout the inflated preferences will
* need to be set.
Expand Down Expand Up @@ -91,8 +115,8 @@ private boolean handleChangePasscodeClick() {
*/
private void refreshPreferenceState() {
if (mTogglePasscodePreference != null && mChangePasscodePreference != null) {
mTogglePasscodePreference.setOnPreferenceClickListener(this);
mChangePasscodePreference.setOnPreferenceClickListener(this);
mTogglePasscodePreference.setOnPreferenceChangeListener(this);

if (AppLockManager.getInstance().getAppLock().isPasswordLocked()) {
mTogglePasscodePreference.setTitle(R.string.passcode_turn_off);
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
buildToolsVersion "25.0.0"

buildTypes {
release {
Expand All @@ -22,7 +22,7 @@ android {

buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:2.2.2'
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</style>

<style name="PasscodeKeyboardButtonStyle" parent="@android:style/Widget.Button">
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
<item name="android:clickable">true</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/passcodelock_button_text_size</item>
Expand Down