Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ad98be5 authored by Wysie's avatar Wysie Committed by ABAAKOUK Mehdi
Browse files

Release 0.8:

Added navigation action beside the address of a contact
Added preference to hide sms action for all numbers except mobile
parent 64139fa5
Loading
Loading
Loading
Loading
+1.49 KiB
Loading image diff...
+257 B
Loading image diff...
+8 −1
Original line number Diff line number Diff line
@@ -1190,6 +1190,13 @@
    <string name="title_contacts_show_dial_button">Show dial button</string>
    <string name="summary_contacts_show_dial_button">Show a dial button for contacts with numbers</string>
    
    <!-- Preferences: Contacts - View Contact -->
    <string name="title_view_contact">View contact</string>
    <string name="summary_view_contact">Set preferences when viewing an individual contact</string>
    <string name="title_show_text_mobile_only">Text action for mobile only</string>
    <string name="summaryon_show_text_mobile_only">Only mobile numbers will have a text/sms action</string>
    <string name="summaryoff_show_text_mobile_only">All numbers will have a text/sms action</string>
    
    <!-- Preferences: Favourites -->
    <string name="title_favourites_hide_freq_call">Hide frequently called</string>
    <string name="summary_favourites_hide_freq_call">The actual data is not cleared, but hidden.</string>
@@ -1207,7 +1214,7 @@
    <string name="title_about_name">Mod Name</string>
    <string name="summary_about_name">WyContacts Eclair</string>
    <string name="title_about_version">Version</string>
    <string name="summary_about_version">0.7</string>
    <string name="summary_about_version">0.8</string>
    <string name="title_about_credits">Credits</string>
    <string name="summary_about_credits">ChainsDD, geesun, niuchl, rac2030 and the rest of XDA! :)</string>
    
+11 −0
Original line number Diff line number Diff line
@@ -124,6 +124,17 @@
            android:title="@string/title_contacts_show_pic"
            android:defaultValue="true" />
        -->
        <PreferenceScreen
            android:key="view_contact"
            android:title="@string/title_view_contact"
            android:summary="@string/summary_view_contact">
            <CheckBoxPreference
                android:key="contacts_show_text_mobile_only"
                android:title="@string/title_show_text_mobile_only"
                android:summaryOn="@string/summaryon_show_text_mobile_only"
                android:summaryOff="@string/summaryoff_show_text_mobile_only"
                android:defaultValue="false" />                
        </PreferenceScreen>
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/contactsFavoritesLabel">
        <CheckBoxPreference
+67 −7
Original line number Diff line number Diff line
@@ -93,6 +93,13 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

//Wysie
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.util.List;

/**
 * Displays the details of a specific contact.
 */
@@ -191,10 +198,15 @@ public class ViewContactActivity extends Activity
    private ListView mListView;
    private boolean mShowSmsLinksForAllPhones;    
    
    //Wysie
    private SharedPreferences ePrefs;

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        
        ePrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

        final Intent intent = getIntent();
        Uri data = intent.getData();
        String authority = data.getAuthority();
@@ -241,12 +253,16 @@ public class ViewContactActivity extends Activity
        mSections.add(mOtherEntries);

        //TODO Read this value from a preference
        mShowSmsLinksForAllPhones = true;
        //mShowSmsLinksForAllPhones = true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        
        //Wysie: Read from preference
        mShowSmsLinksForAllPhones = !ePrefs.getBoolean("contacts_show_text_mobile_only", false);        
        
        startEntityQuery();
    }

@@ -887,7 +903,6 @@ public class ViewContactActivity extends Activity
                    mWritableRawContactIds.add(rawContactId);
                }


                for (NamedContentValues subValue : entity.getSubValues()) {
                    final ContentValues entryValues = subValue.values;
                    entryValues.put(Data.RAW_CONTACT_ID, rawContactId);
@@ -922,8 +937,11 @@ public class ViewContactActivity extends Activity
                        entry.isPrimary = isSuperPrimary;
                        mPhoneEntries.add(entry);
                        
                        if (entry.type == CommonDataKinds.Phone.TYPE_MOBILE
                                || mShowSmsLinksForAllPhones) {
                        //Wysie: Workaround for the entry.type bug, since entry.type always returns -1
                        final Integer type = entryValues.getAsInteger(Phone.TYPE);                        
                        
                        //Wysie: Bug here, entry.type always returns -1.
                        if (/*entry.type*/type == CommonDataKinds.Phone.TYPE_MOBILE || mShowSmsLinksForAllPhones) {
                            // Add an SMS entry
                            if (kind.iconAltRes > 0) {
                                entry.secondaryActionIcon = kind.iconAltRes;
@@ -952,7 +970,19 @@ public class ViewContactActivity extends Activity
                        // Build postal entries
                        entry.maxLines = 4;
                        entry.intent = new Intent(Intent.ACTION_VIEW, entry.uri);                        

                        Intent i = startNavigation(entry.data);
                        
                        if (i != null) {
                            entry.secondaryIntent = i;
                            // Add a navigation entry
                            if (kind.iconAltRes > 0) {
                                entry.secondaryActionIcon = kind.iconAltRes;
                            }
                        }
                        
                        mPostalEntries.add(entry);
                        
                    } else if (Im.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
                        // Build IM entries
                        entry.intent = ContactsUtils.buildImIntent(entryValues);
@@ -1360,4 +1390,34 @@ public class ViewContactActivity extends Activity
            ContactsSearchManager.startSearch(this, initialQuery);
        }
    }
    //Wysie
    public boolean isIntentAvailable(Intent intent) {
        final PackageManager packageManager = this.getPackageManager();
        List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    }
        
    //Wysie: Navigation code. Adapted from rac2030's NavStarter.
    //http://code.google.com/p/andrac/source/browse/trunk/NavWidget/src/ch/racic/android/gnav/NavSearch.java
    public Intent startNavigation(String address) {
        address = address.replace('#', ' ');
        Intent i = new Intent();
        i.setAction(Intent.ACTION_VIEW);
        i.setData(Uri.parse("http://maps.google.com/maps?myl=saddr&daddr=" + address + "&dirflg=d&nav=1"));
        i.addFlags(0x10800000);
        i.setClassName("com.google.android.apps.m4ps", "com.google.android.maps.driveabout.app.NavigationActivity");
        
        if (isIntentAvailable(i)) {
            return i;
        }
        else {
            i.setClassName("com.google.android.apps.maps", "com.google.android.maps.driveabout.app.NavigationActivity");
            if (isIntentAvailable(i)) {
                return i;
            }
            else {
                return null;
            }
        }
    }
}
Loading