1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-09 11:47:04 +01:00

Make R class fields non-final

This commit is contained in:
José Rebelo 2024-06-30 20:27:12 +01:00
parent 39708e5fb6
commit d7242c1f12
31 changed files with 433 additions and 459 deletions

View File

@ -217,11 +217,11 @@ public abstract class AbstractSettingsActivity extends AppCompatPreferenceActivi
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -72,12 +72,12 @@ public abstract class AbstractSettingsActivityV2 extends AbstractGBActivity impl
@Override @Override
public boolean onOptionsItemSelected(@NonNull final MenuItem item) { public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// Simulate a back press, so that we don't actually exit the activity when // Simulate a back press, so that we don't actually exit the activity when
// in a nested PreferenceScreen // in a nested PreferenceScreen
this.onBackPressed(); this.onBackPressed();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -125,22 +125,21 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
boolean processed = false; final int itemId = item.getItemId();
switch (item.getItemId()) { if (itemId == android.R.id.home) {
case android.R.id.home: // back button, close drawer if open, otherwise exit
// back button, close drawer if open, otherwise exit finish();
finish(); return true;
return true; } else if (itemId == R.id.activity_action_manage_timestamp) {
case R.id.activity_action_manage_timestamp: resetFetchTimestampToChosenDate();
resetFetchTimestampToChosenDate(); return true;
processed = true; } else if (itemId == R.id.activity_action_filter) {
break; runFilterActivity();
case R.id.activity_action_filter: return true;
runFilterActivity();
return true;
} }
return processed;
return false;
} }
@Override @Override
@ -229,77 +228,72 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
} }
@Override @Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) {
boolean processed = false; boolean processed = false;
SparseBooleanArray checked = getItemListView().getCheckedItemPositions(); final SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
switch (menuItem.getItemId()) { final int itemId = menuItem.getItemId();
case R.id.activity_action_delete: if (itemId == R.id.activity_action_delete) {
final List<BaseActivitySummary> toDelete = new ArrayList<>(); final List<BaseActivitySummary> toDelete = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) { for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) { if (checked.valueAt(i)) {
toDelete.add(getItemAdapter().getItem(checked.keyAt(i))); toDelete.add(getItemAdapter().getItem(checked.keyAt(i)));
}
} }
}
new MaterialAlertDialogBuilder(ActivitySummariesActivity.this) new MaterialAlertDialogBuilder(ActivitySummariesActivity.this)
.setTitle(ActivitySummariesActivity.this.getString(R.string.sports_activity_confirm_delete_title, toDelete.size())) .setTitle(ActivitySummariesActivity.this.getString(R.string.sports_activity_confirm_delete_title, toDelete.size()))
.setMessage(ActivitySummariesActivity.this.getString(R.string.sports_activity_confirm_delete_description, toDelete.size())) .setMessage(ActivitySummariesActivity.this.getString(R.string.sports_activity_confirm_delete_description, toDelete.size()))
.setIcon(R.drawable.ic_delete_forever) .setIcon(R.drawable.ic_delete_forever)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int whichButton) { public void onClick(final DialogInterface dialog, final int whichButton) {
deleteItems(toDelete); deleteItems(toDelete);
} }
}) })
.setNegativeButton(android.R.string.no, null) .setNegativeButton(android.R.string.no, null)
.show(); .show();
processed = true; processed = true;
break; } else if (itemId == R.id.activity_action_export) {
case R.id.activity_action_export: final List<String> paths = new ArrayList<>();
List<String> paths = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) { for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) { if (checked.valueAt(i)) {
BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i)); BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
if (item != null) { if (item != null) {
ActivitySummary summary = item; ActivitySummary summary = item;
String gpxTrack = summary.getGpxTrack(); String gpxTrack = summary.getGpxTrack();
if (gpxTrack != null) { if (gpxTrack != null) {
paths.add(gpxTrack); paths.add(gpxTrack);
}
} }
} }
} }
shareMultiple(paths); }
processed = true; shareMultiple(paths);
break; processed = true;
case R.id.activity_action_select_all: } else if (itemId == R.id.activity_action_select_all) {
for (int i = 0; i < getItemListView().getCount(); i++) { for (int i = 0; i < getItemListView().getCount(); i++) {
getItemListView().setItemChecked(i, true); getItemListView().setItemChecked(i, true);
} }
return true; //don't finish actionmode in this case! return true; //don't finish actionmode in this case!
case R.id.activity_action_addto_filter: } else if (itemId == R.id.activity_action_addto_filter) {
List<Long> toFilter = new ArrayList<>(); final List<Long> toFilter = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) { for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) { if (checked.valueAt(i)) {
BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i)); BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
if (item != null && item.getId() != null) { if (item != null && item.getId() != null) {
ActivitySummary summary = item; ActivitySummary summary = item;
Long id = summary.getId(); Long id = summary.getId();
toFilter.add(id); toFilter.add(id);
}
} }
} }
itemsFilter = toFilter; }
setItemsFilter(itemsFilter); itemsFilter = toFilter;
refresh(); setItemsFilter(itemsFilter);
refresh();
processed = true; processed = true;
break;
default:
break;
} }
actionMode.finish(); actionMode.finish();
return processed; return processed;

View File

@ -236,12 +236,12 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -563,27 +563,27 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
case R.id.activity_action_take_screenshot: } else if (itemId == R.id.activity_action_take_screenshot) {
take_share_screenshot(ActivitySummaryDetail.this); take_share_screenshot(ActivitySummaryDetail.this);
return true; return true;
case R.id.activity_action_show_gpx: } else if (itemId == R.id.activity_action_show_gpx) {
viewGpxTrack(ActivitySummaryDetail.this); viewGpxTrack(ActivitySummaryDetail.this);
return true; return true;
case R.id.activity_action_share_gpx: } else if (itemId == R.id.activity_action_share_gpx) {
shareGpxTrack(ActivitySummaryDetail.this, currentItem); shareGpxTrack(ActivitySummaryDetail.this, currentItem);
return true; return true;
case R.id.activity_action_dev_share_raw_summary: } else if (itemId == R.id.activity_action_dev_share_raw_summary) {
shareRawSummary(ActivitySummaryDetail.this, currentItem); shareRawSummary(ActivitySummaryDetail.this, currentItem);
return true; return true;
case R.id.activity_action_dev_share_raw_details: } else if (itemId == R.id.activity_action_dev_share_raw_details) {
shareRawDetails(ActivitySummaryDetail.this, currentItem); shareRawDetails(ActivitySummaryDetail.this, currentItem);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -260,12 +260,12 @@ public class AlarmDetails extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -22,9 +22,6 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.core.app.NavUtils; import androidx.core.app.NavUtils;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -34,32 +31,30 @@ import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
public class AppBlacklistActivity extends AbstractGBActivity { public class AppBlacklistActivity extends AbstractGBActivity {
private static final Logger LOG = LoggerFactory.getLogger(AppBlacklistActivity.class);
private AppBlacklistAdapter appBlacklistAdapter; private AppBlacklistAdapter appBlacklistAdapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appblacklist); setContentView(R.layout.activity_appblacklist);
RecyclerView appListView = (RecyclerView) findViewById(R.id.appListView); final RecyclerView appListView = (RecyclerView) findViewById(R.id.appListView);
appListView.setLayoutManager(new LinearLayoutManager(this)); appListView.setLayoutManager(new LinearLayoutManager(this));
appBlacklistAdapter = new AppBlacklistAdapter(R.layout.item_app_blacklist, this); appBlacklistAdapter = new AppBlacklistAdapter(R.layout.item_app_blacklist, this);
appListView.setAdapter(appBlacklistAdapter); appListView.setAdapter(appBlacklistAdapter);
SearchView searchView = (SearchView) findViewById(R.id.appListViewSearch); final SearchView searchView = findViewById(R.id.appListViewSearch);
searchView.setIconifiedByDefault(false); searchView.setIconifiedByDefault(false);
searchView.setIconified(false); searchView.setIconified(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(final String query) {
return false; return false;
} }
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(final String newText) {
appBlacklistAdapter.getFilter().filter(newText); appBlacklistAdapter.getFilter().filter(newText);
return true; return true;
} }
@ -67,24 +62,24 @@ public class AppBlacklistActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(final Menu menu) {
MenuInflater inflater = getMenuInflater(); final MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.app_blacklist_menu, menu); inflater.inflate(R.menu.app_blacklist_menu, menu);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
case R.id.check_all_applications: } else if (itemId == R.id.check_all_applications) {
appBlacklistAdapter.checkAllApplications(); appBlacklistAdapter.checkAllApplications();
return true; return true;
case R.id.uncheck_all_applications: } else if (itemId == R.id.uncheck_all_applications) {
appBlacklistAdapter.uncheckAllApplications(); appBlacklistAdapter.uncheckAllApplications();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -103,11 +103,11 @@ public class CalBlacklistActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -151,12 +151,12 @@ public class ConfigureAlarms extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -142,12 +142,12 @@ public class ConfigureContacts extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -174,12 +174,12 @@ public class ConfigureReminders extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -189,12 +189,12 @@ public class ConfigureWorldClocks extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -120,12 +120,12 @@ public class ContactDetails extends AbstractGBActivity {
@Override @Override
public boolean onOptionsItemSelected(final MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
// TODO confirm when exiting without saving // TODO confirm when exiting without saving
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -200,13 +200,11 @@ public class ControlCenterv2 extends AppCompatActivity
navigationView.setVisibility(View.GONE); navigationView.setVisibility(View.GONE);
} }
navigationView.setOnItemSelectedListener(menuItem -> { navigationView.setOnItemSelectedListener(menuItem -> {
switch (menuItem.getItemId()) { final int itemId = menuItem.getItemId();
case R.id.bottom_nav_dashboard: if (itemId == R.id.bottom_nav_dashboard) {
viewPager.setCurrentItem(0, true); viewPager.setCurrentItem(0, true);
break; } else if (itemId == R.id.bottom_nav_devices) {
case R.id.bottom_nav_devices: viewPager.setCurrentItem(1, true);
viewPager.setCurrentItem(1, true);
break;
} }
return true; return true;
}); });
@ -386,58 +384,57 @@ public class ControlCenterv2 extends AppCompatActivity
} }
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
switch (item.getItemId()) { final int itemId = item.getItemId();
case R.id.action_settings: if (itemId == R.id.action_settings) {
Intent settingsIntent = new Intent(this, SettingsActivity.class); final Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, MENU_REFRESH_CODE); startActivityForResult(settingsIntent, MENU_REFRESH_CODE);
return false; //we do not want the drawer menu item to get selected return false;
case R.id.action_debug: } else if (itemId == R.id.action_debug) {
Intent debugIntent = new Intent(this, DebugActivity.class); final Intent debugIntent = new Intent(this, DebugActivity.class);
startActivity(debugIntent); startActivity(debugIntent);
return false; return false;
case R.id.action_data_management: } else if (itemId == R.id.action_data_management) {
Intent dbIntent = new Intent(this, DataManagementActivity.class); final Intent dbIntent = new Intent(this, DataManagementActivity.class);
startActivity(dbIntent); startActivity(dbIntent);
return false; return false;
case R.id.action_notification_management: } else if (itemId == R.id.action_notification_management) {
Intent blIntent = new Intent(this, NotificationManagementActivity.class); final Intent blIntent = new Intent(this, NotificationManagementActivity.class);
startActivity(blIntent); startActivity(blIntent);
return false; return false;
case R.id.device_action_discover: } else if (itemId == R.id.device_action_discover) {
launchDiscoveryActivity(); launchDiscoveryActivity();
return false; return false;
case R.id.action_quit: } else if (itemId == R.id.action_quit) {
GBApplication.quit(); GBApplication.quit();
return false; return false;
case R.id.donation_link: } else if (itemId == R.id.donation_link) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://liberapay.com/Gadgetbridge")); //TODO: centralize if ever used somewhere else final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://liberapay.com/Gadgetbridge")); //TODO: centralize if ever used somewhere else
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
return false; return false;
case R.id.external_changelog: } else if (itemId == R.id.external_changelog) {
GBChangeLog cl = createChangeLog(); final GBChangeLog cl = createChangeLog();
try { try {
if (cl.hasChanges(false)) { if (cl.hasChanges(false)) {
cl.getMaterialLogDialog().show(); cl.getMaterialLogDialog().show();
} else { } else {
cl.getMaterialFullLogDialog().show(); cl.getMaterialFullLogDialog().show();
}
} catch (Exception ignored) {
GB.toast(getBaseContext(), getString(R.string.error_showing_changelog), Toast.LENGTH_LONG, GB.ERROR);
} }
return false; } catch (Exception ignored) {
case R.id.about: GB.toast(getBaseContext(), getString(R.string.error_showing_changelog), Toast.LENGTH_LONG, GB.ERROR);
Intent aboutIntent = new Intent(this, AboutActivity.class); }
startActivity(aboutIntent); return false;
return false; } else if (itemId == R.id.about) {
final Intent aboutIntent = new Intent(this, AboutActivity.class);
startActivity(aboutIntent);
return false;
} }
return false; return false; // we do not want the drawer menu item to get selected
} }
private GBChangeLog createChangeLog() { private GBChangeLog createChangeLog() {

View File

@ -175,13 +175,13 @@ public class DashboardFragment extends Fragment {
} }
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) { public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case R.id.dashboard_show_calendar: if (itemId == R.id.dashboard_show_calendar) {
Intent intent = new Intent(requireActivity(), DashboardCalendarActivity.class); final Intent intent = new Intent(requireActivity(), DashboardCalendarActivity.class);
intent.putExtra(DashboardCalendarActivity.EXTRA_TIMESTAMP, day.getTimeInMillis()); intent.putExtra(DashboardCalendarActivity.EXTRA_TIMESTAMP, day.getTimeInMillis());
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
return false; return false;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -1014,11 +1014,11 @@ public class DebugActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -227,11 +227,11 @@ public class ExternalPebbleJSActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -289,11 +289,11 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -33,12 +33,11 @@ import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -51,12 +50,9 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.entities.Reminder; import nodomain.freeyourgadget.gadgetbridge.entities.Reminder;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class ReminderDetails extends AbstractGBActivity implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener { public class ReminderDetails extends AbstractGBActivity implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
private static final Logger LOG = LoggerFactory.getLogger(ReminderDetails.class);
private Reminder reminder; private Reminder reminder;
private GBDevice device; private GBDevice device;
@ -168,13 +164,13 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
// TODO confirm when exiting without saving // TODO confirm when exiting without saving
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -184,13 +180,13 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
} }
@Override @Override
protected void onSaveInstanceState(Bundle state) { protected void onSaveInstanceState(@NonNull final Bundle state) {
super.onSaveInstanceState(state); super.onSaveInstanceState(state);
state.putSerializable("reminder", reminder); state.putSerializable("reminder", reminder);
} }
@Override @Override
protected void onRestoreInstanceState(Bundle savedInstanceState) { protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);
reminder = (Reminder) savedInstanceState.getSerializable("reminder"); reminder = (Reminder) savedInstanceState.getSerializable("reminder");
updateUiFromReminder(); updateUiFromReminder();

View File

@ -81,27 +81,20 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
} }
@Override @Override
public void onClick(View v) { public void onClick(final View v) {
final int viewId = v.getId();
switch (v.getId()) { if (viewId == R.id.alarm1) {
case R.id.alarm1: setAlarm(5);
setAlarm(5); } else if (viewId == R.id.alarm2) {
break; setAlarm(10);
case R.id.alarm2: } else if (viewId == R.id.alarm3) {
setAlarm(10); setAlarm(20);
break; } else if (viewId == R.id.alarm4) {
case R.id.alarm3: setAlarm(60);
setAlarm(20); } else if (viewId == R.id.alarm5) {
break; setAlarm(0);
case R.id.alarm4:
setAlarm(60);
break;
case R.id.alarm5:
setAlarm(0);
break;
default:
break;
} }
//this is to prevent screen flashing during closing //this is to prevent screen flashing during closing
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override

View File

@ -29,12 +29,11 @@ import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.TimeZone; import java.util.TimeZone;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
@ -42,13 +41,10 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.entities.WorldClock; import nodomain.freeyourgadget.gadgetbridge.entities.WorldClock;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class WorldClockDetails extends AbstractGBActivity { public class WorldClockDetails extends AbstractGBActivity {
private static final Logger LOG = LoggerFactory.getLogger(WorldClockDetails.class);
private WorldClock worldClock; private WorldClock worldClock;
private GBDevice device; private GBDevice device;
@ -80,6 +76,12 @@ public class WorldClockDetails extends AbstractGBActivity {
worldClockCode = findViewById(R.id.world_clock_code); worldClockCode = findViewById(R.id.world_clock_code);
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE); device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
if (device == null) {
GB.toast("No device provided to WorldClockDetails Activity", Toast.LENGTH_LONG, GB.ERROR);
finish();
return;
}
final DeviceCoordinator coordinator = device.getDeviceCoordinator(); final DeviceCoordinator coordinator = device.getDeviceCoordinator();
final String[] timezoneIDs = TimeZone.getAvailableIDs(); final String[] timezoneIDs = TimeZone.getAvailableIDs();
@ -153,13 +155,13 @@ public class WorldClockDetails extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
// TODO confirm when exiting without saving // TODO confirm when exiting without saving
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -169,13 +171,13 @@ public class WorldClockDetails extends AbstractGBActivity {
} }
@Override @Override
protected void onSaveInstanceState(Bundle state) { protected void onSaveInstanceState(@NonNull final Bundle state) {
super.onSaveInstanceState(state); super.onSaveInstanceState(state);
state.putSerializable("worldClock", worldClock); state.putSerializable("worldClock", worldClock);
} }
@Override @Override
protected void onRestoreInstanceState(Bundle savedInstanceState) { protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);
worldClock = (WorldClock) savedInstanceState.getSerializable("worldClock"); worldClock = (WorldClock) savedInstanceState.getSerializable("worldClock");
updateUiFromWorldClock(); updateUiFromWorldClock();

View File

@ -577,94 +577,91 @@ public abstract class AbstractAppManagerFragment extends Fragment {
return true; return true;
} }
private boolean onContextItemSelected(MenuItem item, GBDeviceApp selectedApp) { private boolean onContextItemSelected(final MenuItem item, final GBDeviceApp selectedApp) {
File appCacheDir; final File appCacheDir;
try { try {
appCacheDir = mCoordinator.getAppCacheDir(); appCacheDir = mCoordinator.getAppCacheDir();
} catch (IOException e) { } catch (final IOException e) {
LOG.warn("could not get external dir while trying to access app cache."); LOG.warn("could not get external dir while trying to access app cache.");
return true; return true;
} }
switch (item.getItemId()) { final int itemId = item.getItemId();
case R.id.appmanager_app_delete_cache: if (itemId == R.id.appmanager_app_delete_cache) {
deleteAppConfirm(selectedApp, true); deleteAppConfirm(selectedApp, true);
return true;
} else if (itemId == R.id.appmanager_app_delete) {
deleteAppConfirm(selectedApp, false);
return true;
} else if (itemId == R.id.appmanager_app_start || itemId == R.id.appmanager_watchface_activate) {
GBApplication.deviceService(mGBDevice).onAppStart(selectedApp.getUUID(), true);
return true;
} else if (itemId == R.id.appmanager_app_download) {
GBApplication.deviceService(mGBDevice).onAppDownload(selectedApp.getUUID());
GB.toast(requireContext().getString(R.string.appmanager_download_started), Toast.LENGTH_LONG, GB.INFO);
return true;
} else if (itemId == R.id.appmanager_app_reinstall) {
final File cachePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension());
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.fromFile(cachePath));
return true;
} else if (itemId == R.id.appmanager_app_share) {
final File origFilePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension());
final File appTempDir = new File(appCacheDir, "temp_sharing");
final File sharedAppFile = new File(appTempDir, selectedApp.getName() + mCoordinator.getAppFileExtension());
try {
appTempDir.mkdirs();
FileUtils.copyFile(origFilePath, sharedAppFile);
} catch (final IOException e) {
return true; return true;
case R.id.appmanager_app_delete: }
deleteAppConfirm(selectedApp, false); final Uri contentUri = FileProvider.getUriForFile(requireContext(), requireContext().getApplicationContext().getPackageName() + ".screenshot_provider", sharedAppFile);
return true; final Intent shareIntent = new Intent(Intent.ACTION_SEND);
case R.id.appmanager_app_start: shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
case R.id.appmanager_watchface_activate: shareIntent.setType("*/*");
GBApplication.deviceService(mGBDevice).onAppStart(selectedApp.getUUID(), true); try {
return true; startActivity(Intent.createChooser(shareIntent, null));
case R.id.appmanager_app_download: } catch (ActivityNotFoundException e) {
GBApplication.deviceService(mGBDevice).onAppDownload(selectedApp.getUUID()); LOG.warn("Sharing watchface failed", e);
GB.toast(getContext().getString(R.string.appmanager_download_started), Toast.LENGTH_LONG, GB.INFO); }
return true; return true;
case R.id.appmanager_app_reinstall: } else if (itemId == R.id.appmanager_health_activate) {
File cachePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension()); GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://health"));
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.fromFile(cachePath)); return true;
return true; } else if (itemId == R.id.appmanager_hrm_activate) {
case R.id.appmanager_app_share: GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://hrm"));
File origFilePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension()); return true;
File appTempDir = new File(appCacheDir, "temp_sharing"); } else if (itemId == R.id.appmanager_weather_activate) {
File sharedAppFile = new File(appTempDir, selectedApp.getName() + mCoordinator.getAppFileExtension()); GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://weather"));
try { return true;
appTempDir.mkdirs(); } else if (itemId == R.id.appmanager_health_deactivate || itemId == R.id.appmanager_hrm_deactivate || itemId == R.id.appmanager_weather_deactivate) {
FileUtils.copyFile(origFilePath, sharedAppFile); GBApplication.deviceService(mGBDevice).onAppDelete(selectedApp.getUUID());
} catch (IOException e) { return true;
return true; } else if (itemId == R.id.appmanager_weather_install_provider) {
} startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://f-droid.org/app/ru.gelin.android.weather.notification")));
Uri contentUri = FileProvider.getUriForFile(getContext(),getContext().getApplicationContext().getPackageName() + ".screenshot_provider", sharedAppFile); return true;
Intent shareIntent = new Intent(Intent.ACTION_SEND); } else if (itemId == R.id.appmanager_app_configure) {
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); GBApplication.deviceService(mGBDevice).onAppStart(selectedApp.getUUID(), true);
shareIntent.setType("*/*");
try {
startActivity(Intent.createChooser(shareIntent, null));
} catch (ActivityNotFoundException e) {
LOG.warn("Sharing watchface failed", e);
}
return true;
case R.id.appmanager_health_activate:
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://health"));
return true;
case R.id.appmanager_hrm_activate:
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://hrm"));
return true;
case R.id.appmanager_weather_activate:
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://weather"));
return true;
case R.id.appmanager_health_deactivate:
case R.id.appmanager_hrm_deactivate:
case R.id.appmanager_weather_deactivate:
GBApplication.deviceService(mGBDevice).onAppDelete(selectedApp.getUUID());
return true;
case R.id.appmanager_weather_install_provider:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://f-droid.org/app/ru.gelin.android.weather.notification")));
return true;
case R.id.appmanager_app_configure:
GBApplication.deviceService(mGBDevice).onAppStart(selectedApp.getUUID(), true);
Intent startIntent = new Intent(getContext().getApplicationContext(), ExternalPebbleJSActivity.class); final Intent startIntent = new Intent(getContext().getApplicationContext(), ExternalPebbleJSActivity.class);
startIntent.putExtra(DeviceService.EXTRA_APP_UUID, selectedApp.getUUID()); startIntent.putExtra(DeviceService.EXTRA_APP_UUID, selectedApp.getUUID());
startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice); startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
startIntent.putExtra(ExternalPebbleJSActivity.SHOW_CONFIG, true); startIntent.putExtra(ExternalPebbleJSActivity.SHOW_CONFIG, true);
startActivity(startIntent); startActivity(startIntent);
return true; return true;
case R.id.appmanager_app_openinstore: } else if (itemId == R.id.appmanager_app_openinstore) {
String url = "https://apps.rebble.io/en_US/search/" + ((selectedApp.getType() == GBDeviceApp.Type.WATCHFACE) ? "watchfaces" : "watchapps") + "/1/?native=true&?query=" + Uri.encode(selectedApp.getName()); final String url = "https://apps.rebble.io/en_US/search/" + ((selectedApp.getType() == GBDeviceApp.Type.WATCHFACE) ? "watchfaces" : "watchapps") + "/1/?native=true&?query=" + Uri.encode(selectedApp.getName());
Intent intent = new Intent(Intent.ACTION_VIEW); final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url)); intent.setData(Uri.parse(url));
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.appmanager_app_edit: } else if (itemId == R.id.appmanager_app_edit) {
Intent editWatchfaceIntent = new Intent(getContext(), watchfaceDesignerActivity); final Intent editWatchfaceIntent = new Intent(getContext(), watchfaceDesignerActivity);
editWatchfaceIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice); editWatchfaceIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
editWatchfaceIntent.putExtra(GBDevice.EXTRA_UUID, selectedApp.getUUID().toString()); editWatchfaceIntent.putExtra(GBDevice.EXTRA_UUID, selectedApp.getUUID().toString());
startActivityForResult(editWatchfaceIntent, CHILD_ACTIVITY_WATCHFACE_EDITOR); startActivityForResult(editWatchfaceIntent, CHILD_ACTIVITY_WATCHFACE_EDITOR);
return true; return true;
default:
return super.onContextItemSelected(item);
} }
return super.onContextItemSelected(item);
} }
private void deleteAppConfirm(final GBDeviceApp selectedApp, final boolean deleteFromCache) { private void deleteAppConfirm(final GBDeviceApp selectedApp, final boolean deleteFromCache) {

View File

@ -162,11 +162,11 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this); NavUtils.navigateUpFromSameTask(this);
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -142,12 +142,12 @@ public class WidgetScreenDetailsActivity extends AbstractGBActivity {
@Override @Override
public boolean onOptionsItemSelected(final MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
// TODO confirm when exiting without saving // TODO confirm when exiting without saving
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -139,12 +139,12 @@ public class WidgetScreensListActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
// back button // back button
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View File

@ -857,54 +857,55 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(final MenuItem item) {
switch (item.getItemId()){ final int itemId = item.getItemId();
case R.id.controlcenter_device_submenu_connect: if (itemId == R.id.controlcenter_device_submenu_connect) {
if (device.getState() != GBDevice.State.CONNECTED) { if (device.getState() != GBDevice.State.CONNECTED) {
showTransientSnackbar(R.string.controlcenter_snackbar_connecting); showTransientSnackbar(R.string.controlcenter_snackbar_connecting);
handleDeviceConnect(device); handleDeviceConnect(device);
} }
return true; return true;
case R.id.controlcenter_device_submenu_disconnect: } else if (itemId == R.id.controlcenter_device_submenu_disconnect) {
if (device.getState() != GBDevice.State.NOT_CONNECTED) { if (device.getState() != GBDevice.State.NOT_CONNECTED) {
showTransientSnackbar(R.string.controlcenter_snackbar_disconnecting); showTransientSnackbar(R.string.controlcenter_snackbar_disconnecting);
GBApplication.deviceService(device).disconnect(); GBApplication.deviceService(device).disconnect();
} }
removeFromLastDeviceAddressesPref(device); removeFromLastDeviceAddressesPref(device);
return true; return true;
case R.id.controlcenter_device_submenu_set_alias: } else if (itemId == R.id.controlcenter_device_submenu_set_alias) {
showSetAliasDialog(device); showSetAliasDialog(device);
return true; return true;
case R.id.controlcenter_device_submenu_remove: } else if (itemId == R.id.controlcenter_device_submenu_remove) {
showRemoveDeviceDialog(device); showRemoveDeviceDialog(device);
return true; return true;
case R.id.controlcenter_device_submenu_show_details: } else if (itemId == R.id.controlcenter_device_submenu_show_details) {
final String previouslyExpandedDeviceAddress = expandedDeviceAddress; final String previouslyExpandedDeviceAddress = expandedDeviceAddress;
expandedDeviceAddress = detailsShown ? "" : device.getAddress(); expandedDeviceAddress = detailsShown ? "" : device.getAddress();
if (!previouslyExpandedDeviceAddress.isEmpty()) { if (!previouslyExpandedDeviceAddress.isEmpty()) {
// Notify the previously expanded device for a change (collapsing it) // Notify the previously expanded device for a change (collapsing it)
for (int i = 0; i < devicesListWithFolders.size(); i++) { for (int i = 0; i < devicesListWithFolders.size(); i++) {
final GBDevice gbDevice = devicesListWithFolders.get(i); final GBDevice gbDevice = devicesListWithFolders.get(i);
if (gbDevice.getAddress().equals(previouslyExpandedDeviceAddress)) { if (gbDevice.getAddress().equals(previouslyExpandedDeviceAddress)) {
notifyItemChanged(devicesListWithFolders.indexOf(gbDevice)); notifyItemChanged(devicesListWithFolders.indexOf(gbDevice));
break; break;
}
} }
} }
}
// Update the current one // Update the current one
notifyItemChanged(devicesListWithFolders.indexOf(device)); notifyItemChanged(devicesListWithFolders.indexOf(device));
return true; return true;
case R.id.controlcenter_device_submenu_set_parent_folder: } else if (itemId == R.id.controlcenter_device_submenu_set_parent_folder) {
showSetParentFolderDialog(device); showSetParentFolderDialog(device);
return true; return true;
case R.id.controlcenter_device_submenu_installer: } else if (itemId == R.id.controlcenter_device_submenu_installer) {
Intent openFwIntent = new Intent(context, OpenFwAppInstallerActivity.class); Intent openFwIntent = new Intent(context, OpenFwAppInstallerActivity.class);
openFwIntent.putExtra(GBDevice.EXTRA_DEVICE, device); openFwIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
context.startActivity(openFwIntent); context.startActivity(openFwIntent);
return false; return false;
} }
return false; return false;
} }
}); });

