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

Commit c2ffa237 authored by Wysie's avatar Wysie
Browse files

Release 1.7. Added ability to clear frequently called, as well as hide it altogether.

parent 290da69e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
    <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+7 −0
Original line number Diff line number Diff line
@@ -754,6 +754,9 @@
    <string name="total_outgoing">Outgoing</string>
    <string name="total_button_ok">Ok</string>
    
    <!-- Favourites menu -->
    <string name="fav_clear_freq">Clear Frequently Called</string>
    
    <!-- Wysie_Soh: Preferences strings (based on ChainsDD's code) -->
    <string name="title_dialer_category">Dialer</string>
    <string name="title_vm_button">Left action button</string>    
@@ -775,6 +778,10 @@
    <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>
    
    <string name="title_favourites_category">Favourites</string>
    <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>
    
    <string name="title_misc_category">Miscellaneous</string>
    <string name="title_sensor_rotation">Enable sensor rotation</string>    
    
+7 −0
Original line number Diff line number Diff line
@@ -65,6 +65,13 @@
            android:summary="@string/summary_contacts_show_pic"
            android:defaultValue="true" />
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/title_favourites_category">
        <CheckBoxPreference
            android:key="favourites_hide_freq_called"
            android:title="@string/title_favourites_hide_freq_call"
            android:summary="@string/summary_favourites_hide_freq_call"
            android:defaultValue="false" />
    </PreferenceCategory>    
    <PreferenceCategory android:title="@string/title_misc_category">
        <CheckBoxPreference
            android:key="misc_sensor_rotation"
+61 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.CharArrayBuffer;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -119,6 +120,7 @@ public final class ContactsListActivity extends ListActivity
    public static final int MENU_DISPLAY_GROUP = 11;
    public static final int MENU_IMPORT_CONTACTS = 12;
    public static final int MENU_EXPORT_CONTACTS = 13;
    public static final int MENU_CLEAR_FREQ_CONTACTS = 14;

    static final int MENU_ITEM_SEND_BT = 14;
    static final int MENU_ITEM_GET_BT  = 15;
@@ -330,6 +332,7 @@ public final class ContactsListActivity extends ListActivity

    private String mShortcutAction;
    private boolean mDefaultMode = false;
    private boolean mFavTab = false;

    /**
     * Internal query type when in mode {@link #MODE_QUERY_PICK_TO_VIEW}.
@@ -426,6 +429,7 @@ public final class ContactsListActivity extends ListActivity
            mMode = MODE_FREQUENT;
        } else if (UI.LIST_STREQUENT_ACTION.equals(action)) {
            mMode = MODE_STREQUENT;
            mFavTab = true;
        } else if (UI.LIST_CONTACTS_WITH_PHONES_ACTION.equals(action)) {
            mMode = MODE_WITH_PHONES;
        } else if (Intent.ACTION_PICK.equals(action)) {
@@ -856,6 +860,11 @@ public final class ContactsListActivity extends ListActivity
        menu.setGroupEnabled(MENU_GROUP_BT, bluetoothEnabled);
        menu.setGroupVisible(MENU_GROUP_BT, bluetoothEnabled);
        
        //Wysie_Soh: Clear frequently called
        if (mFavTab) {
	        menu.add(0, MENU_CLEAR_FREQ_CONTACTS, 0, R.string.fav_clear_freq).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
        }
        //Preferences
        Intent i = new Intent(this, ContactsPreferences.class);
        menu.add(0, 0, 0, R.string.menu_preferences).setIcon(android.R.drawable.ic_menu_preferences).setIntent(i);       

@@ -958,6 +967,11 @@ public final class ContactsListActivity extends ListActivity

            case MENU_EXPORT_CONTACTS:
                handleExportContacts();
                
            case MENU_CLEAR_FREQ_CONTACTS:
            	clearFrequentlyCalled();
            	return true;
            	
        }
        return false;
    }
@@ -1518,9 +1532,16 @@ public final class ContactsListActivity extends ListActivity
                break;

            case MODE_STREQUENT:
            	if (ePrefs.getBoolean("favourites_hide_freq_called", false)) {
	            	mQueryHandler.startQuery(QUERY_TOKEN, null, People.CONTENT_URI,
        	                CONTACTS_PROJECTION,
        	                People.STARRED + "=1", null, getSortOrder(CONTACTS_PROJECTION));
        	}
        	else {
	                mQueryHandler.startQuery(QUERY_TOKEN, null,
        	                Uri.withAppendedPath(People.CONTENT_URI, "strequent"), STREQUENT_PROJECTION,
        	                null, null, null);
        	}
                break;

            case MODE_PICK_PHONE:
@@ -2187,4 +2208,40 @@ public final class ContactsListActivity extends ListActivity
            return super.getItemId(getRealPosition(pos));
        }
    }
    
    //Wysie_Soh: It does not actually delete, but rather, set the TIMES_Contacted to 0 for everyone. 
    /* Not working for some reason: http://code.google.com/p/android/issues/detail?id=3495
    private void clearFrequentlyCalled() {
    	//Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, recNo);
    	ContentValues values = new ContentValues();
	values.put(Contacts.PeopleColumns.TIMES_CONTACTED, "0");
    	
    	try  {
    		getContentResolver().update(People.CONTENT_URI, values, null, null);
    		//TODO The change notification should do this automatically, but it isn't working
    		// right now. Remove this when the change notification is working properly.
    		startQuery();
    	} catch (SQLiteException sqle) {
    		//Nothing :P
    	}
    }
    */
    
    private void clearFrequentlyCalled() {
	ContentValues values = new ContentValues();
	values.put(People.TIMES_CONTACTED, "0");
	
	String[] PROJECTION = new String[] { People._ID };
	
    	Cursor c = getContentResolver().query(People.CONTENT_URI, PROJECTION, People.TIMES_CONTACTED + " > 0", null, null);    	
    	if(c.moveToFirst()) {
    		do {
                    getContentResolver().update(ContentUris.withAppendedId(People.CONTENT_URI, c.getLong(0)),
                    	values, null, null);
                    Log.d("HERE", "WE GO");
               } while(c.moveToNext());
	}
    } 

    
}