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

Commit 56f6587c authored by Wysie's avatar Wysie
Browse files

Release 2.5.

Rebased call logging portion of Contacts on geesun's code for grouped call logs.
Some minor fixes and code cleanup in other portions.
parent 8cb347ee
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -22,26 +22,24 @@
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:orientation="horizontal"
    android:paddingLeft="9dip"
    android:paddingRight="5dip"
    android:gravity="center_vertical"
>

    <RelativeLayout android:id="@+id/line_action"
        android:layout_width="fill_parent"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:paddingLeft="0dip"
        android:paddingRight="0dip"
        android:paddingLeft="5dip"
    >
    
        <ImageView android:id="@+id/sms_icon"
        <com.android.contacts.ui.widget.DontPressWithParentImageView android:id="@+id/sms_icon"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:paddingLeft="8dip"
            android:paddingRight="8dip"
            android:paddingLeft="14dip"
            android:paddingRight="14dip"
            android:src="@drawable/sym_action_sms"
            android:background="@android:drawable/list_selector_background"
            android:background="@drawable/call_background"
            android:layout_alignParentRight="true"
            android:gravity="center_vertical"
        />      
        
        <TextView android:id="@+id/call"
@@ -56,33 +54,34 @@
        />
        
        <View android:id="@+id/divider1"
            android:layout_width="1dip"
            android:layout_marginLeft="4dip"
            android:layout_width="1px"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dip"
            android:layout_toLeftOf="@id/sms_icon"
            android:layout_marginRight="4dip"
            android:background="@drawable/divider_vertical_dark"
            android:focusable = "false"
        />
        
        <ImageView android:id="@+id/call_icon"
        <com.android.contacts.ui.widget.DontPressWithParentImageView android:id="@+id/call_icon"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:paddingLeft="8dip"
            android:paddingRight="8dip"
            android:paddingLeft="14dip"
            android:paddingRight="14dip"
            android:gravity="center_vertical"
            android:layout_toLeftOf="@id/divider1"
            android:src="@android:drawable/sym_action_call"
            android:background="@android:drawable/list_selector_background"
            android:background="@drawable/call_background"
        />
        
    </RelativeLayout>
    
    <LinearLayout android:id="@+id/line_log"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:background="@android:drawable/list_selector_background"
        android:paddingLeft="5dip"
    >
    
        <ImageView android:id="@+id/icon"
+3 −1
Original line number Diff line number Diff line
@@ -794,6 +794,8 @@
    <string name="title_cl_ask_before_clear">Ask before clearing</string>
    <string name="summaryon_cl_ask_before_clear">Ask before clearing call log</string>
    <string name="summaryoff_cl_ask_before_clear">Call logs will be cleared without asking</string>
    <string name="title_view_cl">Individual call log</string>
    <string name="summary_view_cl">Set preferences when viewing an individual's call log</string>
    
    <string name="title_contacts_category">Contacts</string>
    <string name="title_contacts_show_pic">Show contact pictures</string>
@@ -839,7 +841,7 @@
    <string name="title_about_name">Mod Name</string>
    <string name="summary_about_name">Wysie Contacts</string>
    <string name="title_about_version">Version</string>
    <string name="summary_about_version">2.5 beta</string>
    <string name="summary_about_version">2.5</string>
    <string name="title_about_credits">Credits</string>
    <string name="summary_about_credits">ChainsDD and the rest of XDA! :)</string>
    
+13 −0
Original line number Diff line number Diff line
@@ -131,6 +131,19 @@
            android:summaryOn="@string/summaryon_cl_ask_before_clear"
            android:summaryOff="@string/summaryoff_cl_ask_before_clear"
            android:defaultValue="false" />
        <PreferenceScreen
            android:key="view_call_log"
            android:title="@string/title_view_cl"
            android:summary="@string/summary_view_cl">
            <ListPreference
                android:key="cl_view_contact_pic_size"
                android:title="@string/title_contacts_view_pic_size"
                android:summary="@string/summary_contacts_view_pic_size"
                android:dialogTitle="@string/title_contacts_choose_pic_size"
                android:entries="@array/view_contact_pic_sizes"
                android:entryValues="@array/view_contact_pic_sizes_values"
                android:defaultValue="78" />                
        </PreferenceScreen>            
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/contactsIconLabel">
        <CheckBoxPreference
