Search in sources :

Example 1 with FeaturesViewAdapter

use of com.owncloud.android.ui.adapter.FeaturesViewAdapter in project android by nextcloud.

the class WhatsNewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.whats_new_activity);
    int fontColor = getResources().getColor(R.color.login_text_color);
    mProgress = findViewById(R.id.progressIndicator);
    mPager = findViewById(R.id.contentPanel);
    String[] urls = getResources().getStringArray(R.array.whatsnew_urls);
    boolean showWebView = urls.length > 0;
    if (showWebView) {
        FeaturesWebViewAdapter featuresWebViewAdapter = new FeaturesWebViewAdapter(getSupportFragmentManager(), urls);
        mProgress.setNumberOfSteps(featuresWebViewAdapter.getCount());
        mPager.setAdapter(featuresWebViewAdapter);
    } else {
        FeaturesViewAdapter featuresViewAdapter = new FeaturesViewAdapter(getSupportFragmentManager(), onboarding.getWhatsNew());
        mProgress.setNumberOfSteps(featuresViewAdapter.getCount());
        mPager.setAdapter(featuresViewAdapter);
    }
    mPager.addOnPageChangeListener(this);
    mForwardFinishButton = findViewById(R.id.forward);
    ThemeButtonUtils.colorImageButton(mForwardFinishButton, fontColor);
    mForwardFinishButton.setOnClickListener(view -> {
        if (mProgress.hasNextStep()) {
            mPager.setCurrentItem(mPager.getCurrentItem() + 1, true);
            mProgress.animateToStep(mPager.getCurrentItem() + 1);
        } else {
            onFinish();
            finish();
        }
        updateNextButtonIfNeeded();
    });
    mForwardFinishButton.setBackground(null);
    mSkipButton = findViewById(R.id.skip);
    mSkipButton.setTextColor(fontColor);
    mSkipButton.setOnClickListener(view -> {
        onFinish();
        finish();
    });
    TextView tv = findViewById(R.id.welcomeText);
    if (showWebView) {
        tv.setText(R.string.app_name);
    } else {
        tv.setText(String.format(getString(R.string.whats_new_title), appInfo.getVersionName()));
    }
    updateNextButtonIfNeeded();
}
Also used : FeaturesViewAdapter(com.owncloud.android.ui.adapter.FeaturesViewAdapter) FeaturesWebViewAdapter(com.owncloud.android.ui.adapter.FeaturesWebViewAdapter) TextView(android.widget.TextView)

Example 2 with FeaturesViewAdapter

use of com.owncloud.android.ui.adapter.FeaturesViewAdapter in project android by nextcloud.

the class FirstRunActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    enableAccountHandling = false;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.first_run_activity);
    boolean isProviderOrOwnInstallationVisible = getResources().getBoolean(R.bool.show_provider_or_own_installation);
    setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
    Button loginButton = findViewById(R.id.login);
    loginButton.setBackgroundColor(getResources().getColor(R.color.login_btn_tint));
    loginButton.setTextColor(getResources().getColor(R.color.primary));
    loginButton.setOnClickListener(v -> {
        if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
            Intent authenticatorActivityIntent = new Intent(this, AuthenticatorActivity.class);
            authenticatorActivityIntent.putExtra(AuthenticatorActivity.EXTRA_USE_PROVIDER_AS_WEBLOGIN, false);
            startActivityForResult(authenticatorActivityIntent, FIRST_RUN_RESULT_CODE);
        } else {
            finish();
        }
    });
    Button providerButton = findViewById(R.id.signup);
    providerButton.setBackgroundColor(getResources().getColor(R.color.primary));
    providerButton.setTextColor(getResources().getColor(R.color.login_text_color));
    providerButton.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
    providerButton.setOnClickListener(v -> {
        Intent authenticatorActivityIntent = new Intent(this, AuthenticatorActivity.class);
        authenticatorActivityIntent.putExtra(AuthenticatorActivity.EXTRA_USE_PROVIDER_AS_WEBLOGIN, true);
        if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
            startActivityForResult(authenticatorActivityIntent, FIRST_RUN_RESULT_CODE);
        } else {
            authenticatorActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(authenticatorActivityIntent);
        }
    });
    TextView hostOwnServerTextView = findViewById(R.id.host_own_server);
    hostOwnServerTextView.setTextColor(getResources().getColor(R.color.login_text_color));
    hostOwnServerTextView.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
    if (!isProviderOrOwnInstallationVisible) {
        hostOwnServerTextView.setOnClickListener(v -> onHostYourOwnServerClick());
    }
    progressIndicator = findViewById(R.id.progressIndicator);
    ViewPager viewPager = findViewById(R.id.contentPanel);
    // Sometimes, accounts are not deleted when you uninstall the application so we'll do it now
    if (onboarding.isFirstRun()) {
        userAccountManager.removeAllAccounts();
    }
    FeaturesViewAdapter featuresViewAdapter = new FeaturesViewAdapter(getSupportFragmentManager(), getFirstRun());
    progressIndicator.setNumberOfSteps(featuresViewAdapter.getCount());
    viewPager.setAdapter(featuresViewAdapter);
    viewPager.addOnPageChangeListener(this);
}
Also used : FeaturesViewAdapter(com.owncloud.android.ui.adapter.FeaturesViewAdapter) Button(android.widget.Button) Intent(android.content.Intent) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager)

Aggregations

TextView (android.widget.TextView)2 FeaturesViewAdapter (com.owncloud.android.ui.adapter.FeaturesViewAdapter)2 Intent (android.content.Intent)1 Button (android.widget.Button)1 ViewPager (androidx.viewpager.widget.ViewPager)1 FeaturesWebViewAdapter (com.owncloud.android.ui.adapter.FeaturesWebViewAdapter)1