mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-01 13:35:49 +01:00
Use checkboxes for notification and pebblemsg blacklist
also support dark theme and add a menu entry for accessing blacklist functionality
This commit is contained in:
parent
d55d551943
commit
b81de63b30
@ -248,6 +248,10 @@ public class ControlCenterv2 extends AppCompatActivity
|
|||||||
Intent dbIntent = new Intent(this, DbManagementActivity.class);
|
Intent dbIntent = new Intent(this, DbManagementActivity.class);
|
||||||
startActivity(dbIntent);
|
startActivity(dbIntent);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_blacklist:
|
||||||
|
Intent blIntent = new Intent(this, AppBlacklistActivity.class);
|
||||||
|
startActivity(blIntent);
|
||||||
|
return true;
|
||||||
case R.id.action_quit:
|
case R.id.action_quit:
|
||||||
GBApplication.quit();
|
GBApplication.quit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ import android.support.v7.widget.RecyclerView;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckedTextView;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -99,25 +99,24 @@ public class AppBlacklistAdapter extends RecyclerView.Adapter<AppBlacklistAdapte
|
|||||||
holder.deviceImageView.setImageDrawable(appInfo.loadIcon(mPm));
|
holder.deviceImageView.setImageDrawable(appInfo.loadIcon(mPm));
|
||||||
|
|
||||||
holder.blacklist_checkbox.setChecked(GBApplication.appIsNotifBlacklisted(appInfo.packageName));
|
holder.blacklist_checkbox.setChecked(GBApplication.appIsNotifBlacklisted(appInfo.packageName));
|
||||||
holder.blacklist_checkbox.setTextColor(mContext.getResources().getColorStateList(R.color.blacklist_checkboxes));
|
|
||||||
|
|
||||||
holder.blacklist_pebble_checkbox.setChecked(GBApplication.appIsPebbleBlacklisted(packageNameToPebbleMsgSender(appInfo.packageName)));
|
holder.blacklist_pebble_checkbox.setChecked(GBApplication.appIsPebbleBlacklisted(packageNameToPebbleMsgSender(appInfo.packageName)));
|
||||||
|
|
||||||
holder.blacklist_pebble_checkbox.setTextColor(mContext.getResources().getColorStateList(R.color.blacklist_checkboxes));
|
|
||||||
holder.blacklist_pebble_checkbox.setOnClickListener(new View.OnClickListener() {
|
holder.blacklist_pebble_checkbox.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if ( ((CheckBox)view).isChecked() ) {
|
((CheckedTextView) view).toggle();
|
||||||
|
if ( ((CheckedTextView)view).isChecked() ) {
|
||||||
GBApplication.addAppToPebbleBlacklist(appInfo.packageName);
|
GBApplication.addAppToPebbleBlacklist(appInfo.packageName);
|
||||||
} else {
|
} else {
|
||||||
GBApplication.removeFromAppsPebbleBlacklist(appInfo.packageName);
|
GBApplication.removeFromAppsPebbleBlacklist(appInfo.packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
CheckBox checkBox = ((CheckBox) v.findViewById(R.id.item_checkbox));
|
CheckedTextView checkBox = ((CheckedTextView) v.findViewById(R.id.item_checkbox));
|
||||||
checkBox.toggle();
|
checkBox.toggle();
|
||||||
if (checkBox.isChecked()) {
|
if (checkBox.isChecked()) {
|
||||||
GBApplication.addAppToNotifBlacklist(appInfo.packageName);
|
GBApplication.addAppToNotifBlacklist(appInfo.packageName);
|
||||||
@ -159,8 +158,8 @@ public class AppBlacklistAdapter extends RecyclerView.Adapter<AppBlacklistAdapte
|
|||||||
|
|
||||||
class AppBLViewHolder extends RecyclerView.ViewHolder {
|
class AppBLViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
final CheckBox blacklist_checkbox;
|
final CheckedTextView blacklist_checkbox;
|
||||||
final CheckBox blacklist_pebble_checkbox;
|
final CheckedTextView blacklist_pebble_checkbox;
|
||||||
final ImageView deviceImageView;
|
final ImageView deviceImageView;
|
||||||
final TextView deviceAppVersionAuthorLabel;
|
final TextView deviceAppVersionAuthorLabel;
|
||||||
final TextView deviceAppNameLabel;
|
final TextView deviceAppNameLabel;
|
||||||
@ -168,8 +167,8 @@ public class AppBlacklistAdapter extends RecyclerView.Adapter<AppBlacklistAdapte
|
|||||||
AppBLViewHolder(View itemView) {
|
AppBLViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
blacklist_checkbox = (CheckBox) itemView.findViewById(R.id.item_checkbox);
|
blacklist_checkbox = (CheckedTextView) itemView.findViewById(R.id.item_checkbox);
|
||||||
blacklist_pebble_checkbox = (CheckBox) itemView.findViewById(R.id.item_pebble_checkbox);
|
blacklist_pebble_checkbox = (CheckedTextView) itemView.findViewById(R.id.item_pebble_checkbox);
|
||||||
deviceImageView = (ImageView) itemView.findViewById(R.id.item_image);
|
deviceImageView = (ImageView) itemView.findViewById(R.id.item_image);
|
||||||
deviceAppVersionAuthorLabel = (TextView) itemView.findViewById(R.id.item_details);
|
deviceAppVersionAuthorLabel = (TextView) itemView.findViewById(R.id.item_details);
|
||||||
deviceAppNameLabel = (TextView) itemView.findViewById(R.id.item_name);
|
deviceAppNameLabel = (TextView) itemView.findViewById(R.id.item_name);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:state_checked="true" android:color="#FF0000"/> <!-- checked -->
|
<item android:state_checked="true" android:color="?attr/colorAccent"/> <!-- checked -->
|
||||||
<item android:state_checked="true" android:state_enabled="false" app:alpha="?android:disabledAlpha" android:color="#FF0000"/> <!-- checked, disabled -->
|
<item android:color="?attr/textColorPrimary"/> <!-- anything else -->
|
||||||
<item android:color="#000000"/> <!-- anything else -->
|
|
||||||
</selector>
|
</selector>
|
9
app/src/main/res/drawable/ic_block_black.xml
Normal file
9
app/src/main/res/drawable/ic_block_black.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
@ -6,7 +6,7 @@
|
|||||||
android:minHeight="60dp">
|
android:minHeight="60dp">
|
||||||
|
|
||||||
|
|
||||||
<CheckBox
|
<android.support.v7.widget.AppCompatCheckedTextView
|
||||||
android:id="@+id/item_checkbox"
|
android:id="@+id/item_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -14,23 +14,23 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:clickable="false"
|
android:textColor="@color/blacklist_checkboxes"
|
||||||
android:focusable="false"
|
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||||
android:button="@null"
|
android:text="NOTIF"
|
||||||
android:text="NOTIF"/>
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<CheckBox
|
<android.support.v7.widget.AppCompatCheckedTextView
|
||||||
android:id="@+id/item_pebble_checkbox"
|
android:id="@+id/item_pebble_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:button="@null"
|
|
||||||
android:layout_toEndOf="@+id/item_checkbox"
|
android:layout_toEndOf="@+id/item_checkbox"
|
||||||
android:text="PEBBLE"/>
|
android:textColor="@color/blacklist_checkboxes"
|
||||||
|
android:drawableTop="?android:attr/listChoiceIndicatorMultiple"
|
||||||
|
android:text="PEBBLE"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/item_image"
|
android:id="@+id/item_image"
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
<item android:id="@+id/action_db_management"
|
<item android:id="@+id/action_db_management"
|
||||||
android:title="@string/action_db_management"
|
android:title="@string/action_db_management"
|
||||||
android:icon="@drawable/ic_database_management" />
|
android:icon="@drawable/ic_database_management" />
|
||||||
|
<item android:id="@+id/action_blacklist"
|
||||||
|
android:title="@string/title_activity_appblacklist"
|
||||||
|
android:icon="@drawable/ic_block_black" />
|
||||||
|
|
||||||
<item android:id="@+id/action_quit"
|
<item android:id="@+id/action_quit"
|
||||||
android:title="@string/action_quit"
|
android:title="@string/action_quit"
|
||||||
android:icon="@drawable/ic_quit" />
|
android:icon="@drawable/ic_quit" />
|
||||||
|
Loading…
Reference in New Issue
Block a user