Browse Source

intent camotion:// for auto configuration link

tags/0.0.5^0
Robin Thoni 9 years ago
parent
commit
282594fc1f

+ 1
- 0
.gitignore View File

5
 .DS_Store
5
 .DS_Store
6
 /build
6
 /build
7
 /captures
7
 /captures
8
+*.apk

BIN
app/app-release.apk View File


+ 6
- 0
app/src/main/AndroidManifest.xml View File

44
             android:name=".ui.AddAccountActivity"
44
             android:name=".ui.AddAccountActivity"
45
             android:label="@string/add_location_title"
45
             android:label="@string/add_location_title"
46
             android:screenOrientation="portrait">
46
             android:screenOrientation="portrait">
47
+            <intent-filter>
48
+                <action android:name="android.intent.action.VIEW" />
49
+                <category android:name="android.intent.category.DEFAULT" />
50
+                <category android:name="android.intent.category.BROWSABLE" />
51
+                <data android:scheme="camotion" />
52
+            </intent-filter>
47
         </activity>
53
         </activity>
48
 
54
 
49
         <activity
55
         <activity

+ 30
- 3
app/src/main/java/com/rthoni/camotion/ui/AddAccountActivity.java View File

4
 import android.accounts.AccountAuthenticatorResponse;
4
 import android.accounts.AccountAuthenticatorResponse;
5
 import android.accounts.AccountManager;
5
 import android.accounts.AccountManager;
6
 import android.app.Activity;
6
 import android.app.Activity;
7
-import android.support.v7.app.AppCompatActivity;
7
+import android.net.Uri;
8
 import android.os.Bundle;
8
 import android.os.Bundle;
9
+import android.support.v7.app.AppCompatActivity;
9
 import android.view.View;
10
 import android.view.View;
10
 import android.widget.CheckBox;
11
 import android.widget.CheckBox;
11
 import android.widget.EditText;
12
 import android.widget.EditText;
13
 
14
 
14
 import com.luticate.auth.dbo.LuLoginDbo;
15
 import com.luticate.auth.dbo.LuLoginDbo;
15
 import com.luticate.utils.business.LuPromise;
16
 import com.luticate.utils.business.LuPromise;
17
+import com.luticate.utils.business.LuRequest;
16
 import com.rthoni.camotion.R;
18
 import com.rthoni.camotion.R;
17
 import com.rthoni.camotion.dbo.LocationDbo;
19
 import com.rthoni.camotion.dbo.LocationDbo;
18
 import com.rthoni.camotion.ui.dialogs.LoginDialog;
20
 import com.rthoni.camotion.ui.dialogs.LoginDialog;
19
 
21
 
22
+import org.json.JSONObject;
23
+
20
 public class AddAccountActivity extends AppCompatActivity {
24
 public class AddAccountActivity extends AppCompatActivity {
21
 
25
 
22
     private EditText _nameInput;
26
     private EditText _nameInput;
30
     @Override
34
     @Override
31
     protected void onCreate(Bundle savedInstanceState) {
35
     protected void onCreate(Bundle savedInstanceState) {
32
         super.onCreate(savedInstanceState);
36
         super.onCreate(savedInstanceState);
37
+        LuRequest.init(this);
33
         setContentView(R.layout.activity_add_account);
38
         setContentView(R.layout.activity_add_account);
34
         _nameInput = (EditText) findViewById(R.id.name_input);
39
         _nameInput = (EditText) findViewById(R.id.name_input);
35
         _usernameInput = (EditText) findViewById(R.id.username_input);
40
         _usernameInput = (EditText) findViewById(R.id.username_input);
56
         if (extras != null) {
61
         if (extras != null) {
57
             _response = extras.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
62
             _response = extras.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
58
         }
63
         }
64
+
65
+        LocationDbo location = new LocationDbo();
66
+        location.setHttps(true);
67
+        try {
68
+            String data = getIntent().getDataString();
69
+            Uri uri= Uri.parse(data);;
70
+            String config = uri.getQueryParameter("config");
71
+
72
+            JSONObject json = new JSONObject(config);
73
+
74
+            location.fromJson(json);
75
+        }
76
+        catch (Exception e)
77
+        {
78
+        }
79
+        _nameInput.setText(location.getName());
80
+        _usernameInput.setText(location.getUsername());
81
+        _passwordInput.setText(location.getPassword());
82
+        _domainInput.setText(location.getDomain());
83
+        _checkBoxHttps.setChecked(location.isHttps());
59
     }
84
     }
60
 
85
 
61
     private LocationDbo validate()
86
     private LocationDbo validate()
107
         Account newUserAccount = new Account(username, getResources().getString(R.string.account_type));
132
         Account newUserAccount = new Account(username, getResources().getString(R.string.account_type));
108
         boolean accountCreated = accountManager.addAccountExplicitly(newUserAccount, location.getPassword(), null);
133
         boolean accountCreated = accountManager.addAccountExplicitly(newUserAccount, location.getPassword(), null);
109
 
134
 
110
-        if (accountCreated && _response != null) {
135
+        if (accountCreated) {
111
             accountManager.setUserData(newUserAccount, "Https", location.isHttps() ? "true" : "false");
136
             accountManager.setUserData(newUserAccount, "Https", location.isHttps() ? "true" : "false");
112
             accountManager.setUserData(newUserAccount, "Domain", location.getDomain());
137
             accountManager.setUserData(newUserAccount, "Domain", location.getDomain());
113
             Bundle result = new Bundle();
138
             Bundle result = new Bundle();
114
             result.putString(AccountManager.KEY_ACCOUNT_NAME, username);
139
             result.putString(AccountManager.KEY_ACCOUNT_NAME, username);
115
             result.putString(AccountManager.KEY_ACCOUNT_TYPE, getString(R.string.account_type));
140
             result.putString(AccountManager.KEY_ACCOUNT_TYPE, getString(R.string.account_type));
116
-            _response.onResult(result);
141
+            if (_response != null) {
142
+                _response.onResult(result);
143
+            }
117
             finish();
144
             finish();
118
         }
145
         }
119
     }
146
     }

Loading…
Cancel
Save