Search in sources :

Example 1 with DialogContent

use of com.github.moko256.twitlatte.view.DialogContent in project twicalico by moko256.

the class OAuthActivity method onStartMastodonAuthClick.

public void onStartMastodonAuthClick(View view) {
    initType(CLIENT_TYPE_MASTODON);
    isUrlEnterDialogShown = true;
    compositeDisposable.add(EditTextsDialogShowerKt.createEditTextsDialog(this, getString(R.string.instance_domain), true, (dialog) -> isUrlEnterDialogShown = false, new DialogContent("e.g. mastodon.social", lastUrl, EditorInfo.TYPE_TEXT_VARIATION_URI, url -> {
        lastUrl = url;
        return Unit.INSTANCE;
    })).subscribe(() -> {
        isUrlEnterDialogShown = false;
        startAuthAndOpenDialogIfNeeded(lastUrl);
    }));
}
Also used : OAuthModelImpl(com.github.moko256.twitlatte.model.impl.OAuthModelImpl) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) DialogContent(com.github.moko256.twitlatte.view.DialogContent) Intent(android.content.Intent) CLIENT_TYPE_TWITTER(com.github.moko256.latte.client.twitter.TwitterApiClientImplKt.CLIENT_TYPE_TWITTER) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) AppCustomTabsKt(com.github.moko256.twitlatte.intent.AppCustomTabsKt) OAuthModel(com.github.moko256.twitlatte.model.base.OAuthModel) MenuItem(android.view.MenuItem) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) Toast(android.widget.Toast) Menu(android.view.Menu) TokenSQLiteOpenHelper(com.github.moko256.twitlatte.database.TokenSQLiteOpenHelper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) CLIENT_TYPE_NOTHING(com.github.moko256.latte.client.base.ApiClientKt.CLIENT_TYPE_NOTHING) ContextCompat(androidx.core.content.ContextCompat) OAuthApiClientGeneratorKt(com.github.moko256.twitlatte.api.OAuthApiClientGeneratorKt) EditTextsDialogShowerKt(com.github.moko256.twitlatte.view.EditTextsDialogShowerKt) KEY_ACCOUNT_KEY(com.github.moko256.twitlatte.repository.PreferenceRepositoryKt.KEY_ACCOUNT_KEY) AccessToken(com.github.moko256.latte.client.base.entity.AccessToken) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Unit(kotlin.Unit) EditorInfo(android.view.inputmethod.EditorInfo) OkHttpHolderKt(com.github.moko256.twitlatte.net.OkHttpHolderKt) CLIENT_TYPE_MASTODON(com.github.moko256.latte.client.mastodon.MastodonApiClientImplKt.CLIENT_TYPE_MASTODON) DialogContent(com.github.moko256.twitlatte.view.DialogContent)

Example 2 with DialogContent

use of com.github.moko256.twitlatte.view.DialogContent in project twicalico by moko256.

the class OAuthActivity method startAuthAndOpenDialogIfNeeded.

private void startAuthAndOpenDialogIfNeeded(@NonNull String url) {
    String callbackUrl;
    if (requirePin) {
        showPinDialog();
        callbackUrl = null;
    } else {
        callbackUrl = getString(R.string.app_name) + "://OAuthActivity";
    }
    if (useAnotherConsumerToken && authClientType == CLIENT_TYPE_TWITTER) {
        compositeDisposable.add(EditTextsDialogShowerKt.createEditTextsDialog(this, "Consumer key/secret", true, null, new DialogContent("consumer key", enteringConsumerKey, EditorInfo.TYPE_CLASS_TEXT, ck -> {
            enteringConsumerKey = ck;
            return Unit.INSTANCE;
        }), new DialogContent("consumer secret", enteringConsumerSecret, EditorInfo.TYPE_CLASS_TEXT, cs -> {
            enteringConsumerSecret = cs;
            return Unit.INSTANCE;
        })).subscribe(() -> startAuth(url, callbackUrl, enteringConsumerKey, enteringConsumerSecret)));
    } else {
        startAuth(url, callbackUrl, null, null);
    }
}
Also used : OAuthModelImpl(com.github.moko256.twitlatte.model.impl.OAuthModelImpl) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) DialogContent(com.github.moko256.twitlatte.view.DialogContent) Intent(android.content.Intent) CLIENT_TYPE_TWITTER(com.github.moko256.latte.client.twitter.TwitterApiClientImplKt.CLIENT_TYPE_TWITTER) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) AppCustomTabsKt(com.github.moko256.twitlatte.intent.AppCustomTabsKt) OAuthModel(com.github.moko256.twitlatte.model.base.OAuthModel) MenuItem(android.view.MenuItem) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) Toast(android.widget.Toast) Menu(android.view.Menu) TokenSQLiteOpenHelper(com.github.moko256.twitlatte.database.TokenSQLiteOpenHelper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) CLIENT_TYPE_NOTHING(com.github.moko256.latte.client.base.ApiClientKt.CLIENT_TYPE_NOTHING) ContextCompat(androidx.core.content.ContextCompat) OAuthApiClientGeneratorKt(com.github.moko256.twitlatte.api.OAuthApiClientGeneratorKt) EditTextsDialogShowerKt(com.github.moko256.twitlatte.view.EditTextsDialogShowerKt) KEY_ACCOUNT_KEY(com.github.moko256.twitlatte.repository.PreferenceRepositoryKt.KEY_ACCOUNT_KEY) AccessToken(com.github.moko256.latte.client.base.entity.AccessToken) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) Unit(kotlin.Unit) EditorInfo(android.view.inputmethod.EditorInfo) OkHttpHolderKt(com.github.moko256.twitlatte.net.OkHttpHolderKt) CLIENT_TYPE_MASTODON(com.github.moko256.latte.client.mastodon.MastodonApiClientImplKt.CLIENT_TYPE_MASTODON) DialogContent(com.github.moko256.twitlatte.view.DialogContent)

Aggregations

Intent (android.content.Intent)2 Uri (android.net.Uri)2 Bundle (android.os.Bundle)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 EditorInfo (android.view.inputmethod.EditorInfo)2 Toast (android.widget.Toast)2 NonNull (androidx.annotation.NonNull)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 CustomTabsIntent (androidx.browser.customtabs.CustomTabsIntent)2 ContextCompat (androidx.core.content.ContextCompat)2 CLIENT_TYPE_NOTHING (com.github.moko256.latte.client.base.ApiClientKt.CLIENT_TYPE_NOTHING)2 AccessToken (com.github.moko256.latte.client.base.entity.AccessToken)2 CLIENT_TYPE_MASTODON (com.github.moko256.latte.client.mastodon.MastodonApiClientImplKt.CLIENT_TYPE_MASTODON)2 CLIENT_TYPE_TWITTER (com.github.moko256.latte.client.twitter.TwitterApiClientImplKt.CLIENT_TYPE_TWITTER)2 OAuthApiClientGeneratorKt (com.github.moko256.twitlatte.api.OAuthApiClientGeneratorKt)2 TokenSQLiteOpenHelper (com.github.moko256.twitlatte.database.TokenSQLiteOpenHelper)2 AppCustomTabsKt (com.github.moko256.twitlatte.intent.AppCustomTabsKt)2 OAuthModel (com.github.moko256.twitlatte.model.base.OAuthModel)2