diff --git a/app/build.gradle b/app/build.gradle index 3eb5f6e..524cda3 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,15 +9,15 @@ repositories { } android { - compileSdkVersion 31 - buildToolsVersion "31.0.0" + compileSdk 34 + namespace "com.farmerbb.secondscreen" defaultConfig { applicationId "com.farmerbb.secondscreen" - minSdkVersion 17 + minSdkVersion 21 //noinspection OldTargetApi - targetSdkVersion 31 + targetSdkVersion 34 versionCode 185 versionName "2.9.3" @@ -25,14 +25,19 @@ android { resConfigs "en", "es", "fr", "sk", "nl", "it", "zh" vectorDrawables.useSupportLibrary = true - buildConfigField "float", "TESTED_API_VERSION", "33.0f" + buildConfigField "float", "TESTED_API_VERSION", "35.0f" buildConfigField "String", "SUPPORT_APPLICATION_ID", "\"com.farmerbb.secondscreen.support\"" buildConfigField "long", "TIMESTAMP", "${System.currentTimeMillis()}L" } + buildFeatures { + buildConfig true + } + compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 } signingConfigs { @@ -55,7 +60,7 @@ android { release { minifyEnabled true shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release manifestPlaceholders = [appName: "@string/app_name"] @@ -93,16 +98,18 @@ android { } dependencies { - def shizuku_version = '12.0.0' + def shizuku_version = '12.1.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' implementation "dev.rikka.shizuku:api:$shizuku_version" implementation "dev.rikka.shizuku:provider:$shizuku_version" - implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'eu.chainfire:libsuperuser:1.1.0.202004101746' + implementation 'org.apache.commons:commons-lang3:3.17.0' + implementation 'eu.chainfire:libsuperuser:1.1.1' implementation 'moe.banana:toast-compat:1.0.5' - implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:2.0' + implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:3.0' implementation group:'com.twofortyfouram', name:'android-plugin-api-for-locale', version:'[1.0.2,2.0[' + + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7aad7f4..2b3ef65 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,6 @@ + + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + + android:exported="true" + android:foregroundServiceType="specialUse"> + = Build.VERSION_CODES.TIRAMISU + && checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED + && !hasPreviouslyRequestedPermission) { + requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS}, 42); + } else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || U.hasElevatedPermissions(this)) showMoreDialogs(); else startActivity(new Intent(this, UnableToStartActivity.class)); @@ -1071,4 +1077,10 @@ public void onSystemAlertPermissionDialogNegativeClick() { onFirstLoadPositiveClick(null, filename, false); } } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + showDialogs(true); + } } \ No newline at end of file diff --git a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileEditFragment.java b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileEditFragment.java index c212b53..cff1357 100644 --- a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileEditFragment.java +++ b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileEditFragment.java @@ -74,12 +74,19 @@ public final class ProfileEditFragment extends PreferenceFragment implements * implement this interface in order to receive event call backs. */ public interface Listener { void showDeleteDialog(); + void showExpertModeDialog(); + void showReloadDialog(String filename, boolean isEdit, boolean returnToList); + String getProfileTitle(String filename) throws IOException; + void setDefaultDensity(); + String generateBlurb(String key, String value); + void setEmptyTitle(String title); + void showUiRefreshDialog(String filename, boolean isEdit, boolean returnToList); } @@ -114,9 +121,9 @@ public void onActivityCreated(Bundle savedInstanceState) { // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Animate elevation change - if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) { + if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) { LinearLayout profileViewEdit = getActivity().findViewById(R.id.profileViewEdit); LinearLayout profileList = getActivity().findViewById(R.id.profileList); profileList.animate().z(0f); @@ -125,9 +132,9 @@ public void onActivityCreated(Bundle savedInstanceState) { // Remove dividers View rootView = getView(); - if(rootView != null) { + if (rootView != null) { ListView list = rootView.findViewById(android.R.id.list); - if(list != null) list.setDivider(null); + if (list != null) list.setDivider(null); } } } @@ -138,8 +145,8 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get filename - if(getArguments() != null) - if(getArguments().getString("filename") != null) { + if (getArguments() != null) + if (getArguments().getString("filename") != null) { filename = getArguments().getString("filename"); isSavedProfile = true; } @@ -148,21 +155,21 @@ public void onCreate(Bundle savedInstanceState) { SharedPreferences prefMain = U.getPrefMain(getActivity()); // If editing a previously saved profile, begin loading saved settings - if(isSavedProfile) { + if (isSavedProfile) { SharedPreferences prefSaved = U.getPrefSaved(getActivity(), filename); SharedPreferences.Editor editor = prefNew.edit(); - if("fallback".equals(prefSaved.getString("rotation_lock_new", "fallback")) && prefSaved.getBoolean("rotation_lock", false)) + if ("fallback".equals(prefSaved.getString("rotation_lock_new", "fallback")) && prefSaved.getBoolean("rotation_lock", false)) editor.putString("rotation_lock_new", "landscape"); else editor.putString("rotation_lock_new", prefSaved.getString("rotation_lock_new", "do-nothing")); - if("fallback".equals(prefSaved.getString("immersive_new", "fallback")) && prefSaved.getBoolean("immersive", false)) + if ("fallback".equals(prefSaved.getString("immersive_new", "fallback")) && prefSaved.getBoolean("immersive", false)) editor.putString("immersive_new", "immersive-mode"); else editor.putString("immersive_new", prefSaved.getString("immersive_new", "do-nothing")); - if(prefSaved.getBoolean("overscan", false)) { + if (prefSaved.getBoolean("overscan", false)) { editor.putBoolean("overscan", true); editor.putInt("overscan_left", prefSaved.getInt("overscan_left", 0)); editor.putInt("overscan_right", prefSaved.getInt("overscan_right", 0)); @@ -176,8 +183,8 @@ public void onCreate(Bundle savedInstanceState) { editor.putInt("overscan_bottom", 0); } - if(prefMain.getBoolean("expert_mode", false)) { - if("reset".equals(prefSaved.getString("size", "reset"))) { + if (prefMain.getBoolean("expert_mode", false)) { + if ("reset".equals(prefSaved.getString("size", "reset"))) { editor.putString("size", prefMain.getInt("width", 0) + "x" + prefMain.getInt("height", 0)); @@ -186,30 +193,30 @@ public void onCreate(Bundle savedInstanceState) { } else editor.putString("size", prefSaved.getString("size", "reset")); - if("reset".equals(prefSaved.getString("density", "reset"))) { + if ("reset".equals(prefSaved.getString("density", "reset"))) { editor.putString("density", Integer.toString(U.getSystemProperty("ro.sf.lcd_density", prefMain.getInt("density", 0)))); editor.putBoolean("density-reset", true); } else editor.putString("density", prefSaved.getString("density", "reset")); } else { - if(prefSaved.getBoolean("size-reset", false)) { + if (prefSaved.getBoolean("size-reset", false)) { editor.remove("size-reset"); String nativeRes = prefMain.getInt("width", 0) + "x" + prefMain.getInt("height", 0); - if(nativeRes.equals(prefSaved.getString("size", "reset"))) + if (nativeRes.equals(prefSaved.getString("size", "reset"))) editor.putString("size", "reset"); else editor.putString("size", prefSaved.getString("size", "reset")); } else editor.putString("size", prefSaved.getString("size", "reset")); - if(prefSaved.getBoolean("density-reset", false)) { + if (prefSaved.getBoolean("density-reset", false)) { editor.remove("density-reset"); - if(Integer.toString(U.getSystemProperty("ro.sf.lcd_density", prefMain.getInt("density", 0))).equals(prefSaved.getString("density", "reset"))) + if (Integer.toString(U.getSystemProperty("ro.sf.lcd_density", prefMain.getInt("density", 0))).equals(prefSaved.getString("density", "reset"))) editor.putString("density", "reset"); else editor.putString("density", prefSaved.getString("density", "reset")); @@ -217,7 +224,7 @@ public void onCreate(Bundle savedInstanceState) { editor.putString("density", prefSaved.getString("density", "reset")); } - if(getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android") + if (getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android") && Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1 && prefSaved.getString("ui_refresh", "do-nothing").equals("system-ui")) { editor.putString("ui_refresh", "activity-manager"); @@ -248,12 +255,12 @@ public void onCreate(Bundle savedInstanceState) { // Add preferences addPreferencesFromResource(R.xml.profile_name_setting); - if(prefMain.getBoolean("expert_mode", false)) + if (prefMain.getBoolean("expert_mode", false)) addPreferencesFromResource(R.xml.display_settings_expert); else addPreferencesFromResource(R.xml.display_settings); - if(U.isPlayStoreInstalled(getActivity()) + if (U.isPlayStoreInstalled(getActivity()) && U.isPlayStoreRelease(getActivity()) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { addPreferencesFromResource(R.xml.desktop_optimization); @@ -265,19 +272,19 @@ public void onCreate(Bundle savedInstanceState) { addPreferencesFromResource(R.xml.additional_settings); // Modifications for certain scenarios - if(!prefMain.getBoolean("expert_mode", false) && prefMain.getBoolean("landscape", false)) { + if (!prefMain.getBoolean("expert_mode", false) && prefMain.getBoolean("landscape", false)) { ListPreference size = (ListPreference) findPreference("size"); size.setEntryValues(R.array.pref_resolution_list_values_landscape); } - if(getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android") + if (getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android") && Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) { ListPreference uiRefresh = (ListPreference) findPreference("ui_refresh"); uiRefresh.setEntries(R.array.pref_ui_refresh_list_alt); uiRefresh.setEntryValues(R.array.pref_ui_refresh_list_values_alt); } - if(U.isInNonRootMode(getActivity())) { + if (U.isInNonRootMode(getActivity())) { ListPreference uiRefresh = (ListPreference) findPreference("ui_refresh"); uiRefresh.setEntries(R.array.pref_ui_refresh_list_non_root); } @@ -287,7 +294,7 @@ public void onCreate(Bundle savedInstanceState) { findPreference("overscan_settings").setOnPreferenceClickListener(this); findPreference("freeform").setOnPreferenceClickListener(this); - if(prefMain.getBoolean("expert_mode", false)) + if (prefMain.getBoolean("expert_mode", false)) findPreference("size").setOnPreferenceClickListener(this); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to @@ -303,36 +310,36 @@ public void onCreate(Bundle savedInstanceState) { U.bindPreferenceSummaryToValue(findPreference("hdmi_rotation"), opcl); // Disable unsupported preferences - if(!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) + if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) disablePreference("bluetooth_on", "additional_settings", true); - if(!U.canEnableWifi(getActivity())) + if (!U.canEnableWifi(getActivity())) disablePreference("wifi_on", "additional_settings", true); - if(!getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android")) + if (!getActivity().getPackageManager().hasSystemFeature("com.cyanogenmod.android")) disablePreference("navbar", "additional_settings", true); - if(!U.canEnableOverscan()) + if (!U.canEnableOverscan()) disablePreference("overscan_settings", "display_settings", false); - if(!U.canEnableImmersiveMode()) + if (!U.canEnableImmersiveMode()) disablePreference("immersive_new", "display_settings", false); - if(!U.canEnableFreeform(getActivity())) + if (!U.canEnableFreeform(getActivity())) disablePreference("freeform", "desktop_optimization", true); - if(U.getChromePackageName(getActivity()) == null) + if (U.getChromePackageName(getActivity()) == null) disablePreference("chrome", "desktop_optimization", true); - if(U.isInNonRootMode(getActivity())) { + if (U.isInNonRootMode(getActivity())) { disablePreference("hdmi_rotation", "display_settings", false); disablePreference("chrome", "desktop_optimization", false); - if(!U.hasSupportLibrary(getActivity())) + if (!U.hasSupportLibrary(getActivity())) disablePreference("show_touches", "additional_settings", false); } - if(U.getTaskbarPackageName(getActivity()) == null || !U.isPlayStoreRelease(getActivity())) + if (U.getTaskbarPackageName(getActivity()) == null || !U.isPlayStoreRelease(getActivity())) disablePreference("taskbar", "desktop_optimization", true); uiRefreshWarning = true; @@ -345,19 +352,19 @@ public void onResume() { SharedPreferences prefNew = U.getPrefNew(getActivity()); // Change window title - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getActivity().setTitle(prefNew.getString("profile_name", getResources().getString(R.string.action_new))); else getActivity().setTitle(" " + prefNew.getString("profile_name", getResources().getString(R.string.action_new))); - if(U.canEnableOverscan()) { - if(prefNew.getBoolean("overscan", false)) + if (U.canEnableOverscan()) { + if (prefNew.getBoolean("overscan", false)) findPreference("overscan_settings").setSummary(getResources().getString(R.string.enabled)); else findPreference("overscan_settings").setSummary(getResources().getString(R.string.disabled)); } - if(taskbarSettingsPrefEnabled) { + if (taskbarSettingsPrefEnabled) { findPreference("taskbar_settings").setTitle( U.getTaskbarPackageName(getActivity()) == null ? R.string.pref_taskbar_settings_title_install @@ -388,34 +395,35 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch(item.getItemId()) { - case android.R.id.home: - // Override default Android "up" behavior to instead mimic the back button - onBackPressed(filename, false, true); - return true; - - // Save button - case R.id.action_save: - onBackPressed(filename, false, false); - return true; - - // Delete button - case R.id.action_delete: - // Show toast if this is the currently active profile - SharedPreferences prefCurrent = U.getPrefCurrent(getActivity()); - if("quick_actions".equals(prefCurrent.getString("filename", "0"))) { - SharedPreferences prefSaved = U.getPrefQuickActions(getActivity()); - if(filename.equals(prefSaved.getString("original_filename", "0"))) - U.showToast(getActivity(), R.string.deleting_current_profile); - else - listener.showDeleteDialog(); - } else if(filename.equals(prefCurrent.getString("filename", "0"))) + int itemId = item.getItemId(); + + // Override default Android "up" behavior to instead mimic the back button + if (itemId == android.R.id.home) { + onBackPressed(filename, false, true); + return true; + } + // Save button + else if (itemId == R.id.action_save) { + onBackPressed(filename, false, false); + return true; + } + // Delete button + else if (itemId == R.id.action_delete) { + // Show toast if this is the currently active profile + SharedPreferences prefCurrent = U.getPrefCurrent(getActivity()); + if ("quick_actions".equals(prefCurrent.getString("filename", "0"))) { + SharedPreferences prefSaved = U.getPrefQuickActions(getActivity()); + if (filename.equals(prefSaved.getString("original_filename", "0"))) U.showToast(getActivity(), R.string.deleting_current_profile); else listener.showDeleteDialog(); - return true; - default: - return super.onOptionsItemSelected(item); + } else if (filename.equals(prefCurrent.getString("filename", "0"))) + U.showToast(getActivity(), R.string.deleting_current_profile); + else + listener.showDeleteDialog(); + return true; + } else { + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileListFragment.java b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileListFragment.java index fb818f1..80b6002 100644 --- a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileListFragment.java +++ b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileListFragment.java @@ -15,6 +15,7 @@ package com.farmerbb.secondscreen.fragment; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.DialogFragment; import android.app.Fragment; @@ -62,7 +63,7 @@ public final class ProfileListFragment extends Fragment { private final class ListNotesReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - if(getActivity() != null) listProfiles(); + if (getActivity() != null) listProfiles(); } } @@ -76,7 +77,7 @@ public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position String profile = getItem(position); // Check if an existing view is being reused, otherwise inflate the view - if(convertView == null) { + if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout, parent, false); } // Lookup view for data population @@ -96,10 +97,15 @@ public View getView(int position, View convertView, ViewGroup parent) { * implement this interface in order to receive event call backs. */ public interface Listener { void viewProfile(String filename); + void editProfile(String filename); + SharedPreferences getPrefCurrent(); + SharedPreferences getPrefQuickActions(); + TextView getHelperText(); + boolean isDebugModeEnabled(boolean isClick); } @@ -118,7 +124,7 @@ public void onAttach(Activity activity) { } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception throw new ClassCastException(activity - + " must implement Listener"); + + " must implement Listener"); } } @@ -140,9 +146,9 @@ public void onActivityCreated(Bundle savedInstanceState) { public void onResume() { super.onResume(); - if(getId() == R.id.profileViewEdit) { + if (getId() == R.id.profileViewEdit) { // Change window title - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getActivity().setTitle(getResources().getString(R.string.app_name)); else getActivity().setTitle(" " + getResources().getString(R.string.app_name)); @@ -165,10 +171,10 @@ public void onStart() { // Floating action button FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action); floatingActionButton.setImageResource(R.drawable.ic_action_new); - if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) + if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) floatingActionButton.hide(); - if(getId() == R.id.profileViewEdit) { + if (getId() == R.id.profileViewEdit) { floatingActionButton.show(); floatingActionButton.setOnClickListener(v -> { DialogFragment newProfileFragment = new NewProfileDialogFragment(); @@ -187,35 +193,36 @@ public void onStop() { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate action bar menu - if(getId() == R.id.profileViewEdit) + if (getId() == R.id.profileViewEdit) inflater.inflate(R.menu.main, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items - switch(item.getItemId()) { - // Quick Actions button - case R.id.action_quick: - Intent intentQuick = new Intent(getActivity(), TaskerQuickActionsActivity.class); - intentQuick.putExtra("launched-from-app", true); - startActivity(intentQuick); - return true; - - // Settings button - case R.id.action_settings: - Intent intentSettings = new Intent(getActivity(), FragmentContainerActivity.class); - intentSettings.putExtra("tag", "SettingsFragment"); - startActivity(intentSettings); - return true; - - // About button - case R.id.action_about: - DialogFragment aboutFragment = new AboutDialogFragment(); - aboutFragment.show(getFragmentManager(), "about"); - return true; - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + + // Quick Actions button + if (itemId == R.id.action_quick) { + Intent intentQuick = new Intent(getActivity(), TaskerQuickActionsActivity.class); + intentQuick.putExtra("launched-from-app", true); + startActivity(intentQuick); + return true; + } + // Settings button + else if (itemId == R.id.action_settings) { + Intent intentSettings = new Intent(getActivity(), FragmentContainerActivity.class); + intentSettings.putExtra("tag", "SettingsFragment"); + startActivity(intentSettings); + return true; + } + // About button + else if (itemId == R.id.action_about) { + DialogFragment aboutFragment = new AboutDialogFragment(); + aboutFragment.show(getFragmentManager(), "about"); + return true; + } else { + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileViewFragment.java b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileViewFragment.java index 1fd3326..240b40e 100644 --- a/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileViewFragment.java +++ b/app/src/main/java/com/farmerbb/secondscreen/fragment/ProfileViewFragment.java @@ -266,45 +266,46 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // Override default Android "up" behavior to instead mimic the back button - onBackPressed(); - return true; - - // Edit button - case R.id.action_edit: - Bundle bundle = new Bundle(); - bundle.putString("filename", filename); - - Fragment fragment = new ProfileEditFragment(); - fragment.setArguments(bundle); - - getFragmentManager() - .beginTransaction() - .replace(R.id.profileViewEdit, fragment, "ProfileEditFragment") - .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) - .commit(); - - return true; - - // Delete button - case R.id.action_delete_2: - // Show toast if this is the currently active profile - SharedPreferences prefCurrent = U.getPrefCurrent(getActivity()); - if("quick_actions".equals(prefCurrent.getString("filename", "0"))) { - SharedPreferences prefSaved = U.getPrefQuickActions(getActivity()); - if(filename.equals(prefSaved.getString("original_filename", "0"))) - U.showToast(getActivity(), R.string.deleting_current_profile); - else - listener.showDeleteDialog(); - } else if(filename.equals(prefCurrent.getString("filename", "0"))) + int itemId = item.getItemId(); + + // Override default Android "up" behavior to instead mimic the back button + if (itemId == android.R.id.home) { + onBackPressed(); + return true; + } + // Edit button + else if (itemId == R.id.action_edit) { + Bundle bundle = new Bundle(); + bundle.putString("filename", filename); + + Fragment fragment = new ProfileEditFragment(); + fragment.setArguments(bundle); + + getFragmentManager() + .beginTransaction() + .replace(R.id.profileViewEdit, fragment, "ProfileEditFragment") + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .commit(); + + return true; + } + // Delete button + else if (itemId == R.id.action_delete_2) { + // Show toast if this is the currently active profile + SharedPreferences prefCurrent = U.getPrefCurrent(getActivity()); + if ("quick_actions".equals(prefCurrent.getString("filename", "0"))) { + SharedPreferences prefSaved = U.getPrefQuickActions(getActivity()); + if (filename.equals(prefSaved.getString("original_filename", "0"))) U.showToast(getActivity(), R.string.deleting_current_profile); else listener.showDeleteDialog(); - return true; - default: - return super.onOptionsItemSelected(item); + } else if (filename.equals(prefCurrent.getString("filename", "0"))) + U.showToast(getActivity(), R.string.deleting_current_profile); + else + listener.showDeleteDialog(); + return true; + } else { + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/farmerbb/secondscreen/fragment/WelcomeFragment.java b/app/src/main/java/com/farmerbb/secondscreen/fragment/WelcomeFragment.java index 0541b6e..0be6378 100644 --- a/app/src/main/java/com/farmerbb/secondscreen/fragment/WelcomeFragment.java +++ b/app/src/main/java/com/farmerbb/secondscreen/fragment/WelcomeFragment.java @@ -108,28 +108,29 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items - switch(item.getItemId()) { - // Quick Actions button - case R.id.action_quick: - Intent intentQuick = new Intent(getActivity(), TaskerQuickActionsActivity.class); - intentQuick.putExtra("launched-from-app", true); - startActivity(intentQuick); - return true; - - // Settings button - case R.id.action_settings: - Intent intentSettings = new Intent(getActivity(), FragmentContainerActivity.class); - intentSettings.putExtra("tag", "SettingsFragment"); - startActivity(intentSettings); - return true; - - // About button - case R.id.action_about: - DialogFragment aboutFragment = new AboutDialogFragment(); - aboutFragment.show(getFragmentManager(), "about"); - return true; - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + + // Quick Actions button + if (itemId == R.id.action_quick) { + Intent intentQuick = new Intent(getActivity(), TaskerQuickActionsActivity.class); + intentQuick.putExtra("launched-from-app", true); + startActivity(intentQuick); + return true; + } + // Settings button + else if (itemId == R.id.action_settings) { + Intent intentSettings = new Intent(getActivity(), FragmentContainerActivity.class); + intentSettings.putExtra("tag", "SettingsFragment"); + startActivity(intentSettings); + return true; + } + // About button + else if (itemId == R.id.action_about) { + DialogFragment aboutFragment = new AboutDialogFragment(); + aboutFragment.show(getFragmentManager(), "about"); + return true; + } else { + return super.onOptionsItemSelected(item); } } } diff --git a/build.gradle b/build.gradle index 88f62a7..54b6a83 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,9 @@ buildscript { repositories { google() mavenCentral() - jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' + classpath 'com.android.tools.build:gradle:8.5.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -27,7 +26,6 @@ allprojects { repositories { google() mavenCentral() - jcenter() } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2b22d05..66cd5a0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,10 +85,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +134,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 6689b85..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail