Skip to content

Commit

Permalink
Open GitHub release on version click
Browse files Browse the repository at this point in the history
  • Loading branch information
italankin committed Jun 6, 2022
1 parent 2c771a4 commit 90a0cbf
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;

import com.italankin.lnch.BuildConfig;
import com.italankin.lnch.R;
import com.italankin.lnch.feature.home.fragmentresult.SignalFragmentResultContract;
import com.italankin.lnch.feature.settings.base.BasePreferenceFragment;
import com.italankin.lnch.util.IntentUtils;
import com.italankin.lnch.util.PackageUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;

public class SettingsRootFragment extends BasePreferenceFragment {

public static SettingsRootFragment newInstance(String requestKey) {
Expand All @@ -35,6 +35,7 @@ public static SettingsRootFragment newInstance(String requestKey) {
}

private static final String SOURCE_CODE_URL = "https://github.com/italankin/lnch";
private static final String RELEASE_NOTES_FORMAT = "https://github.com/italankin/lnch/releases/tag/%s";

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -97,6 +98,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
});
Preference version = findPreference(R.string.pref_key_version);
version.setTitle(getString(R.string.settings_version, BuildConfig.VERSION_NAME));
version.setOnPreferenceClickListener(preference -> {
String releaseNotesUrl = String.format(RELEASE_NOTES_FORMAT, BuildConfig.VERSION_NAME);
Uri uri = Uri.parse(releaseNotesUrl);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(Intent.createChooser(intent, ""));
return true;
});
Preference sourceCode = findPreference(R.string.pref_key_source_code);
sourceCode.setOnPreferenceClickListener(preference -> {
Uri uri = Uri.parse(SOURCE_CODE_URL);
Expand Down

0 comments on commit 90a0cbf

Please sign in to comment.