Merge black list and scope list into one activity
This commit is contained in:
parent
84a8d12992
commit
2e36702560
|
|
@ -26,10 +26,7 @@
|
|||
<activity
|
||||
android:name=".ui.activity.LogsActivity"
|
||||
android:label="@string/Logs" />
|
||||
<activity android:name=".ui.activity.BlackListActivity" />
|
||||
<activity
|
||||
android:name=".ui.activity.ModuleScopeActivity"
|
||||
android:label="@string/menu_scope" />
|
||||
<activity android:name=".ui.activity.AppListActivity" />
|
||||
<activity
|
||||
android:name=".ui.activity.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
|
@ -71,6 +68,7 @@
|
|||
<receiver
|
||||
android:name=".util.NotificationUtil$RebootReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.ViewHolder> impl
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.pm.ApplicationInfo;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
@ -17,15 +18,16 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||
import org.meowcat.edxposed.manager.R;
|
||||
import org.meowcat.edxposed.manager.adapters.AppAdapter;
|
||||
import org.meowcat.edxposed.manager.adapters.AppHelper;
|
||||
import org.meowcat.edxposed.manager.adapters.BlackListAdapter;
|
||||
import org.meowcat.edxposed.manager.adapters.ScopeAdapter;
|
||||
import org.meowcat.edxposed.manager.databinding.ActivityScopeListBinding;
|
||||
import org.meowcat.edxposed.manager.util.LinearLayoutManagerFix;
|
||||
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
|
||||
public class ModuleScopeActivity extends BaseActivity implements AppAdapter.Callback {
|
||||
public class AppListActivity extends BaseActivity implements AppAdapter.Callback {
|
||||
private SearchView searchView;
|
||||
private ScopeAdapter appAdapter;
|
||||
private AppAdapter appAdapter;
|
||||
|
||||
private SearchView.OnQueryTextListener searchListener;
|
||||
private ActivityScopeListBinding binding;
|
||||
|
|
@ -47,11 +49,17 @@ public class ModuleScopeActivity extends BaseActivity implements AppAdapter.Call
|
|||
setSupportActionBar(binding.toolbar);
|
||||
binding.toolbar.setNavigationOnClickListener(view -> finish());
|
||||
ActionBar bar = getSupportActionBar();
|
||||
if (bar != null) {
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
if (!TextUtils.isEmpty(modulePackageName)) {
|
||||
bar.setTitle(R.string.menu_scope);
|
||||
bar.setSubtitle(moduleName);
|
||||
appAdapter = new ScopeAdapter(this, modulePackageName, binding.masterSwitch);
|
||||
} else {
|
||||
final boolean isWhiteListMode = AppHelper.isWhiteListMode();
|
||||
bar.setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list);
|
||||
binding.masterSwitch.setVisibility(View.GONE);
|
||||
appAdapter = new BlackListAdapter(this, isWhiteListMode);
|
||||
}
|
||||
appAdapter = new ScopeAdapter(this, modulePackageName, binding.masterSwitch);
|
||||
appAdapter.setHasStableIds(true);
|
||||
binding.recyclerView.setAdapter(appAdapter);
|
||||
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
||||
|
|
@ -99,22 +107,6 @@ public class ModuleScopeActivity extends BaseActivity implements AppAdapter.Call
|
|||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
changeTitle(isWhiteListMode());
|
||||
}
|
||||
|
||||
|
||||
private void changeTitle(boolean isWhiteListMode) {
|
||||
setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list);
|
||||
|
||||
}
|
||||
|
||||
private boolean isWhiteListMode() {
|
||||
return AppHelper.isWhiteListMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataReady() {
|
||||
handler.removeCallbacks(runnable);
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
package org.meowcat.edxposed.manager.ui.activity;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
|
||||
import org.meowcat.edxposed.manager.R;
|
||||
import org.meowcat.edxposed.manager.adapters.AppAdapter;
|
||||
import org.meowcat.edxposed.manager.adapters.AppHelper;
|
||||
import org.meowcat.edxposed.manager.adapters.BlackListAdapter;
|
||||
import org.meowcat.edxposed.manager.databinding.ActivityBlackListBinding;
|
||||
import org.meowcat.edxposed.manager.util.LinearLayoutManagerFix;
|
||||
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
|
||||
public class BlackListActivity extends BaseActivity implements AppAdapter.Callback {
|
||||
private SearchView searchView;
|
||||
private AppAdapter appAdapter;
|
||||
|
||||
private SearchView.OnQueryTextListener searchListener;
|
||||
private ActivityBlackListBinding binding;
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
}
|
||||
};
|
||||
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityBlackListBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
binding.toolbar.setNavigationOnClickListener(view -> finish());
|
||||
ActionBar bar = getSupportActionBar();
|
||||
if (bar != null) {
|
||||
bar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
final boolean isWhiteListMode = isWhiteListMode();
|
||||
appAdapter = new BlackListAdapter(this, isWhiteListMode);
|
||||
appAdapter.setHasStableIds(true);
|
||||
binding.recyclerView.setAdapter(appAdapter);
|
||||
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
|
||||
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
|
||||
if (!preferences.getBoolean("md2", false)) {
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
|
||||
DividerItemDecoration.VERTICAL);
|
||||
binding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
} else {
|
||||
fastScrollerBuilder.useMd2Style();
|
||||
}
|
||||
fastScrollerBuilder.build();
|
||||
appAdapter.setCallback(this);
|
||||
handler.postDelayed(runnable, 300);
|
||||
binding.swipeRefreshLayout.setOnRefreshListener(appAdapter::refresh);
|
||||
|
||||
searchListener = new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
appAdapter.filter(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
appAdapter.filter(newText);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (!appAdapter.onOptionsItemSelected(item)) {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
appAdapter.onCreateOptionsMenu(menu, getMenuInflater());
|
||||
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
|
||||
searchView.setOnQueryTextListener(searchListener);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
changeTitle(isWhiteListMode());
|
||||
}
|
||||
|
||||
|
||||
private void changeTitle(boolean isWhiteListMode) {
|
||||
setTitle(isWhiteListMode ? R.string.title_white_list : R.string.title_black_list);
|
||||
|
||||
}
|
||||
|
||||
private boolean isWhiteListMode() {
|
||||
return AppHelper.isWhiteListMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataReady() {
|
||||
handler.removeCallbacks(runnable);
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
String queryStr = searchView != null ? searchView.getQuery().toString() : "";
|
||||
runOnUiThread(() -> appAdapter.getFilter().filter(queryStr));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View v, ApplicationInfo info) {
|
||||
AppHelper.showMenu(this, getSupportFragmentManager(), v, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (searchView.isIconified()) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
searchView.setIconified(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ public class MainActivity extends BaseActivity implements ModuleUtil.ModuleListe
|
|||
});
|
||||
binding.apps.setOnClickListener(v -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(getApplicationContext(), BlackListActivity.class);
|
||||
intent.setClass(getApplicationContext(), AppListActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
binding.status.setOnClickListener(v -> {
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
|
|||
return true;
|
||||
} else if (itemId == R.id.menu_scope) {
|
||||
if (App.supportScope()) {
|
||||
Intent intent = new Intent(this, ModuleScopeActivity.class);
|
||||
Intent intent = new Intent(this, AppListActivity.class);
|
||||
intent.putExtra("modulePackageName", module.packageName);
|
||||
intent.putExtra("moduleName", module.getAppName());
|
||||
startActivity(intent);
|
||||
|
|
|
|||
Loading…
Reference in New Issue