bug fix, layout fix
This commit is contained in:
parent
faf73fed91
commit
a347b67907
|
@ -17,7 +17,7 @@ import android.widget.ProgressBar;
|
|||
import android.widget.Toast;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -33,7 +33,7 @@ import java.util.Date;
|
|||
import java.util.Locale;
|
||||
|
||||
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.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
@ -176,21 +176,22 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
|||
|
||||
@Override
|
||||
public void onImageClick(Bitmap image) {
|
||||
setImage(image);
|
||||
changeImage(image);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onImageTouch(Bitmap image) {
|
||||
boolean accessGranted = true;
|
||||
if (type == MEDIAVIEWER_IMAGE) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int check = checkSelfPermission(WRITE_EXTERNAL_STORAGE);
|
||||
if (check == PERMISSION_GRANTED) {
|
||||
storeImage(image);
|
||||
} else {
|
||||
if (check == PERMISSION_DENIED) {
|
||||
requestPermissions(REQ_WRITE_SD, REQCODE_SD);
|
||||
accessGranted = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (accessGranted) {
|
||||
storeImage(image);
|
||||
}
|
||||
}
|
||||
|
@ -225,17 +226,20 @@ public class MediaViewer extends AppCompatActivity implements OnImageClickListen
|
|||
}
|
||||
|
||||
|
||||
public ImageAdapter getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
||||
public void disableProgressbar() {
|
||||
public void setImage(@Nullable Bitmap image) {
|
||||
if (image != null) {
|
||||
if (adapter.isEmpty()) {
|
||||
changeImage(image);
|
||||
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;
|
||||
int destHeight = (int) (image.getHeight() / ratio);
|
||||
image = Bitmap.createScaledBitmap(image, width, destHeight, false);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.nuclearfog.twidda.database.GlobalSettings;
|
|||
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
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.os.AsyncTask.Status.RUNNING;
|
||||
import static android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
|
@ -147,18 +148,15 @@ public class MessagePopup extends AppCompatActivity implements OnClickListener {
|
|||
|
||||
|
||||
private void getMedia() {
|
||||
boolean accessGranted = true;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int check = checkSelfPermission(READ_EXTERNAL_STORAGE);
|
||||
if (check == PERMISSION_GRANTED) {
|
||||
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 {
|
||||
if (check == PERMISSION_DENIED) {
|
||||
requestPermissions(PERM_READ, REQ_PERM_READ);
|
||||
accessGranted = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (accessGranted) {
|
||||
Intent galleryIntent = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
|
||||
if (galleryIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivityForResult(galleryIntent, REQ_PERM_READ);
|
||||
|
|
|
@ -130,7 +130,11 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
|||
String userLoc = loc.getText().toString();
|
||||
String userBio = bio.getText().toString();
|
||||
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 {
|
||||
UserHolder userHolder = new UserHolder(username, userLink, userLoc, userBio, profileLink, bannerLink);
|
||||
editorAsync = new ProfileUpdater(this, userHolder);
|
||||
|
@ -208,18 +212,15 @@ public class ProfileEditor extends AppCompatActivity implements OnClickListener
|
|||
|
||||
|
||||
private void getMedia(int request) {
|
||||
boolean accessGranted = true;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int check = checkSelfPermission(READ_EXTERNAL_STORAGE);
|
||||
if (check == PackageManager.PERMISSION_GRANTED) {
|
||||
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 {
|
||||
if (check == PackageManager.PERMISSION_DENIED) {
|
||||
requestPermissions(PERM_READ, REQ_PERM);
|
||||
accessGranted = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (accessGranted) {
|
||||
Intent media = new Intent(ACTION_PICK, EXTERNAL_CONTENT_URI);
|
||||
if (media.resolveActivity(getPackageManager()) != null)
|
||||
startActivityForResult(media, request);
|
||||
|
|
|
@ -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_MODE;
|
||||
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,
|
||||
|
@ -136,7 +135,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
|||
replyName.setOnClickListener(this);
|
||||
ansButton.setOnClickListener(this);
|
||||
rtwButton.setOnClickListener(this);
|
||||
favButton.setOnClickListener(this);
|
||||
rtwButton.setOnLongClickListener(this);
|
||||
favButton.setOnLongClickListener(this);
|
||||
profile_img.setOnClickListener(this);
|
||||
|
@ -241,13 +239,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
|||
startActivity(userList);
|
||||
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:
|
||||
if (tweet != null) {
|
||||
Intent profile = new Intent(getApplicationContext(), UserProfile.class);
|
||||
|
|
|
@ -9,7 +9,6 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.activity.MediaViewer;
|
||||
import org.nuclearfog.twidda.adapter.ImageAdapter;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -26,7 +25,6 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
|
|||
}
|
||||
|
||||
private WeakReference<MediaViewer> ui;
|
||||
private ImageAdapter imageAdapter;
|
||||
private Action action;
|
||||
|
||||
|
||||
|
@ -38,7 +36,6 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
|
|||
*/
|
||||
public ImageLoader(@NonNull MediaViewer context, Action action) {
|
||||
ui = new WeakReference<>(context);
|
||||
imageAdapter = context.getAdapter();
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
@ -75,14 +72,8 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
|
|||
|
||||
@Override
|
||||
protected void onProgressUpdate(Bitmap[] btm) {
|
||||
Bitmap image = btm[0];
|
||||
if (ui.get() != null) {
|
||||
if (imageAdapter.isEmpty()) {
|
||||
ui.get().setImage(image);
|
||||
ui.get().disableProgressbar();
|
||||
}
|
||||
imageAdapter.addLast(btm[0]);
|
||||
}
|
||||
if (ui.get() != null)
|
||||
ui.get().setImage(btm[0]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,7 +81,7 @@ public class ImageLoader extends AsyncTask<String, Bitmap, Boolean> {
|
|||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() != null) {
|
||||
if (success) {
|
||||
imageAdapter.disableLoading();
|
||||
ui.get().setImage(null);
|
||||
} else {
|
||||
Toast.makeText(ui.get(), R.string.error_image_download, Toast.LENGTH_SHORT).show();
|
||||
ui.get().finish();
|
||||
|
|
|
@ -112,8 +112,8 @@
|
|||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dm_item_button_height"
|
||||
android:layout_marginEnd="@dimen/padding_side"
|
||||
android:layout_marginRight="@dimen/padding_side"
|
||||
android:layout_marginEnd="@dimen/margin_side"
|
||||
android:layout_marginRight="@dimen/margin_side"
|
||||
android:background="@drawable/button"
|
||||
android:text="@string/dm_answer"
|
||||
android:textSize="@dimen/textsize_button" />
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
android:layout_width="@dimen/profile_image"
|
||||
android:layout_height="@dimen/profile_image"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="@dimen/padding_side"
|
||||
android:layout_marginLeft="@dimen/padding_side"
|
||||
android:layout_marginStart="@dimen/margin_side"
|
||||
android:layout_marginLeft="@dimen/margin_side"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="@string/image_preview" />
|
||||
|
||||
|
|
|
@ -152,19 +152,17 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/padding_side"
|
||||
android:paddingRight="@dimen/padding_side">
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bio"
|
||||
android:layout_width="match_parent"
|
||||
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:fadeScrollbars="false"
|
||||
android:linksClickable="true"
|
||||
|
@ -175,6 +173,10 @@
|
|||
android:id="@+id/location"
|
||||
android:layout_width="match_parent"
|
||||
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:drawablePadding="@dimen/padding_drawable"
|
||||
android:singleLine="true"
|
||||
|
@ -186,6 +188,10 @@
|
|||
android:id="@+id/links"
|
||||
android:layout_width="match_parent"
|
||||
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:drawablePadding="@dimen/padding_drawable"
|
||||
android:linksClickable="true"
|
||||
|
@ -198,13 +204,16 @@
|
|||
android:id="@+id/profile_date"
|
||||
android:layout_width="match_parent"
|
||||
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:drawablePadding="@dimen/padding_drawable"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_profile"
|
||||
app:drawableLeftCompat="@drawable/calendar"
|
||||
app:drawableStartCompat="@drawable/calendar" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -148,4 +148,5 @@
|
|||
<string name="enter_username">Nutzernamen eingeben</string>
|
||||
<string name="profile_banner">Profilbanner</string>
|
||||
<string name="editprofile_add_banner">Profilbanner hinzufügen</string>
|
||||
<string name="error_invalid_link">Ungültiger Link!</string>
|
||||
</resources>
|
|
@ -13,10 +13,11 @@
|
|||
<dimen name="margin_layout">5dp</dimen>
|
||||
<dimen name="margin_layout_tweet">2dp</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_drawable">5dp</dimen>
|
||||
<dimen name="padding_side">10dp</dimen>
|
||||
|
||||
<dimen name="text_padding">5dp</dimen>
|
||||
<dimen name="text_bio_height">150dp</dimen>
|
||||
|
|
|
@ -149,4 +149,5 @@
|
|||
<string name="enter_username">Enter username</string>
|
||||
<string name="profile_banner">Profile banner image</string>
|
||||
<string name="editprofile_add_banner">add banner</string>
|
||||
<string name="error_invalid_link">invalid link!</string>
|
||||
</resources>
|
Loading…
Reference in New Issue