+200 −81
Original line number Diff line number Diff line
@@ -27,11 +27,12 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.provider.CallLog;
import android.provider.Contacts;
import android.provider.CallLog.Calls;
@@ -56,6 +57,7 @@ import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -65,8 +67,7 @@ import java.util.List;
/**
 * Displays the details of a specific call log entry.
 */
public class CallDetailActivity extends ListActivity 	
	 {
public class CallDetailActivity extends ListActivity implements View.OnCreateContextMenuListener {
    private static final String TAG = "CallDetail";

    private TextView mCallType;
@@ -77,8 +78,6 @@ public class CallDetailActivity extends ListActivity
    private int mNoPhotoResource;
    Uri personUri = null ;
    private ImageView mPhotoView;    
    static String mIpPrefix = null; 
    
    
    private String mNumber = null;
    
@@ -112,10 +111,23 @@ public class CallDetailActivity extends ListActivity
    static final int COLUMN_INDEX_LABEL = 3;
    static final int COLUMN_INDEX_NUMBER = 4;
    
    private static final int MENU_ITEM_DELETE = 1;
    private static final int MENU_ITEM_DELETE_ALL = 2;
    private static final int MENU_ITEM_DELETE_ALL_INCOMING = 3;
    private static final int MENU_ITEM_DELETE_ALL_OUTGOING = 4;
    private static final int MENU_ITEM_DELETE_ALL_MISSED = 5;
    private static final int MENU_ITEM_VIEW_CONTACT = 6;
    private static final int MENU_ITEM_ADD_CONTACT = 7;
    
    private ViewAdapter adapter;
    private List<ViewEntryData> logs;
    private SharedPreferences prefs;

    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        setContentView(R.layout.call_detail);

        mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
@@ -123,6 +135,8 @@ public class CallDetailActivity extends ListActivity

        mPhotoView = (ImageView) findViewById(R.id.photo);
        
        getListView().setOnCreateContextMenuListener(this);
          
        // Set the photo with a random "no contact" image
        long now = SystemClock.elapsedRealtime();
        int num = (int) now & 0xf;
@@ -188,12 +202,6 @@ public class CallDetailActivity extends ListActivity
        where.append(Calls.NUMBER);
        where.append(" = '" + number + "'");
        
        where.append(" or " + Calls.NUMBER);
        where.append(" = '" + mIpPrefix + number + "'");
        
        where.append(" or " + Calls.NUMBER);
        where.append(" = '" + "+86" + number + "'");
        
        Cursor callCursor = getContentResolver().query(Calls.CONTENT_URI, CALL_LOG_PROJECTION,where.toString(), null,
        		Calls.DEFAULT_SORT_ORDER);
        
@@ -241,7 +249,11 @@ public class CallDetailActivity extends ListActivity
            }
        }
        
    	List<ViewEntryData> logs = new ArrayList<ViewEntryData>();
        int size = Integer.parseInt(prefs.getString("cl_view_contact_pic_size", "78"));
        //Wysie_Soh: Set contact picture size
        mPhotoView.setLayoutParams(new LinearLayout.LayoutParams(size, size));
    	
    	logs = new ArrayList<ViewEntryData>();
    	ViewEntryData firstPlaceHolder = new ViewEntryData();
    	firstPlaceHolder.number = mNumber;
    	logs.add(firstPlaceHolder);
@@ -271,7 +283,7 @@ public class CallDetailActivity extends ListActivity
            }
        }
        
        ViewAdapter adapter = new ViewAdapter(this, logs);
        adapter = new ViewAdapter(this, logs);
        setListAdapter(adapter);         
    }

