1717
1818import androidx .annotation .Nullable ;
1919
20- import static android .content .Intent .ACTION_INSTALL_PACKAGE ;
21- import static android .content .Intent .FLAG_GRANT_READ_URI_PERMISSION ;
2220import static com .oasisfeng .nevo .decorators .wechat .WeChatDecorator .WECHAT_PACKAGE ;
21+ import static java .util .Objects .requireNonNull ;
2322
2423/**
2524 * 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 {
6968 preference_extension .setSelectable (! android_auto_installed );
7069 preference_extension .setSummary (android_auto_installed ? R .string .pref_extension_summary_installed
7170 : 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 );
7372
7473 @ SuppressWarnings ("deprecation" ) final Preference preference_version = findPreference (getString (R .string .pref_version ));
7574 try {
@@ -81,7 +80,7 @@ public class WeChatDecoratorSettingsActivity extends PreferenceActivity {
8180 preference_extension .setEnabled (true );
8281 preference_extension .setSelectable (true );
8382 preference_extension .setSummary (R .string .pref_extension_summary );
84- preference_extension .setOnPreferenceClickListener (this ::installExtension );
83+ preference_extension .setOnPreferenceClickListener (this ::redirectToExtensionPageOnline );
8584 }
8685 return true ;
8786 });
@@ -90,7 +89,7 @@ public class WeChatDecoratorSettingsActivity extends PreferenceActivity {
9089 private boolean installNevolution (final @ SuppressWarnings ("unused" ) Preference preference ) {
9190 try {
9291 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
9493 return true ;
9594 }
9695
@@ -105,13 +104,15 @@ private boolean activate(final @SuppressWarnings("unused") Preference preference
105104 return true ;
106105 }
107106
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+ }
115116 return true ;
116117 }
117118
0 commit comments