-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a crash when clicking on the Donate button but there is no brow…
…ser on the device
- Loading branch information
Showing
3 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/src/main/java/io/github/sspanak/tt9/preferences/screens/main/ItemDonate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.sspanak.tt9.preferences.screens.main; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import androidx.preference.Preference; | ||
|
||
import io.github.sspanak.tt9.R; | ||
import io.github.sspanak.tt9.preferences.PreferencesActivity; | ||
import io.github.sspanak.tt9.preferences.items.ItemClickable; | ||
import io.github.sspanak.tt9.util.Logger; | ||
|
||
class ItemDonate extends ItemClickable { | ||
static final String NAME = "donate_link"; | ||
private final PreferencesActivity activity; | ||
|
||
ItemDonate(Preference preference, PreferencesActivity activity) { | ||
super(preference); | ||
this.activity = activity; | ||
} | ||
|
||
public ItemDonate populate() { | ||
if (item != null) { | ||
String appName = activity.getString(R.string.app_name_short); | ||
String url = activity.getString(R.string.donate_url_short); | ||
item.setSummary(activity.getString(R.string.donate_summary, appName, url)); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
protected boolean onClick(Preference p) { | ||
try { | ||
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(activity.getString(R.string.donate_url)))); | ||
return true; | ||
} catch (Exception e) { | ||
Logger.w(getClass().getSimpleName(), "Cannot navigate to the donation page. " + e.getMessage() + " (do you have a browser?)"); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters