mirror of https://github.com/tasks/tasks
Convert google tasks status bar to checkbox
parent
7c4bc038ff
commit
a19efd96a7
@ -1,86 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.utility;
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.PreferenceGroup;
|
|
||||||
|
|
||||||
import org.tasks.injection.InjectingPreferenceActivity;
|
|
||||||
import org.tasks.preferences.Preferences;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a preference screen for users to edit their preferences. Override
|
|
||||||
* updatePreferences to update the summary with preference values.
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
abstract public class TodorooPreferenceActivity extends InjectingPreferenceActivity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update preferences for the given preference
|
|
||||||
* @param value setting. may be null.
|
|
||||||
*/
|
|
||||||
public abstract void updatePreferences(Preference preference, Object value);
|
|
||||||
|
|
||||||
// --- implementation
|
|
||||||
|
|
||||||
@Inject Preferences preferences;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
|
||||||
return preferences.getPrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializePreference(Preference preference) {
|
|
||||||
if(preference instanceof PreferenceGroup) {
|
|
||||||
PreferenceGroup group = (PreferenceGroup)preference;
|
|
||||||
for(int i = 0; i < group.getPreferenceCount(); i++) {
|
|
||||||
initializePreference(group.getPreference(i));
|
|
||||||
}
|
|
||||||
updatePreferences(group, null);
|
|
||||||
} else {
|
|
||||||
Object value = null;
|
|
||||||
if(preference instanceof ListPreference) {
|
|
||||||
value = ((ListPreference) preference).getValue();
|
|
||||||
} else if(preference instanceof CheckBoxPreference) {
|
|
||||||
value = ((CheckBoxPreference) preference).isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePreferences(preference, value);
|
|
||||||
|
|
||||||
if (preference.getOnPreferenceChangeListener() == null) {
|
|
||||||
preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference myPreference, Object newValue) {
|
|
||||||
updatePreferences(myPreference, newValue);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
|
||||||
super.onWindowFocusChanged(hasFocus);
|
|
||||||
if(hasFocus) {
|
|
||||||
initializePreference(getPreferenceScreen());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2006 The Android Open Source Project
|
|
||||||
|
|
||||||
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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Layout for a visually child-like Preference in a PreferenceActivity. -->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/status"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingRight="?android:attr/scrollbarSize">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="20dip"
|
|
||||||
android:layout_marginRight="6dip"
|
|
||||||
android:layout_marginTop="6dip"
|
|
||||||
android:layout_marginBottom="6dip"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<TextView android:id="@+android:id/title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="false"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:ellipsize="none"
|
|
||||||
android:fadingEdge="horizontal" />
|
|
||||||
|
|
||||||
<TextView android:id="@+android:id/summary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@android:id/title"
|
|
||||||
android:layout_alignLeft="@android:id/title"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<!-- Preference should place its actual preference widget here. -->
|
|
||||||
<LinearLayout android:id="@+android:id/widget_frame"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
Loading…
Reference in New Issue