@@ -291,8 +303,7 @@ public class CallDetailActivity extends ListActivity
    }

    static final class ViewAdapter extends BaseAdapter 
    	implements View.OnClickListener,
    	View.OnLongClickListener
    	implements View.OnClickListener 
    	{
        
        private final List<ViewEntryData> mLogs;
@@ -353,8 +364,6 @@ public class CallDetailActivity extends ListActivity
            	layout.setVisibility(View.VISIBLE);
                ImageView call_icon = (ImageView) convertView.findViewById(R.id.call_icon);
                ImageView sms_icon = (ImageView) convertView.findViewById(R.id.sms_icon);
               
                //TextView tvSms = (TextView) convertView.findViewById(R.id.send_sms);
                TextView tvCall = (TextView) convertView.findViewById(R.id.call);
               
                //Geesun                
@@ -383,13 +392,11 @@ public class CallDetailActivity extends ListActivity
                
                
                call_icon.setTag(callIntent);
                tvCall.setTag(callIntent);
                //tvCall.setTag(callIntent);
                sms_icon.setTag(smsIntent);
                //tvSms.setTag(smsIntent);                
                call_icon.setOnClickListener(this);                
                sms_icon.setOnClickListener(this);
                //tvSms.setOnClickListener(this);
                tvCall.setOnClickListener(this); 
                //tvCall.setOnClickListener(this); 
                
                convertView.setTag(null);
                
@@ -435,8 +442,6 @@ public class CallDetailActivity extends ListActivity
                        break;
                }                
                convertView.setTag(entry);
                convertView.setLongClickable(true);
                convertView.setOnLongClickListener(this);
            }
            
            return convertView;
