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

Commit 92b10b07 authored by Wysie's avatar Wysie
Browse files

2.52 Beta 2.

Sped up call log loading speed. Main issue of lag was due to querying Phones.CONTENT_FILTER_URL.
Used a SparseArray to avoid querying if information already exists.
Lag of 1.5 to 3 seconds still happens, but it's significantly better.
parent 10a75a32
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@
                android:text="@string/unknown"
            />
            
            <!--
            <TextView android:id="@+id/number"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
@@ -67,6 +68,7 @@
                android:textColor="?android:attr/textColorPrimaryInverse"
                android:text="@string/unknown"
            />
            -->
        </LinearLayout>
    </LinearLayout>  
          
+82 −11
Original line number Diff line number Diff line
@@ -42,17 +42,6 @@
            android:gravity="center_vertical"
        />
        
        <TextView android:id="@+id/call"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="11dip"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/callBack"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="17dip"
            android:gravity="center_vertical"
        />
        
        <com.android.contacts.ui.widget.DontPressWithParentImageView android:id="@+id/divider1"
            android:layout_width="1px"
            android:layout_height="fill_parent"
@@ -73,6 +62,88 @@
            android:background="@drawable/call_background"
        />
        
    <TextView android:id="@+id/most_recent_num_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="8dip"
        android:layout_marginTop="-10dip"

        android:singleLine="true"
        android:ellipsize="marquee"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textStyle="bold"
    />

    <TextView android:id="@+id/most_recent_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dip"
        android:layout_toRightOf="@id/most_recent_num_label"
        android:layout_alignBaseline="@id/most_recent_num_label"
        android:layout_toLeftOf="@id/call_icon"
        android:layout_alignWithParentIfMissing="true"

        android:singleLine="true"
        android:ellipsize="marquee"
        android:textAppearance="?android:attr/textAppearanceSmall"
    />

    <TextView android:id="@+id/call"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/most_recent_num_label"
        android:layout_alignWithParentIfMissing="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="1dip"

        android:singleLine="true"
        android:ellipsize="marquee"
        android:gravity="center_vertical|left"
        android:textAppearance="?android:attr/textAppearanceLarge"
    />
        
        <!--
        <TextView android:id="@+id/call"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="11dip"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/callBack"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="17dip"
            android:gravity="center_vertical"
        />
        
        <TextView android:id="@+id/most_recent_num_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="11dip"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="@string/title_contacts_category"
            android:layout_below="@id/call"
            android:layout_alignLeft="@id/call"
            android:textStyle="bold"
        />
        
        <TextView android:id="@+id/most_recent_num"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_toRightOf="@id/most_recent_num_label"
            android:layout_below="@id/call"
            android:layout_alignBaseline="@id/most_recent_num_label"
            android:layout_alignWithParentIfMissing="true"
            
            android:singleLine="true"
            android:ellipsize="marquee"
            android:textAppearance="?android:attr/textAppearanceSmall"
        />
        -->       
        
    </RelativeLayout>
    
    <LinearLayout android:id="@+id/line_log"
+7 −1
Original line number Diff line number Diff line
@@ -797,6 +797,12 @@
    <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_cl_grouping_settings">Group call log settings</string>
    <string name="title_cl_use_exp_grouping">Group unknown numbers (Experimental)</string>
    <string name="summary_cl_use_exp_grouping">Slows down performance</string>
    <string name="title_cl_exp_grouping_num">Number of digits to compare</string>
    <string name="summary_cl_exp_grouping_num">Higher number = stricter</string>
    
    <string name="title_contacts_category">Contacts</string>
    <string name="title_contacts_show_pic">Show contact pictures</string>
    <string name="title_contacts_show_dial_button">Show dial button</string>
@@ -841,7 +847,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.52 BETA</string>
    <string name="summary_about_version">2.52 BETA 2</string>
    <string name="title_about_credits">Credits</string>
    <string name="summary_about_credits">ChainsDD and the rest of XDA! :)</string>
    
+17 −0
Original line number Diff line number Diff line
@@ -131,6 +131,23 @@
            android:summaryOn="@string/summaryon_cl_ask_before_clear"
            android:summaryOff="@string/summaryoff_cl_ask_before_clear"
            android:defaultValue="false" />
        <PreferenceScreen
            android:key="cl_grouping_settings"
            android:title="@string/title_cl_grouping_settings">
            <CheckBoxPreference
                android:key="cl_use_exp_grouping"
                android:title="@string/title_cl_use_exp_grouping"
                android:summary="@string/summary_cl_use_exp_grouping"
                android:disableDependentsState="false"
                android:defaultValue="false" />
            <EditTextPreference
                android:key="cl_exp_grouping_num"
                android:numeric="integer"
                android:title="@string/title_cl_exp_grouping_num"
                android:summary="@string/summary_cl_exp_grouping_num"
                android:dependency="cl_use_exp_grouping"
                android:defaultValue="8" />              
        </PreferenceScreen> 
        <PreferenceScreen
            android:key="view_call_log"
            android:title="@string/title_view_cl"
