Hello! I collect custom firmware, port functions into it, I have a question about this code:

package com.octogen.settings.fragments; import android.content.Context; import android.content.ContentResolver; import android.content.Intent; import android.content.pm.UserInfo; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.support.v7.preference.ListPreference; import android.support.v7.preference.PreferenceManager; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v14.preference.SwitchPreference; import android.provider.Settings; import com.android.settings.R; import android.support.annotation.NonNull; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.util.abc.AbcUtils; import com.android.settings.SettingsPreferenceFragment; import java.util.Arrays; import java.util.ArrayList; import java.util.List; import java.util.LinkedHashMap; import android.provider.SearchIndexableResource; import android.text.TextUtils; import android.util.Log; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; import com.octogen.settings.preferences.SecureSettingSwitchPreference; public class PowerMenuSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener, Indexable { private static final String TAG = "PowerMenuSettings"; private static final String TORCH_POWER_BUTTON_GESTURE = "torch_power_button_gesture"; private ListPreference mPowerMenuAnimations; private SecureSettingSwitchPreference mAdvancedReboot; private ListPreference mTorchPowerButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.octogen_settings_power); final ContentResolver resolver = getActivity().getContentResolver(); final PreferenceScreen prefScreen = getPreferenceScreen(); mPowerMenuAnimations = (ListPreference) findPreference(POWER_MENU_ANIMATIONS); mPowerMenuAnimations.setValue(String.valueOf(Settings.System.getInt( getContentResolver(), Settings.System.POWER_MENU_ANIMATIONS, 0))); mPowerMenuAnimations.setSummary(mPowerMenuAnimations.getEntry()); mPowerMenuAnimations.setOnPreferenceChangeListener(this); mAdvancedReboot = (SecureSettingSwitchPreference) findPreference(Settings.Secure.ADVANCED_REBOOT); mAdvancedReboot.setOnPreferenceChangeListener(this); if (!AbcUtils.deviceHasFlashlight(getContext())) { Preference toRemove = prefScreen.findPreference(TORCH_POWER_BUTTON_GESTURE); if (toRemove != null) { prefScreen.removePreference(toRemove); } } else { mTorchPowerButton = (ListPreference) findPreference(TORCH_POWER_BUTTON_GESTURE); int mTorchPowerButtonValue = Settings.Secure.getInt(resolver, Settings.Secure.TORCH_POWER_BUTTON_GESTURE, 0); mTorchPowerButton.setValue(Integer.toString(mTorchPowerButtonValue)); mTorchPowerButton.setSummary(mTorchPowerButton.getEntry()); mTorchPowerButton.setOnPreferenceChangeListener(this); } } @Override public boolean onPreferenceTreeClick(Preference preference) { return super.onPreferenceTreeClick(preference); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { ContentResolver resolver = getActivity().getContentResolver(); boolean result = false; if (preference instanceof ListPreference) { if (preference == mPowerMenuAnimations) { Settings.System.putInt(getContentResolver(), Settings.System.POWER_MENU_ANIMATIONS, Integer.valueOf((String) newValue)); mPowerMenuAnimations.setValue(String.valueOf(newValue)); mPowerMenuAnimations.setSummary(mPowerMenuAnimations.getEntry()); return true; } } else if (preference instanceof SecureSettingSwitchPreference) { if (preference == mAdvancedReboot) { boolean value = (Boolean) newValue; Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADVANCED_REBOOT, value ? 1:0); Settings.Secure.putInt(getContentResolver(), Settings.Secure.GLOBAL_ACTION_DNAA, value ? 1:0); } return true; } if (preference == mTorchPowerButton) { int mTorchPowerButtonValue = Integer.valueOf((String) newValue); int index = mTorchPowerButton.findIndexOfValue((String) newValue); mTorchPowerButton.setSummary( mTorchPowerButton.getEntries()[index]); Settings.Secure.putInt(resolver, Settings.Secure.TORCH_POWER_BUTTON_GESTURE, mTorchPowerButtonValue); if (mTorchPowerButtonValue == 1) { //if doubletap for torch is enabled, switch off double tap for camera Settings.Secure.putInt(resolver, Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 1); } return true; } return result; } public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @Override public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled) { ArrayList<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>(); SearchIndexableResource sir = new SearchIndexableResource(context); sir.xmlResId = R.xml.octogen_settings_power; result.add(sir); return result; } public List<String> getNonIndexableKeys(Context context) { ArrayList<String> result = new ArrayList<String>(); return result; } }; @Override public int getMetricsCategory() { return MetricsProto.MetricsEvent.OCTOGEN_SETTINGS; } } 

Not going with an error:

 PowerMenuSettings.java:70.64: POWER_MENU_ANIMATIONS cannot be resolved to a variable 

Closed due to the fact that off-topic participants diraria , katso , Cheg , andreymal , HamSter Sep 17 '17 at 7:07 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - diraria, katso, Cheg, andreymal, HamSter
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Try to replace POWER_MENU_ANIMATIONS with Settings.System.POWER_MENU_ANIMATIONS in line 70 - diraria
  • one
    Thank you, but this was not the case =) I added an answer to my question) - MrMEX
  • Yes, I saw, and even plied it) - diraria

1 answer 1

Oops, the question is removed, it did not add:

 private static final String POWER_MENU_ANIMATIONS = "power_menu_animations";