Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

odoo社区版安卓APK反编译问题



  • odoo只有企业版才能用apk,没办法只能自己试着反编译试试了,让odooAPK也能使用社区版,这段代码不太理解怎么改,麻烦高手给予指点啊。
    ``
    package com.odoo.mobile;

    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnCancelListener;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.content.IntentFilter;
    import android.graphics.PorterDuff.Mode;
    import android.graphics.drawable.Drawable;
    import android.net.Uri;
    import android.os.Bundle;
    import android.support.design.widget.Snackbar;
    import android.support.v4.content.LocalBroadcastManager;
    import android.support.v7.app.AlertDialog.Builder;
    import android.view.KeyEvent;
    import android.view.LayoutInflater;
    import android.view.MotionEvent;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.View.OnKeyListener;
    import android.view.View.OnTouchListener;
    import android.view.inputmethod.InputMethodManager;
    import android.widget.EditText;
    import android.widget.ProgressBar;
    import android.widget.Toast;
    import com.odoo.mobile.accounts.OdooAccountManager;
    import com.odoo.mobile.accounts.OdooUser;
    import com.odoo.mobile.accounts.manager.AllAccountsActivity;
    import com.odoo.mobile.core.OdooAppCompactActivity;
    import com.odoo.mobile.core.service.OdooIntentService;
    import com.odoo.mobile.core.utils.NetworkUtils;
    import com.odoo.mobile.core.utils.OControlUtils;
    import com.odoo.mobile.core.utils.UserSession;
    import java.util.List;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    public class Login
    extends OdooAppCompactActivity
    implements View.OnClickListener, View.OnKeyListener, View.OnTouchListener
    {
    private EditText edtLogin;
    private EditText edtPassword;
    private EditText edtServerUrl;
    private BroadcastReceiver loginResponseReceiver = new BroadcastReceiver()
    {
    public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
    {
    paramAnonymousContext = paramAnonymousIntent.getExtras();
    paramAnonymousIntent = paramAnonymousContext.getString("service_action");
    if (paramAnonymousContext.containsKey("error_type")) {
    Login.this.handleError(paramAnonymousIntent, paramAnonymousContext);
    }
    int i;
    if (paramAnonymousContext.containsKey("service_response"))
    {
    i = -1;
    switch (paramAnonymousIntent.hashCode())
    {
    }
    }
    for (;;)
    {
    switch (i)
    {
    default:
    return;
    if (paramAnonymousIntent.equals("odoo_version"))
    {
    i = 0;
    continue;
    if (paramAnonymousIntent.equals("db_list"))
    {
    i = 1;
    continue;
    if (paramAnonymousIntent.equals("authenticate_user")) {
    i = 2;
    }
    }
    }
    break;
    }
    }
    if (Boolean.valueOf(paramAnonymousContext.getBoolean("service_response")).booleanValue())
    {
    paramAnonymousContext = new Bundle();
    paramAnonymousContext.putString("host", Login.this.getHost());
    Login.this.requestRPCService("db_list", paramAnonymousContext);
    return;
    }
    Login.this.toggleProgressBarView(false);
    Snackbar.make(Login.this.findViewById(16908290), 2131165290, 0).show();
    return;
    paramAnonymousContext = paramAnonymousContext.getStringArrayList("service_response");
    if (paramAnonymousContext.size() > 1)
    {
    Login.this.showDatabaseDialog(paramAnonymousContext);
    return;
    }
    if (paramAnonymousContext.size() == 1)
    {
    Login.this.login((String)paramAnonymousContext.get(0));
    return;
    }
    paramAnonymousContext = Uri.parse(Login.this.getHost());
    if (paramAnonymousContext.getHost().equals("www.odoo.com"))
    {
    Login.this.login("openerp");
    return;
    }
    if (paramAnonymousContext.getHost().endsWith(".odoo.com"))
    {
    Login.this.login(paramAnonymousContext.getHost().replace(".odoo.com", ""));
    return;
    }
    Login.this.askUserForDatabase();
    return;
    Login.this.createAccount((OdooUser)paramAnonymousContext.getParcelable("service_response"));
    }
    };
    private OdooAccountManager odooAccountManager;

    private void askUserForDatabase()
    {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
    localBuilder.setTitle(2131165256);
    View localView = LayoutInflater.from(this).inflate(2130968622, null, false);
    final EditText localEditText = (EditText)localView.findViewById(16908297);
    localEditText.setHint(2131165274);
    localBuilder.setView(localView);
    localBuilder.setPositiveButton(17039370, new DialogInterface.OnClickListener()
    {
    public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
    {
    if (!localEditText.getText().toString().trim().isEmpty())
    {
    Login.this.login(localEditText.getText().toString().trim());
    return;
    }
    Toast.makeText(Login.this, 2131165281, 0).show();
    Login.this.toggleProgressBarView(false);
    }
    });
    localBuilder.setNegativeButton(17039360, new DialogInterface.OnClickListener()
    {
    public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
    {
    Login.this.toggleProgressBarView(false);
    }
    });
    localBuilder.setOnCancelListener(new DialogInterface.OnCancelListener()
    {
    public void onCancel(DialogInterface paramAnonymousDialogInterface)
    {
    Login.this.toggleProgressBarView(false);
    }
    });
    localBuilder.show();
    }

    private void createAccount(OdooUser paramOdooUser)
    {
    if (this.odooAccountManager.createAccount(paramOdooUser))
    {
    this.odooAccountManager.makeActive(paramOdooUser);
    startWebViewActivity(paramOdooUser);
    return;
    }
    Toast.makeText(this, 2131165288, 0).show();
    toggleProgressBarView(false);
    }

    private String getHost()
    {
    Object localObject2 = this.edtServerUrl.getText().toString().trim();
    boolean bool = isRunbotURL((String)localObject2);
    Object localObject1 = localObject2;
    if (!((String)localObject2).startsWith("http")) {
    localObject1 = "http://" + (String)localObject2;
    }
    if (bool) {}
    do
    {
    return localObject1;
    localObject2 = Uri.parse((String)localObject1);
    if (((Uri)localObject2).getHost().equals("odoo.com")) {
    return "https://www." + ((Uri)localObject2).getHost();
    }
    } while (!((Uri)localObject2).getHost().endsWith(".odoo.com"));
    return "https://" + ((Uri)localObject2).getHost();
    }

    private void handleError(String paramString, Bundle paramBundle)
    {
    toggleProgressBarView(false);
    Object localObject2 = null;
    Object localObject1 = localObject2;
    int i;
    if (paramString.equals("error_response"))
    {
    paramString = paramBundle.getString("error_type");
    i = -1;
    switch (paramString.hashCode())
    {
    default:
    switch (i)
    {
    default:
    localObject1 = localObject2;
    }
    break;
    }
    }
    for (;;)
    {
    if (localObject1 != null) {
    Snackbar.make(findViewById(16908290), (CharSequence)localObject1, 0).show();
    }
    return;
    if (!paramString.equals("no_network_connection")) {
    break;
    }
    i = 0;
    break;
    if (!paramString.equals("time_out")) {
    break;
    }
    i = 1;
    break;
    if (!paramString.equals("authentication_failed")) {
    break;
    }
    i = 2;
    break;
    if (!paramString.equals("server_not_reachable")) {
    break;
    }
    i = 3;
    break;
    if (!paramString.equals("database_not_found")) {
    break;
    }
    i = 4;
    break;
    if (!paramString.equals("certificate_not_trusted")) {
    break;
    }
    i = 5;
    break;
    localObject1 = getString(2131165231);
    continue;
    localObject1 = getString(2131165229);
    continue;
    localObject1 = getString(2131165241);
    continue;
    localObject1 = getString(2131165268);
    continue;
    localObject1 = paramBundle.getString("error_message");
    continue;
    localObject1 = paramBundle.getString("error_message");
    }
    }

    private boolean isRunbotURL(String paramString)
    {
    return Pattern.compile(".runbot.{1,2}\.odoo\.com", 2).matcher(paramString).find();
    }

    private void login()
    {
    if ((OControlUtils.isVisible((View)this.edtServerUrl.getParent())) && (this.edtServerUrl.getText().toString().trim().isEmpty()))
    {
    this.edtServerUrl.setError(getString(2131165233));
    this.edtServerUrl.requestFocus();
    return;
    }
    if (this.edtLogin.getText().toString().trim().isEmpty())
    {
    this.edtLogin.setError(getString(2131165234));
    this.edtLogin.requestFocus();
    return;
    }
    if (this.edtPassword.getText().toString().trim().isEmpty())
    {
    this.edtPassword.setError(getString(2131165232));
    this.edtPassword.requestFocus();
    return;
    }
    toggleProgressBarView(true);
    Bundle localBundle = new Bundle();
    localBundle.putString("host", getHost());
    requestRPCService("odoo_version", localBundle);
    }

    private void login(String paramString)
    {
    String str1 = getHost();
    String str2 = this.edtLogin.getText().toString();
    String str3 = this.edtPassword.getText().toString();
    if (this.odooAccountManager.hasAccount(OdooUser.createAccountName(str2, str1, paramString)))
    {
    Snackbar.make(findViewById(16908290), 2131165225, 0).show();
    toggleProgressBarView(false);
    return;
    }
    Bundle localBundle = new Bundle();
    localBundle.putString("host", str1);
    localBundle.putString("username", str2);
    localBundle.putString("password", str3);
    localBundle.putString("database", paramString);
    requestRPCService("authenticate_user", localBundle);
    }

    private void requestRPCService(String paramString, Bundle paramBundle)
    {
    if (paramBundle != null) {}
    for (;;)
    {
    paramBundle.putString("service_action", paramString);
    paramString = new Intent(this, OdooIntentService.class);
    paramString.putExtras(paramBundle);
    startService(paramString);
    return;
    paramBundle = new Bundle();
    }
    }

    private void showDatabaseDialog(final List paramList)
    {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
    localBuilder.setTitle(2131165277);
    localBuilder.setSingleChoiceItems((CharSequence[])paramList.toArray(new String[paramList.size()]), -1, new DialogInterface.OnClickListener()
    {
    public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
    {
    Login.this.login((String)paramList.get(paramAnonymousInt));
    paramAnonymousDialogInterface.dismiss();
    }
    });
    localBuilder.setOnCancelListener(new DialogInterface.OnCancelListener()
    {
    public void onCancel(DialogInterface paramAnonymousDialogInterface)
    {
    Login.this.toggleProgressBarView(false);
    }
    });
    localBuilder.show();
    }

    private void startWebViewActivity(OdooUser paramOdooUser)
    {
    paramOdooUser.getSession(this).registerSession(paramOdooUser.session_id);
    paramOdooUser = new Intent(this, WebViewActivity.class);
    paramOdooUser.setFlags(268468224);
    Bundle localBundle = getIntent().getExtras();
    if ((localBundle != null) && (localBundle.containsKey("link"))) {
    paramOdooUser.putExtra("link", localBundle.getString("link"));
    }
    startActivity(paramOdooUser);
    overridePendingTransition(2131034129, 2131034130);
    finish();
    }

    private void toggleProgressBarView(boolean paramBoolean)
    {
    int j = 0;
    View localView = findViewById(2131558523);
    if (!paramBoolean)
    {
    i = 0;
    localView.setVisibility(i);
    localView = findViewById(2131558521);
    if (!paramBoolean) {
    break label71;
    }
    }
    label71:
    for (int i = j;; i = 😎
    {
    localView.setVisibility(i);
    ((ProgressBar)findViewById(2131558522)).getIndeterminateDrawable().setColorFilter(-1, PorterDuff.Mode.SRC_IN);
    return;
    i = 8;
    break;
    }
    }

    public void onClick(View paramView)
    {
    switch (paramView.getId())
    {
    default:
    return;
    case 2131558528:
    login();
    return;
    }
    if (NetworkUtils.isConnected(this))
    {
    startActivity(new Intent(this, CreateAccount.class));
    return;
    }
    Toast.makeText(this, 2131165231, 0).show();
    }

    protected void onCreate(Bundle paramBundle)
    {
    super.onCreate(paramBundle);
    setContentView(2130968604);
    this.odooAccountManager = new OdooAccountManager(this);
    this.edtLogin = ((EditText)findViewById(2131558525));
    this.edtPassword = ((EditText)findViewById(2131558526));
    this.edtServerUrl = ((EditText)findViewById(2131558524));
    findViewById(2131558528).setOnClickListener(this);
    findViewById(2131558529).setOnClickListener(this);
    findViewById(2131558527).setOnTouchListener(this);
    this.edtPassword.setOnKeyListener(this);
    LocalBroadcastManager.getInstance(this).registerReceiver(this.loginResponseReceiver, new IntentFilter(OdooIntentService.TAG));
    }

    protected void onDestroy()
    {
    LocalBroadcastManager.getInstance(this).unregisterReceiver(this.loginResponseReceiver);
    super.onDestroy();
    }

    public boolean onKey(View paramView, int paramInt, KeyEvent paramKeyEvent)
    {
    if (paramKeyEvent.getKeyCode() == 66)
    {
    login();
    ((InputMethodManager)getSystemService("input_method")).hideSoftInputFromWindow(paramView.getWindowToken(), 0);
    }
    return false;
    }

    protected void onStart()
    {
    super.onStart();
    int i;
    Object localObject1;
    if ((getIntent().getExtras() != null) && (getIntent().getExtras().containsKey("force_new_login")))
    {
    i = 1;
    if (i == 0)
    {
    localObject1 = this.odooAccountManager.getActiveAccount();
    if (localObject1 == null) {
    break label162;
    }
    toggleProgressBarView(true);
    if (!((OdooUser)localObject1).getSession(this).isValid()) {
    break label128;
    }
    localObject1 = new Intent(this, WebViewActivity.class);
    localObject2 = getIntent().getExtras();
    if ((localObject2 != null) && (((Bundle)localObject2).containsKey("link"))) {
    ((Intent)localObject1).putExtra("link", ((Bundle)localObject2).getString("link"));
    }
    startActivity((Intent)localObject1);
    finish();
    }
    }
    label128:
    label162:
    while (!this.odooAccountManager.hasAnyAccount())
    {
    return;
    i = 0;
    break;
    Object localObject2 = new Intent(this, UserLoginActivity.class);
    ((Intent)localObject2).putExtra("user_name", ((OdooUser)localObject1).getAccountName());
    startActivity((Intent)localObject2);
    finish();
    return;
    }
    startActivity(new Intent(this, AllAccountsActivity.class));
    finish();
    }

    public boolean onTouch(View paramView, MotionEvent paramMotionEvent)
    {
    if (1 == paramMotionEvent.getAction())
    {
    this.edtPassword.setInputType(129);
    return true;
    }
    this.edtPassword.setInputType(145);
    return true;
    }
    }