Skip to content

Commit

Permalink
Merge c8c4625 into 0985d25
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr authored Jun 25, 2023
2 parents 0985d25 + c8c4625 commit 96e7dc0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdkVersion 29
targetSdkVersion 32
versionCode 4
versionName "2.1_beta_230620"
versionName "2.2_beta_230625"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
android:configChanges="uiMode" />
<activity
android:name=".MainActivity"
android:exported="true"
android:noHistory="true">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
</intent-filter>
</activity>
Expand Down
26 changes: 19 additions & 7 deletions app/src/main/java/com/maary/shareas/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,27 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());

try {
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.startsWith("image/")) {
bitmap = Util.getBitmap(intent, MainActivity.this);
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
bitmap = Util.getBitmap(intent, MainActivity.this);}}
else {
if (ContextCompat.checkSelfPermission(
getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
}
if (wallpaperManager.getWallpaperInfo() == null) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
bitmap = ((BitmapDrawable) wallpaperManager.getDrawable()).getBitmap();
} else {
Toast.makeText(getApplicationContext(), R.string.cannot_getpermission_lacking_permission, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getApplicationContext(), R.string.cannot_get_livewallpaper, Toast.LENGTH_SHORT).show();
}
}
//Parent layout
ConstraintLayout container = findViewById(R.id.container);
//parent layout of bottomAppBar
Expand Down Expand Up @@ -253,7 +268,6 @@ protected void onCreate(Bundle savedInstanceState) {

});


//如果 SharedPreferences 里没有关于是否保存图像历史的偏好就询问是否保存
if (!sharedPreferences.contains(getString(R.string.enabled_history_key))) {
AlertDialog dialog_history = saveHistoryDialog();
Expand Down Expand Up @@ -578,10 +592,8 @@ public void onBlurFailed(Throwable error) {
}));

bottomAppBarContainer.bringToFront();
}
}
} catch (Exception e) {
e.printStackTrace();
} catch (IOException e) {
throw new RuntimeException(e);
}

}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
<string name="apply_to_home">应用到桌面</string>
<string name="wallpaper_setted">壁纸已改变</string>
<string name="gohome">回桌面</string>
<string name="cannot_getpermission_lacking_permission">Wallpaper Tunnel 缺少必要权限,无法获得当前壁纸</string>
<string name="cannot_get_livewallpaper">Wallpaper Tunnel 无法处理动态壁纸</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
<string name="apply_to_home">Apply to Home</string>
<string name="wallpaper_setted">Wallpaper changed.</string>
<string name="gohome">Go Home</string>
<string name="cannot_getpermission_lacking_permission">Wallpaper Tunnel cannot get current wallpaper due to lacking permission.</string>
<string name="cannot_get_livewallpaper">Wallpaper Tunnel cannot process live wallpaper.</string>
</resources>

0 comments on commit 96e7dc0

Please sign in to comment.