/*
* Copyright (c) 2015 Ha Duy Trung
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.hidroh.materialistic;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;
public class AboutActivity extends InjectableActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
//noinspection ConstantConditions
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
String versionName = "";
int versionCode = 0;
try {
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
// do nothing
}
setTextWithLinks(R.id.text_application_info, getString(R.string.application_info_text, versionName, versionCode));
setTextWithLinks(R.id.text_developer_info, getString(R.string.developer_info_text));
setTextWithLinks(R.id.text_libraries, getString(R.string.libraries_text));
setTextWithLinks(R.id.text_license, getString(R.string.license_text));
setTextWithLinks(R.id.text_3rd_party_licenses, getString(R.string.third_party_licenses_text));
setTextWithLinks(R.id.text_privacy_policy, getString(R.string.privacy_policy_text));
}
private void setTextWithLinks(@IdRes int textViewResId, String htmlText) {
AppUtils.setTextWithLinks((TextView) findViewById(textViewResId), AppUtils.fromHtml(htmlText));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}