17
17
18
18
import androidx .annotation .Nullable ;
19
19
20
- import static android .content .Intent .ACTION_INSTALL_PACKAGE ;
21
- import static android .content .Intent .FLAG_GRANT_READ_URI_PERMISSION ;
22
20
import static com .oasisfeng .nevo .decorators .wechat .WeChatDecorator .WECHAT_PACKAGE ;
21
+ import static java .util .Objects .requireNonNull ;
23
22
24
23
/**
25
24
* Entry activity. Some ROMs (including Samsung, OnePlus) require a launcher activity to allow any component being bound by other app.
@@ -69,7 +68,7 @@ public class WeChatDecoratorSettingsActivity extends PreferenceActivity {
69
68
preference_extension .setSelectable (! android_auto_installed );
70
69
preference_extension .setSummary (android_auto_installed ? R .string .pref_extension_summary_installed
71
70
: isPlayStoreSystemApp () ? R .string .pref_extension_summary_auto : R .string .pref_extension_summary );
72
- preference_extension .setOnPreferenceClickListener (android_auto_installed ? null : this ::installExtension );
71
+ preference_extension .setOnPreferenceClickListener (android_auto_installed ? null : this ::redirectToExtensionPageOnline );
73
72
74
73
@ SuppressWarnings ("deprecation" ) final Preference preference_version = findPreference (getString (R .string .pref_version ));
75
74
try {
@@ -81,7 +80,7 @@ public class WeChatDecoratorSettingsActivity extends PreferenceActivity {
81
80
preference_extension .setEnabled (true );
82
81
preference_extension .setSelectable (true );
83
82
preference_extension .setSummary (R .string .pref_extension_summary );
84
- preference_extension .setOnPreferenceClickListener (this ::installExtension );
83
+ preference_extension .setOnPreferenceClickListener (this ::redirectToExtensionPageOnline );
85
84
}
86
85
return true ;
87
86
});
@@ -90,7 +89,7 @@ public class WeChatDecoratorSettingsActivity extends PreferenceActivity {
90
89
private boolean installNevolution (final @ SuppressWarnings ("unused" ) Preference preference ) {
91
90
try {
92
91
startActivity (new Intent (Intent .ACTION_VIEW , Uri .parse (APP_MARKET_PREFIX + NEVOLUTION_PACKAGE )));
93
- } catch (final ActivityNotFoundException e ) {} // TODO: Landing web page
92
+ } catch (final ActivityNotFoundException ignored ) {} // TODO: Landing web page
94
93
return true ;
95
94
}
96
95
@@ -105,13 +104,15 @@ private boolean activate(final @SuppressWarnings("unused") Preference preference
105
104
return true ;
106
105
}
107
106
108
- private boolean installExtension (final @ SuppressWarnings ("unused" ) Preference preference ) {
109
- if (mVersionClickCount > 0 && isPlayStoreSystemApp ())
110
- startActivity (new Intent (Intent .ACTION_VIEW , Uri .parse (APP_MARKET_PREFIX + ANDROID_AUTO_PACKAGE )).setPackage (PLAY_STORE_PACKAGE ));
111
- else try {
112
- final String authority = getPackageManager ().getProviderInfo (new ComponentName (this , AssetFileProvider .class ), 0 ).authority ;
113
- startActivity (new Intent (ACTION_INSTALL_PACKAGE , Uri .parse ("content://" + authority + "/dummy-auto.apk" )).addFlags (FLAG_GRANT_READ_URI_PERMISSION ));
114
- } catch (final PackageManager .NameNotFoundException | ActivityNotFoundException ignored ) {} // Should never happen
107
+ private boolean redirectToExtensionPageOnline (@ SuppressWarnings ("unused" ) final Preference preference ) {
108
+ final Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://github.com/Nevolution/decorator-wechat" ));
109
+ try {
110
+ startActivity (intent );
111
+ } catch (final ActivityNotFoundException e ) {
112
+ try {
113
+ startActivity (intent .setData (requireNonNull (intent .getData ()).buildUpon ().scheme ("http" ).build ()));
114
+ } catch (final ActivityNotFoundException ignored ) {}
115
+ }
115
116
return true ;
116
117
}
117
118
0 commit comments