Skip to content

Commit

Permalink
pk-drive clone for vcic owncloud#6: xử lý nút back trang login, kiểm …
Browse files Browse the repository at this point in the history
…tra không có internet thì không bật webview
  • Loading branch information
NganNTK committed Aug 9, 2017
1 parent d63b243 commit a2a011e
Show file tree
Hide file tree
Showing 11 changed files with 595 additions and 542 deletions.
4 changes: 3 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
android:theme="@style/Theme.ownCloud.Toolbar"
android:manageSpaceActivity=".ui.activity.ManageSpaceActivity"
android:resizeableActivity="true"
android:supportsPictureInPicture="false" >
android:supportsPictureInPicture="false"
android:screenOrientation="portrait">
<activity
android:name=".ui.activity.FileDisplayActivity"
android:theme="@style/Theme.ownCloud.Toolbar.Drawer">
Expand Down Expand Up @@ -167,6 +168,7 @@
android:name=".authentication.AuthenticatorActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down
Binary file modified res/drawable-hdpi-v11/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-hdpi/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-mdpi-v11/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-mdpi/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-xhdpi-v11/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-xhdpi/notification_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
551 changes: 286 additions & 265 deletions res/layout-land/account_setup.xml

Large diffs are not rendered by default.

531 changes: 271 additions & 260 deletions res/layout/account_setup.xml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions res/layout/account_setup_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
android:layout_height="match_parent"
android:orientation="vertical">
<include android:id="@+id/welcome_toolbar" layout="@layout/toolbar_standard"/>
<WebView
android:id="@+id/webViewLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!--<WebView-->
<!--android:id="@+id/webViewLogin"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"/>-->
</LinearLayout>

</ScrollView>
43 changes: 31 additions & 12 deletions src/com/owncloud/android/authentication/AuthenticatorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
Expand Down Expand Up @@ -63,6 +65,7 @@
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
Expand Down Expand Up @@ -209,6 +212,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private WebView webViewLogin, webvViewSignUp;
private String pkAccessToken;
private Toolbar myToolbar;
private View accountWelcomeSetup;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -276,6 +280,7 @@ protected void onCreate(Bundle savedInstanceState) {
myToolbar = (Toolbar) findViewById(R.id.welcome_toolbar);
setSupportActionBar(myToolbar);

accountWelcomeSetup = findViewById(R.id.account_welcome_setup);
mOkButton = findViewById(R.id.buttonOK);
mOkButton.setOnClickListener(new View.OnClickListener() {

Expand Down Expand Up @@ -305,7 +310,14 @@ public void onClick(View v) {
mButtonLogIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setWebView();
ConnectivityManager cm = (ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
if (!isConnected)
Toast.makeText(getBaseContext(), "No internet", Toast.LENGTH_LONG).show();
else
setWebView();
}
});
//
Expand All @@ -323,6 +335,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
String url = "https://id.projectkit.net/signup-mobile?locale=en-US";
//change this, shouldn't use setContentView
setContentView(R.layout.account_webview_signup);
webvViewSignUp = (WebView) findViewById(R.id.webViewSignUp);
webvViewSignUp.loadUrl(url);
Expand All @@ -335,7 +348,6 @@ public void onClick(View v) {

//Log_OC.e(TAG, "onCreate end");


}


Expand All @@ -353,14 +365,13 @@ else if (locale.equals("en_US"))
"&scope=" + getString(R.string.oauth2_scope) +
"&contextData={%22fromApp%22:%22mobileApp%22}&nonce=g4sg6";

setContentView(R.layout.account_setup_webview);
Toolbar myToolbar1 = (Toolbar) findViewById(R.id.welcome_toolbar);
setSupportActionBar(myToolbar1);
webViewLogin = (WebView) findViewById(R.id.webViewLogin);
accountWelcomeSetup.setVisibility(View.GONE);
webViewLogin.setVisibility(View.VISIBLE);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
webViewLogin = (WebView) findViewById(R.id.webViewLogin);
webViewLogin.loadUrl(url);

webViewLogin.setWebViewClient(new WebViewClient() {
Expand All @@ -379,7 +390,6 @@ public void onPageFinished(WebView view, String url) {
checkBasicAuthorization();
}
}

}

@Override
Expand All @@ -393,16 +403,25 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
startActivity( intent );
return true;
}

});
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
setContentView(R.layout.account_setup);
}
public void onBackPressed() {
accountWelcomeSetup.setVisibility(View.VISIBLE);
webViewLogin.setVisibility(View.GONE);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}

return super.onOptionsItemSelected(item);
@Override
public boolean onSupportNavigateUp() {
accountWelcomeSetup.setVisibility(View.VISIBLE);
webViewLogin.setVisibility(View.GONE);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
return true;
}

private void initAuthTokenType() {
Expand Down

0 comments on commit a2a011e

Please sign in to comment.