Design changes in app info list

This commit is contained in:
Ash 2020-03-01 21:23:24 +05:30
parent db71e28e67
commit e85f1f8e9a
2 changed files with 66 additions and 28 deletions

View File

@ -24,7 +24,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -63,11 +63,17 @@ public class AppInfoAdapter extends RecyclerView.Adapter {
} catch (Resources.NotFoundException e) {
holder.app_icon.setImageResource(R.drawable.ic_android);
}
holder.information.setText(appInfo.getApplicationInfo().packageName);
String app_label = context.getPackageManager().getApplicationLabel(appInfo.getApplicationInfo()).toString();
if (appInfo.getApplicationInfo().packageName.compareTo(BuildConfig.APPLICATION_ID) == 0) {
holder.application_label.setText(app_label);
holder.package_name.setVisibility(View.GONE);
holder.valid.setImageResource(R.drawable.ic_check);
holder.valid.setContentDescription(context.getString(R.string.valid));
} else {
String package_name = appInfo.getApplicationInfo().packageName;
holder.application_label.setText(app_label);
holder.package_name.setVisibility(View.VISIBLE);
holder.package_name.setText(String.format("(%s)", package_name));
holder.valid.setImageResource(R.drawable.ic_error);
holder.valid.setContentDescription(context.getString(R.string.error));
}
@ -78,7 +84,7 @@ public class AppInfoAdapter extends RecyclerView.Adapter {
context.startActivity(intent);
});
} else {
holder.information.setText(R.string.no_apps);
holder.application_label.setText(R.string.no_apps);
holder.app_icon.setImageResource(R.drawable.ic_android);
holder.valid.setContentDescription(context.getString(R.string.warning));
holder.valid.setImageResource(R.drawable.ic_warning);
@ -106,14 +112,15 @@ public class AppInfoAdapter extends RecyclerView.Adapter {
static class ViewHolder extends RecyclerView.ViewHolder {
ImageView app_icon, valid;
TextView information, domain;
LinearLayout main_container;
TextView application_label, package_name, domain;
ConstraintLayout main_container;
ViewHolder(@NonNull View itemView) {
super(itemView);
app_icon = itemView.findViewById(R.id.app_icon);
valid = itemView.findViewById(R.id.valid);
information = itemView.findViewById(R.id.information);
application_label = itemView.findViewById(R.id.application_label);
package_name = itemView.findViewById(R.id.package_name);
domain = itemView.findViewById(R.id.domain);
main_container = itemView.findViewById(R.id.main_container);
}

View File

@ -1,43 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginTop="5dp"
android:layout_marginEnd="@dimen/fab_margin"
android:orientation="horizontal">
android:layout_margin="5dp">
<ImageView
android:id="@+id/app_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/icon_of_the_app" />
android:contentDescription="@string/icon_of_the_app"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
<TextView
android:id="@+id/domain"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_weight="1"
android:orientation="vertical">
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/application_label"
app:layout_constraintEnd_toStartOf="@id/valid"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/domain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold" />
<TextView
android:id="@+id/application_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/valid"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toBottomOf="@id/domain"
app:layout_constraintWidth_default="wrap" />
<TextView
android:id="@+id/information"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/package_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#A1A1A1"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/valid"
app:layout_constraintStart_toEndOf="@id/application_label"
app:layout_constraintTop_toBottomOf="@id/domain" />
<ImageView
android:id="@+id/valid"
android:layout_width="30dp"
android:layout_height="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>