Skip to content

Commit

Permalink
Convert to kt
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 3, 2023
1 parent 2fccced commit d987e95
Showing 1 changed file with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
package com.owncloud.android.authentication;
package com.owncloud.android.authentication

import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import com.nextcloud.client.di.Injectable
import com.owncloud.android.R

import com.nextcloud.client.di.Injectable;
import com.owncloud.android.R;
class DeepLinkLoginActivity : AuthenticatorActivity(), Injectable {

public class DeepLinkLoginActivity extends AuthenticatorActivity implements Injectable {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (!getResources().getBoolean(R.bool.multiaccount_support) &&
accountManager.getAccounts().length == 1) {
Toast.makeText(this, R.string.no_mutliple_accounts_allowed, Toast.LENGTH_LONG).show();
return;
if (!resources.getBoolean(R.bool.multiaccount_support) &&
accountManager.accounts.size == 1
) {
Toast.makeText(this, R.string.no_mutliple_accounts_allowed, Toast.LENGTH_LONG).show()
return
}

setContentView(R.layout.deep_link_login);

Uri data = getIntent().getData();
setContentView(R.layout.deep_link_login)

if (data != null) {
intent.data?.let {
try {
String prefix = getString(R.string.login_data_own_scheme) + PROTOCOL_SUFFIX + "login/";
LoginUrlInfo loginUrlInfo = parseLoginDataUrl(prefix, data.toString());

TextView loginText = findViewById(R.id.loginInfo);
loginText.setText(String.format(getString(R.string.direct_login_text), loginUrlInfo.username,
loginUrlInfo.serverAddress));
} catch (IllegalArgumentException e) {
Toast.makeText(this, R.string.direct_login_failed, Toast.LENGTH_LONG).show();
val prefix = getString(R.string.login_data_own_scheme) + PROTOCOL_SUFFIX + "login/"
val loginUrlInfo = parseLoginDataUrl(prefix, it.toString())
val loginText = findViewById<TextView>(R.id.loginInfo)
loginText.text = String.format(
getString(R.string.direct_login_text), loginUrlInfo.username,
loginUrlInfo.serverAddress
)
} catch (e: IllegalArgumentException) {
Toast.makeText(this, R.string.direct_login_failed, Toast.LENGTH_LONG).show()
}
}
}
Expand Down

0 comments on commit d987e95

Please sign in to comment.