anotherim/src/main/java/eu/siacs/conversations/ui/ActionBarActivity.java
2021-01-23 09:25:34 +01:00

36 lines
1 KiB
Java

package eu.siacs.conversations.ui;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
public abstract class ActionBarActivity extends AppCompatActivity {
public static void configureActionBar(ActionBar actionBar) {
configureActionBar(actionBar, true);
}
public static void configureActionBar(ActionBar actionBar, boolean upNavigation) {
if (actionBar != null) {
actionBar.setHomeButtonEnabled(upNavigation);
actionBar.setDisplayHomeAsUpEnabled(upNavigation);
}
}
public void setSupportActionBar(View toolbar) {
super.setSupportActionBar((Toolbar) toolbar);
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
}