You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
etesync-android/app/src/main/java/at/bitfire/davdroid/MainActivity.java

82 lines
2.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import at.bitfire.davdroid.syncadapter.AddAccountActivity;
import at.bitfire.davdroid.syncadapter.SettingsActivity;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tvWorkaround = (TextView)findViewById(R.id.text_workaround);
if (fromPlayStore()) {
tvWorkaround.setVisibility(View.VISIBLE);
tvWorkaround.setText(Html.fromHtml(getString(R.string.html_main_workaround)));
tvWorkaround.setMovementMethod(LinkMovementMethod.getInstance());
}
TextView tvInfo = (TextView)findViewById(R.id.text_info);
tvInfo.setText(Html.fromHtml(getString(R.string.html_main_info, Constants.APP_VERSION)));
tvInfo.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity, menu);
return true;
}
public void addAccount(MenuItem item) {
startActivity(new Intent(this, AddAccountActivity.class));
}
public void showSettings(MenuItem item) {
startActivity(new Intent(this, SettingsActivity.class));
}
public void showSyncSettings(MenuItem item) {
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
startActivity(intent);
}
public void showWebsite(MenuItem item) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(Constants.WEB_URL_HELP + "&pk_kwd=main-activity"));
startActivity(intent);
}
private boolean fromPlayStore() {
try {
return "com.android.vending".equals(getPackageManager().getInstallerPackageName("at.bitfire.davdroid"));
} catch(IllegalArgumentException e) {
return false;
}
}
}