Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityAbout.java
Show All 11 Lines | BusTO - Arrival times for Turin public transports. | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino; | package it.reyboz.bustorino; | ||||
import android.content.Intent; | |||||
import android.net.Uri; | |||||
import android.util.Log; | import android.util.Log; | ||||
import androidx.appcompat.widget.Toolbar; | import androidx.appcompat.widget.Toolbar; | ||||
import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
import android.text.Html; | import android.text.Html; | ||||
import android.text.Spanned; | import android.text.Spanned; | ||||
import android.text.method.LinkMovementMethod; | import android.text.method.LinkMovementMethod; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.view.MenuItem; | import android.view.MenuItem; | ||||
import android.view.View; | |||||
import android.widget.Button; | |||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import android.widget.Toast; | |||||
import it.reyboz.bustorino.middleware.BarcodeScanUtils; | |||||
public class ActivityAbout extends AppCompatActivity { | public class ActivityAbout extends AppCompatActivity { | ||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setContentView(R.layout.activity_about); | setContentView(R.layout.activity_about); | ||||
Spanned htmlText = Html.fromHtml(getResources().getString( | Spanned htmlText = Html.fromHtml(getResources().getString( | ||||
R.string.about_history)); | R.string.about_history)); | ||||
TextView aboutTextView = (TextView) findViewById(R.id.aboutTextView); | TextView aboutTextView = findViewById(R.id.aboutTextView); | ||||
assert aboutTextView != null; | assert aboutTextView != null; | ||||
aboutTextView.setText(htmlText); | aboutTextView.setText(htmlText); | ||||
aboutTextView.setMovementMethod(LinkMovementMethod.getInstance()); | aboutTextView.setMovementMethod(LinkMovementMethod.getInstance()); | ||||
Toolbar mToolbar = findViewById(R.id.default_toolbar); | Toolbar mToolbar = findViewById(R.id.default_toolbar); | ||||
setSupportActionBar(mToolbar); | setSupportActionBar(mToolbar); | ||||
if (getSupportActionBar()!=null) | if (getSupportActionBar()!=null) | ||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||||
TextView versionText = findViewById(R.id.versionTextView); | TextView versionText = findViewById(R.id.versionTextView); | ||||
Log.d("BusTO About", "The version text view is: "+versionText); | Log.d("BusTO About", "The version text view is: "+versionText); | ||||
versionText.setText(getResources().getText(R.string.app_version)+": "+BuildConfig.VERSION_NAME); | versionText.setText(getResources().getText(R.string.app_version)+": "+BuildConfig.VERSION_NAME); | ||||
Button openTelegramButton = findViewById(R.id.openTelegramButton); | |||||
openTelegramButton.setOnClickListener(view -> { | |||||
Intent trueIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("tg://resolve?domain=busto_fdroid")); | |||||
if(BarcodeScanUtils.checkTargetPackageExists(this, trueIntent)) | |||||
startActivity(trueIntent); | |||||
else{ | |||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/busto_fdroid")); | |||||
startActivity(intent); | |||||
// Toast.makeText(this, "Install Telegram and retry", Toast.LENGTH_SHORT).show(); | |||||
} | |||||
}); | |||||
} | } | ||||
@Override | @Override | ||||
public boolean onOptionsItemSelected(MenuItem item) { | public boolean onOptionsItemSelected(MenuItem item) { | ||||
// Respond to the action bar's Up/Home button | // Respond to the action bar's Up/Home button | ||||
if (item.getItemId() == android.R.id.home) {//NavUtils.navigateUpFromSameTask(this); | if (item.getItemId() == android.R.id.home) {//NavUtils.navigateUpFromSameTask(this); | ||||
onBackPressed(); | onBackPressed(); | ||||
return true; | return true; | ||||
} | } | ||||
return super.onOptionsItemSelected(item); | return super.onOptionsItemSelected(item); | ||||
} | } | ||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register