bug fix, layout fix

This commit is contained in:
nuclearfog 2020-04-30 11:50:17 +02:00
parent faf73fed91
commit a347b67907
No known key found for this signature in database
GPG Key ID: ED35E22099354A64
11 changed files with 102 additions and 105 deletions

View File

@ -17,7 +17,7 @@ import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
import android.widget.VideoView; import android.widget.VideoView;
import androidx.annotation.NonNull; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -33,7 +33,7 @@ import java.util.Date;
import java.util.Locale; import java.util.Locale;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.media.MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START; import static android.media.MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START;
import static android.view.View.INVISIBLE; import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
@ -176,21 +176,22 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
@Override @Override
public void onImageClick(Bitmap image) { public void onImageClick(Bitmap image) {
setImage(image); changeImage(image);
} }
@Override @Override
public void onImageTouch(Bitmap image) { public void onImageTouch(Bitmap image) {
boolean accessGranted = true;
if (type == MEDIAVIEWER_IMAGE) { if (type == MEDIAVIEWER_IMAGE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int check = checkSelfPermission(WRITE_EXTERNAL_STORAGE); int check = checkSelfPermission(WRITE_EXTERNAL_STORAGE);
if (check == PERMISSION_GRANTED) { if (check == PERMISSION_DENIED) {
storeImage(image);
} else {
requestPermissions(REQ_WRITE_SD, REQCODE_SD); requestPermissions(REQ_WRITE_SD, REQCODE_SD);
accessGranted = false;
} }
} else { }
if (accessGranted) {
storeImage(image); storeImage(image);
} }
} }
@ -225,17 +226,20 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
} }
public ImageAdapter getAdapter() { public void setImage(@Nullable Bitmap image) {
return adapter; if (image != null) {
} if (adapter.isEmpty()) {
changeImage(image);
public void disableProgressbar() {
image_progress.setVisibility(View.INVISIBLE); image_progress.setVisibility(View.INVISIBLE);
} }
adapter.addLast(image);
} else {
adapter.disableLoading();
}
}
public void setImage(@NonNull Bitmap image) { private void changeImage(Bitmap image) {
float ratio = image.getWidth() / (float) width; float ratio = image.getWidth() / (float) width;
int destHeight = (int) (image.getHeight() / ratio); int destHeight = (int) (image.getHeight() / ratio);
image = Bitmap.createScaledBitmap(image, width, destHeight, false); image = Bitmap.createScaledBitmap(image, width, destHeight, false);

View File

@ -24,6 +24,7 @@ import org.nuclearfog.twidda.database.GlobalSettings;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE; import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.content.Intent.ACTION_PICK; import static android.content.Intent.ACTION_PICK;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.AsyncTask.Status.RUNNING; import static android.os.AsyncTask.Status.RUNNING;
import static android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI; import static android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
@ -147,18 +148,15 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener {
private void getMedia() { private void getMedia() {
boolean accessGranted = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int check = checkSelfPermission(READ_EXTERNAL_STORAGE); int check = checkSelfPermission(READ_EXTERNAL_STORAGE);
if (check == PERMISSION_GRANTED) { if (check == PERMISSION_DENIED) {
Intent galleryIntent = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
if (galleryIntent.resolveActivity(getPackageManager()) != null)
startActivityForResult(galleryIntent, REQ_PERM_READ);
else
Toast.makeText(getApplicationContext(), R.string.error_no_media_app, LENGTH_SHORT).show();
} else {
requestPermissions(PERM_READ, REQ_PERM_READ); requestPermissions(PERM_READ, REQ_PERM_READ);
accessGranted = false;
} }
} else { }
if (accessGranted) {
Intent galleryIntent = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI); Intent galleryIntent = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
if (galleryIntent.resolveActivity(getPackageManager()) != null) if (galleryIntent.resolveActivity(getPackageManager()) != null)
startActivityForResult(galleryIntent, REQ_PERM_READ); startActivityForResult(galleryIntent, REQ_PERM_READ);

View File

@ -130,7 +130,11 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
String userLoc = loc.getText().toString(); String userLoc = loc.getText().toString();
String userBio = bio.getText().toString(); String userBio = bio.getText().toString();
if (username.trim().isEmpty()) { if (username.trim().isEmpty()) {
Toast.makeText(this, R.string.error_empty_name, LENGTH_SHORT).show(); String errMsg = getString(R.string.error_empty_name);
name.setError(errMsg);
} else if (!userLink.isEmpty() && userLink.contains(" ")) {
String errMsg = getString(R.string.error_invalid_link);
link.setError(errMsg);
} else { } else {
UserHolder userHolder = new UserHolder(username, userLink, userLoc, userBio, profileLink, bannerLink); UserHolder userHolder = new UserHolder(username, userLink, userLoc, userBio, profileLink, bannerLink);
editorAsync = new ProfileUpdater(this, userHolder); editorAsync = new ProfileUpdater(this, userHolder);
@ -208,18 +212,15 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
private void getMedia(int request) { private void getMedia(int request) {
boolean accessGranted = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int check = checkSelfPermission(READ_EXTERNAL_STORAGE); int check = checkSelfPermission(READ_EXTERNAL_STORAGE);
if (check == PackageManager.PERMISSION_GRANTED) { if (check == PackageManager.PERMISSION_DENIED) {
Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
if (media.resolveActivity(getPackageManager()) != null)
startActivityForResult(media, request);
else
Toast.makeText(getApplicationContext(), R.string.error_no_media_app, LENGTH_SHORT).show();
} else {
requestPermissions(PERM_READ, REQ_PERM); requestPermissions(PERM_READ, REQ_PERM);
accessGranted = false;
} }
} else { }
if (accessGranted) {
Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI); Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
if (media.resolveActivity(getPackageManager()) != null) if (media.resolveActivity(getPackageManager()) != null)
startActivityForResult(media, request); startActivityForResult(media, request);

View File

@ -63,7 +63,6 @@ import static org.nuclearfog.twidda.activity.TweetPopup.KEY_TWEETPOPUP_REPLYID;
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID; import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE; import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS; import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS;
import static org.nuclearfog.twidda.activity.UserDetail.USERLSIT_FAVORITS;
public class TweetDetail extends AppCompatActivity implements OnClickListener, OnTouchListener, public class TweetDetail extends AppCompatActivity implements OnClickListener, OnTouchListener,
@ -136,7 +135,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
replyName.setOnClickListener(this); replyName.setOnClickListener(this);
ansButton.setOnClickListener(this); ansButton.setOnClickListener(this);
rtwButton.setOnClickListener(this); rtwButton.setOnClickListener(this);
favButton.setOnClickListener(this);
rtwButton.setOnLongClickListener(this); rtwButton.setOnLongClickListener(this);
favButton.setOnLongClickListener(this); favButton.setOnLongClickListener(this);
profile_img.setOnClickListener(this); profile_img.setOnClickListener(this);
@ -241,13 +239,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
startActivity(userList); startActivity(userList);
break; break;
case R.id.tweet_favorit:
userList = new Intent(this, UserDetail.class);
userList.putExtra(KEY_USERDETAIL_ID, tweetID);
userList.putExtra(KEY_USERDETAIL_MODE, USERLSIT_FAVORITS);
startActivity(userList);
break;
case R.id.profileimage_detail: case R.id.profileimage_detail:
if (tweet != null) { if (tweet != null) {
Intent profile = new Intent(getApplicationContext(), UserProfile.class); Intent profile = new Intent(getApplicationContext(), UserProfile.class);

View File

@ -9,7 +9,6 @@ import androidx.annotation.NonNull;
import org.nuclearfog.twidda.R; import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.activity.MediaViewer; import org.nuclearfog.twidda.activity.MediaViewer;
import org.nuclearfog.twidda.adapter.ImageAdapter;
import java.io.InputStream; import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -26,7 +25,6 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
} }
private WeakReference<MediaViewer> ui; private WeakReference<MediaViewer> ui;
private ImageAdapter imageAdapter;
private Action action; private Action action;
@ -38,7 +36,6 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
*/ */
public ImageLoader(@NonNull MediaViewer context, Action action) { public ImageLoader(@NonNull MediaViewer context, Action action) {
ui = new WeakReference<>(context); ui = new WeakReference<>(context);
imageAdapter = context.getAdapter();
this.action = action; this.action = action;
} }
@ -75,14 +72,8 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
@Override @Override
protected void onProgressUpdate(Bitmap[] btm) { protected void onProgressUpdate(Bitmap[] btm) {
Bitmap image = btm[0]; if (ui.get() != null)
if (ui.get() != null) { ui.get().setImage(btm[0]);
if (imageAdapter.isEmpty()) {
ui.get().setImage(image);
ui.get().disableProgressbar();
}
imageAdapter.addLast(btm[0]);
}
} }
@ -90,7 +81,7 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
protected void onPostExecute(Boolean success) { protected void onPostExecute(Boolean success) {
if (ui.get() != null) { if (ui.get() != null) {
if (success) { if (success) {
imageAdapter.disableLoading(); ui.get().setImage(null);
} else { } else {
Toast.makeText(ui.get(), R.string.error_image_download, Toast.LENGTH_SHORT).show(); Toast.makeText(ui.get(), R.string.error_image_download, Toast.LENGTH_SHORT).show();
ui.get().finish(); ui.get().finish();

View File

@ -112,8 +112,8 @@
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/dm_item_button_height" android:layout_height="@dimen/dm_item_button_height"
android:layout_marginEnd="@dimen/padding_side" android:layout_marginEnd="@dimen/margin_side"
android:layout_marginRight="@dimen/padding_side" android:layout_marginRight="@dimen/margin_side"
android:background="@drawable/button" android:background="@drawable/button"
android:text="@string/dm_answer" android:text="@string/dm_answer"
android:textSize="@dimen/textsize_button" /> android:textSize="@dimen/textsize_button" />

View File

@ -55,8 +55,8 @@
android:layout_width="@dimen/profile_image" android:layout_width="@dimen/profile_image"
android:layout_height="@dimen/profile_image" android:layout_height="@dimen/profile_image"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginStart="@dimen/padding_side" android:layout_marginStart="@dimen/margin_side"
android:layout_marginLeft="@dimen/padding_side" android:layout_marginLeft="@dimen/margin_side"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:contentDescription="@string/image_preview" /> android:contentDescription="@string/image_preview" />

View File

@ -152,19 +152,17 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout>
<LinearLayout </FrameLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/padding_side"
android:paddingRight="@dimen/padding_side">
<TextView <TextView
android:id="@+id/bio" android:id="@+id/bio"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_side"
android:layout_marginStart="@dimen/margin_side"
android:layout_marginRight="@dimen/margin_side"
android:layout_marginEnd="@dimen/margin_side"
android:layout_marginTop="@dimen/profile_tv_margin" android:layout_marginTop="@dimen/profile_tv_margin"
android:fadeScrollbars="false" android:fadeScrollbars="false"
android:linksClickable="true" android:linksClickable="true"
@ -175,6 +173,10 @@
android:id="@+id/location" android:id="@+id/location"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_side"
android:layout_marginStart="@dimen/margin_side"
android:layout_marginRight="@dimen/margin_side"
android:layout_marginEnd="@dimen/margin_side"
android:layout_marginTop="@dimen/profile_tv_margin" android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable" android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true" android:singleLine="true"
@ -186,6 +188,10 @@
android:id="@+id/links" android:id="@+id/links"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_side"
android:layout_marginStart="@dimen/margin_side"
android:layout_marginRight="@dimen/margin_side"
android:layout_marginEnd="@dimen/margin_side"
android:layout_marginTop="@dimen/profile_tv_margin" android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable" android:drawablePadding="@dimen/padding_drawable"
android:linksClickable="true" android:linksClickable="true"
@ -198,13 +204,16 @@
android:id="@+id/profile_date" android:id="@+id/profile_date"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_side"
android:layout_marginStart="@dimen/margin_side"
android:layout_marginRight="@dimen/margin_side"
android:layout_marginEnd="@dimen/margin_side"
android:layout_marginTop="@dimen/profile_tv_margin" android:layout_marginTop="@dimen/profile_tv_margin"
android:drawablePadding="@dimen/padding_drawable" android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true" android:singleLine="true"
android:textSize="@dimen/textsize_profile" android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/calendar" app:drawableLeftCompat="@drawable/calendar"
app:drawableStartCompat="@drawable/calendar" /> app:drawableStartCompat="@drawable/calendar" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -148,4 +148,5 @@
<string name="enter_username">Nutzernamen eingeben</string> <string name="enter_username">Nutzernamen eingeben</string>
<string name="profile_banner">Profilbanner</string> <string name="profile_banner">Profilbanner</string>
<string name="editprofile_add_banner">Profilbanner hinzufügen</string> <string name="editprofile_add_banner">Profilbanner hinzufügen</string>
<string name="error_invalid_link">Ungültiger Link!</string>
</resources> </resources>

View File

@ -13,10 +13,11 @@
<dimen name="margin_layout">5dp</dimen> <dimen name="margin_layout">5dp</dimen>
<dimen name="margin_layout_tweet">2dp</dimen> <dimen name="margin_layout_tweet">2dp</dimen>
<dimen name="margin_upload_btn">20dp</dimen> <dimen name="margin_upload_btn">20dp</dimen>
<dimen name="margin_side">10dp</dimen>
<dimen name="padding_side">10dp</dimen>
<dimen name="padding_editprofile">20dp</dimen> <dimen name="padding_editprofile">20dp</dimen>
<dimen name="padding_drawable">5dp</dimen> <dimen name="padding_drawable">5dp</dimen>
<dimen name="padding_side">10dp</dimen>
<dimen name="text_padding">5dp</dimen> <dimen name="text_padding">5dp</dimen>
<dimen name="text_bio_height">150dp</dimen> <dimen name="text_bio_height">150dp</dimen>

View File

@ -149,4 +149,5 @@
<string name="enter_username">Enter username</string> <string name="enter_username">Enter username</string>
<string name="profile_banner">Profile banner image</string> <string name="profile_banner">Profile banner image</string>
<string name="editprofile_add_banner">add banner</string> <string name="editprofile_add_banner">add banner</string>
<string name="error_invalid_link">invalid link!</string>
</resources> </resources>