added login feedback, added login dialog, media picker bug fix
This commit is contained in:
parent
82de84a008
commit
65425e9cea
app/src/main
java/org/nuclearfog/twidda/activity
res
@ -216,7 +216,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.settings_info) {
|
||||
Dialog dialog = new Dialog(this, R.style.AppInfoDialog);
|
||||
dialog.setContentView(R.layout.popup_app_info);
|
||||
dialog.setContentView(R.layout.dialog_app_info);
|
||||
String versionName = " V" + BuildConfig.VERSION_NAME;
|
||||
TextView appInfo = dialog.findViewById(R.id.settings_app_info);
|
||||
appInfo.setLinkTextColor(settings.getHighlightColor());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.nuclearfog.twidda.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -10,6 +11,7 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -33,7 +35,6 @@ import static android.content.Intent.ACTION_VIEW;
|
||||
import static android.os.AsyncTask.Status.FINISHED;
|
||||
import static android.os.AsyncTask.Status.RUNNING;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
|
||||
/**
|
||||
* Login Activity of the App
|
||||
@ -42,6 +43,7 @@ import static android.widget.Toast.LENGTH_SHORT;
|
||||
public class LoginActivity extends AppCompatActivity implements OnClickListener {
|
||||
|
||||
private Registration registerAsync;
|
||||
private GlobalSettings settings;
|
||||
|
||||
private Button linkButton, loginButton;
|
||||
private EditText pinInput;
|
||||
@ -57,6 +59,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
root = findViewById(R.id.login_root);
|
||||
pinInput = findViewById(R.id.pin);
|
||||
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
toolbar.setTitle(R.string.login_info);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
@ -69,7 +72,6 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
linkButton.setTypeface(settings.getFontFace());
|
||||
loginButton.setTypeface(settings.getFontFace());
|
||||
pinInput.setTypeface(settings.getFontFace());
|
||||
@ -112,12 +114,10 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (registerAsync != null && registerAsync.getStatus() == RUNNING)
|
||||
registerAsync.cancel(true);
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.linkButton:
|
||||
if (registerAsync == null || registerAsync.getStatus() != RUNNING) {
|
||||
Toast.makeText(this, R.string.info_fetching_link, LENGTH_LONG).show();
|
||||
registerAsync = new Registration(this);
|
||||
registerAsync.execute();
|
||||
}
|
||||
@ -127,6 +127,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
if (registerAsync == null || registerAsync.getStatus() != FINISHED) {
|
||||
Toast.makeText(this, R.string.info_get_link, LENGTH_LONG).show();
|
||||
} else if (pinInput.getText() != null && pinInput.length() > 0) {
|
||||
Toast.makeText(this, R.string.info_login_to_twitter, LENGTH_LONG).show();
|
||||
String twitterPin = pinInput.getText().toString();
|
||||
registerAsync = new Registration(this);
|
||||
registerAsync.execute(twitterPin);
|
||||
@ -146,8 +147,13 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
Intent loginIntent = new Intent(ACTION_VIEW, Uri.parse(link));
|
||||
if (loginIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(loginIntent);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.error_connection_failed, LENGTH_SHORT).show();
|
||||
} else { // If no browser was found, a popup with the login link appears
|
||||
Dialog dialog = new Dialog(this, R.style.AppInfoDialog);
|
||||
dialog.setContentView(R.layout.dialog_login_info);
|
||||
TextView callbackURL = dialog.findViewById(R.id.login_request_link);
|
||||
callbackURL.setLinkTextColor(settings.getHighlightColor());
|
||||
callbackURL.setText(link);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +175,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if phone supports TLS 1.2
|
||||
* Check if phone supports TLS 1.2 which is required for twitter api
|
||||
*/
|
||||
private void checkTLSSupport() {
|
||||
boolean tls12Found = false;
|
||||
@ -177,7 +183,7 @@ public class LoginActivity extends AppCompatActivity implements OnClickListener
|
||||
SSLParameters param = SSLContext.getDefault().getDefaultSSLParameters();
|
||||
String[] protocols = param.getProtocols();
|
||||
for (String protocol : protocols) {
|
||||
if (protocol.equals("TLSv1.2")) {
|
||||
if (protocol.equals("TLSv1.2") || protocol.equals("TLSv1.3")) {
|
||||
tls12Found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
|
||||
public static final String KEY_DM_PREFIX = "dm_prefix";
|
||||
private static final String[] PERM_READ = {Manifest.permission.READ_EXTERNAL_STORAGE};
|
||||
private static final String[] PICK_IMAGE = {MediaStore.Images.Media.DATA};
|
||||
private static final String TYPE_IMAGE = "image/*";
|
||||
private static final int REQ_MEDIA = 3;
|
||||
private static final int REQ_PERM_READ = 4;
|
||||
|
||||
private MessageUploader messageAsync;
|
||||
@ -126,7 +128,7 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
|
||||
@Override
|
||||
protected void onActivityResult(int reqCode, int returnCode, @Nullable Intent intent) {
|
||||
super.onActivityResult(reqCode, returnCode, intent);
|
||||
if (reqCode == REQ_PERM_READ && returnCode == RESULT_OK) {
|
||||
if (reqCode == REQ_MEDIA && returnCode == RESULT_OK) {
|
||||
if (intent != null && intent.getData() != null) {
|
||||
Cursor c = getContentResolver().query(intent.getData(), PICK_IMAGE, null, null, null);
|
||||
if (c != null && c.moveToFirst()) {
|
||||
@ -231,9 +233,10 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
}
|
||||
if (accessGranted) {
|
||||
Intent galleryIntent = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
|
||||
Intent galleryIntent = new Intent(ACTION_PICK);
|
||||
galleryIntent.setDataAndType(EXTERNAL_CONTENT_URI, TYPE_IMAGE);
|
||||
if (galleryIntent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivityForResult(galleryIntent, REQ_PERM_READ);
|
||||
startActivityForResult(galleryIntent, REQ_MEDIA);
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_media_app, LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -394,11 +394,15 @@ public class TweetPopup extends AppCompatActivity implements OnClickListener, Lo
|
||||
}
|
||||
if (accessGranted) {
|
||||
Intent mediaSelect = new Intent(ACTION_PICK);
|
||||
String mediaType;
|
||||
if (selectedFormat == MediaType.IMAGE) {
|
||||
mediaSelect.setDataAndType(EXTERNAL_CONTENT_URI, TYPE_IMAGE);
|
||||
// pick only images
|
||||
mediaType = TYPE_IMAGE;
|
||||
} else {
|
||||
mediaSelect.setDataAndType(EXTERNAL_CONTENT_URI, TYPE_IMAGE + TYPE_VIDEO);
|
||||
// pick image or video
|
||||
mediaType = TYPE_IMAGE + ";" + TYPE_VIDEO;
|
||||
}
|
||||
mediaSelect.setDataAndType(EXTERNAL_CONTENT_URI, mediaType);
|
||||
if (mediaSelect.resolveActivity(getPackageManager()) != null) {
|
||||
startActivityForResult(mediaSelect, REQ_PICK_MEDIA);
|
||||
} else {
|
||||
|
23
app/src/main/res/layout/dialog_login_info.xml
Normal file
23
app/src/main/res/layout/dialog_login_info.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/loginpopup_text_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/info_twitter_login_link"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_request_link"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/loginpopup_text_margin"
|
||||
android:autoLink="web"
|
||||
android:linksClickable="true"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
@ -152,4 +152,7 @@
|
||||
<string name="error_image_exists">Fehler, Bild ist bereits vorhanden!</string>
|
||||
<string name="info_phone_tls_support">TLS 1.2 wird nicht unterstützt. Die App wird möglicherweise nicht funktionieren!</string>
|
||||
<string name="login_info">3 Schritte zum Login</string>
|
||||
<string name="info_fetching_link">öffne Twitter login Seite</string>
|
||||
<string name="info_login_to_twitter">Melde in Twitter an</string>
|
||||
<string name="info_twitter_login_link">Zum Anmelden bitte Link anklicken</string>
|
||||
</resources>
|
@ -180,7 +180,11 @@
|
||||
<!--dimens of page_list.xml-->
|
||||
<dimen name="dmpage_toolbar_height">@dimen/toolbar_height</dimen>
|
||||
|
||||
<!--dimens of popup_app_info.xml-->
|
||||
<!--dimens of dialog_app_info.xml-->
|
||||
<dimen name="infopopup_text_padding">5dp</dimen>
|
||||
|
||||
<!--dimens of dialog_login_info.xml-->
|
||||
<dimen name="loginpopup_text_padding">20dp</dimen>
|
||||
<dimen name="loginpopup_text_margin">5dp</dimen>
|
||||
|
||||
</resources>
|
@ -123,8 +123,8 @@
|
||||
<string name="edit_hint_enter_descr">enter profile description</string>
|
||||
<string name="settins_font">Font style</string>
|
||||
<string name="page_profile_edior">Edit profile</string>
|
||||
<string name="error_no_card_app">No card app installed!</string>
|
||||
<string name="error_no_media_app">No media app found!</string>
|
||||
<string name="error_no_card_app">No card app found!</string>
|
||||
<string name="error_no_media_app">No gallery app found!</string>
|
||||
<string name="delete_list">delete list</string>
|
||||
<string name="confirm_delete_list">Delete list?</string>
|
||||
<string name="confirm_delete_message">Delete message?</string>
|
||||
@ -158,4 +158,7 @@
|
||||
<string name="login_first_opt" translatable="false">1.</string>
|
||||
<string name="login_sec_opt" translatable="false">2.</string>
|
||||
<string name="login_thr_opt" translatable="false">3.</string>
|
||||
<string name="info_fetching_link">opening twitter login site</string>
|
||||
<string name="info_login_to_twitter">login to Twitter</string>
|
||||
<string name="info_twitter_login_link">Please click the link below to login</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user