@@ -448,79 +453,193 @@ public class CallDetailActivity extends ListActivity
           if(intent != null)
            mContext.startActivity(intent);
		}
    }   

    
	    private class DeleteClickListener implements DialogInterface.OnClickListener {
	        private ViewEntryData  mData;
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, MENU_ITEM_DELETE_ALL, 0, R.string.recentCalls_deleteAll).setIcon(
                android.R.drawable.ic_menu_close_clear_cancel);
                
        /* Wysie: WIP. Not working for now :(
        menu.add(0, MENU_ITEM_DELETE_ALL_INCOMING, 0, R.string.recentCalls_deleteAllIncoming).setIcon(
                android.R.drawable.ic_menu_close_clear_cancel);
        menu.add(0, MENU_ITEM_DELETE_ALL_OUTGOING, 0, R.string.recentCalls_deleteAllOutgoing).setIcon(
                android.R.drawable.ic_menu_close_clear_cancel);
        menu.add(0, MENU_ITEM_DELETE_ALL_MISSED, 0, R.string.recentCalls_deleteAllMissed).setIcon(
                android.R.drawable.ic_menu_close_clear_cancel);
        */
    
	        public DeleteClickListener(ViewEntryData data) {
	        	mData = data;
        if (personUri != null) {
            menu.add(0, MENU_ITEM_VIEW_CONTACT, 0, R.string.menu_viewContact)
            	.setIcon(R.drawable.ic_tab_contacts); 
        } else if (!(mNumber.equals(CallerInfo.UNKNOWN_NUMBER) ||
                mNumber.equals(CallerInfo.PRIVATE_NUMBER))) {
            menu.add(0, MENU_ITEM_ADD_CONTACT, 0, R.string.recentCalls_addToContact)
            .setIcon(android.R.drawable.ic_menu_add);
        }

	        public void onClick(DialogInterface dialog, int which) {
                StringBuilder where = new StringBuilder();
                where.append(Calls._ID);
                where.append(" =  " + mData.id);
                mContext.getContentResolver().delete(Calls.CONTENT_URI, where.toString(), null);
                mLogs.remove(mData);
                if(mLogs.size() != 1)
                	notifyDataSetChanged();
                else{
        return true;
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        if (position == 0) {
            Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
                        Uri.fromParts("tel", mNumber, null));
            startActivity(callIntent);
        }        
    }
    
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case MENU_ITEM_DELETE_ALL: {
            clearCallLog();
            return true;
        }

        case MENU_ITEM_DELETE_ALL_INCOMING: {
            clearCallLogType(Calls.INCOMING_TYPE);
            return true;
        }

        case MENU_ITEM_DELETE_ALL_OUTGOING: {
            clearCallLogType(Calls.OUTGOING_TYPE);
            return true;
        }

                	((Activity) mContext).finish();
        case MENU_ITEM_DELETE_ALL_MISSED: {
            clearCallLogType(Calls.MISSED_TYPE);
            return true;
        }
        case MENU_ITEM_VIEW_CONTACT: {
            Intent viewIntent = new Intent(Intent.ACTION_VIEW, personUri);
            startActivity(viewIntent);
            return true;
        }
        case MENU_ITEM_ADD_CONTACT: {
            Intent createIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
            createIntent.setType(People.CONTENT_ITEM_TYPE);
            createIntent.putExtra(Insert.PHONE, mNumber);
            startActivity(createIntent);
            return true;
        }
        }
        return super.onOptionsItemSelected(item);

    }
    
		public boolean onLongClick(View v) {
			//v.setBackgroundResource(android.R.drawable.list_selector_background);
    @Override
    public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
        AdapterView.AdapterContextMenuInfo menuInfo;
        try {
            menuInfo = (AdapterView.AdapterContextMenuInfo) menuInfoIn;
        } catch (ClassCastException e) {
            Log.e(TAG, "bad menuInfoIn", e);
            return;
        }
        if (menuInfo.position == 0) {
            return;
        }
    
			ViewEntryData entryData  =  (ViewEntryData) v.getTag();
			if(entryData != null){
        menu.add(0, MENU_ITEM_DELETE, 0, R.string.recentCalls_removeFromRecentList);
    }
    
	public boolean onContextItemSelected(MenuItem item) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        ViewEntryData entryData = (ViewEntryData)adapter.getItem(info.position);
	
                Uri uri = ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI,
                		entryData.id);
                //TODO make this dialog persist across screen rotations
                new AlertDialog.Builder(mContext)
                    .setTitle(R.string.deleteConfirmation_title)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage("Wysie?")
                    .setNegativeButton(android.R.string.cancel, null)
                    .setPositiveButton(android.R.string.ok, new DeleteClickListener(entryData))
                    .show();
		switch(item.getItemId()) {		
		    case MENU_ITEM_DELETE:
		        getContentResolver().delete(Calls.CONTENT_URI, "Calls._ID=?", new String[] { Long.toString(entryData.id) } );
                logs.remove(entryData);
                if(logs.size() != 1) { //1 because the top row is for calling/smsing
                	adapter.notifyDataSetChanged();
                }
			// TODO Auto-generated method stub
			return false;
                else {                	
                	finish();
                }
                return true;
		
		}
        
		return super.onContextItemSelected(item);
	}
	
    private void clearCallLog() {        
        if (prefs.getBoolean("cl_ask_before_clear", false)) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.setTitle(R.string.alert_clear_call_log_title);
            alert.setMessage("Are you sure you want to clear all call records of " + mNumber + "?");
      
    public boolean onCreateOptionsMenu(Menu menu) {
        if (personUri != null) {
            menu.add(0, 0, 0, R.string.menu_viewContact)
            	.setIcon(R.drawable.sym_action_view_contact); 
        } else {
            menu.add(0, 0, 0, R.string.recentCalls_addToContact)
            .setIcon(R.drawable.sym_action_add);
            alert.setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    getContentResolver().delete(Calls.CONTENT_URI, Calls.NUMBER + "=?",
                                                new String[] { mNumber });
                    logs.clear();
                    finish();
                }
            });
        
        return true;
            alert.setNegativeButton(android.R.string.cancel,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {// Canceled.
                }
    public boolean onOptionsItemSelected(MenuItem item) {
        if (personUri != null) {
            Intent viewIntent = new Intent(Intent.ACTION_VIEW, personUri);
            startActivity(viewIntent);
            });
        
            alert.show();
        } else {
            Intent createIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
            createIntent.setType(People.CONTENT_ITEM_TYPE);
            createIntent.putExtra(Insert.PHONE, mNumber);
            startActivity(createIntent);
            getContentResolver().delete(Calls.CONTENT_URI, Calls.NUMBER + "=?",
                                        new String[] { mNumber });
            logs.clear();
            finish();
        }
    }

                return true;
    private void clearCallLogType(final int type) {
        String message = null;
        
        if (type == Calls.INCOMING_TYPE) {
            message = "Are you sure you want to clear all incoming call records from " + mNumber + "?" ;            
        } else if (type == Calls.OUTGOING_TYPE) {
            message = "Are you sure you want to clear all outgoing call records to " + mNumber + "?" ;
        } else if (type == Calls.MISSED_TYPE) {
            message = "Are you sure you want to clear all missed call records from " + mNumber + "?" ;
        }
        
        if (prefs.getBoolean("cl_ask_before_clear", false)) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.setTitle(R.string.alert_clear_call_log_title);
            alert.setMessage(message);
            alert.setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    getContentResolver().delete(Calls.CONTENT_URI, Calls.TYPE + "=? AND " + Calls.NUMBER + "=?",
                                                new String[] { Integer.toString(type), mNumber });
                }
            });        
            alert.setNegativeButton(android.R.string.cancel,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {// Canceled.
                }
            });        
            alert.show();
            
        } else {
            getContentResolver().delete(Calls.CONTENT_URI, Calls.TYPE + "=? AND " + Calls.NUMBER + "=?",
                                        new String[] { Integer.toString(type), mNumber });
        }
        updateData();
        if(logs.size() != 1) { //1 because the top row is for calling/smsing
            adapter.notifyDataSetInvalidated();
            Log.d("WYSIE", "Data Changed 2");
        }
        else {                	
            finish();
        }        
        
    }

}
+10 −8
Original line number Diff line number Diff line
@@ -522,9 +522,11 @@ public class RecentCallsListActivity extends ListActivity
            if (!prefs.getBoolean("cl_show_dial_button", true)) {
                views.iconView.setTag(number);
                views.iconView.setOnClickListener(this);
                //views.iconView.setBackgroundResource(R.drawable.call_background);
            } else {
                views.iconView.setTag(null);
                views.iconView.setOnClickListener(null);
                //views.iconView.setBackgroundResource(0);
            }

            // Lookup contacts with this number