+73 −54
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
    private void updateData() {
    	Bundle bundle = getIntent().getExtras();
    	long personId = bundle.getLong("PERSONID");
    	String number = bundle.getString("NUMBER");
    	ArrayList<NumberInfo> personNumbers = new ArrayList<NumberInfo>();
    	String displayName = null;
    	Uri personUri = null;
@@ -240,7 +241,6 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
            
            if (phonesCursor != null && phonesCursor.moveToFirst()) {
                int type = -1;
                String number = null;
                String label = null;
                CharSequence actualLabel = null;
                do {
@@ -256,15 +256,12 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
                phonesCursor.close();
            }            
            
            boolean hasCallLog = false;
            
            for (NumberInfo i : personNumbers) {
                callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(i.number));
                callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null);
                
                try {                
                    if (callCursor != null && callCursor.moveToFirst()) {
                        hasCallLog = true;
                        do {
                            ViewEntryData data = new ViewEntryData();
                            data.label = i.label;
@@ -282,15 +279,9 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
                    callCursor.close();
                }
            }
            //Wysie_Soh: No call log found for this personId
            if (!hasCallLog) {
                Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show();
                finish();
            }
    	}
    	//Wysie_Soh: If no person found, query by number instead
    	else {    	    
    	    String number = bundle.getString("NUMBER");
    	    callUri = Uri.withAppendedPath(Calls.CONTENT_FILTER_URI, Uri.encode(number));
    	    callCursor = getContentResolver().query(callUri, CALL_LOG_PROJECTION, null, null, null);
    	    
@@ -329,11 +320,6 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
	                
                		logs.add(data);	              
                	} while(callCursor.moveToNext());
                } else {
                    // Something went wrong reading in our primary data, so we're going to
                    // bail out and show error to users.
                    Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show();
                    finish();
                }
            } finally {
                if (callCursor != null)
@@ -344,13 +330,22 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
    	//Sort arraylist here
    	Collections.sort(logs ,new LogsSortByTime());
    	
    	try {    	    	
            mNumber = logs.get(0).number;
        }
        catch (IndexOutOfBoundsException e) { //If logs is size 0, no content, exit.
            Toast.makeText(this, R.string.toast_call_detail_error_wysie, Toast.LENGTH_SHORT).show();
            this.finish();
        }       

    	
    	if (mNumber != null) {
            ViewEntryData firstPlaceHolder = new ViewEntryData();
        	firstPlaceHolder.number = mNumber;
        	firstPlaceHolder.label = logs.get(0).label;
        	logs.add(0, firstPlaceHolder);
            
        	TextView tvName = (TextView) findViewById(R.id.name);
    	TextView tvNumber = (TextView) findViewById(R.id.number);
    	
    	    if (mNumber.equals(CallerInfo.UNKNOWN_NUMBER) ||
                    mNumber.equals(CallerInfo.PRIVATE_NUMBER)) {
@@ -365,11 +360,9 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
                if (personId != -1) {
                    mPhotoView.setImageBitmap(People.loadContactPhoto(this, personUri, mNoPhotoResource, null /* use the default options */));
                    tvName.setText(displayName);
                tvNumber.setText(mNumber);
                }
                else {
                    tvName.setText("("+ getString(R.string.unknown) + ")");
                tvNumber.setText(mNumber);// = PhoneNumberUtils.formatNumber(mNumber);
                    mPhotoView.setImageResource(mNoPhotoResource);
                }            
            }
@@ -381,7 +374,7 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
            adapter = new ViewAdapter(this, logs);
            setListAdapter(adapter);
        }         

    }

    static final class ViewEntry {
        public int icon = -1;
@@ -450,6 +443,7 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
        	 long duration = entry.duration;
        	 int callType = entry.callType; 
        	 final String num = entry.number;
        	 final String label = entry.label;

            
        	RelativeLayout layout = (RelativeLayout) convertView.findViewById(R.id.line_action);
@@ -461,6 +455,8 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
                ImageView call_icon = (ImageView) convertView.findViewById(R.id.call_icon);
                ImageView sms_icon = (ImageView) convertView.findViewById(R.id.sms_icon);
                TextView tvCall = (TextView) convertView.findViewById(R.id.call);
                TextView tvNumLabel = (TextView) convertView.findViewById(R.id.most_recent_num_label);
                TextView tvNum = (TextView) convertView.findViewById(R.id.most_recent_num);
               
                //Geesun                
                Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
@@ -486,6 +482,29 @@ public class CallDetailActivity extends ListActivity implements View.OnCreateCon
		           		break;
	           	 }
	           	 
                RelativeLayout.LayoutParams newCallLayout = (RelativeLayout.LayoutParams) tvCall.getLayoutParams();
                RelativeLayout.LayoutParams newNumberLayout = (RelativeLayout.LayoutParams) tvNum.getLayoutParams();
	           	 	           	 
	           	if (label != null) {
	           	    tvNumLabel.setText(label);
	           	    tvNumLabel.setVisibility(View.VISIBLE);
                    newCallLayout.addRule(RelativeLayout.ABOVE, R.id.most_recent_num_label);
                    newNumberLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
                    newNumberLayout.addRule(RelativeLayout.ALIGN_BASELINE, R.id.most_recent_num_label);
                    newNumberLayout.setMargins(5, 0, 0, 0);
	           	}
	           	else {
	           	    tvNumLabel.setVisibility(View.GONE);
                    newCallLayout.addRule(RelativeLayout.ABOVE, R.id.most_recent_num);
                    newNumberLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                    newNumberLayout.addRule(RelativeLayout.ALIGN_BASELINE, 0);
                    newNumberLayout.setMargins(0, -10, 0, 8);
	           	}
	           	
                tvCall.setLayoutParams(newCallLayout);
                tvNum.setLayoutParams(newNumberLayout);
	           	
	           	tvNum.setText(num);
                
                call_icon.setTag(callIntent);
                //tvCall.setTag(callIntent);
Loading