Skip to content

Commit

Permalink
Merge pull request #310 from NordicSemiconductor/dev
Browse files Browse the repository at this point in the history
Adds dark theme support
  • Loading branch information
roshanrajaratnam authored May 12, 2020
2 parents 0e691c3 + 1ef0228 commit 8533400
Show file tree
Hide file tree
Showing 327 changed files with 3,583 additions and 3,120 deletions.
13 changes: 8 additions & 5 deletions Example/nrf-mesh/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
buildToolsVersion '29.0.3'

defaultConfig {
applicationId "no.nordicsemi.android.nrfmeshprovisioner"
minSdkVersion 18
targetSdkVersion 29
versionCode 62
versionName "2.2.0"
versionCode 63
versionName "2.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -73,8 +73,8 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

// Butter Knife
implementation 'com.jakewharton:butterknife:10.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
// Brings the new BluetoothLeScanner API to older platforms
implementation 'no.nordicsemi.android.support.v18:scanner:1.4.3'
// Android BLE Library
Expand All @@ -87,3 +87,6 @@ dependencies {
annotationProcessor 'com.google.dagger:dagger-android-processor:2.27'
implementation project(':meshprovisioner')
}
repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand Down Expand Up @@ -198,7 +197,7 @@ public boolean onGroupAdded(@NonNull final Group group) {
private void displaySnackBar(final Group group) {
final String message = getString(R.string.group_deleted, group.getName());
Snackbar.make(container, message, Snackbar.LENGTH_LONG)
.setActionTextColor(getResources().getColor(R.color.colorPrimaryDark))
.setActionTextColor(getResources().getColor(R.color.colorSecondary))
.setAction(R.string.undo, v -> {
mEmptyView.setVisibility(View.INVISIBLE);
final MeshNetwork network = mViewModel.getNetworkLiveData().getMeshNetwork();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand All @@ -49,8 +48,8 @@
import no.nordicsemi.android.meshprovisioner.transport.ProvisionedMeshNode;
import no.nordicsemi.android.nrfmeshprovisioner.ble.ScannerActivity;
import no.nordicsemi.android.nrfmeshprovisioner.di.Injectable;
import no.nordicsemi.android.nrfmeshprovisioner.dialog.DialogFragmentError;
import no.nordicsemi.android.nrfmeshprovisioner.dialog.DialogFragmentDeleteNode;
import no.nordicsemi.android.nrfmeshprovisioner.dialog.DialogFragmentError;
import no.nordicsemi.android.nrfmeshprovisioner.node.NodeConfigurationActivity;
import no.nordicsemi.android.nrfmeshprovisioner.node.adapter.NodeAdapter;
import no.nordicsemi.android.nrfmeshprovisioner.utils.Utils;
Expand Down Expand Up @@ -91,8 +90,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final
mNodeAdapter = new NodeAdapter(requireContext(), mViewModel.getNodes());
mNodeAdapter.setOnItemClickListener(this);
mRecyclerViewNodes.setLayoutManager(new LinearLayoutManager(getContext()));
final DividerItemDecoration decoration = new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL);
mRecyclerViewNodes.addItemDecoration(decoration);
mRecyclerViewNodes.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));
final ItemTouchHelper.Callback itemTouchHelperCallback = new RemovableItemTouchHelperCallback(this);
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
itemTouchHelper.attachToRecyclerView(mRecyclerViewNodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
Expand Down Expand Up @@ -134,7 +133,7 @@ protected void onCreate(final Bundle savedInstanceState) {

final View containerName = findViewById(R.id.container_name);
containerName.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_label_outline_black_alpha_24dp));
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_label_outline));
final TextView nameTitle = containerName.findViewById(R.id.title);
nameTitle.setText(R.string.summary_name);
final TextView nameView = containerName.findViewById(R.id.text);
Expand All @@ -146,7 +145,7 @@ protected void onCreate(final Bundle savedInstanceState) {

final View containerUnicastAddress = findViewById(R.id.container_unicast);
containerUnicastAddress.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_lan_black_alpha_24dp));
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_lan_24dp));
final TextView unicastAddressTitle = containerUnicastAddress.findViewById(R.id.title);
unicastAddressTitle.setText(R.string.title_unicast_address);
final TextView unicastAddressView = containerUnicastAddress.findViewById(R.id.text);
Expand All @@ -164,7 +163,7 @@ protected void onCreate(final Bundle savedInstanceState) {

final View containerAppKey = findViewById(R.id.container_app_keys);
containerAppKey.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_vpn_key_black_alpha_24dp));
.setBackground(ContextCompat.getDrawable(this, R.drawable.ic_vpn_key_24dp));
final TextView appKeyTitle = containerAppKey.findViewById(R.id.title);
appKeyTitle.setText(R.string.title_app_keys);
final TextView appKeyView = containerAppKey.findViewById(R.id.text);
Expand Down Expand Up @@ -365,7 +364,7 @@ public void setupProvisionerStateObservers(final View provisioningStatusContaine
switch (state) {
case PROVISIONING_FAILED:
if (getSupportFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_PROVISIONING_FAILED) == null) {
final String statusMessage = ProvisioningFailedState.parseProvisioningFailure(getApplicationContext(), provisionerProgress.getStatusReceived());
final String statusMessage = ProvisioningFailedState.parseProvisioningFailure(this, provisionerProgress.getStatusReceived());
DialogFragmentProvisioningFailedError message = DialogFragmentProvisioningFailedError.newInstance(getString(R.string.title_error_provisioning_failed), statusMessage);
message.show(getSupportFragmentManager(), DIALOG_FRAGMENT_PROVISIONING_FAILED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import java.io.FileNotFoundException;
import java.io.OutputStream;

import javax.inject.Inject;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import no.nordicsemi.android.nrfmeshprovisioner.di.Injectable;
import no.nordicsemi.android.nrfmeshprovisioner.dialog.DialogFragmentMeshExportMsg;
import no.nordicsemi.android.nrfmeshprovisioner.dialog.DialogFragmentMeshImport;
Expand Down Expand Up @@ -97,7 +96,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
// Set up views
final View containerNetworkName = rootView.findViewById(R.id.container_network_name);
containerNetworkName.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_label_black_alpha_24dp));
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_label));
final TextView networkNameTitle = containerNetworkName.findViewById(R.id.title);
networkNameTitle.setText(R.string.title_network_name);
final TextView networkNameView = containerNetworkName.findViewById(R.id.text);
Expand All @@ -110,7 +109,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,

