use of androidx.appcompat.widget.Toolbar in project Slide by ccrama.
the class ReaderMode method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstanceState);
applyColorTheme("");
setContentView(R.layout.activity_reader);
mSubredditColor = getIntent().getExtras().getInt(LinkUtil.EXTRA_COLOR, Palette.getDefaultColor());
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
setupAppBar(R.id.toolbar, "", true, mSubredditColor, R.id.appbar);
if (getIntent().hasExtra("url")) {
url = getIntent().getExtras().getString(LinkUtil.EXTRA_URL, "");
((Toolbar) findViewById(R.id.toolbar)).setTitle(url);
}
v = (SpoilerRobotoTextView) findViewById(R.id.body);
final SwipeRefreshLayout mSwipeRefreshLayout = ((SwipeRefreshLayout) ReaderMode.this.findViewById(R.id.refresh));
mSwipeRefreshLayout.setColorSchemeColors(Palette.getColors("", this));
// If we use 'findViewById(R.id.header).getMeasuredHeight()', 0 is always returned.
// So, we estimate the height of the header in dp.
mSwipeRefreshLayout.setProgressViewOffset(false, Constants.SINGLE_HEADER_VIEW_OFFSET - Constants.PTR_OFFSET_TOP, Constants.SINGLE_HEADER_VIEW_OFFSET + Constants.PTR_OFFSET_BOTTOM);
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});
new AsyncGetArticle().execute();
}
use of androidx.appcompat.widget.Toolbar in project Slide by ccrama.
the class DonateView method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
disableSwipeBackLayout();
super.onCreate(savedInstanceState);
applyColorTheme();
setContentView(R.layout.activity_donate);
Toolbar t = (Toolbar) findViewById(R.id.toolbar);
t.setTitle(R.string.settings_title_support);
setRecentBar(getString(R.string.settings_title_support), Palette.getDarkerColor(ContextCompat.getColor(DonateView.this, R.color.md_light_green_500)));
setSupportActionBar(t);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Palette.getDarkerColor(ContextCompat.getColor(DonateView.this, R.color.md_light_green_500)));
if (SettingValues.colorNavBar) {
window.setNavigationBarColor(Palette.getDarkerColor(ContextCompat.getColor(DonateView.this, R.color.md_light_green_500)));
}
}
final Slider slider = (Slider) findViewById(R.id.slider_sl_discrete);
slider.setValue(4, false);
final TextView ads = (TextView) findViewById(R.id.ads);
final TextView hours = (TextView) findViewById(R.id.hours);
final TextView money = (TextView) findViewById(R.id.money);
slider.setOnPositionChangeListener(new Slider.OnPositionChangeListener() {
@Override
public void onPositionChanged(Slider view, boolean fromUser, float oldPos, float newPos, int oldValue, int newValue) {
ads.setText(" " + newValue * 330 + " ");
hours.setText(" " + (double) newValue / 10 + " ");
money.setText("$" + newValue);
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ads.setText(" " + 4 * 330 + " ");
hours.setText(" " + (double) 4 / 10 + " ");
money.setText("$" + 4);
findViewById(R.id.donate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String name = "";
if (Authentication.isLoggedIn) {
name = Authentication.name;
}
if (Reddit.mHelper != null) {
Reddit.mHelper.flagEndAsync();
}
Reddit.mHelper.queryInventoryAsync(new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
if (inv != null) {
SkuDetails donation = inv.getSkuDetails("donation_" + slider.getValue());
LogUtil.v("Trying to get donation_" + slider.getValue());
if (donation != null) {
LogUtil.v("Not null");
Reddit.mHelper.launchPurchaseFlow(DonateView.this, donation.getSku(), 4000, new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
if (result.isSuccess()) {
new AlertDialog.Builder(DonateView.this).setTitle("Thank you!").setMessage("Thank you very much for your support :)").setPositiveButton(R.string.btn_done, null).show();
} else {
new AlertDialog.Builder(DonateView.this).setTitle(R.string.err_something_wrong).setMessage("Please try again soon! Sorry for the inconvenience.").setPositiveButton(android.R.string.ok, null).show();
}
}
});
} else {
LogUtil.v("Null");
}
} else {
new AlertDialog.Builder(DonateView.this).setTitle(R.string.err_something_wrong).setMessage("Please try again soon! Sorry for the inconvenience.").setPositiveButton(android.R.string.ok, null).show();
}
}
});
}
});
}
use of androidx.appcompat.widget.Toolbar in project Slide by ccrama.
the class SettingsThemeFragment method setupSettingsThemePrimary.
private void setupSettingsThemePrimary() {
final LinearLayout mainTheme = (LinearLayout) context.findViewById(R.id.settings_theme_main);
mainTheme.setOnClickListener(v -> {
final ChoosemainBinding choosemainBinding = ChoosemainBinding.inflate(context.getLayoutInflater());
final TextView title = choosemainBinding.title;
title.setBackgroundColor(Palette.getDefaultColor());
final LineColorPicker colorPicker = choosemainBinding.picker;
final LineColorPicker colorPicker2 = choosemainBinding.picker2;
colorPicker.setColors(ColorPreferences.getBaseColors(context));
int currentColor = Palette.getDefaultColor();
for (int i : colorPicker.getColors()) {
for (int i2 : ColorPreferences.getColors(context.getBaseContext(), i)) {
if (i2 == currentColor) {
colorPicker.setSelectedColor(i);
colorPicker2.setColors(ColorPreferences.getColors(context.getBaseContext(), i));
colorPicker2.setSelectedColor(i2);
break;
}
}
}
colorPicker.setOnColorChangedListener(c -> {
SettingsThemeFragment.changed = true;
colorPicker2.setColors(ColorPreferences.getColors(context.getBaseContext(), c));
colorPicker2.setSelectedColor(c);
});
colorPicker2.setOnColorChangedListener(i -> {
SettingsThemeFragment.changed = true;
title.setBackgroundColor(colorPicker2.getColor());
final Toolbar toolbar = (Toolbar) context.findViewById(R.id.toolbar);
if (toolbar != null)
toolbar.setBackgroundColor(colorPicker2.getColor());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = context.getWindow();
window.setStatusBarColor(Palette.getDarkerColor(colorPicker2.getColor()));
}
context.setRecentBar(context.getString(R.string.title_theme_settings), colorPicker2.getColor());
});
choosemainBinding.ok.setOnClickListener(v1 -> {
if (SettingValues.colorIcon) {
setComponentState(ColorPreferences.getIconName(context, Reddit.colors.getInt("DEFAULTCOLOR", 0)), PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
setComponentState(ColorPreferences.getIconName(context, colorPicker2.getColor()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
Reddit.colors.edit().putInt("DEFAULTCOLOR", colorPicker2.getColor()).apply();
context.restartActivity();
});
new AlertDialog.Builder(context).setView(choosemainBinding.getRoot()).show();
});
}
use of androidx.appcompat.widget.Toolbar in project fdroidclient by f-droid.
the class ManageReposActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
FDroidApp fdroidApp = (FDroidApp) getApplication();
fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.repo_list_activity);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.action_add_repo) {
showAddRepo();
return true;
}
return false;
}
});
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent upIntent = NavUtils.getParentActivityIntent(ManageReposActivity.this);
if (NavUtils.shouldUpRecreateTask(ManageReposActivity.this, upIntent) || isTaskRoot()) {
TaskStackBuilder.create(ManageReposActivity.this).addNextIntentWithParentStack(upIntent).startActivities();
} else {
NavUtils.navigateUpTo(ManageReposActivity.this, upIntent);
}
}
});
final ListView repoList = (ListView) findViewById(R.id.list);
repoAdapter = new RepoAdapter(this);
repoAdapter.setEnabledListener(this);
repoList.setAdapter(repoAdapter);
repoList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Repo repo = new Repo((Cursor) repoList.getItemAtPosition(position));
editRepo(repo);
}
});
}
use of androidx.appcompat.widget.Toolbar in project sdk_demo_app_android by zendesk.
the class CreateProfileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_profile);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
bindViews();
storage = getStorage(getApplicationContext());
uri = storage.getUserProfile().getUri();
}
Aggregations