mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-07 06:39:10 +08:00
[fix] resolve cross-platform build warnings
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
plugins { id 'com.android.application' }
|
||||
|
||||
android {
|
||||
namespace 'cn.crossdesk.mobile'
|
||||
compileSdk 36
|
||||
ndkVersion '28.2.13676358'
|
||||
namespace = 'cn.crossdesk.mobile'
|
||||
compileSdk = 36
|
||||
ndkVersion = '28.2.13676358'
|
||||
defaultConfig {
|
||||
applicationId 'cn.crossdesk.mobile'
|
||||
minSdk 26
|
||||
targetSdk 36
|
||||
versionCode providers.gradleProperty('crossdeskVersionCode').get().toInteger()
|
||||
versionName providers.gradleProperty('crossdeskVersionName').get()
|
||||
applicationId = 'cn.crossdesk.mobile'
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = providers.gradleProperty('crossdeskVersionCode').get().toInteger()
|
||||
versionName = providers.gradleProperty('crossdeskVersionName').get()
|
||||
ndk { abiFilters 'arm64-v8a' }
|
||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||
testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner'
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
sourceSets.main.jniLibs.srcDirs = [layout.buildDirectory.dir('native')]
|
||||
sourceSets.main.assets.srcDirs += [layout.buildDirectory.dir('generated/notices')]
|
||||
sourceSets.androidTest.java.srcDirs = ['../test/android/java']
|
||||
sourceSets.androidTest.assets.srcDirs = ['../test/android/assets']
|
||||
buildTypes.release { minifyEnabled false }
|
||||
buildTypes.release { minifyEnabled = false }
|
||||
packaging.jniLibs.useLegacyPackaging = false
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,9 @@ public final class MainActivity extends Activity implements NativeSession.Listen
|
||||
private String serverKey(){return host+":"+port;}
|
||||
private void toast(String value){Toast.makeText(this,value,Toast.LENGTH_SHORT).show();}
|
||||
private void hideKeyboard(){((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(root.getWindowToken(),0);root.clearFocus();}
|
||||
// Legacy inset handling also includes the IME on non-session pages. The
|
||||
// decor-fitting call below is restricted to Android 11–14.
|
||||
@SuppressWarnings("deprecation")
|
||||
private void installRoot(String nextPage,boolean dark){
|
||||
PageHost.Motion motion=PageHost.Motion.NONE;
|
||||
if(canvas!=null&&foreground&&!page.equals(nextPage)){
|
||||
@@ -147,6 +150,8 @@ public final class MainActivity extends Activity implements NativeSession.Listen
|
||||
root.setFocusableInTouchMode(true);pageHost.show(canvas,motion);
|
||||
applySystemBars(dark);
|
||||
}
|
||||
// Android 8–10 require system UI flags instead of WindowInsetsController.
|
||||
@SuppressWarnings("deprecation")
|
||||
private void applySystemBars(boolean dark){
|
||||
if(android.os.Build.VERSION.SDK_INT>=30){
|
||||
android.view.WindowInsetsController controller=getWindow().getInsetsController();
|
||||
@@ -302,7 +307,9 @@ public final class MainActivity extends Activity implements NativeSession.Listen
|
||||
rememberPassword=remember.isChecked();password.setText("");dialog.dismiss();begin(id,secret);
|
||||
});connect.setContentDescription(L10n.tr("确认连接"));sheet.addView(connect,ui.size(-1,48));
|
||||
ScrollView scroll=new ScrollView(this);scroll.addView(sheet);
|
||||
dialog.setContentView(scroll);Window window=dialog.getWindow();if(window!=null){window.setBackgroundDrawableResource(android.R.color.transparent);window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);window.setDimAmount(.22f);}dialog.show();sizePasswordDialog();password.requestFocus();if(!error.isEmpty())password.setError(error);
|
||||
// This floating dialog uses window-managed IME resizing on all supported APIs.
|
||||
@SuppressWarnings("deprecation") int resizeMode=WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
|
||||
dialog.setContentView(scroll);Window window=dialog.getWindow();if(window!=null){window.setBackgroundDrawableResource(android.R.color.transparent);window.setSoftInputMode(resizeMode);window.setDimAmount(.22f);}dialog.show();sizePasswordDialog();password.requestFocus();if(!error.isEmpty())password.setError(error);
|
||||
dialog.setOnDismissListener(d->{password.setText("");passwordDialog=null;});
|
||||
}
|
||||
private void sizePasswordDialog(){
|
||||
@@ -715,6 +722,8 @@ public final class MainActivity extends Activity implements NativeSession.Listen
|
||||
private void navigateBack(){if(backAction==null)return;navigatingBack=true;try{backAction.run();}finally{navigatingBack=false;}}
|
||||
private void back(){if(controls!=null&&controls.closeKeyboard())return;pageHost.finish();if(session!=null){if(ready)confirmDisconnect();else end("");}else if(backAction!=null)navigateBack();else finish();}
|
||||
@Override public void onWindowFocusChanged(boolean focus){super.onWindowFocusChanged(focus);if(!focus)releaseKeys();else applySystemBars(ready);}
|
||||
// API 26–32 use this callback; API 33+ registers OnBackInvokedCallback in onCreate.
|
||||
@SuppressWarnings("deprecation")
|
||||
@android.annotation.SuppressLint("GestureBackNavigation") @Override public void onBackPressed(){back();}
|
||||
@Override public void onConfigurationChanged(Configuration config){
|
||||
super.onConfigurationChanged(config);
|
||||
|
||||
@@ -90,6 +90,8 @@ final class MobileUi {
|
||||
}
|
||||
@Override public void setAlpha(int alpha) { bitmapPaint.setAlpha(alpha);invalidateSelf(); }
|
||||
@Override public void setColorFilter(ColorFilter filter) { bitmapPaint.setColorFilter(filter);invalidateSelf(); }
|
||||
// Drawable still requires this abstract method, including on API 26.
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public int getOpacity() { return PixelFormat.TRANSLUCENT; }
|
||||
}
|
||||
@android.annotation.SuppressLint("ViewConstructor") // Programmatic icon primitive, not inflated from XML.
|
||||
|
||||
Reference in New Issue
Block a user