final View containerProvisioner = rootView.findViewById(R.id.container_provisioners);
containerProvisioner.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_provisioner_black_alpha_24dp));
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_provisioner_24dp));
final TextView provisionerTitle = containerProvisioner.findViewById(R.id.title);
final TextView provisionerSummary = containerProvisioner.findViewById(R.id.text);
provisionerSummary.setVisibility(View.VISIBLE);
Expand All @@ -122,7 +121,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,

final View containerNetKey = rootView.findViewById(R.id.container_net_keys);
containerNetKey.findViewById(R.id.image)
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_black_24dp_alpha));
.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_24dp));
final TextView keyTitle = containerNetKey.findViewById(R.id.title);
keyTitle.setText(R.string.title_net_keys);
final TextView netKeySummary = containerNetKey.findViewById(R.id.text);
Expand All @@ -135,7 +134,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,

final View containerAppKey = rootView.findViewById(R.id.container_app_keys);
containerAppKey.findViewById(R.id.image).
setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_black_24dp_alpha));
setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_24dp));
((TextView) containerAppKey.findViewById(R.id.title)).setText(R.string.title_app_keys);
final TextView appKeySummary = containerAppKey.findViewById(R.id.text);
appKeySummary.setVisibility(View.VISIBLE);
Expand All @@ -147,7 +146,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater,

final View containerIvTestMode = rootView.findViewById(R.id.container_iv_test_mode);
containerIvTestMode.findViewById(R.id.image).
setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_black_24dp_alpha));
setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.ic_folder_key_24dp));
((TextView) containerIvTestMode.findViewById(R.id.title)).setText(R.string.title_iv_test_mode);
final TextView ivTestModeSummary = containerIvTestMode.findViewById(R.id.text);
ivTestModeSummary.setText(R.string.iv_test_mode_summary);
Expand Down Expand Up @@ -189,15 +188,15 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
mViewModel.getNetworkLoadState().observe(getViewLifecycleOwner(), networkImportState -> {
final String title = getString(R.string.title_network_import);
final DialogFragmentMeshImportMsg fragment =
DialogFragmentMeshImportMsg.newInstance(R.drawable.ic_info_outline_black_alpha,
DialogFragmentMeshImportMsg.newInstance(R.drawable.ic_info_outline,
title, networkImportState);
fragment.show(getChildFragmentManager(), null);
});

mViewModel.getNetworkExportState().observe(getViewLifecycleOwner(), networkExportState -> {
final String title = getString(R.string.title_network_export);
final DialogFragmentMeshExportMsg fragment =
DialogFragmentMeshExportMsg.newInstance(R.drawable.ic_info_outline_black_alpha,
DialogFragmentMeshExportMsg.newInstance(R.drawable.ic_info_outline,
title, networkExportState);
fragment.show(getChildFragmentManager(), null);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
package no.nordicsemi.android.nrfmeshprovisioner.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.google.android.material.elevation.ElevationOverlayProvider;

import java.util.ArrayList;

import androidx.annotation.NonNull;
Expand All @@ -52,18 +54,18 @@ public FilterAddressAdapter(@NonNull final Context context) {
this.mContext = context;
}

public void updateData(@NonNull final ProxyFilter filter){
public void updateData(@NonNull final ProxyFilter filter) {
mAddresses.clear();
mAddresses.addAll(filter.getAddresses());
notifyDataSetChanged();
}

public void clearData(){
public void clearData() {
mAddresses.clear();
notifyDataSetChanged();
}

public void clearRow(final int position){
public void clearRow(final int position) {
mAddresses.remove(position);
notifyDataSetChanged();
}
Expand Down Expand Up @@ -112,7 +114,8 @@ public interface OnItemClickListener {
}

public final class ViewHolder extends RemovableViewHolder {

@BindView(R.id.container)
FrameLayout container;
@BindView(R.id.address_id)
TextView addressTitle;
@BindView(R.id.title)
Expand All @@ -121,7 +124,10 @@ public final class ViewHolder extends RemovableViewHolder {
private ViewHolder(final View view) {
super(view);
ButterKnife.bind(this, view);
view.findViewById(R.id.removable).setOnClickListener(v -> {
final ElevationOverlayProvider provider = new ElevationOverlayProvider(itemView.getContext());
final int color = provider.compositeOverlayIfNeeded(provider.getThemeSurfaceColor(), 3.5f);
getSwipeableView().setBackgroundColor(color);
container.setOnClickListener(v -> {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(getAdapterPosition(), mAddresses.get(getAdapterPosition()).getAddress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
package no.nordicsemi.android.nrfmeshprovisioner.adapter;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import no.nordicsemi.android.meshprovisioner.Group;
Expand Down Expand Up @@ -119,6 +120,8 @@ public interface OnItemClickListener {
}

public final class ViewHolder extends RemovableViewHolder {
@BindView(R.id.container)
FrameLayout container;
@BindView(R.id.group_name)
TextView groupName;
@BindView(R.id.group_address)
Expand All @@ -129,7 +132,7 @@ public final class ViewHolder extends RemovableViewHolder {
private ViewHolder(final View view) {
super(view);
ButterKnife.bind(this, view);
view.findViewById(R.id.container).setOnClickListener(v -> {
container.setOnClickListener(v -> {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(mGroups.get(getAdapterPosition()).getAddress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.material.elevation.ElevationOverlayProvider;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -80,16 +82,10 @@ public void onBindViewHolder(@NonNull final GroupAddressAdapter.ViewHolder holde
final int address = mAddresses.get(position);
final Group group = network.getGroup(address);
if (group != null) {
holder.icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_outline_group_work_black_alpha_24dp));
holder.icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_outline_group_24dp));
holder.name.setText(group.getName());
holder.address.setText(MeshAddress.formatAddress(address, true));
}/* else {
if(MeshAddress.isValidVirtualAddress(address)) {
holder.icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_label_outline_black_alpha_24dp));
holder.name.setText(group.getName());
holder.address.setText(model.getLabelUUID(address).toString().toUpperCase(Locale.US));
}
}*/
}
}
}

Expand Down Expand Up @@ -119,6 +115,9 @@ public final class ViewHolder extends RemovableViewHolder {
private ViewHolder(final View view) {
super(view);
ButterKnife.bind(this, view);
final ElevationOverlayProvider provider = new ElevationOverlayProvider(itemView.getContext());
final int color = provider.compositeOverlayIfNeeded(provider.getThemeSurfaceColor(), 3.5f);
getSwipeableView().setBackgroundColor(color);
}
}
}
Loading

0 comments on commit 8533400

Please sign in to comment.