Fix some leaks + optimized layouts for 7 and 10 tablets
This commit is contained in:
parent
4fa44cc7e6
commit
6f9b8141b2
9 changed files with 245 additions and 16 deletions
|
@ -137,7 +137,7 @@
|
|||
android:id="@+id/dialer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.25"
|
||||
android:layout_weight="0.24"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/content_description_dialer"
|
||||
android:scaleType="fitXY"
|
||||
|
|
175
res/layout-sw720dp-land/main.xml
Normal file
175
res/layout-sw720dp-land/main.xml
Normal file
|
@ -0,0 +1,175 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/landscape_background">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/background_logo"/>
|
||||
|
||||
<!-- Hack to adjust perfectly on every screen the bottom of the fragment with the curved menu -->
|
||||
<LinearLayout
|
||||
android:id="@+id/mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/mark"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/mark"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.24"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/mark"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/mark"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/mark"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/mark"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:baselineAligned="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="40dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.67" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fragmentContainer2"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.33" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/status"
|
||||
android:name="org.linphone.StatusFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:layout="@layout/status" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2">
|
||||
|
||||
<include layout="@layout/menu_history_button" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missedCalls"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/missed_calls_bg"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/menu_contact_button" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.245"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/content_description_dialer"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/dialer" />
|
||||
|
||||
<include layout="@layout/menu_about_chat_button" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/completeChat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2">
|
||||
|
||||
<include layout="@layout/menu_chat_button" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missedChats"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/missed_calls_bg"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/menu_settings_button" />
|
||||
|
||||
<include layout="@layout/menu_about_settings_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -117,6 +117,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
private Bitmap imageToUpload;
|
||||
private Uri imageToUploadUri;
|
||||
private Thread uploadThread;
|
||||
private TextWatcher textWatcher;
|
||||
private OnGlobalLayoutListener keyboardListener;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
@ -174,9 +176,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
uploadServerUri = getActivity().getResources().getString(R.string.pref_image_sharing_server_key);
|
||||
addVirtualKeyboardVisiblityListener();
|
||||
|
||||
message.addTextChangedListener(new TextWatcher() {
|
||||
textWatcher = new TextWatcher() {
|
||||
public void afterTextChanged(Editable arg0) {
|
||||
|
||||
}
|
||||
|
@ -193,13 +194,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
sendMessage.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void addVirtualKeyboardVisiblityListener() {
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
keyboardListener = new OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
Rect visibleArea = new Rect();
|
||||
|
@ -212,7 +213,12 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
hideKeyboardVisibleMode();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(keyboardListener);
|
||||
}
|
||||
|
||||
private void removeVirtualKeyboardVisiblityListener() {
|
||||
Compatibility.removeGlobalLayoutListener(view.getViewTreeObserver(), keyboardListener);
|
||||
}
|
||||
|
||||
public void showKeyboardVisibleMode() {
|
||||
|
@ -357,8 +363,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
latestImageMessages = null;
|
||||
message.removeTextChangedListener(textWatcher);
|
||||
removeVirtualKeyboardVisiblityListener();
|
||||
|
||||
super.onPause();
|
||||
|
||||
if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
|
||||
ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage();
|
||||
|
@ -376,6 +385,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
@Override
|
||||
public void onResume() {
|
||||
latestImageMessages = new HashMap<Integer, String>();
|
||||
message.addTextChangedListener(textWatcher);
|
||||
addVirtualKeyboardVisiblityListener();
|
||||
|
||||
super.onResume();
|
||||
|
||||
|
@ -643,7 +654,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
Cursor cursor = loader.loadInBackground();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
return cursor.getString(column_index);
|
||||
String result = cursor.getString(column_index);
|
||||
cursor.close();
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -251,7 +251,8 @@ public class ChatStorage {
|
|||
c.close();
|
||||
return rawImage;
|
||||
}
|
||||
|
||||
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public final class ContactHelper {
|
|||
boolean valid = checkPhotosUris(resolver, c,
|
||||
android.provider.ContactsContract.Data.CONTACT_ID,
|
||||
android.provider.ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
|
||||
c.close();
|
||||
if (valid) return true;
|
||||
}
|
||||
|
||||
|
@ -202,6 +203,7 @@ public final class ContactHelper {
|
|||
boolean valid = checkPhotosUris(resolver, c,
|
||||
android.provider.ContactsContract.Data.CONTACT_ID,
|
||||
android.provider.ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
|
||||
c.close();
|
||||
if (valid) return true;
|
||||
|
||||
// Finally using phone number
|
||||
|
@ -216,7 +218,7 @@ public final class ContactHelper {
|
|||
android.provider.ContactsContract.PhoneLookup.NUMBER,
|
||||
android.provider.ContactsContract.PhoneLookup.DISPLAY_NAME};
|
||||
c = resolver.query(lookupUri, projection, null, null, null);
|
||||
while (c.moveToNext()) {
|
||||
while (c != null && c.moveToNext()) {
|
||||
long id = c.getLong(c.getColumnIndex(android.provider.ContactsContract.PhoneLookup._ID));
|
||||
String enteredNumber = c.getString(c.getColumnIndex(android.provider.ContactsContract.PhoneLookup.NUMBER));
|
||||
if (!normalizedNumber.equals(PhoneNumberUtils.getStrippedReversed(enteredNumber))) {
|
||||
|
|
|
@ -351,8 +351,13 @@ public class EditContactFragment extends Fragment {
|
|||
new String[]{RawContacts._ID},
|
||||
RawContacts.CONTACT_ID + "=?",
|
||||
new String[]{contactID}, null);
|
||||
if (c != null && c.moveToFirst()) {
|
||||
return c.getString(c.getColumnIndex(RawContacts._ID));
|
||||
if (c != null) {
|
||||
String result = null;
|
||||
if (c.moveToFirst()) {
|
||||
result = c.getString(c.getColumnIndex(RawContacts._ID));
|
||||
}
|
||||
c.close();
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -362,8 +367,13 @@ public class EditContactFragment extends Fragment {
|
|||
new String[]{ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME},
|
||||
RawContacts.CONTACT_ID + "=?",
|
||||
new String[]{contactID}, null);
|
||||
if (c != null && c.moveToFirst()) {
|
||||
return c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
|
||||
if (c != null) {
|
||||
String result = null;
|
||||
if (c.moveToFirst()) {
|
||||
result = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
|
||||
}
|
||||
c.close();
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -373,8 +383,13 @@ public class EditContactFragment extends Fragment {
|
|||
new String[]{ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME},
|
||||
RawContacts.CONTACT_ID + "=?",
|
||||
new String[]{contactID}, null);
|
||||
if (c != null && c.moveToFirst()) {
|
||||
return c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
|
||||
if (c != null) {
|
||||
String result = null;
|
||||
if (c.moveToFirst()) {
|
||||
result = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
|
||||
}
|
||||
c.close();
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import android.provider.ContactsContract.Data;
|
|||
import android.provider.ContactsContract.Intents.Insert;
|
||||
import android.text.ClipboardManager;
|
||||
import android.view.Display;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
|
||||
/*
|
||||
ApiFivePlus.java
|
||||
|
@ -421,4 +423,8 @@ public class ApiFivePlus {
|
|||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||
viewTreeObserver.removeGlobalOnLayoutListener(keyboardListener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import android.app.Notification;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
/*
|
||||
ApiSixteenPlus.java
|
||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
||||
|
@ -76,4 +78,8 @@ public class ApiSixteenPlus {
|
|||
|
||||
return notif;
|
||||
}
|
||||
|
||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ import android.graphics.Bitmap;
|
|||
import android.net.Uri;
|
||||
import android.preference.Preference;
|
||||
import android.view.Display;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -243,4 +245,13 @@ public class Compatibility {
|
|||
ApiFivePlus.deleteSipAddressFromContact(ops, oldSipAddress, contactID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||
if (Version.sdkAboveOrEqual(16)) {
|
||||
ApiSixteenPlus.removeGlobalLayoutListener(viewTreeObserver, keyboardListener);
|
||||
} else {
|
||||
ApiFivePlus.removeGlobalLayoutListener(viewTreeObserver, keyboardListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue