Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline fingerprint vibration switch into lockscreen fragment [2/2] #9

Open
wants to merge 1 commit into
base: r
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions res/values/wave_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,7 @@
<string name="pocket_judge_title">Pocket detection</string>
<string name="pocket_judge_summary">Block screen and button inputs when device is in pocket</string>

<!-- Fingerprint authentication vibration -->
<string name="fprint_sucess_vib_title">Fingerprint authentication vibration</string>
<string name="fprint_sucess_vib_summary">Vibrate on successful fingerprint authentication</string>
</resources>
6 changes: 6 additions & 0 deletions res/xml/security_lockscreen_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
android:summary="@string/lockscreen_battery_info_summary"
android:defaultValue="true" />

<SwitchPreference
android:key="fingerprint_success_vib"
android:title="@string/fprint_sucess_vib_title"
android:summary="@string/fprint_sucess_vib_summary"
android:defaultValue="true" />

</PreferenceCategory>

<PreferenceCategory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2018 ArrowOS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.settings.security;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

import androidx.preference.SwitchPreference;
import androidx.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.DisplaySettings;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;

import static android.provider.Settings.System.FINGERPRINT_SUCCESS_VIB;

public class FPVibrationPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin, Preference.OnPreferenceChangeListener{

private static final String PREF_FINGERPRINT_VIBE = "fingerprint_success_vib";

public FPVibrationPreferenceController(Context context) {
super(context);
}

@Override
public String getPreferenceKey() {
return PREF_FINGERPRINT_VIBE;
}

@Override
public void updateState(Preference preference) {
int FPVibrationValue = Settings.System.getInt(mContext.getContentResolver(),
FINGERPRINT_SUCCESS_VIB, 1);
((SwitchPreference) preference).setChecked(FPVibrationValue != 0);
}

@Override
public boolean isAvailable() {
return true;
}

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean FPVibrationValue = (Boolean) newValue;
Settings.System.putInt(mContext.getContentResolver(), FINGERPRINT_SUCCESS_VIB, FPVibrationValue ? 1 : 0);
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected List<AbstractPreferenceController> createPreferenceControllers(Context
controllers.add(notificationController);
mOwnerInfoPreferenceController = new OwnerInfoPreferenceController(context, this);
controllers.add(mOwnerInfoPreferenceController);
controllers.add(new FPVibrationPreferenceController(context));

return controllers;
}
Expand Down Expand Up @@ -137,6 +138,7 @@ public List<AbstractPreferenceController> createPreferenceControllers(
controllers.add(new LockScreenNotificationPreferenceController(context));
controllers.add(new OwnerInfoPreferenceController(
context, null /* fragment */));
controllers.add(new FPVibrationPreferenceController(context));
return controllers;
}

Expand Down