mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-30 14:02:56 +01:00
Make R class fields non-final
This commit is contained in:
parent
39708e5fb6
commit
d7242c1f12
@ -217,9 +217,9 @@ public abstract class AbstractSettingsActivity extends AppCompatPreferenceActivi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ public abstract class AbstractSettingsActivityV2 extends AbstractGBActivity impl
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// Simulate a back press, so that we don't actually exit the activity when
|
||||
// in a nested PreferenceScreen
|
||||
this.onBackPressed();
|
||||
|
@ -125,22 +125,21 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean processed = false;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button, close drawer if open, otherwise exit
|
||||
finish();
|
||||
return true;
|
||||
case R.id.activity_action_manage_timestamp:
|
||||
} else if (itemId == R.id.activity_action_manage_timestamp) {
|
||||
resetFetchTimestampToChosenDate();
|
||||
processed = true;
|
||||
break;
|
||||
case R.id.activity_action_filter:
|
||||
return true;
|
||||
} else if (itemId == R.id.activity_action_filter) {
|
||||
runFilterActivity();
|
||||
return true;
|
||||
}
|
||||
return processed;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -229,11 +228,11 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
||||
public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) {
|
||||
boolean processed = false;
|
||||
SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.activity_action_delete:
|
||||
final SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
|
||||
final int itemId = menuItem.getItemId();
|
||||
if (itemId == R.id.activity_action_delete) {
|
||||
final List<BaseActivitySummary> toDelete = new ArrayList<>();
|
||||
for (int i = 0; i < checked.size(); i++) {
|
||||
if (checked.valueAt(i)) {
|
||||
@ -254,9 +253,8 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
.show();
|
||||
|
||||
processed = true;
|
||||
break;
|
||||
case R.id.activity_action_export:
|
||||
List<String> paths = new ArrayList<>();
|
||||
} else if (itemId == R.id.activity_action_export) {
|
||||
final List<String> paths = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < checked.size(); i++) {
|
||||
if (checked.valueAt(i)) {
|
||||
@ -274,14 +272,13 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
}
|
||||
shareMultiple(paths);
|
||||
processed = true;
|
||||
break;
|
||||
case R.id.activity_action_select_all:
|
||||
} else if (itemId == R.id.activity_action_select_all) {
|
||||
for (int i = 0; i < getItemListView().getCount(); i++) {
|
||||
getItemListView().setItemChecked(i, true);
|
||||
}
|
||||
return true; //don't finish actionmode in this case!
|
||||
case R.id.activity_action_addto_filter:
|
||||
List<Long> toFilter = new ArrayList<>();
|
||||
} else if (itemId == R.id.activity_action_addto_filter) {
|
||||
final List<Long> toFilter = new ArrayList<>();
|
||||
for (int i = 0; i < checked.size(); i++) {
|
||||
if (checked.valueAt(i)) {
|
||||
BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
|
||||
@ -297,9 +294,6 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
refresh();
|
||||
|
||||
processed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
actionMode.finish();
|
||||
return processed;
|
||||
|
@ -236,9 +236,9 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -563,25 +563,25 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
case R.id.activity_action_take_screenshot:
|
||||
} else if (itemId == R.id.activity_action_take_screenshot) {
|
||||
take_share_screenshot(ActivitySummaryDetail.this);
|
||||
return true;
|
||||
case R.id.activity_action_show_gpx:
|
||||
} else if (itemId == R.id.activity_action_show_gpx) {
|
||||
viewGpxTrack(ActivitySummaryDetail.this);
|
||||
return true;
|
||||
case R.id.activity_action_share_gpx:
|
||||
} else if (itemId == R.id.activity_action_share_gpx) {
|
||||
shareGpxTrack(ActivitySummaryDetail.this, currentItem);
|
||||
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);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -260,9 +260,9 @@ public class AlarmDetails extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -22,9 +22,6 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -34,32 +31,30 @@ import nodomain.freeyourgadget.gadgetbridge.adapter.AppBlacklistAdapter;
|
||||
|
||||
|
||||
public class AppBlacklistActivity extends AbstractGBActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppBlacklistActivity.class);
|
||||
|
||||
private AppBlacklistAdapter appBlacklistAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
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));
|
||||
|
||||
appBlacklistAdapter = new AppBlacklistAdapter(R.layout.item_app_blacklist, this);
|
||||
|
||||
appListView.setAdapter(appBlacklistAdapter);
|
||||
|
||||
SearchView searchView = (SearchView) findViewById(R.id.appListViewSearch);
|
||||
final SearchView searchView = findViewById(R.id.appListViewSearch);
|
||||
searchView.setIconifiedByDefault(false);
|
||||
searchView.setIconified(false);
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
public boolean onQueryTextSubmit(final String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
public boolean onQueryTextChange(final String newText) {
|
||||
appBlacklistAdapter.getFilter().filter(newText);
|
||||
return true;
|
||||
}
|
||||
@ -67,22 +62,22 @@ public class AppBlacklistActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.app_blacklist_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
case R.id.check_all_applications:
|
||||
} else if (itemId == R.id.check_all_applications) {
|
||||
appBlacklistAdapter.checkAllApplications();
|
||||
return true;
|
||||
case R.id.uncheck_all_applications:
|
||||
} else if (itemId == R.id.uncheck_all_applications) {
|
||||
appBlacklistAdapter.uncheckAllApplications();
|
||||
return true;
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ public class CalBlacklistActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -151,9 +151,9 @@ public class ConfigureAlarms extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -142,9 +142,9 @@ public class ConfigureContacts extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -174,9 +174,9 @@ public class ConfigureReminders extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -189,9 +189,9 @@ public class ConfigureWorldClocks extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -120,8 +120,8 @@ public class ContactDetails extends AbstractGBActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
// TODO confirm when exiting without saving
|
||||
finish();
|
||||
|
@ -200,13 +200,11 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
navigationView.setVisibility(View.GONE);
|
||||
}
|
||||
navigationView.setOnItemSelectedListener(menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.bottom_nav_dashboard:
|
||||
final int itemId = menuItem.getItemId();
|
||||
if (itemId == R.id.bottom_nav_dashboard) {
|
||||
viewPager.setCurrentItem(0, true);
|
||||
break;
|
||||
case R.id.bottom_nav_devices:
|
||||
} else if (itemId == R.id.bottom_nav_devices) {
|
||||
viewPager.setCurrentItem(1, true);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -386,41 +384,40 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
|
||||
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_settings:
|
||||
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_settings) {
|
||||
final Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
||||
startActivityForResult(settingsIntent, MENU_REFRESH_CODE);
|
||||
return false; //we do not want the drawer menu item to get selected
|
||||
case R.id.action_debug:
|
||||
Intent debugIntent = new Intent(this, DebugActivity.class);
|
||||
return false;
|
||||
} else if (itemId == R.id.action_debug) {
|
||||
final Intent debugIntent = new Intent(this, DebugActivity.class);
|
||||
startActivity(debugIntent);
|
||||
return false;
|
||||
case R.id.action_data_management:
|
||||
Intent dbIntent = new Intent(this, DataManagementActivity.class);
|
||||
} else if (itemId == R.id.action_data_management) {
|
||||
final Intent dbIntent = new Intent(this, DataManagementActivity.class);
|
||||
startActivity(dbIntent);
|
||||
return false;
|
||||
case R.id.action_notification_management:
|
||||
Intent blIntent = new Intent(this, NotificationManagementActivity.class);
|
||||
} else if (itemId == R.id.action_notification_management) {
|
||||
final Intent blIntent = new Intent(this, NotificationManagementActivity.class);
|
||||
startActivity(blIntent);
|
||||
return false;
|
||||
case R.id.device_action_discover:
|
||||
} else if (itemId == R.id.device_action_discover) {
|
||||
launchDiscoveryActivity();
|
||||
return false;
|
||||
case R.id.action_quit:
|
||||
} else if (itemId == R.id.action_quit) {
|
||||
GBApplication.quit();
|
||||
return false;
|
||||
case R.id.donation_link:
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://liberapay.com/Gadgetbridge")); //TODO: centralize if ever used somewhere else
|
||||
} else if (itemId == R.id.donation_link) {
|
||||
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);
|
||||
startActivity(i);
|
||||
return false;
|
||||
case R.id.external_changelog:
|
||||
GBChangeLog cl = createChangeLog();
|
||||
} else if (itemId == R.id.external_changelog) {
|
||||
final GBChangeLog cl = createChangeLog();
|
||||
try {
|
||||
if (cl.hasChanges(false)) {
|
||||
cl.getMaterialLogDialog().show();
|
||||
@ -431,13 +428,13 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
GB.toast(getBaseContext(), getString(R.string.error_showing_changelog), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
return false;
|
||||
case R.id.about:
|
||||
Intent aboutIntent = new Intent(this, AboutActivity.class);
|
||||
} 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() {
|
||||
|
@ -175,10 +175,10 @@ public class DashboardFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.dashboard_show_calendar:
|
||||
Intent intent = new Intent(requireActivity(), DashboardCalendarActivity.class);
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.dashboard_show_calendar) {
|
||||
final Intent intent = new Intent(requireActivity(), DashboardCalendarActivity.class);
|
||||
intent.putExtra(DashboardCalendarActivity.EXTRA_TIMESTAMP, day.getTimeInMillis());
|
||||
startActivityForResult(intent, 0);
|
||||
return false;
|
||||
|
@ -1014,9 +1014,9 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -227,9 +227,9 @@ public class ExternalPebbleJSActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -289,9 +289,9 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -33,12 +33,11 @@ import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -51,12 +50,9 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Reminder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class ReminderDetails extends AbstractGBActivity implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReminderDetails.class);
|
||||
|
||||
private Reminder reminder;
|
||||
private GBDevice device;
|
||||
|
||||
@ -168,9 +164,9 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
// TODO confirm when exiting without saving
|
||||
finish();
|
||||
@ -184,13 +180,13 @@ public class ReminderDetails extends AbstractGBActivity implements TimePickerDia
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
protected void onSaveInstanceState(@NonNull final Bundle state) {
|
||||
super.onSaveInstanceState(state);
|
||||
state.putSerializable("reminder", reminder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
reminder = (Reminder) savedInstanceState.getSerializable("reminder");
|
||||
updateUiFromReminder();
|
||||
|
@ -81,27 +81,20 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.alarm1:
|
||||
public void onClick(final View v) {
|
||||
final int viewId = v.getId();
|
||||
if (viewId == R.id.alarm1) {
|
||||
setAlarm(5);
|
||||
break;
|
||||
case R.id.alarm2:
|
||||
} else if (viewId == R.id.alarm2) {
|
||||
setAlarm(10);
|
||||
break;
|
||||
case R.id.alarm3:
|
||||
} else if (viewId == R.id.alarm3) {
|
||||
setAlarm(20);
|
||||
break;
|
||||
case R.id.alarm4:
|
||||
} else if (viewId == R.id.alarm4) {
|
||||
setAlarm(60);
|
||||
break;
|
||||
case R.id.alarm5:
|
||||
} else if (viewId == R.id.alarm5) {
|
||||
setAlarm(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//this is to prevent screen flashing during closing
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
|
@ -29,12 +29,11 @@ import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
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.entities.WorldClock;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public class WorldClockDetails extends AbstractGBActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WorldClockDetails.class);
|
||||
|
||||
private WorldClock worldClock;
|
||||
private GBDevice device;
|
||||
|
||||
@ -80,6 +76,12 @@ public class WorldClockDetails extends AbstractGBActivity {
|
||||
worldClockCode = findViewById(R.id.world_clock_code);
|
||||
|
||||
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 String[] timezoneIDs = TimeZone.getAvailableIDs();
|
||||
@ -153,9 +155,9 @@ public class WorldClockDetails extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
// TODO confirm when exiting without saving
|
||||
finish();
|
||||
@ -169,13 +171,13 @@ public class WorldClockDetails extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
protected void onSaveInstanceState(@NonNull final Bundle state) {
|
||||
super.onSaveInstanceState(state);
|
||||
state.putSerializable("worldClock", worldClock);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
worldClock = (WorldClock) savedInstanceState.getSerializable("worldClock");
|
||||
updateUiFromWorldClock();
|
||||
|
@ -577,45 +577,44 @@ public abstract class AbstractAppManagerFragment extends Fragment {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onContextItemSelected(MenuItem item, GBDeviceApp selectedApp) {
|
||||
File appCacheDir;
|
||||
private boolean onContextItemSelected(final MenuItem item, final GBDeviceApp selectedApp) {
|
||||
final File appCacheDir;
|
||||
try {
|
||||
appCacheDir = mCoordinator.getAppCacheDir();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
LOG.warn("could not get external dir while trying to access app cache.");
|
||||
return true;
|
||||
}
|
||||
switch (item.getItemId()) {
|
||||
case R.id.appmanager_app_delete_cache:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.appmanager_app_delete_cache) {
|
||||
deleteAppConfirm(selectedApp, true);
|
||||
return true;
|
||||
case R.id.appmanager_app_delete:
|
||||
} else if (itemId == R.id.appmanager_app_delete) {
|
||||
deleteAppConfirm(selectedApp, false);
|
||||
return true;
|
||||
case R.id.appmanager_app_start:
|
||||
case R.id.appmanager_watchface_activate:
|
||||
} else if (itemId == R.id.appmanager_app_start || itemId == R.id.appmanager_watchface_activate) {
|
||||
GBApplication.deviceService(mGBDevice).onAppStart(selectedApp.getUUID(), true);
|
||||
return true;
|
||||
case R.id.appmanager_app_download:
|
||||
} else if (itemId == R.id.appmanager_app_download) {
|
||||
GBApplication.deviceService(mGBDevice).onAppDownload(selectedApp.getUUID());
|
||||
GB.toast(getContext().getString(R.string.appmanager_download_started), Toast.LENGTH_LONG, GB.INFO);
|
||||
GB.toast(requireContext().getString(R.string.appmanager_download_started), Toast.LENGTH_LONG, GB.INFO);
|
||||
return true;
|
||||
case R.id.appmanager_app_reinstall:
|
||||
File cachePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension());
|
||||
} 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;
|
||||
case R.id.appmanager_app_share:
|
||||
File origFilePath = new File(appCacheDir, selectedApp.getUUID() + mCoordinator.getAppFileExtension());
|
||||
File appTempDir = new File(appCacheDir, "temp_sharing");
|
||||
File sharedAppFile = new File(appTempDir, selectedApp.getName() + mCoordinator.getAppFileExtension());
|
||||
} 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 (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
return true;
|
||||
}
|
||||
Uri contentUri = FileProvider.getUriForFile(getContext(),getContext().getApplicationContext().getPackageName() + ".screenshot_provider", sharedAppFile);
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
final Uri contentUri = FileProvider.getUriForFile(requireContext(), requireContext().getApplicationContext().getPackageName() + ".screenshot_provider", sharedAppFile);
|
||||
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
|
||||
shareIntent.setType("*/*");
|
||||
try {
|
||||
@ -624,47 +623,45 @@ public abstract class AbstractAppManagerFragment extends Fragment {
|
||||
LOG.warn("Sharing watchface failed", e);
|
||||
}
|
||||
return true;
|
||||
case R.id.appmanager_health_activate:
|
||||
} else if (itemId == R.id.appmanager_health_activate) {
|
||||
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://health"));
|
||||
return true;
|
||||
case R.id.appmanager_hrm_activate:
|
||||
} else if (itemId == R.id.appmanager_hrm_activate) {
|
||||
GBApplication.deviceService(mGBDevice).onInstallApp(Uri.parse("fake://hrm"));
|
||||
return true;
|
||||
case R.id.appmanager_weather_activate:
|
||||
} else if (itemId == 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:
|
||||
} else if (itemId == R.id.appmanager_health_deactivate || itemId == R.id.appmanager_hrm_deactivate || itemId == R.id.appmanager_weather_deactivate) {
|
||||
GBApplication.deviceService(mGBDevice).onAppDelete(selectedApp.getUUID());
|
||||
return true;
|
||||
case R.id.appmanager_weather_install_provider:
|
||||
} 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")));
|
||||
return true;
|
||||
case R.id.appmanager_app_configure:
|
||||
} else if (itemId == 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(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
startIntent.putExtra(ExternalPebbleJSActivity.SHOW_CONFIG, true);
|
||||
startActivity(startIntent);
|
||||
return true;
|
||||
case 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());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
} else if (itemId == R.id.appmanager_app_openinstore) {
|
||||
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());
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.appmanager_app_edit:
|
||||
Intent editWatchfaceIntent = new Intent(getContext(), watchfaceDesignerActivity);
|
||||
} else if (itemId == R.id.appmanager_app_edit) {
|
||||
final Intent editWatchfaceIntent = new Intent(getContext(), watchfaceDesignerActivity);
|
||||
editWatchfaceIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
editWatchfaceIntent.putExtra(GBDevice.EXTRA_UUID, selectedApp.getUUID().toString());
|
||||
startActivityForResult(editWatchfaceIntent, CHILD_ACTIVITY_WATCHFACE_EDITOR);
|
||||
return true;
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
private void deleteAppConfirm(final GBDeviceApp selectedApp, final boolean deleteFromCache) {
|
||||
|
@ -162,9 +162,9 @@ public class AppManagerActivity extends AbstractGBFragmentActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ public class WidgetScreenDetailsActivity extends AbstractGBActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
// TODO confirm when exiting without saving
|
||||
finish();
|
||||
|
@ -139,9 +139,9 @@ public class WidgetScreensListActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
|
@ -857,28 +857,28 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
||||
|
||||
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()){
|
||||
case R.id.controlcenter_device_submenu_connect:
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.controlcenter_device_submenu_connect) {
|
||||
if (device.getState() != GBDevice.State.CONNECTED) {
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_connecting);
|
||||
handleDeviceConnect(device);
|
||||
}
|
||||
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) {
|
||||
showTransientSnackbar(R.string.controlcenter_snackbar_disconnecting);
|
||||
GBApplication.deviceService(device).disconnect();
|
||||
}
|
||||
removeFromLastDeviceAddressesPref(device);
|
||||
return true;
|
||||
case R.id.controlcenter_device_submenu_set_alias:
|
||||
} else if (itemId == R.id.controlcenter_device_submenu_set_alias) {
|
||||
showSetAliasDialog(device);
|
||||
return true;
|
||||
case R.id.controlcenter_device_submenu_remove:
|
||||
} else if (itemId == R.id.controlcenter_device_submenu_remove) {
|
||||
showRemoveDeviceDialog(device);
|
||||
return true;
|
||||
case R.id.controlcenter_device_submenu_show_details:
|
||||
} else if (itemId == R.id.controlcenter_device_submenu_show_details) {
|
||||
final String previouslyExpandedDeviceAddress = expandedDeviceAddress;
|
||||
expandedDeviceAddress = detailsShown ? "" : device.getAddress();
|
||||
|
||||
@ -896,15 +896,16 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
||||
// Update the current one
|
||||
notifyItemChanged(devicesListWithFolders.indexOf(device));
|
||||
return true;
|
||||
case R.id.controlcenter_device_submenu_set_parent_folder:
|
||||
} else if (itemId == R.id.controlcenter_device_submenu_set_parent_folder) {
|
||||
showSetParentFolderDialog(device);
|
||||
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);
|
||||
openFwIntent.putExtra(GBDevice.EXTRA_DEVICE, device);
|
||||
context.startActivity(openFwIntent);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -21,6 +21,7 @@ import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
@ -68,7 +69,7 @@ public class HybridHRWatchfaceSettingsActivity extends AbstractSettingsActivityV
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
// Action bar back button
|
||||
Intent output = new Intent();
|
||||
|
@ -21,6 +21,7 @@ import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
@ -84,7 +85,7 @@ public class HybridHRWatchfaceWidgetActivity extends AbstractSettingsActivityV2
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
// Action bar back button
|
||||
Intent output = new Intent();
|
||||
|
@ -550,8 +550,8 @@ public class QHybridConfigActivity extends AbstractGBActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
this.onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
|
||||
MINUTES((short)0),
|
||||
ACTIVITY_TARGET((short)2);
|
||||
|
||||
private short code;
|
||||
private Hands(short code) {
|
||||
private final short code;
|
||||
Hands(short code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
|
||||
|
||||
private GBDevice device;
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private String[] calibrationAdvices = new String[3];
|
||||
private Hands[] hands = new Hands[]{Hands.HOURS, Hands.MINUTES, Hands.ACTIVITY_TARGET};
|
||||
private final String[] calibrationAdvices = new String[3];
|
||||
private final Hands[] hands = new Hands[]{Hands.HOURS, Hands.MINUTES, Hands.ACTIVITY_TARGET};
|
||||
private short handIndex = 0;
|
||||
private Button previousButton;
|
||||
private Button nextButton;
|
||||
@ -141,9 +141,9 @@ public class WithingsCalibrationActivity extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
@ -20,8 +20,5 @@ org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
|
||||
android.useAndroidX=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
|
||||
android.enableR8.fullMode=false
|
||||
|
Loading…
Reference in New Issue
Block a user