Skip to content

Commit

Permalink
LockscreenWidgets: update prefs.
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Dec 4, 2024
1 parent 08a578f commit 0fd16d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.preference.ListPreference;
Expand All @@ -32,7 +33,7 @@
import it.dhd.oxygencustomizer.weather.OmniJawsClient;
import it.dhd.oxygencustomizer.weather.WeatherConfig;

public class LockscreenWidgets extends ControlledPreferenceFragmentCompat implements Preference.OnPreferenceChangeListener{
public class LockscreenWidgets extends ControlledPreferenceFragmentCompat{

private OmniJawsClient mWeatherClient;
private PackageListAdapter mPackageAdapter;
Expand Down Expand Up @@ -103,12 +104,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
mExtraWidget4,
mDeviceInfoWidgetPref);

for (Preference widgetPref : mWidgetPreferences) {
if (widgetPref != null) {
widgetPref.setOnPreferenceChangeListener(this);
}
}

}

private List<String> replaceEmptyWithNone(List<String> inputList) {
Expand Down Expand Up @@ -143,6 +138,15 @@ public void updateScreen(String key) {

if (key == null) return;

for (Preference widgetPref : mWidgetPreferences) {
if (widgetPref != null && key.equals(widgetPref.getKey())) {
String value = mPreferences.getString(key, "none");
if (value.equals("customapp")) {
pickApp(key);
}
}
}

savePrefs();
}

Expand Down Expand Up @@ -183,13 +187,4 @@ private void savePrefs() {
WeatherScheduler.scheduleUpdateNow(getContext());
}
}

@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
if (newValue.equals("customapp")) {
pickApp(preference.getKey());
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;

Expand All @@ -174,6 +175,7 @@
import java.util.Collections;
import java.util.List;

import it.dhd.oneplusui.preference.OplusListPreference;
import it.dhd.oneplusui.preference.OplusSliderPreference;
import it.dhd.oneplusui.preference.OplusSwitchPreference;
import it.dhd.oxygencustomizer.BuildConfig;
Expand Down Expand Up @@ -1176,6 +1178,8 @@ public static void setupPreference(Preference preference) {
if (prefValue.contains("customapp:")) {
preference.setSummaryProvider(preference1 -> preference1.getContext().getString(R.string.qs_widget_custom_app) + "\n" +
AppUtils.getAppName(preference1.getContext(), prefValue.replace("customapp:", "")));
} else {
preference.setSummaryProvider(ListPreference.SimpleSummaryProvider.getInstance());
}
}

Expand Down

0 comments on commit 0fd16d3

Please sign in to comment.