Minor UI adjustments (#19)
* Add accent color and medium weight to "Recommended" * Rename "Android System" to System Framework * Remove minWidth and minHeight for checkboxes
This commit is contained in:
parent
b583da4ab9
commit
ced2805566
|
|
@ -7,10 +7,17 @@ import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
|
import android.text.style.TypefaceSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
|
@ -110,7 +117,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
rmList.add(info);
|
rmList.add(info);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkedList.contains(info.packageName)) {
|
if (checkedList.contains(info.packageName) || info.packageName.equals("android")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!preferences.getBoolean("show_modules", false)) {
|
if (!preferences.getBoolean("show_modules", false)) {
|
||||||
|
|
@ -130,7 +137,7 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) == 0 && !info.packageName.equals("android")) {
|
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) == 0) {
|
||||||
rmList.add(info);
|
rmList.add(info);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -150,6 +157,17 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
private void sortApps() {
|
private void sortApps() {
|
||||||
Comparator<PackageInfo> cmp = AppHelper.getAppListComparator(preferences.getInt("list_sort", 0), pm);
|
Comparator<PackageInfo> cmp = AppHelper.getAppListComparator(preferences.getInt("list_sort", 0), pm);
|
||||||
fullList.sort((a, b) -> {
|
fullList.sort((a, b) -> {
|
||||||
|
boolean aAndroid = a.packageName.equals("android");
|
||||||
|
boolean bAnrdoid = b.packageName.equals("android");
|
||||||
|
if (aAndroid || bAnrdoid) {
|
||||||
|
if (aAndroid == bAnrdoid) {
|
||||||
|
return 0;
|
||||||
|
} else if (aAndroid) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean aChecked = checkedList.contains(a.packageName);
|
boolean aChecked = checkedList.contains(a.packageName);
|
||||||
boolean bChecked = checkedList.contains(b.packageName);
|
boolean bChecked = checkedList.contains(b.packageName);
|
||||||
if (aChecked == bChecked) {
|
if (aChecked == bChecked) {
|
||||||
|
|
@ -299,7 +317,8 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
holder.root.setAlpha(enabled ? 1.0f : .5f);
|
holder.root.setAlpha(enabled ? 1.0f : .5f);
|
||||||
PackageInfo info = showList.get(position);
|
PackageInfo info = showList.get(position);
|
||||||
holder.appName.setText(getAppLabel(info.applicationInfo, pm));
|
boolean android = info.packageName.equals("android");
|
||||||
|
holder.appName.setText(android ? activity.getString(R.string.android_framework) : getAppLabel(info.applicationInfo, pm));
|
||||||
GlideApp.with(holder.appIcon)
|
GlideApp.with(holder.appIcon)
|
||||||
.load(info)
|
.load(info)
|
||||||
.into(new CustomTarget<Drawable>() {
|
.into(new CustomTarget<Drawable>() {
|
||||||
|
|
@ -313,11 +332,25 @@ public class ScopeAdapter extends RecyclerView.Adapter<ScopeAdapter.ViewHolder>
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String description = activity.getString(R.string.app_description, info.packageName, info.versionName);
|
SpannableStringBuilder sb = new SpannableStringBuilder(android ? "" : activity.getString(R.string.app_description, info.packageName, info.versionName));
|
||||||
|
holder.appDescription.setVisibility(View.VISIBLE);
|
||||||
if (hasRecommended() && recommendedList.contains(info.packageName)) {
|
if (hasRecommended() && recommendedList.contains(info.packageName)) {
|
||||||
description += "\n" + activity.getString(R.string.requested_by_module);
|
if (!android) sb.append("\n");
|
||||||
|
String recommended = activity.getString(R.string.requested_by_module);
|
||||||
|
sb.append(recommended);
|
||||||
|
final ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(activity.getThemedColor(R.attr.colorAccent));
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
final TypefaceSpan typefaceSpan = new TypefaceSpan(Typeface.create("sans-serif-medium", Typeface.NORMAL));
|
||||||
|
sb.setSpan(typefaceSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
} else {
|
||||||
|
final StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
|
||||||
|
sb.setSpan(styleSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
}
|
||||||
|
sb.setSpan(foregroundColorSpan, sb.length() - recommended.length(), sb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
} else if (android) {
|
||||||
|
holder.appDescription.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.appDescription.setText(description);
|
holder.appDescription.setText(sb);
|
||||||
|
|
||||||
holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
|
holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
|
||||||
activity.getMenuInflater().inflate(R.menu.menu_app_item, menu);
|
activity.getMenuInflater().inflate(R.menu.menu_app_item, menu);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
android:minHeight="?attr/listPreferredItemHeight"
|
android:minHeight="?attr/listPreferredItemHeight"
|
||||||
android:paddingVertical="16dp"
|
android:paddingVertical="16dp"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp">
|
android:paddingEnd="24dp">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/item_root"
|
android:id="@+id/item_root"
|
||||||
|
|
@ -29,16 +29,16 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_name"
|
android:id="@+id/app_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:textAppearance="?android:attr/textAppearance"
|
android:textAppearance="?android:attr/textAppearance"
|
||||||
android:textSize="16sp"
|
|
||||||
android:textIsSelectable="false"
|
android:textIsSelectable="false"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/description"
|
||||||
app:layout_constraintStart_toEndOf="@id/app_icon"
|
app:layout_constraintStart_toEndOf="@id/app_icon"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/description"
|
|
||||||
tools:text="@tools:sample/first_names" />
|
tools:text="@tools:sample/first_names" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -81,8 +81,6 @@
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:minHeight="0dp"
|
|
||||||
android:minWidth="0dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
|
||||||
|
|
@ -159,4 +159,5 @@
|
||||||
<string name="use_recommended_message">选择推荐的应用?</string>
|
<string name="use_recommended_message">选择推荐的应用?</string>
|
||||||
<string name="requested_by_module">推荐的应用</string>
|
<string name="requested_by_module">推荐的应用</string>
|
||||||
<string name="module_disabled_no_selection">由于未选择任何应用,模块 %s 已被禁用。</string>
|
<string name="module_disabled_no_selection">由于未选择任何应用,模块 %s 已被禁用。</string>
|
||||||
|
<string name="android_framework">系统框架</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -167,4 +167,5 @@
|
||||||
<string name="use_recommended_message">Select recommended apps?</string>
|
<string name="use_recommended_message">Select recommended apps?</string>
|
||||||
<string name="requested_by_module">Recommended</string>
|
<string name="requested_by_module">Recommended</string>
|
||||||
<string name="module_disabled_no_selection">Module %s has been disabled since no app selected.</string>
|
<string name="module_disabled_no_selection">Module %s has been disabled since no app selected.</string>
|
||||||
|
<string name="android_framework">System Framework</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,16 @@
|
||||||
<item name="liftOnScroll">false</item>
|
<item name="liftOnScroll">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Widget.MaterialComponents.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox" tools:override="true">
|
||||||
|
<item name="enforceMaterialTheme">true</item>
|
||||||
|
<item name="useMaterialThemeColors">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Widget.MaterialComponents.CompoundButton.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton" tools:override="true">
|
||||||
|
<item name="enforceMaterialTheme">true</item>
|
||||||
|
<item name="useMaterialThemeColors">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />
|
||||||
|
|
||||||
<style name="MasterSwitch" parent="@style/ThemeOverlay.AppCompat.Dark">
|
<style name="MasterSwitch" parent="@style/ThemeOverlay.AppCompat.Dark">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue