mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-23 08:34:20 +01:00
MaterialComponents theme
This commit is contained in:
@@ -32,6 +32,8 @@ import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
@@ -92,7 +94,7 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
drawer.addDrawerListener(mDrawerToggle);
|
||||
|
||||
// setup plug-ins in the drawer
|
||||
setupPluginsInDrawer((ViewGroup) drawer.findViewById(R.id.plugin_container));
|
||||
setupPluginsInDrawer(drawer.findViewById(R.id.plugin_container));
|
||||
|
||||
// configure the app grid
|
||||
final GridView grid = findViewById(R.id.grid);
|
||||
@@ -132,7 +134,7 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(final Configuration newConfig) {
|
||||
public void onConfigurationChanged(@NonNull final Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
@@ -168,7 +170,7 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
final TextView nrfConnectItem = container.findViewById(R.id.link_mcp);
|
||||
if (nrfConnectInfo == null) {
|
||||
nrfConnectItem.setTextColor(Color.GRAY);
|
||||
ColorMatrix grayscale = new ColorMatrix();
|
||||
final ColorMatrix grayscale = new ColorMatrix();
|
||||
grayscale.setSaturation(0.0f);
|
||||
nrfConnectItem.getCompoundDrawables()[0].mutate().setColorFilter(new ColorMatrixColorFilter(grayscale));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,12 +24,12 @@ package no.nordicsemi.android.nrftoolbox.csc.settings;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public static final String SETTINGS_WHEEL_SIZE = "settings_wheel_size";
|
||||
public static final int SETTINGS_WHEEL_SIZE_DEFAULT = 2340;
|
||||
public static final String SETTINGS_UNIT = "settings_csc_unit";
|
||||
@@ -38,11 +38,8 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
|
||||
public static final int SETTINGS_UNIT_MPH = 2; // [m/s]
|
||||
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_KM_H;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.settings_csc);
|
||||
|
||||
// set initial values
|
||||
|
||||
@@ -25,10 +25,10 @@ package no.nordicsemi.android.nrftoolbox.dfu.settings;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class AboutDfuPreference extends Preference {
|
||||
@@ -44,7 +44,8 @@ public class AboutDfuPreference extends Preference {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
final Context context = getContext();
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk52.v0.9.1%2Fexamples_ble_dfu.html&cp=4_0_0_4_2"));
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-3-0/ble_sdk_app_dfu_bootloader"));
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,22 +24,20 @@ package no.nordicsemi.android.nrftoolbox.dfu.settings;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import no.nordicsemi.android.dfu.DfuServiceInitiator;
|
||||
import no.nordicsemi.android.dfu.DfuSettingsConstants;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment implements DfuSettingsConstants, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class SettingsFragment extends PreferenceFragmentCompat implements DfuSettingsConstants, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public static final String SETTINGS_KEEP_BOND = "settings_keep_bond";
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.settings_dfu);
|
||||
|
||||
// set initial values
|
||||
@@ -70,7 +68,7 @@ public class SettingsFragment extends PreferenceFragment implements DfuSettingsC
|
||||
if (SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED.equals(key)) {
|
||||
final boolean disabled = !preferences.getBoolean(SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED, true);
|
||||
if (disabled && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.dfu_settings_dfu_number_of_packets_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
new AlertDialog.Builder(requireContext()).setMessage(R.string.dfu_settings_dfu_number_of_packets_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
.setPositiveButton(R.string.ok, null).show();
|
||||
}
|
||||
} else if (SETTINGS_NUMBER_OF_PACKETS.equals(key)) {
|
||||
@@ -78,7 +76,7 @@ public class SettingsFragment extends PreferenceFragment implements DfuSettingsC
|
||||
} else if (SETTINGS_MBR_SIZE.equals(key)) {
|
||||
updateMBRSize();
|
||||
} else if (SETTINGS_ASSUME_DFU_NODE.equals(key) && sharedPreferences.getBoolean(key, false)) {
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.dfu_settings_dfu_assume_dfu_mode_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
new AlertDialog.Builder(requireContext()).setMessage(R.string.dfu_settings_dfu_assume_dfu_mode_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
@@ -98,7 +96,7 @@ public class SettingsFragment extends PreferenceFragment implements DfuSettingsC
|
||||
|
||||
final int valueInt = Integer.parseInt(value);
|
||||
if (valueInt > 200 && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.dfu_settings_dfu_number_of_packets_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
new AlertDialog.Builder(requireContext()).setMessage(R.string.dfu_settings_dfu_number_of_packets_info).setTitle(R.string.dfu_settings_dfu_information)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,9 +25,10 @@ package no.nordicsemi.android.nrftoolbox.hts.settings;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
public static final String SETTINGS_UNIT = "settings_hts_unit";
|
||||
public static final int SETTINGS_UNIT_C = 0; // [C]
|
||||
public static final int SETTINGS_UNIT_F = 1; // [F]
|
||||
@@ -35,9 +36,7 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_C;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.settings_hts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,9 +25,10 @@ package no.nordicsemi.android.nrftoolbox.rsc.settings;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
public static final String SETTINGS_UNIT = "settings_rsc_unit";
|
||||
public static final int SETTINGS_UNIT_M_S = 0; // [m/s]
|
||||
public static final int SETTINGS_UNIT_KM_H = 1; // [m/s]
|
||||
@@ -35,9 +36,7 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_KM_H;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.settings_rsc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,11 @@ public class TemplateActivity extends BleProfileServiceReadyActivity<TemplateSer
|
||||
mValueView = findViewById(R.id.value);
|
||||
mBatteryLevelView = findViewById(R.id.battery);
|
||||
|
||||
findViewById(R.id.action_set_name).setOnClickListener(v -> getService().performAction("Template"));
|
||||
findViewById(R.id.action_set_name).setOnClickListener(v -> {
|
||||
if (isDeviceConnected()) {
|
||||
getService().performAction("Template");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,18 +25,17 @@ package no.nordicsemi.android.nrftoolbox.template.settings;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
public static final String SETTINGS_DATA = "settings_template_data"; // TODO values matching those in settings_template.xml file in /res/xml
|
||||
public static final int SETTINGS_VARIANT_A = 0;
|
||||
public static final int SETTINGS_VARIANT_B = 1;
|
||||
public static final int SETTINGS_VARIANT_DEFAULT = SETTINGS_VARIANT_A;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
addPreferencesFromResource(R.xml.settings_template);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package no.nordicsemi.android.nrftoolbox.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class TrebuchetBoldTextView extends androidx.appcompat.widget.AppCompatTextView {
|
||||
|
||||
public TrebuchetBoldTextView(Context context) {
|
||||
super(context);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public TrebuchetBoldTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public TrebuchetBoldTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!isInEditMode()) {
|
||||
final Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), getContext().getString(R.string.font_path));
|
||||
setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Nordic Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package no.nordicsemi.android.nrftoolbox.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class TrebuchetTextView extends androidx.appcompat.widget.AppCompatTextView {
|
||||
|
||||
public TrebuchetTextView(Context context) {
|
||||
super(context);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public TrebuchetTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public TrebuchetTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!isInEditMode()) {
|
||||
final Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), getContext().getString(R.string.normal_font_path));
|
||||
setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user