Refactored some things to better specify plugin preference groups from the manifest

pull/14/head
Sam Bosley 13 years ago
parent 219fd78678
commit 3e25e0fb8a

@ -149,7 +149,10 @@
<string name="SyP_progress_toast">Synchronizing...</string> <string name="SyP_progress_toast">Synchronizing...</string>
<!-- Sync Label: used in menu to denote synchronization --> <!-- Sync Label: used in menu to denote synchronization -->
<string name="SyP_label">Synchronization</string> <string name="SyP_label">Sync &amp; Backup</string>
<!-- Sync label subtitle -->
<string name="SyP_summary">Astrid.com, Google Tasks, Saved Data &amp; Local Backup</string>
<!-- Error msg when io exception --> <!-- Error msg when io exception -->
<string name="SyP_ioerror">Connection Error! Check your Internet connection.</string> <string name="SyP_ioerror">Connection Error! Check your Internet connection.</string>

@ -265,6 +265,8 @@
<activity android:name="com.todoroo.astrid.core.DefaultsPreferences" <activity android:name="com.todoroo.astrid.core.DefaultsPreferences"
android:theme="@android:style/Theme" android:theme="@android:style/Theme"
android:label="@string/EPr_defaults_header"> android:label="@string/EPr_defaults_header">
<meta-data android:name="summary"
android:resource="@string/EPr_defaults_summary" />
<intent-filter> <intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" /> <action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@ -274,24 +276,6 @@
android:theme="@android:style/Theme"> android:theme="@android:style/Theme">
</activity> </activity>
<activity android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:theme="@android:style/Theme"
android:label="@string/EPr_manage_header">
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.todoroo.astrid.core.LabsPreferences"
android:theme="@android:style/Theme"
android:label="@string/EPr_labs_header">
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.todoroo.astrid.calls.MissedCallActivity" <activity android:name="com.todoroo.astrid.calls.MissedCallActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"> android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity> </activity>
@ -502,6 +486,18 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- old tasks -->
<activity android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:theme="@android:style/Theme"
android:label="@string/EPr_manage_header">
<meta-data android:name="category"
android:resource="@string/SyP_label" />
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- backup --> <!-- backup -->
<service android:name="com.todoroo.astrid.backup.BackupService"/> <service android:name="com.todoroo.astrid.backup.BackupService"/>
<activity android:name="com.todoroo.astrid.backup.BackupActivity" <activity android:name="com.todoroo.astrid.backup.BackupActivity"
@ -509,6 +505,8 @@
<activity android:name="com.todoroo.astrid.backup.BackupPreferences" <activity android:name="com.todoroo.astrid.backup.BackupPreferences"
android:theme="@android:style/Theme" android:theme="@android:style/Theme"
android:label="@string/backup_BPr_header"> android:label="@string/backup_BPr_header">
<meta-data android:name="category"
android:resource="@string/SyP_label" />
<intent-filter> <intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" /> <action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@ -569,6 +567,8 @@
<activity android:name="com.todoroo.astrid.reminders.ReminderPreferences" <activity android:name="com.todoroo.astrid.reminders.ReminderPreferences"
android:theme="@android:style/Theme" android:theme="@android:style/Theme"
android:label="@string/rmd_EPr_alerts_header"> android:label="@string/rmd_EPr_alerts_header">
<meta-data android:name="summary"
android:resource="@string/rmd_EPr_alerts_summary" />
<intent-filter> <intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" /> <action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

@ -8,6 +8,7 @@
<!-- slide 32g: Preference Category: Defaults Title --> <!-- slide 32g: Preference Category: Defaults Title -->
<string name="EPr_defaults_header">New Task Defaults</string> <string name="EPr_defaults_header">New Task Defaults</string>
<string name="EPr_defaults_summary">Importance, Due Date, Add to Calendar</string>
<!-- slide 41f: Preference: Default Urgency Title --> <!-- slide 41f: Preference: Default Urgency Title -->
<string name="EPr_default_urgency_title">Default Urgency</string> <string name="EPr_default_urgency_title">Default Urgency</string>

@ -10,6 +10,7 @@
<!-- slide 32j: Preference Category: Power Pack --> <!-- slide 32j: Preference Category: Power Pack -->
<string name="EPr_powerpack_header">Premium and Misc. Settings</string> <string name="EPr_powerpack_header">Premium and Misc. Settings</string>
<string name="EPr_powerpack_summary">Missed call reminders, voice input and miscellaneous settings</string>
<!-- slide 32e: Preference: Anonymous User Statistics --> <!-- slide 32e: Preference: Anonymous User Statistics -->
<string name="EPr_statistics_title">Anonymous Usage Stats</string> <string name="EPr_statistics_title">Anonymous Usage Stats</string>