View File

@ -21,6 +21,7 @@ import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.Preference; import androidx.preference.Preference;
@ -68,7 +69,7 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivityV
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {
// Action bar back button // Action bar back button
Intent output = new Intent(); Intent output = new Intent();

View File

@ -21,6 +21,7 @@ import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.Preference; import androidx.preference.Preference;
@ -84,7 +85,7 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {
// Action bar back button // Action bar back button
Intent output = new Intent(); Intent output = new Intent();

View File

@ -550,10 +550,10 @@ public class QHybridConfigActivity extends AbstractGBActivity {
@Override @Override
public boolean onOptionsItemSelected(@NonNull final MenuItem item) { public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
this.onBackPressed(); this.onBackPressed();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -42,8 +42,8 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
MINUTES((short)0), MINUTES((short)0),
ACTIVITY_TARGET((short)2); ACTIVITY_TARGET((short)2);
private short code; private final short code;
private Hands(short code) { Hands(short code) {
this.code = code; this.code = code;
} }
@ -51,8 +51,8 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
private GBDevice device; private GBDevice device;
private LocalBroadcastManager localBroadcastManager; private LocalBroadcastManager localBroadcastManager;
private String[] calibrationAdvices = new String[3]; private final String[] calibrationAdvices = new String[3];
private Hands[] hands = new Hands[]{Hands.HOURS, Hands.MINUTES, Hands.ACTIVITY_TARGET}; private final Hands[] hands = new Hands[]{Hands.HOURS, Hands.MINUTES, Hands.ACTIVITY_TARGET};
private short handIndex = 0; private short handIndex = 0;
private Button previousButton; private Button previousButton;
private Button nextButton; private Button nextButton;
@ -141,11 +141,11 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -20,8 +20,5 @@ org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
# FIXME: Migrate all switches to if statements
android.nonFinalResIds=false
# FIXME: This optimizes away some classes it should not - see #3853 # FIXME: This optimizes away some classes it should not - see #3853
android.enableR8.fullMode=false android.enableR8.fullMode=false