This repository has been archived by the owner on Mar 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
246 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/net/frakbot/FWeather/fragments/AdvancedPreferencesFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2013 Sebastiano Poggi and Francesco Pontillo | ||
* | ||
* 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 net.frakbot.FWeather.fragments; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.annotation.TargetApi; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import net.frakbot.FWeather.R; | ||
import net.frakbot.FWeather.activity.SettingsActivity; | ||
import org.jraf.android.backport.switchwidget.SwitchPreference; | ||
|
||
/** | ||
* This fragment shows advanced settings only. It is used when the activity | ||
* is showing a two-pane settings UI. | ||
*/ | ||
@SuppressLint("ValidFragment") | ||
@TargetApi(Build.VERSION_CODES.HONEYCOMB) | ||
public class AdvancedPreferencesFragment extends BackupPreferenceFragment { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.pref_advanced); | ||
|
||
if (getActivity() instanceof SettingsActivity) { | ||
((SettingsActivity)getActivity()).setupAnalyticsOnChangeListener( | ||
(SwitchPreference) findPreference(getString(R.string.pref_key_analytics))); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/net/frakbot/FWeather/fragments/BackupPreferenceFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2013 Sebastiano Poggi and Francesco Pontillo | ||
* | ||
* 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 net.frakbot.FWeather.fragments; | ||
|
||
import android.annotation.TargetApi; | ||
import android.app.backup.BackupManager; | ||
import android.content.SharedPreferences; | ||
import android.os.Build; | ||
import android.preference.PreferenceFragment; | ||
|
||
/** | ||
* PreferenceFragment extension that takes care of registering/unregistering against | ||
* SharedPreferences changes and notifying any changes to the underlying BackupManager. | ||
* | ||
* @author Francesco Pontillo | ||
*/ | ||
@TargetApi(Build.VERSION_CODES.HONEYCOMB) | ||
public class BackupPreferenceFragment extends PreferenceFragment implements | ||
SharedPreferences.OnSharedPreferenceChangeListener { | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
getPreferenceManager().getSharedPreferences() | ||
.registerOnSharedPreferenceChangeListener(this); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
getPreferenceManager().getSharedPreferences() | ||
.unregisterOnSharedPreferenceChangeListener(this); | ||
} | ||
|
||
@Override | ||
public void onSharedPreferenceChanged( | ||
SharedPreferences sharedPreferences, String s) { | ||
new BackupManager(getActivity()).dataChanged(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/net/frakbot/FWeather/fragments/CustomizationPreferencesFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2013 Sebastiano Poggi and Francesco Pontillo | ||
* | ||
* 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 net.frakbot.FWeather.fragments; | ||
|
||
import android.annotation.TargetApi; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import net.frakbot.FWeather.R; | ||
|
||
/** | ||
* This fragment shows customization preferences only. It is used when the | ||
* activity is showing a two-pane settings UI. | ||
*/ | ||
@TargetApi(Build.VERSION_CODES.HONEYCOMB) | ||
public class CustomizationPreferencesFragment extends BackupPreferenceFragment { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.pref_customization); | ||
} | ||
} |
Oops, something went wrong.