@@ -12,11 +12,13 @@ import android.security.KeyChainAliasCallback;
import android.util.Pair;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
+import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -31,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.databinding.ActivityManageAccountsBinding;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -60,6 +63,9 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
protected AtomicBoolean mInvokedAddAccount = new AtomicBoolean(false);
protected Intent mMicIntent = null;
+ private ActivityManageAccountsBinding binding;
+ private RelativeLayout phoneAccountsFooter;
+
protected Pair<Integer, Intent> mPostponedActivityResult = null;
@Override
@@ -81,14 +87,14 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
invalidateOptionsMenu();
mAccountAdapter.notifyDataSetChanged();
- findViewById(R.id.phone_accounts).setVisibility(View.GONE);
- findViewById(R.id.phone_accounts).setOnClickListener((View v) -> {
+ phoneAccountsFooter.setVisibility(View.GONE);
+ phoneAccountsFooter.setOnClickListener((View v) -> {
mMicIntent = new Intent();
mMicIntent.setComponent(new ComponentName("com.android.server.telecom",
"com.android.server.telecom.settings.EnableAccountPreferenceActivity"));
requestMicPermission();
});
- findViewById(R.id.phone_accounts_settings).setOnClickListener((View v) -> {
+ phoneAccountsFooter.findViewById(R.id.phone_accounts_settings).setOnClickListener((View v) -> {
mMicIntent = new Intent(android.telecom.TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
requestMicPermission();
});
@@ -102,7 +108,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
final var hasPhoneAccounts = xmppConnectionService.getAccounts().stream().anyMatch(a -> a.getGateways("pstn").size() > 0);
if (hasPhoneAccounts) {
- findViewById(R.id.phone_accounts).setVisibility(View.VISIBLE);
+ phoneAccountsFooter.setVisibility(View.VISIBLE);
}
}
@@ -110,8 +116,9 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ binding = ActivityManageAccountsBinding.inflate(getLayoutInflater());
- setContentView(R.layout.activity_manage_accounts);
+ setContentView(binding.getRoot());
Activities.setStatusAndNavigationBarColors(this, findViewById(android.R.id.content));
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
@@ -126,10 +133,20 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
}
}
- accountListView = findViewById(R.id.account_list);
+ accountListView = binding.accountList;
this.mAccountAdapter = new AccountAdapter(this, accountList);
accountListView.setAdapter(this.mAccountAdapter);
accountListView.setOnItemClickListener((arg0, view, position, arg3) -> switchToAccount(accountList.get(position)));
+
+
+ LayoutInflater inflater = getLayoutInflater();
+ phoneAccountsFooter = (RelativeLayout) inflater.inflate(
+ R.layout.footer_manage_phone_accounts,
+ accountListView,
+ false
+ );
+ accountListView.addFooterView(phoneAccountsFooter);
+
registerForContextMenu(accountListView);
}
@@ -25,61 +25,5 @@
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
-
- <RelativeLayout
- android:id="@+id/phone_accounts"
- android:visibility="gone"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?selectableItemBackground"
- android:paddingLeft="8dp"
- android:paddingBottom="8dp"
- android:paddingTop="8dp">
-
- <com.google.android.material.imageview.ShapeableImageView
- android:id="@+id/phone_accounts_image"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_alignParentLeft="true"
- android:background="@color/yeller"
- android:src="@drawable/ic_call_24dp"
- android:tint="@color/white"
- app:shapeAppearance="@style/ShapeAppearanceOverlay.Photo" />
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_toRightOf="@+id/phone_accounts_image"
- android:orientation="vertical"
- android:paddingLeft="@dimen/avatar_item_distance">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:scrollHorizontally="false"
- android:singleLine="true"
- android:text="Manage Phone Accounts"
- android:textAppearance="?textAppearanceBodyLarge" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Android system dialler integration"
- android:textAppearance="?textAppearanceBodyMedium" />
- </LinearLayout>
-
- <com.google.android.material.imageview.ShapeableImageView
- android:id="@+id/phone_accounts_settings"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:paddingRight="16dp"
- app:strokeColor="@null"
- android:src="@drawable/ic_settings_24dp"
- app:shapeAppearance="@style/ShapeAppearanceOverlay.Photo" />
- </RelativeLayout>
-
</LinearLayout>
</layout>
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
+<RelativeLayout
+ android:id="@+id/phone_accounts"
+ android:visibility="gone"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?selectableItemBackground"
+ android:paddingLeft="8dp"
+ android:paddingBottom="8dp"
+ android:paddingTop="8dp">
+
+ <com.google.android.material.imageview.ShapeableImageView
+ android:id="@+id/phone_accounts_image"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_alignParentLeft="true"
+ android:background="@color/yeller"
+ android:src="@drawable/ic_call_24dp"
+ android:tint="@color/white"
+ app:shapeAppearance="@style/ShapeAppearanceOverlay.Photo" />
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_toRightOf="@+id/phone_accounts_image"
+ android:orientation="vertical"
+ android:paddingLeft="@dimen/avatar_item_distance">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:scrollHorizontally="false"
+ android:singleLine="true"
+ android:text="Manage Phone Accounts"
+ android:textAppearance="?textAppearanceBodyLarge" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Android system dialler integration"
+ android:textAppearance="?textAppearanceBodyMedium" />
+ </LinearLayout>
+
+ <com.google.android.material.imageview.ShapeableImageView
+ android:id="@+id/phone_accounts_settings"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:paddingRight="16dp"
+ app:strokeColor="@null"
+ android:src="@drawable/ic_settings_24dp"
+ app:shapeAppearance="@style/ShapeAppearanceOverlay.Photo" />
+</RelativeLayout>
+</layout>