@ -105,6 +105,7 @@
<!-- slide 33d: Reminder Preference Screen Title --> <!-- slide 33d: Reminder Preference Screen Title -->
<string name="rmd_EPr_alerts_header">Reminder Settings</string> <string name="rmd_EPr_alerts_header">Reminder Settings</string>
<string name="rmd_EPr_alerts_summary">Quiet hours, snooze options, persistence level</string>
<!-- Reminder Preference: Reminders Enabled Title --> <!-- Reminder Preference: Reminders Enabled Title -->
<string name="rmd_EPr_enabled_title">Reminders Enabled?</string> <string name="rmd_EPr_enabled_title">Reminders Enabled?</string>

@ -101,7 +101,8 @@
<PreferenceScreen <PreferenceScreen
android:title="@string/EPr_powerpack_header"> android:title="@string/EPr_powerpack_header"
android:summary="@string/EPr_powerpack_summary">
<PreferenceScreen android:title="@string/p_files_dir" android:key="@string/p_files_dir" /> <PreferenceScreen android:title="@string/p_files_dir" android:key="@string/p_files_dir" />

@ -5,12 +5,21 @@
*/ */
package com.todoroo.astrid.activity; package com.todoroo.astrid.activity;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import org.weloveastrid.rmilk.MilkPreferences;
import org.weloveastrid.rmilk.MilkUtilities;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -20,6 +29,7 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
@ -41,7 +51,12 @@ import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.files.FileExplore; import com.todoroo.astrid.files.FileExplore;
import com.todoroo.astrid.files.FileMetadata; import com.todoroo.astrid.files.FileMetadata;
import com.todoroo.astrid.gtasks.GtasksPreferences;
import com.todoroo.astrid.helper.MetadataHelper;
import com.todoroo.astrid.producteev.ProducteevPreferences;
import com.todoroo.astrid.producteev.ProducteevUtilities;
import com.todoroo.astrid.service.AddOnService; import com.todoroo.astrid.service.AddOnService;
import com.todoroo.astrid.service.MarketStrategy.AmazonMarketStrategy;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
@ -118,7 +133,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
PreferenceScreen screen = getPreferenceScreen(); PreferenceScreen screen = getPreferenceScreen();
voiceInputAssistant = new VoiceInputAssistant(this); voiceInputAssistant = new VoiceInputAssistant(this);
// addPluginPreferences(screen); addPluginPreferences(screen);
screen.getPreference(POWER_PACK_PREFERENCE).setEnabled(addOnService.hasPowerPack()); screen.getPreference(POWER_PACK_PREFERENCE).setEnabled(addOnService.hasPowerPack());
@ -249,78 +264,90 @@ public class EditPreferences extends TodorooPreferenceActivity {
// PREFERENCE_REQUEST_CODES.put(LabsPreferences.class, REQUEST_CODE_LABS); // PREFERENCE_REQUEST_CODES.put(LabsPreferences.class, REQUEST_CODE_LABS);
} }
// private void addPluginPreferences(PreferenceScreen screen) { private void addPluginPreferences(PreferenceScreen screen) {
// Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS);
// PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
// List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent,
// PackageManager.GET_META_DATA); PackageManager.GET_META_DATA);
// int length = resolveInfoList.size(); int length = resolveInfoList.size();
// LinkedHashMap<String, ArrayList<Preference>> categoryPreferences = LinkedHashMap<String, ArrayList<Preference>> categoryPreferences =
// new LinkedHashMap<String, ArrayList<Preference>>(); new LinkedHashMap<String, ArrayList<Preference>>();
//
// // Loop through a list of all packages (including plugins, addons) // Loop through a list of all packages (including plugins, addons)
// // that have a settings action // that have a settings action
// String labsTitle = getString(R.string.EPr_labs_header); for(int i = 0; i < length; i++) {
// for(int i = 0; i < length; i++) { ResolveInfo resolveInfo = resolveInfoList.get(i);
// ResolveInfo resolveInfo = resolveInfoList.get(i); final Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS);
// final Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS); intent.setClassName(resolveInfo.activityInfo.packageName,
// intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
// resolveInfo.activityInfo.name);
// if(MilkPreferences.class.getName().equals(resolveInfo.activityInfo.name) &&
// if(MilkPreferences.class.getName().equals(resolveInfo.activityInfo.name) && !MilkUtilities.INSTANCE.isLoggedIn())
// !MilkUtilities.INSTANCE.isLoggedIn()) continue;
// continue;
// if (GtasksPreferences.class.getName().equals(resolveInfo.activityInfo.name)
// if (GtasksPreferences.class.getName().equals(resolveInfo.activityInfo.name) && AmazonMarketStrategy.isKindleFire())
// && AmazonMarketStrategy.isKindleFire()) continue;
// continue;
// if (ProducteevPreferences.class.getName().equals(resolveInfo.activityInfo.name)
// if (ProducteevPreferences.class.getName().equals(resolveInfo.activityInfo.name) && !Preferences.getBoolean(R.string.p_third_party_addons, false) && !ProducteevUtilities.INSTANCE.isLoggedIn())
// && !Preferences.getBoolean(R.string.p_third_party_addons, false) && !ProducteevUtilities.INSTANCE.isLoggedIn()) continue;
// continue;
// Preference preference = new Preference(this);
// Preference preference = new Preference(this); preference.setTitle(resolveInfo.activityInfo.loadLabel(pm));
// preference.setTitle(resolveInfo.activityInfo.loadLabel(pm)); Bundle metadata = resolveInfo.activityInfo.metaData;
// if (labsTitle.equals(preference.getTitle())) if (metadata != null) {
// preference.setSummary(R.string.EPr_labs_desc); int resource = metadata.getInt("summary", 0); //$NON-NLS-1$
// try { if (resource > 0)
// Class<?> intentComponent = Class.forName(intent.getComponent().getClassName()); preference.setSummary(resource);
// if (intentComponent.getSuperclass().equals(SyncProviderPreferences.class)) }
// intentComponent = SyncProviderPreferences.class; try {
// if (PREFERENCE_REQUEST_CODES.containsKey(intentComponent)) { Class<?> intentComponent = Class.forName(intent.getComponent().getClassName());
// final int code = PREFERENCE_REQUEST_CODES.get(intentComponent); if (intentComponent.getSuperclass().equals(SyncProviderPreferences.class))
// preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { intentComponent = SyncProviderPreferences.class;
// @Override if (PREFERENCE_REQUEST_CODES.containsKey(intentComponent)) {
// public boolean onPreferenceClick(Preference pref) { final int code = PREFERENCE_REQUEST_CODES.get(intentComponent);
// startActivityForResult(intent, code); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
// return true; @Override
// } public boolean onPreferenceClick(Preference pref) {
// }); startActivityForResult(intent, code);
// } else { return true;
// preference.setIntent(intent); }
// } });
// } catch (ClassNotFoundException e) { } else {
// preference.setIntent(intent); preference.setIntent(intent);
// } }
// } catch (ClassNotFoundException e) {
// String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm); preference.setIntent(intent);
// }
// if(!categoryPreferences.containsKey(category))
// categoryPreferences.put(category, new ArrayList<Preference>()); String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm);
// ArrayList<Preference> arrayList = categoryPreferences.get(category);
// arrayList.add(preference); if(!categoryPreferences.containsKey(category))
// } categoryPreferences.put(category, new ArrayList<Preference>());
// ArrayList<Preference> arrayList = categoryPreferences.get(category);
// for(Entry<String, ArrayList<Preference>> entry : categoryPreferences.entrySet()) { arrayList.add(preference);
// Preference header = new Preference(this); }
// header.setLayoutResource(android.R.layout.preference_category);
// header.setTitle(entry.getKey()); for(Entry<String, ArrayList<Preference>> entry : categoryPreferences.entrySet()) {
// screen.addPreference(header); if (entry.getKey().equals(getString(R.string.app_name))) {
// for(Preference preference : entry.getValue())
// for(Preference preference : entry.getValue()) screen.addPreference(preference);
// screen.addPreference(preference); } else {
// } PreferenceManager manager = getPreferenceManager();
// } PreferenceScreen header = manager.createPreferenceScreen(this);
header.setTitle(entry.getKey());
if (entry.getKey().equals(getString(R.string.SyP_label)))
header.setSummary(R.string.SyP_summary);
screen.addPreference(header);
for(Preference preference : entry.getValue())
header.addPreference(preference);
}
}
}
@SuppressWarnings("nls") @SuppressWarnings("nls")
private void addDebugPreferences() { private void addDebugPreferences() {

Loading…
Cancel
Save