Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/UserInterface/MainActivity.java
Show All 28 Lines | |||||
29 | import org.kde.kdeconnect.Helpers.DeviceHelper; | 29 | import org.kde.kdeconnect.Helpers.DeviceHelper; | ||
30 | import org.kde.kdeconnect_tp.R; | 30 | import org.kde.kdeconnect_tp.R; | ||
31 | 31 | | |||
32 | import java.util.Collection; | 32 | import java.util.Collection; | ||
33 | import java.util.HashMap; | 33 | import java.util.HashMap; | ||
34 | import java.util.HashSet; | 34 | import java.util.HashSet; | ||
35 | import java.util.Set; | 35 | import java.util.Set; | ||
36 | 36 | | |||
37 | import butterknife.BindView; | ||||
38 | import butterknife.ButterKnife; | ||||
39 | | ||||
37 | public class MainActivity extends AppCompatActivity { | 40 | public class MainActivity extends AppCompatActivity { | ||
38 | 41 | | |||
39 | private static final int MENU_ENTRY_ADD_DEVICE = 1; //0 means no-selection | 42 | private static final int MENU_ENTRY_ADD_DEVICE = 1; //0 means no-selection | ||
40 | private static final int MENU_ENTRY_SETTINGS = 2; | 43 | private static final int MENU_ENTRY_SETTINGS = 2; | ||
41 | private static final int MENU_ENTRY_DEVICE_FIRST_ID = 1000; //All subsequent ids are devices in the menu | 44 | private static final int MENU_ENTRY_DEVICE_FIRST_ID = 1000; //All subsequent ids are devices in the menu | ||
42 | private static final int MENU_ENTRY_DEVICE_UNKNOWN = 9999; //It's still a device, but we don't know which one yet | 45 | private static final int MENU_ENTRY_DEVICE_UNKNOWN = 9999; //It's still a device, but we don't know which one yet | ||
43 | 46 | | |||
44 | private static final String STATE_SELECTED_MENU_ENTRY = "selected_entry"; //Saved only in onSaveInstanceState | 47 | private static final String STATE_SELECTED_MENU_ENTRY = "selected_entry"; //Saved only in onSaveInstanceState | ||
45 | private static final String STATE_SELECTED_DEVICE = "selected_device"; //Saved persistently in preferences | 48 | private static final String STATE_SELECTED_DEVICE = "selected_device"; //Saved persistently in preferences | ||
46 | 49 | | |||
47 | public static final int RESULT_NEEDS_RELOAD = Activity.RESULT_FIRST_USER; | 50 | public static final int RESULT_NEEDS_RELOAD = Activity.RESULT_FIRST_USER; | ||
48 | 51 | | |||
49 | public static final String PAIR_REQUEST_STATUS = "pair_req_status"; | 52 | public static final String PAIR_REQUEST_STATUS = "pair_req_status"; | ||
50 | public static final String PAIRING_ACCEPTED = "accepted"; | 53 | public static final String PAIRING_ACCEPTED = "accepted"; | ||
51 | public static final String PAIRING_REJECTED = "rejected"; | 54 | public static final String PAIRING_REJECTED = "rejected"; | ||
52 | 55 | | |||
53 | private NavigationView mNavigationView; | 56 | @BindView(R.id.navigation_drawer) NavigationView mNavigationView; | ||
nicolasfella: Any reason why they are not private any more? | |||||
Butterknife can't set private members. It basically generates code to do what it needs to do in the same package. You can see the code in build/generated/source/apt/..../MainActivity_ViewBinding.java eduisters: Butterknife can't set private members. It basically generates code to do what it needs to do in… | |||||
54 | private DrawerLayout mDrawerLayout; | 57 | @BindView(R.id.drawer_layout) DrawerLayout mDrawerLayout; | ||
58 | @BindView(R.id.toolbar) Toolbar mToolbar; | ||||
59 | TextView mNavViewDeviceName; | ||||
55 | 60 | | |||
56 | private String mCurrentDevice; | 61 | private String mCurrentDevice; | ||
57 | private int mCurrentMenuEntry; | 62 | private int mCurrentMenuEntry; | ||
58 | 63 | | |||
59 | private SharedPreferences preferences; | 64 | private SharedPreferences preferences; | ||
60 | 65 | | |||
61 | private final HashMap<MenuItem, String> mMapMenuToDeviceId = new HashMap<>(); | 66 | private final HashMap<MenuItem, String> mMapMenuToDeviceId = new HashMap<>(); | ||
62 | private String pairRequestStatus; | 67 | private String pairRequestStatus; | ||
63 | 68 | | |||
64 | @Override | 69 | @Override | ||
65 | protected void onCreate(Bundle savedInstanceState) { | 70 | protected void onCreate(Bundle savedInstanceState) { | ||
66 | super.onCreate(savedInstanceState); | 71 | super.onCreate(savedInstanceState); | ||
67 | 72 | | |||
68 | // We need to set this theme before the call to 'setContentView' below | 73 | // We need to set this theme before the call to 'setContentView' below | ||
69 | ThemeUtil.setUserPreferredTheme(this); | 74 | ThemeUtil.setUserPreferredTheme(this); | ||
70 | 75 | | |||
71 | setContentView(R.layout.activity_main); | 76 | setContentView(R.layout.activity_main); | ||
72 | mDrawerLayout = findViewById(R.id.drawer_layout); | 77 | | ||
73 | mNavigationView = findViewById(R.id.navigation_drawer); | 78 | ButterKnife.bind(this); | ||
79 | | ||||
74 | View mDrawerHeader = mNavigationView.getHeaderView(0); | 80 | View mDrawerHeader = mNavigationView.getHeaderView(0); | ||
81 | mNavViewDeviceName = mDrawerHeader.findViewById(R.id.device_name); | ||||
75 | 82 | | |||
76 | Toolbar toolbar = findViewById(R.id.toolbar); | 83 | setSupportActionBar(mToolbar); | ||
77 | setSupportActionBar(toolbar); | | |||
78 | 84 | | |||
79 | ActionBar actionBar = getSupportActionBar(); | 85 | ActionBar actionBar = getSupportActionBar(); | ||
80 | 86 | | |||
81 | ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ | 87 | ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ | ||
82 | mDrawerLayout, /* DrawerLayout object */ | 88 | mDrawerLayout, /* DrawerLayout object */ | ||
83 | R.string.open, /* "open drawer" description */ | 89 | R.string.open, /* "open drawer" description */ | ||
84 | R.string.close /* "close drawer" description */ | 90 | R.string.close /* "close drawer" description */ | ||
85 | ); | 91 | ); | ||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Line(s) | 380 | .setPositiveButton(R.string.device_rename_confirm, (dialog, which) -> { | |||
381 | } | 387 | } | ||
382 | }) | 388 | }) | ||
383 | .setNegativeButton(R.string.cancel, (dialog, which) -> { }) | 389 | .setNegativeButton(R.string.cancel, (dialog, which) -> { }) | ||
384 | .setTitle(R.string.device_rename_title) | 390 | .setTitle(R.string.device_rename_title) | ||
385 | .show(); | 391 | .show(); | ||
386 | } | 392 | } | ||
387 | 393 | | |||
388 | private void updateDeviceNameFromMenu(String newDeviceName) { | 394 | private void updateDeviceNameFromMenu(String newDeviceName) { | ||
389 | final TextView nameView = mNavigationView.findViewById(R.id.device_name); | 395 | mNavViewDeviceName.setText(newDeviceName); | ||
390 | nameView.setText(newDeviceName); | | |||
391 | } | 396 | } | ||
392 | } | 397 | } |
Any reason why they are not private any more?