@@ -663,15 +665,15 @@ public class RecentCallsListActivity extends ListActivity

                if (DateFormat.is24HourFormat(context)) {
                    if (prefs.getBoolean("cl_show_seconds", true)) {
                        format = "MMM dd, kk:mm:ss";
                        format = "MMM d, kk:mm:ss";
                    } else {
                        format = "MMM dd, kk:mm";
                        format = "MMM d, kk:mm";
                    }
                } else {
                    if (prefs.getBoolean("cl_show_seconds", true)) {
                        format = "MMM dd, h:mm:ss aa";
                        format = "MMM d, h:mm:ssaa";
                    } else {
                        format = "MMM dd, h:mm aa";
                        format = "MMM d, h:mmaa";
                    }                  	
                }
                
@@ -1417,7 +1419,7 @@ public class RecentCallsListActivity extends ListActivity
            alert.setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    deleteCallLog(type + "='" + value + "'", null);
                    deleteCallLog(type + "=?", new String[] { value });
                }
            });
            alert.setNegativeButton(android.R.string.cancel,
@@ -1428,7 +1430,7 @@ public class RecentCallsListActivity extends ListActivity
            });
            alert.show();
        } else {
            deleteCallLog(type + "='" + value + "'", null);
            deleteCallLog(type + "=?", new String[] { value });
        }
    	
    }
@@ -1454,7 +1456,7 @@ public class RecentCallsListActivity extends ListActivity
            alert.setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    deleteCallLog(Calls.TYPE + "=" + type, null);
                    deleteCallLog(Calls.TYPE + "=?", new String[] { Integer.toString(type) });
                }
            });        
            alert.setNegativeButton(android.R.string.cancel,
@@ -1465,7 +1467,7 @@ public class RecentCallsListActivity extends ListActivity
            alert.show();
            
        } else {
            deleteCallLog(Calls.TYPE + "=" + type, null);
            deleteCallLog(Calls.TYPE + "=?", new String[] { Integer.toString(type) });
        }        
    }