Refine main activity
This commit is contained in:
parent
6e146853ae
commit
becf4a1aad
|
|
@ -58,9 +58,8 @@ public class AppHelper {
|
||||||
String packageName = path.getFileName().toString();
|
String packageName = path.getFileName().toString();
|
||||||
if (forceWhiteList.contains(packageName)) {
|
if (forceWhiteList.contains(packageName)) {
|
||||||
createAppListFile(packageName, white, white);
|
createAppListFile(packageName, white, white);
|
||||||
} else {
|
|
||||||
s.add(packageName);
|
|
||||||
}
|
}
|
||||||
|
if (white) s.add(packageName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return s;
|
return s;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import org.meowcat.edxposed.manager.Constants;
|
import org.meowcat.edxposed.manager.Constants;
|
||||||
import org.meowcat.edxposed.manager.R;
|
import org.meowcat.edxposed.manager.R;
|
||||||
|
import org.meowcat.edxposed.manager.adapters.AppHelper;
|
||||||
import org.meowcat.edxposed.manager.databinding.ActivityMainBinding;
|
import org.meowcat.edxposed.manager.databinding.ActivityMainBinding;
|
||||||
import org.meowcat.edxposed.manager.ui.fragment.StatusDialogBuilder;
|
import org.meowcat.edxposed.manager.ui.fragment.StatusDialogBuilder;
|
||||||
import org.meowcat.edxposed.manager.util.GlideHelper;
|
import org.meowcat.edxposed.manager.util.GlideHelper;
|
||||||
|
|
@ -21,7 +22,7 @@ import org.meowcat.edxposed.manager.util.light.Light;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListener {
|
public class MainActivity extends BaseActivity {
|
||||||
ActivityMainBinding binding;
|
ActivityMainBinding binding;
|
||||||
|
|
||||||
@SuppressLint("PrivateResource")
|
@SuppressLint("PrivateResource")
|
||||||
|
|
@ -34,9 +35,9 @@ public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListe
|
||||||
if (Light.setLightSourceAlpha(getWindow().getDecorView(), 0.01f, 0.029f)) {
|
if (Light.setLightSourceAlpha(getWindow().getDecorView(), 0.01f, 0.029f)) {
|
||||||
binding.status.setElevation(24);
|
binding.status.setElevation(24);
|
||||||
binding.modules.setElevation(12);
|
binding.modules.setElevation(12);
|
||||||
|
binding.apps.setElevation(12);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ModuleUtil.getInstance().addListener(this);
|
|
||||||
binding.modules.setOnClickListener(v -> {
|
binding.modules.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClass(getApplicationContext(), ModulesActivity.class);
|
intent.setClass(getApplicationContext(), ModulesActivity.class);
|
||||||
|
|
@ -94,28 +95,14 @@ public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListe
|
||||||
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
|
binding.status.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
|
||||||
binding.statusIcon.setImageResource(R.drawable.ic_error);
|
binding.statusIcon.setImageResource(R.drawable.ic_error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
|
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), ModuleUtil.getInstance().getEnabledModules().size()));
|
||||||
|
binding.appsTitle.setText(AppHelper.isWhiteListMode() ? R.string.title_white_list : R.string.title_black_list);
|
||||||
|
int count = AppHelper.getAppList(AppHelper.isWhiteListMode()).size();
|
||||||
|
binding.appsSummary.setText(getString(AppHelper.isWhiteListMode() ? R.string.whitelist_summary : R.string.blacklist_summary, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInstalledModulesReloaded(ModuleUtil moduleUtil) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onModuleEnableChange(ModuleUtil moduleUtil) {
|
|
||||||
binding.modulesSummary.setText(String.format(getString(R.string.ModulesDetail), moduleUtil.getEnabledModules().size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSingleInstalledModuleReloaded(ModuleUtil moduleUtil, String packageName, ModuleUtil.InstalledModule module) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
ModuleUtil.getInstance().removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -371,11 +371,6 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
||||||
runOnUiThread(reloadModules);
|
runOnUiThread(reloadModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onModuleEnableChange(ModuleUtil moduleUtil) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
||||||
ModuleUtil.InstalledModule module = ModuleUtil.getInstance().getModule(selectedPackageName);
|
ModuleUtil.InstalledModule module = ModuleUtil.getInstance().getModule(selectedPackageName);
|
||||||
|
|
|
||||||
|
|
@ -148,9 +148,6 @@ public final class ModuleUtil {
|
||||||
} else {
|
} else {
|
||||||
enabledModules.remove(packageName);
|
enabledModules.remove(packageName);
|
||||||
}
|
}
|
||||||
for (ModuleListener listener : listeners) {
|
|
||||||
listener.onModuleEnableChange(instance);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModuleEnabled(String packageName) {
|
public boolean isModuleEnabled(String packageName) {
|
||||||
|
|
@ -246,8 +243,6 @@ public final class ModuleUtil {
|
||||||
* Called whenever all installed modules have been reloaded
|
* Called whenever all installed modules have been reloaded
|
||||||
*/
|
*/
|
||||||
void onInstalledModulesReloaded(ModuleUtil moduleUtil);
|
void onInstalledModulesReloaded(ModuleUtil moduleUtil);
|
||||||
|
|
||||||
void onModuleEnableChange(ModuleUtil moduleUtil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InstalledModule {
|
public class InstalledModule {
|
||||||
|
|
|
||||||
|
|
@ -166,32 +166,56 @@
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/apps"
|
android:id="@+id/apps"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@drawable/item_background_round_nopadding"
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:orientation="horizontal"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:padding="18dp">
|
app:cardCornerRadius="8dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardPreventCornerOverlap="false">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="18dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingEnd="18dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/apps_icon"
|
||||||
android:layout_width="28dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="28dp"
|
android:layout_height="28dp"
|
||||||
android:contentDescription="@string/Apps"
|
android:layout_centerVertical="true"
|
||||||
|
android:contentDescription="@string/Modules"
|
||||||
app:srcCompat="@drawable/outline_list_24" />
|
app:srcCompat="@drawable/outline_list_24" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/apps_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="25dp"
|
android:layout_marginStart="25dp"
|
||||||
|
android:layout_toEndOf="@id/apps_icon"
|
||||||
android:text="@string/Apps"
|
android:text="@string/Apps"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||||
</LinearLayout>
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/apps_summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/apps_title"
|
||||||
|
android:layout_alignStart="@id/apps_title"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="@string/Apps"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textColor="@android:color/darker_gray" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/logs"
|
android:id="@+id/logs"
|
||||||
|
|
|
||||||
|
|
@ -174,4 +174,6 @@
|
||||||
<string name="menu_show_modules">模块</string>
|
<string name="menu_show_modules">模块</string>
|
||||||
<string name="menu_reboot">重启…</string>
|
<string name="menu_reboot">重启…</string>
|
||||||
<string name="menu_sort">排序…</string>
|
<string name="menu_sort">排序…</string>
|
||||||
|
<string name="blacklist_summary">%d 个应用位于黑名单中</string>
|
||||||
|
<string name="whitelist_summary">%d 个应用位于白名单中</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -348,4 +348,6 @@
|
||||||
<string name="menu_show_modules">Modules</string>
|
<string name="menu_show_modules">Modules</string>
|
||||||
<string name="menu_reboot">Reboot…</string>
|
<string name="menu_reboot">Reboot…</string>
|
||||||
<string name="menu_sort">Sorting…</string>
|
<string name="menu_sort">Sorting…</string>
|
||||||
|
<string name="blacklist_summary">%d apps blacklisted</string>
|
||||||
|
<string name="whitelist_summary">%d apps whitelisted</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue