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

Commit 0e8b02b6 authored by Wysie's avatar Wysie
Browse files

Added ability to see total incoming/outgoing duration in call log.

parent 16988878
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:icon="@drawable/ic_launcher_phone"
            android:screenOrientation="sensor"
            android:screenOrientation="nosensor"
        >
            <intent-filter>
                <action android:name="android.intent.action.DIAL" />
+7 −1
Original line number Diff line number Diff line
@@ -737,7 +737,7 @@
    <!-- The string used to describe Contacts as a searchable item within system search settings. -->
    <string name="search_settings_description">Names of your contacts</string>
    
    <!-- Wysie_Soh: Preferences strings -->
    <!-- Wysie_Soh: Dialer preferences strings -->
    <string name="dialersettingsui">Dialer settings</string>
    <string name="prefs_left_button_title">Choose an action for the left button</string>    
    <string name="prefs_left_button_prompt">Left button action</string>
@@ -746,4 +746,10 @@
    <string name="prefs_sensor">Enable sensor-based rotation</string>
    <string name="prefs_warning">Dialer will close after you are done. Please launch it again.</string>
    
    <!-- Wysie_Soh: Total incoming/outgoing dialog -->
    <string name="totalcalllog">Total incoming/outgoing duration</string>
    <string name="total_incoming">Incoming</string>
    <string name="total_outgoing">Outgoing</string>
    <string name="total_button_ok">Ok</string>
    
</resources>
+9 −2
Original line number Diff line number Diff line
@@ -737,12 +737,19 @@
    <!-- The string used to describe Contacts as a searchable item within system search settings. -->
    <string name="search_settings_description">Names of your contacts</string>
    
    <!-- Wysie_Soh: Preferences strings -->
    <!-- Wysie_Soh: Dialer preferences strings -->
    <string name="dialersettingsui">Dialer settings</string>
    <string name="prefs_left_button_title">Choose an action for the left button</string>    
    <string name="prefs_left_button_prompt">Left button action</string>
    <string name="prefs_addcontacts">Use "add to contacts" instead of voicemail for left action button</string>
    <string name="prefs_voicemailapp">Choose a voicemail application</string>
    <string name="prefs_voicemailapp_prompt">Voicemail application</string>
    <string name="prefs_sensor">Enable sensor-based rotation</string>
    <string name="prefs_warning">Dialer will close after you are done. Please launch it again.</string>
    
    <!-- Wysie_Soh: Total incoming/outgoing dialog -->
    <string name="totalcalllog">Total incoming/outgoing duration</string>
    <string name="total_incoming">Incoming</string>
    <string name="total_outgoing">Outgoing</string>
    <string name="total_button_ok">Ok</string>
    
</resources>
+72 −2
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ResourceCursorAdapter;
import android.widget.TextView;
import android.app.Dialog;
import android.widget.Button;
import android.view.View.OnClickListener;

import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.ITelephony;
@@ -118,10 +121,14 @@ public class RecentCallsListActivity extends ListActivity
    private static final int MENU_ITEM_DELETE = 1;
    private static final int MENU_ITEM_DELETE_ALL = 2;
    private static final int MENU_ITEM_VIEW_CONTACTS = 3;
    private static final int MENU_ITEM_TOTAL_CALL_LOG = 4;

    private static final int QUERY_TOKEN = 53;
    private static final int UPDATE_TOKEN = 54;
    
    private static int totalIncoming = 0;
     private static int totalOutgoing = 0;

    RecentCallsAdapter mAdapter;
    private QueryHandler mQueryHandler;
    String mVoiceMailNumber;
@@ -709,6 +716,7 @@ public class RecentCallsListActivity extends ListActivity
    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);   
        menu.add(0, MENU_ITEM_TOTAL_CALL_LOG, 0, "Total Incoming/Outgoing").setIcon(R.drawable.ic_tab_recent);
        return true;
    }

@@ -788,7 +796,13 @@ public class RecentCallsListActivity extends ListActivity
                startQuery();
                return true;
            }

            case MENU_ITEM_TOTAL_CALL_LOG: {
            	//Intent totalCallLog = new Intent(this, TotalCallLog.class);
            	//setIntent(totalCallLog);
            	//startActivity(totalCallLog);
            	showTotalCallLog();
            	return true;
            }
            case MENU_ITEM_VIEW_CONTACTS: {
                Intent intent = new Intent(Intent.ACTION_VIEW, People.CONTENT_URI);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -943,4 +957,60 @@ public class RecentCallsListActivity extends ListActivity
        intent.setData(ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, id));
        startActivity(intent);
    }
    
    private void showTotalCallLog() {
    	final Dialog dialog = new Dialog(this);
    	dialog.setContentView(R.layout.total_call_log);
    	dialog.setTitle("Total Duration");
    	dialog.show();
    	
    	calcTotalTime();
    	
    	TextView incoming = (TextView)dialog.findViewById(R.id.total_in);
        incoming.setText(formatSecToMin(totalIncoming));
        TextView outgoing = (TextView)dialog.findViewById(R.id.total_out);
        outgoing.setText(formatSecToMin(totalOutgoing));

        Button buttonOK = (Button)dialog.findViewById(R.id.buttonOK);
        buttonOK.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
               		dialog.dismiss();
         	}
        });
    }
    
    private String formatSecToMin(int s) {
    	int min = s / 60;
    	int sec = s % 60;
    	String res = min + " mins " + sec + " secs";
    	return res;
    }
    
    private void calcTotalTime() {
    	totalIncoming = 0;
    	totalOutgoing = 0;
    	Cursor c = getContentResolver().query(android .provider.CallLog.Calls.CONTENT_URI, null, null, null,
    		android.provider.CallLog.Calls.DEFAULT_SORT_ORDER) ;
    	startManagingCursor(c);
    	
    	int typeColumn = c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
    	int durationColumn = c.getColumnIndex(android.provider.CallLog.Calls.DURATION);
    	
    	if(c.moveToFirst()) {
    		do {
                    int callType = c.getInt(typeColumn);
                    int callDuration = c.getInt(durationColumn);
                    
                    switch(callType){
                         case android.provider.CallLog.Calls.INCOMING_TYPE:
                              totalIncoming += callDuration;
                              break;
                         case android.provider.CallLog.Calls.OUTGOING_TYPE:
                              totalOutgoing += callDuration;
                              break;
                    }
               } while(c.moveToNext());
	}
   }	

}
+1 −1
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener,
    public boolean onCreateOptionsMenu(Menu menu) {
        mAddToContactMenuItem = menu.add(0, 0, 0, R.string.recentCalls_addToContact).setIcon(android.R.drawable.ic_menu_add);
        mSmsMenuItem = menu.add(0, 1, 0, "SMS / MMS").setIcon(R.drawable.ic_menu_smsmms);
	mPreferences = menu.add(0, 1, 0, "Preferences").setIcon(android.R.drawable.ic_menu_preferences);
	mPreferences = menu.add(0, 2, 0, "Preferences").setIcon(android.R.drawable.ic_menu_preferences);

        return true;
    }
Loading