Profile editing

This commit is contained in:
Grishka
2022-02-10 17:59:47 +03:00
parent b8e3426a1e
commit 82a8d0cc29
24 changed files with 718 additions and 42 deletions

View File

@@ -0,0 +1,31 @@
package org.joinmastodon.android.ui.utils;
import android.text.Editable;
import android.text.TextWatcher;
import java.util.function.Consumer;
import androidx.annotation.NonNull;
public class SimpleTextWatcher implements TextWatcher{
private final Consumer<Editable> delegate;
public SimpleTextWatcher(@NonNull Consumer<Editable> delegate){
this.delegate=delegate;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after){
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count){
}
@Override
public void afterTextChanged(Editable s){
delegate.accept(s);
}
}

View File

@@ -3,13 +3,16 @@ package org.joinmastodon.android.ui.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.OpenableColumns;
import android.util.Log;
import android.widget.TextView;
import org.joinmastodon.android.MastodonApp;
import org.joinmastodon.android.R;
import java.time.Instant;
@@ -80,4 +83,14 @@ public class UiUtils{
public static int lerp(int startValue, int endValue, float fraction) {
return startValue + Math.round(fraction * (endValue - startValue));
}
public static String getFileName(Uri uri){
try(Cursor cursor=MastodonApp.context.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)){
cursor.moveToFirst();
String name=cursor.getString(0);
if(name!=null)
return name;
}
return uri.getLastPathSegment();
}
}