Search in sources :

Example 96 with Toolbar

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();
}
Also used : SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 97 with Toolbar

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();
                    }
                }
            });
        }
    });
}
Also used : Window(android.view.Window) SkuDetails(me.ccrama.redditslide.util.billing.SkuDetails) AlertDialog(androidx.appcompat.app.AlertDialog) Purchase(me.ccrama.redditslide.util.billing.Purchase) Slider(com.rey.material.widget.Slider) IabResult(me.ccrama.redditslide.util.billing.IabResult) TextView(android.widget.TextView) View(android.view.View) IabHelper(me.ccrama.redditslide.util.billing.IabHelper) TextView(android.widget.TextView) Inventory(me.ccrama.redditslide.util.billing.Inventory) Toolbar(androidx.appcompat.widget.Toolbar)

Example 98 with Toolbar

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();
    });
}
Also used : Window(android.view.Window) ChoosemainBinding(me.ccrama.redditslide.databinding.ChoosemainBinding) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) LineColorPicker(uz.shift.colorpicker.LineColorPicker) Toolbar(androidx.appcompat.widget.Toolbar)

Example 99 with Toolbar

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);
        }
    });
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) MenuItem(android.view.MenuItem) Intent(android.content.Intent) Cursor(android.database.Cursor) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) ListView(android.widget.ListView) Repo(org.fdroid.fdroid.data.Repo) AdapterView(android.widget.AdapterView) Toolbar(androidx.appcompat.widget.Toolbar) MaterialToolbar(com.google.android.material.appbar.MaterialToolbar)

Example 100 with Toolbar

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();
}
Also used : Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

Toolbar (androidx.appcompat.widget.Toolbar)271 View (android.view.View)110 TextView (android.widget.TextView)55 RecyclerView (androidx.recyclerview.widget.RecyclerView)44 Bundle (android.os.Bundle)42 NonNull (androidx.annotation.NonNull)36 Intent (android.content.Intent)34 Fragment (androidx.fragment.app.Fragment)32 ActionBar (androidx.appcompat.app.ActionBar)29 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)29 Nullable (androidx.annotation.Nullable)28 BarPainter (com.xabber.android.ui.color.BarPainter)26 R (org.thoughtcrime.securesms.R)26 ViewGroup (android.view.ViewGroup)25 Context (android.content.Context)24 EditText (android.widget.EditText)22 MenuItem (android.view.MenuItem)21 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)20 Navigation (androidx.navigation.Navigation)20 Drawable (android.graphics.drawable.Drawable)18