Clean some activities
This commit is contained in:
parent
0fc0b19e6f
commit
007d6b85fc
|
@ -130,4 +130,5 @@ dependencies {
|
|||
implementation 'com.github.smarteist:autoimageslider:1.3.2'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
|
||||
implementation 'com.jaredrummler:cyanea:1.0.2'
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.app.Activity;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -63,7 +62,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.exoplayer2.ui.PlaybackControlView;
|
||||
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
|
||||
|
@ -130,7 +128,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
private RelativeLayout loader;
|
||||
private TextView peertube_view_count, peertube_playlist, peertube_bookmark, peertube_like_count, peertube_dislike_count, peertube_share, peertube_download, peertube_description, peertube_title;
|
||||
private ScrollView peertube_information_container;
|
||||
private int stopPosition;
|
||||
private Peertube peertube;
|
||||
private TextView toolbar_title;
|
||||
private SimpleExoPlayerView playerView;
|
||||
|
@ -139,7 +136,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
private Dialog fullScreenDialog;
|
||||
private AppCompatImageView fullScreenIcon;
|
||||
private TextView resolution;
|
||||
private DefaultTrackSelector trackSelector;
|
||||
private int mode;
|
||||
private LinearLayout write_comment_container;
|
||||
private ImageView send;
|
||||
|
@ -150,8 +146,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
private List<Playlist> playlists;
|
||||
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null && activity.getWindow().getDecorView() != null) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
activity.getWindow().getDecorView();
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(INPUT_METHOD_SERVICE);
|
||||
assert imm != null;
|
||||
imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
@ -193,16 +191,13 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
add_comment_write = findViewById(R.id.add_comment_write);
|
||||
peertube_playlist = findViewById(R.id.peertube_playlist);
|
||||
send = findViewById(R.id.send);
|
||||
add_comment_read.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
add_comment_read.setOnClickListener(v -> {
|
||||
add_comment_read.setVisibility(View.GONE);
|
||||
add_comment_write.setVisibility(View.VISIBLE);
|
||||
send.setVisibility(View.VISIBLE);
|
||||
add_comment_write.requestFocus();
|
||||
add_comment_write.setSelection(add_comment_write.getText().length());
|
||||
|
||||
}
|
||||
});
|
||||
Helper.changeDrawableColor(PeertubeActivity.this, send, R.color.cyanea_accent);
|
||||
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
|
@ -213,9 +208,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
peertube_bookmark.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
send.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
send.setOnClickListener(v -> {
|
||||
String comment = add_comment_write.getText().toString();
|
||||
if (comment.trim().length() > 0) {
|
||||
new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -225,7 +218,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
send.setVisibility(View.GONE);
|
||||
add_comment_read.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
|
@ -250,12 +242,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,9 +258,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
|
||||
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(PeertubeActivity.this, webview_video, webview_container, videoLayout);
|
||||
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
||||
@Override
|
||||
public void toggledFullscreen(boolean fullscreen) {
|
||||
mastalabWebChromeClient.setOnToggledFullscreen(fullscreen -> {
|
||||
|
||||
if (fullscreen) {
|
||||
videoLayout.setVisibility(View.VISIBLE);
|
||||
|
@ -292,7 +277,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
videoLayout.setVisibility(View.GONE);
|
||||
peertube_information_container.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
|
||||
if (user_agent != null) {
|
||||
|
@ -443,21 +427,13 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
|
||||
String comment = input.getText().toString();
|
||||
if (comment.trim().length() > 0) {
|
||||
new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
}
|
||||
|
@ -496,9 +472,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
|
||||
|
||||
peertube_playlist.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_playlist.setOnClickListener(v -> {
|
||||
if (playlists != null && peertube.getId() != null) {
|
||||
PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist);
|
||||
|
||||
|
@ -514,38 +488,34 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
title = playlist.getDisplayName();
|
||||
}
|
||||
MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
item.setOnMenuItemClickListener(item1 -> {
|
||||
item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item1.setActionView(new View(PeertubeActivity.this));
|
||||
item1.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
item.setActionView(new View(PeertubeActivity.this));
|
||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
public boolean onMenuItemActionExpand(MenuItem item1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
public boolean onMenuItemActionCollapse(MenuItem item1) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (playlistForVideo.contains(playlist.getId())) {
|
||||
item.setTitle(playlist.getDisplayName());
|
||||
item1.setTitle(playlist.getDisplayName());
|
||||
new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.DELETE_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
playlistForVideo.remove(playlist.getId());
|
||||
} else {
|
||||
item.setTitle("✔ " + playlist.getDisplayName());
|
||||
item1.setTitle("✔ " + playlist.getDisplayName());
|
||||
new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.ADD_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
playlistForVideo.add(playlist.getId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -574,54 +544,40 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
initResolution();
|
||||
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
peertube_like_count.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_like_count.setOnClickListener(v -> {
|
||||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||
new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
peertube.setMyRating(newState);
|
||||
changeColor();
|
||||
}
|
||||
});
|
||||
peertube_dislike_count.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_dislike_count.setOnClickListener(v -> {
|
||||
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
||||
new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
peertube.setMyRating(newState);
|
||||
changeColor();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
peertube_like_count.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_like_count.setOnClickListener(v -> {
|
||||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||
Status status = new Status();
|
||||
status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
|
||||
CrossActions.doCrossAction(PeertubeActivity.this, RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.FAVOURITE, null, PeertubeActivity.this, true);
|
||||
peertube.setMyRating(newState);
|
||||
changeColor();
|
||||
}
|
||||
});
|
||||
peertube_dislike_count.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_dislike_count.setOnClickListener(v -> {
|
||||
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
||||
Status status = new Status();
|
||||
status.setUri("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
|
||||
CrossActions.doCrossAction(PeertubeActivity.this, RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE, status, null, API.StatusAction.UNFAVOURITE, null, PeertubeActivity.this, true);
|
||||
peertube.setMyRating(newState);
|
||||
changeColor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -642,9 +598,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
|
||||
|
||||
peertube_download.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_download.setOnClickListener(v -> {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(PeertubeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
|
@ -654,7 +608,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
} else {
|
||||
Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null, peertube.isStreamService()));
|
||||
}
|
||||
}
|
||||
});
|
||||
SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
|
||||
|
@ -667,27 +620,22 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
img = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube);
|
||||
peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, img, null, null);
|
||||
|
||||
peertube_bookmark.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
|
||||
if (peertubes == null || peertubes.size() == 0) {
|
||||
peertube_bookmark.setOnClickListener(v -> {
|
||||
List<Peertube> peertubes1 = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
|
||||
if (peertubes1 == null || peertubes1.size() == 0) {
|
||||
new PeertubeFavoritesDAO(PeertubeActivity.this, db).insert(peertube);
|
||||
Toasty.success(PeertubeActivity.this, getString(R.string.bookmark_add_peertube), Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
new PeertubeFavoritesDAO(PeertubeActivity.this, db).remove(peertube);
|
||||
Toasty.success(PeertubeActivity.this, getString(R.string.bookmark_remove_peertube), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (peertubes != null && peertubes.size() > 0) //Was initially in cache
|
||||
if (peertubes1 != null && peertubes1.size() > 0) //Was initially in cache
|
||||
peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border), null, null);
|
||||
else
|
||||
peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube), null, null);
|
||||
}
|
||||
});
|
||||
|
||||
peertube_share.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
peertube_share.setOnClickListener(v -> {
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via));
|
||||
String url;
|
||||
|
@ -703,7 +651,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
contentToot = Html.fromHtml(peertube.getDescription(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
else
|
||||
//noinspection deprecation
|
||||
contentToot = Html.fromHtml(peertube.getDescription()).toString();
|
||||
extra_text += contentToot;
|
||||
} else {
|
||||
|
@ -712,7 +659,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
|
||||
sendIntent.setType("text/plain");
|
||||
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -731,7 +677,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
change();
|
||||
} else {
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
setFullscreen(FullScreenMediaController.fullscreen.ON);
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
|
@ -822,19 +767,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PeertubeActivity.this, style);
|
||||
builderSingle.setTitle(R.string.pickup_resolution);
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
||||
for (String resolution : peertube.getResolution())
|
||||
arrayAdapter.add(resolution + "p");
|
||||
builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String res = arrayAdapter.getItem(which).substring(0, arrayAdapter.getItem(which).length() - 1);
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
|
||||
String res = Objects.requireNonNull(arrayAdapter.getItem(which)).substring(0, Objects.requireNonNull(arrayAdapter.getItem(which)).length() - 1);
|
||||
|
||||
if (playerView != null) {
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
|
@ -859,7 +797,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
@ -908,14 +845,11 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
PlaybackControlView controlView = playerView.findViewById(R.id.exo_controller);
|
||||
fullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
|
||||
View fullScreenButton = controlView.findViewById(R.id.exo_fullscreen_button);
|
||||
fullScreenButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fullScreenButton.setOnClickListener(v -> {
|
||||
if (!fullScreenMode)
|
||||
openFullscreenDialog();
|
||||
else
|
||||
closeFullscreenDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -923,12 +857,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
PlaybackControlView controlView = playerView.findViewById(R.id.exo_controller);
|
||||
resolution = controlView.findViewById(R.id.resolution);
|
||||
resolution.setText(String.format("%sp", peertube.getResolution().get(0)));
|
||||
resolution.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
displayResolution();
|
||||
}
|
||||
});
|
||||
resolution.setOnClickListener(v -> displayResolution());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ package app.fedilab.android.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -117,12 +116,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
toolbar_title.setText(R.string.update_video);
|
||||
}
|
||||
setContentView(R.layout.activity_peertube_edit);
|
||||
|
@ -142,37 +136,26 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
set_upload_enable_comments = findViewById(R.id.set_upload_enable_comments);
|
||||
|
||||
|
||||
set_upload_delete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
set_upload_delete.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builderInner;
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme1 = sharedpreferences1.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
if (theme1 == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
} else if (theme1 == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
builderInner = new AlertDialog.Builder(PeertubeEditUploadActivity.this, style);
|
||||
builderInner.setMessage(getString(R.string.delete_video_confirmation));
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
new PostActionAsyncTask(PeertubeEditUploadActivity.this, API.StatusAction.PEERTUBEDELETEVIDEO, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
}
|
||||
});
|
||||
//Get params from the API
|
||||
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||
|
@ -359,9 +342,6 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||
LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
||||
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||
LinkedHashMap<String, String> translations = null;
|
||||
if (peertubeInformation.getTranslations() != null)
|
||||
translations = new LinkedHashMap<>(peertubeInformation.getTranslations());
|
||||
|
||||
|
||||
int languagePosition = 0;
|
||||
|
@ -532,17 +512,15 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
});
|
||||
|
||||
|
||||
set_upload_submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String title = p_video_title.getText().toString().trim();
|
||||
set_upload_submit.setOnClickListener(v -> {
|
||||
String title1 = p_video_title.getText().toString().trim();
|
||||
String description = p_video_description.getText().toString().trim();
|
||||
boolean isNSFW = set_upload_nsfw.isChecked();
|
||||
boolean commentEnabled = set_upload_enable_comments.isChecked();
|
||||
peertube.setName(title);
|
||||
boolean isNSFW1 = set_upload_nsfw.isChecked();
|
||||
boolean commentEnabled1 = set_upload_enable_comments.isChecked();
|
||||
peertube.setName(title1);
|
||||
peertube.setDescription(description);
|
||||
peertube.setSensitive(isNSFW);
|
||||
peertube.setCommentsEnabled(commentEnabled);
|
||||
peertube.setSensitive(isNSFW1);
|
||||
peertube.setCommentsEnabled(commentEnabled1);
|
||||
peertube.setCategory(categoryToSend);
|
||||
peertube.setLicense(licenseToSend);
|
||||
peertube.setLanguage(languageToSend);
|
||||
|
@ -552,7 +530,6 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
|
|||
peertube.setTags(tags);
|
||||
set_upload_submit.setEnabled(false);
|
||||
new PostPeertubeAsyncTask(PeertubeEditUploadActivity.this, peertube, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
|
||||
set_upload_privacy.setSelection(privacyPosition);
|
||||
|
|
|
@ -119,12 +119,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
|
||||
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
toolbar_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_close.setOnClickListener(v -> finish());
|
||||
toolbar_title.setText(R.string.upload_video);
|
||||
}
|
||||
setContentView(R.layout.activity_peertube_upload);
|
||||
|
@ -335,9 +330,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
|
||||
}
|
||||
});
|
||||
set_upload_submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
set_upload_submit.setOnClickListener(v -> {
|
||||
if (uri != null) {
|
||||
Map.Entry<String, String> channelM = channelToSend.entrySet().iterator().next();
|
||||
String idChannel = channelM.getValue();
|
||||
|
@ -345,7 +338,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
Integer idPrivacy = privacyM.getKey();
|
||||
|
||||
try {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
UploadNotificationConfig uploadConfig = new UploadNotificationConfig();
|
||||
Intent in = new Intent(PeertubeUploadActivity.this, PeertubeEditUploadActivity.class);
|
||||
|
@ -382,7 +375,6 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
|
|||
exc.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ package app.fedilab.android.activities;
|
|||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -225,12 +224,9 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
public void onEditTextChangeListener(final View rootView, String text, int colorCode) {
|
||||
TextEditorDialogFragment textEditorDialogFragment =
|
||||
TextEditorDialogFragment.show(this, text, colorCode);
|
||||
textEditorDialogFragment.setOnTextEditorListener(new TextEditorDialogFragment.TextEditor() {
|
||||
@Override
|
||||
public void onDone(String inputText, int colorCode) {
|
||||
mPhotoEditor.editText(rootView, inputText, colorCode);
|
||||
textEditorDialogFragment.setOnTextEditorListener((inputText, colorCode1) -> {
|
||||
mPhotoEditor.editText(rootView, inputText, colorCode1);
|
||||
mTxtCurrentTool.setText(R.string.label_text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -295,6 +291,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
|
||||
File file = new File(myDir + "/" + filename);
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.createNewFile();
|
||||
|
||||
SaveSettings saveSettings = new SaveSettings.Builder()
|
||||
|
@ -446,25 +443,10 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this, style);
|
||||
builder.setMessage(getString(R.string.confirm_exit_editing));
|
||||
builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
saveImage();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.save, (dialog, which) -> saveImage());
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
|
||||
builder.setNegativeButton(R.string.discard, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.discard, (dialog, which) -> finish());
|
||||
builder.create().show();
|
||||
|
||||
}
|
||||
|
@ -484,12 +466,9 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
|
|||
break;
|
||||
case TEXT:
|
||||
TextEditorDialogFragment textEditorDialogFragment = TextEditorDialogFragment.show(this);
|
||||
textEditorDialogFragment.setOnTextEditorListener(new TextEditorDialogFragment.TextEditor() {
|
||||
@Override
|
||||
public void onDone(String inputText, int colorCode) {
|
||||
textEditorDialogFragment.setOnTextEditorListener((inputText, colorCode) -> {
|
||||
mPhotoEditor.addText(inputText, colorCode);
|
||||
mTxtCurrentTool.setText(R.string.label_text);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ERASER:
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.ClipData;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -52,11 +51,9 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -113,6 +110,7 @@ import java.util.GregorianCalendar;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -176,7 +174,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
public static boolean autocomplete;
|
||||
public static Uri photoFileUri = null;
|
||||
static boolean active = false;
|
||||
private static String instance;
|
||||
private static int searchDeep = 15;
|
||||
private final int PICK_IMAGE = 56556;
|
||||
private final int TAKE_PHOTO = 56532;
|
||||
|
@ -198,7 +195,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
private TextView toot_space_left;
|
||||
private String initialContent;
|
||||
private Account accountReply;
|
||||
private String userId;
|
||||
private Account account;
|
||||
private boolean removed;
|
||||
private boolean restoredScheduled;
|
||||
|
@ -228,9 +224,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
pixelfed_story.setEnabled(true);
|
||||
JSONObject response = null;
|
||||
ArrayList<String> successfullyUploadedFiles = null;
|
||||
ArrayList<String> successfullyUploadedFiles;
|
||||
try {
|
||||
response = new JSONObject(intent.getStringExtra("response"));
|
||||
response = new JSONObject(Objects.requireNonNull(intent.getStringExtra("response")));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -293,22 +289,19 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
Runnable myRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Runnable myRunnable = () -> {
|
||||
newContent[0] = newContent[0] + hugs.toString();
|
||||
toot_content.setText(newContent[0]);
|
||||
toot_content.setSelection(toot_content.getText().length());
|
||||
// toot_content.addTextChangedListener(finalTextw);
|
||||
autocomplete = false;
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
} else if (s.toString().contains(fedilabMorseTrigger)) {
|
||||
newContent[0] = s.toString().replaceAll(fedilabMorseTrigger, "").trim();
|
||||
List<String> mentions = new ArrayList<>();
|
||||
String mentionPattern = "@[a-z0-9_]+(@[a-z0-9\\.\\-]+[a-z0-9]+)?";
|
||||
String mentionPattern = "@[a-z0-9_]+(@[a-z0-9.\\-]+[a-z0-9]+)?";
|
||||
final Pattern mPattern = Pattern.compile(mentionPattern, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcherMentions = mPattern.matcher(newContent[0]);
|
||||
while (matcherMentions.find()) {
|
||||
|
@ -343,14 +336,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
Runnable myRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Runnable myRunnable = () -> {
|
||||
toot_content.setText(newContent[0]);
|
||||
toot_content.setSelection(toot_content.getText().length());
|
||||
autocomplete = false;
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
}
|
||||
|
@ -524,7 +514,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
String content = toot_content.getText().toString();
|
||||
String contentCount = content;
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||
contentCount = contentCount.replaceAll("(?i)(^|[^/\\w])@(([a-z0-9_]+)@[a-z0-9\\.\\-]+[a-z0-9]+)", "$1@$3");
|
||||
contentCount = contentCount.replaceAll("(?i)(^|[^/\\w])@(([a-z0-9_]+)@[a-z0-9.\\-]+[a-z0-9]+)", "$1@$3");
|
||||
Matcher matcherALink = Patterns.WEB_URL.matcher(contentCount);
|
||||
while (matcherALink.find()) {
|
||||
final String url = matcherALink.group(1);
|
||||
|
@ -540,16 +530,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PixelfedComposeActivity.this));
|
||||
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
switch (theme) {
|
||||
case Helper.THEME_LIGHT:
|
||||
setTheme(R.style.AppTheme_Fedilab);
|
||||
break;
|
||||
case Helper.THEME_DARK:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
break;
|
||||
case Helper.THEME_BLACK:
|
||||
setTheme(R.style.AppThemeBlack);
|
||||
break;
|
||||
|
@ -579,9 +564,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
ImageView close_toot = actionBar.getCustomView().findViewById(R.id.close_toot);
|
||||
|
||||
close_toot.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
close_toot.setOnClickListener(v -> {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
assert inputMethodManager != null;
|
||||
inputMethodManager.hideSoftInputFromWindow(toot_content.getWindowToken(), 0);
|
||||
|
@ -594,9 +577,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
} else {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
|
||||
dialogBuilder.setMessage(R.string.save_draft);
|
||||
dialogBuilder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
|
||||
if (accountReply == null) {
|
||||
storeToot(true, false);
|
||||
} else {
|
||||
|
@ -604,14 +585,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.discard, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialogBuilder.setNegativeButton(R.string.discard, (dialog, id) -> {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
|
@ -621,7 +598,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
|
||||
pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
|
||||
|
@ -658,11 +634,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, false)) {
|
||||
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(drawer_layout).build(toot_content);
|
||||
|
||||
toot_emoji.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toot_emoji.setOnClickListener(v -> {
|
||||
emojiPopup.toggle(); // Toggles visibility of the Popup.
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toot_emoji.setVisibility(View.GONE);
|
||||
|
@ -772,35 +745,18 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
break;
|
||||
}
|
||||
|
||||
toot_sensitive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
isSensitive = isChecked;
|
||||
}
|
||||
});
|
||||
toot_sensitive.setOnCheckedChangeListener((buttonView, isChecked) -> isSensitive = isChecked);
|
||||
|
||||
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
|
||||
|
||||
toot_visibility.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
tootVisibilityDialog();
|
||||
}
|
||||
});
|
||||
toot_visibility.setOnClickListener(v -> tootVisibilityDialog());
|
||||
|
||||
toot_it.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendToot(null);
|
||||
}
|
||||
});
|
||||
toot_it.setOnClickListener(v -> sendToot(null));
|
||||
|
||||
|
||||
pickup_picture.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
pickup_picture.setOnClickListener(v -> {
|
||||
|
||||
if (ContextCompat.checkSelfPermission(PixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -827,12 +783,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
startActivityForResult(chooserIntent, PICK_IMAGE);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
upload_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
upload_media.setOnClickListener(v -> {
|
||||
|
||||
if (ContextCompat.checkSelfPermission(PixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -859,7 +812,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
startActivityForResult(chooserIntent, PICK_IMAGE);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -1184,7 +1136,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
|
||||
LayoutInflater inflater = this.getLayoutInflater();
|
||||
View dialogView = inflater.inflate(R.layout.datetime_picker, null);
|
||||
View dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(PixelfedComposeActivity.this), false);
|
||||
dialogBuilder.setView(dialogView);
|
||||
final AlertDialog alertDialog = dialogBuilder.create();
|
||||
|
||||
|
@ -1198,35 +1150,22 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
|
||||
|
||||
//Buttons management
|
||||
date_time_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
date_time_next.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
|
||||
date_time_next.setOnClickListener(v -> {
|
||||
datePicker.setVisibility(View.GONE);
|
||||
timePicker.setVisibility(View.VISIBLE);
|
||||
date_time_previous.setVisibility(View.VISIBLE);
|
||||
date_time_next.setVisibility(View.GONE);
|
||||
date_time_set.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
date_time_previous.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
date_time_previous.setOnClickListener(v -> {
|
||||
datePicker.setVisibility(View.VISIBLE);
|
||||
timePicker.setVisibility(View.GONE);
|
||||
date_time_previous.setVisibility(View.GONE);
|
||||
date_time_next.setVisibility(View.VISIBLE);
|
||||
date_time_set.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
date_time_set.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
date_time_set.setOnClickListener(v -> {
|
||||
int hour, minute;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
hour = timePicker.getHour();
|
||||
|
@ -1247,26 +1186,19 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
} else {
|
||||
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
|
||||
builderSingle.setTitle(getString(R.string.choose_schedule));
|
||||
builderSingle.setNegativeButton(R.string.device_schedule, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
builderSingle.setNegativeButton(R.string.device_schedule, (dialog, which) -> {
|
||||
deviceSchedule(time[0]);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderSingle.setPositiveButton(R.string.server_schedule, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, int which) {
|
||||
builderSingle.setPositiveButton(R.string.server_schedule, (dialog, which) -> {
|
||||
int offset = TimeZone.getDefault().getRawOffset();
|
||||
calendar.add(Calendar.MILLISECOND, -offset);
|
||||
final String date = Helper.dateToString(new Date(calendar.getTimeInMillis()));
|
||||
serverSchedule(date);
|
||||
}
|
||||
});
|
||||
builderSingle.show();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
return true;
|
||||
|
@ -1336,8 +1268,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (namebar != null && namebar.getParent() != null)
|
||||
((ViewGroup) namebar.getParent()).removeView(namebar);
|
||||
}
|
||||
List<Attachment> tmp_attachment = new ArrayList<>();
|
||||
tmp_attachment.addAll(attachments);
|
||||
List<Attachment> tmp_attachment = new ArrayList<>(attachments);
|
||||
attachments.removeAll(tmp_attachment);
|
||||
tmp_attachment.clear();
|
||||
}
|
||||
|
@ -1413,15 +1344,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
dialog.setTitle(R.string.toot_visibility_tilte);
|
||||
final String[] stringArray = getResources().getStringArray(R.array.toot_visibility);
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PixelfedComposeActivity.this, android.R.layout.simple_list_item_1, stringArray);
|
||||
dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
dialog.setNegativeButton(R.string.cancel, (dialog12, position) -> dialog12.dismiss());
|
||||
dialog.setAdapter(arrayAdapter, (dialog1, position) -> {
|
||||
switch (position) {
|
||||
case 0:
|
||||
visibility = "public";
|
||||
|
@ -1441,8 +1365,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
break;
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
dialog1.dismiss();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
@ -1478,9 +1401,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
} else {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
|
||||
dialogBuilder.setMessage(R.string.save_draft);
|
||||
dialogBuilder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
|
||||
if (accountReply == null) {
|
||||
storeToot(true, false);
|
||||
} else {
|
||||
|
@ -1488,14 +1409,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
}
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.discard, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialogBuilder.setNegativeButton(R.string.discard, (dialog, id) -> {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
|
@ -1549,8 +1466,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (namebar != null && namebar.getParent() != null)
|
||||
((ViewGroup) namebar.getParent()).removeView(namebar);
|
||||
}
|
||||
List<Attachment> tmp_attachment = new ArrayList<>();
|
||||
tmp_attachment.addAll(attachments);
|
||||
List<Attachment> tmp_attachment = new ArrayList<>(attachments);
|
||||
attachments.removeAll(tmp_attachment);
|
||||
tmp_attachment.clear();
|
||||
}
|
||||
|
@ -1597,9 +1513,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
String[] searchA = oldContent.substring(0, currentCursorPosition).split("@");
|
||||
if (searchA.length > 0) {
|
||||
final String search = searchA[searchA.length - 1];
|
||||
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
toot_content.setOnItemClickListener((parent, view, position, id) -> {
|
||||
Account account = accounts.get(position);
|
||||
String deltaSearch = "";
|
||||
int searchLength = searchDeep;
|
||||
|
@ -1624,10 +1538,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot_content.setText(newContent);
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
toot_content.setSelection(newPosition);
|
||||
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
toot_content.setThreshold(1);
|
||||
toot_content.setAdapter(accountsListAdapter);
|
||||
}
|
||||
toot_content.setAdapter(accountsListAdapter1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1664,9 +1577,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
String[] searchA = oldContent.substring(0, currentCursorPosition).split(":");
|
||||
if (searchA.length > 0) {
|
||||
final String search = searchA[searchA.length - 1];
|
||||
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
toot_content.setOnItemClickListener((parent, view, position, id) -> {
|
||||
String shortcode = emojis.get(position).getShortcode();
|
||||
String deltaSearch = "";
|
||||
int searchLength = searchDeep;
|
||||
|
@ -1691,11 +1602,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot_content.setText(newContent);
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
toot_content.setSelection(newPosition);
|
||||
EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
toot_content.setThreshold(1);
|
||||
toot_content.setAdapter(emojisSearchAdapter);
|
||||
toot_content.setAdapter(emojisSearchAdapter1);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1725,9 +1635,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
if (searchA.length < 1)
|
||||
return;
|
||||
final String search = searchA[searchA.length - 1];
|
||||
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
toot_content.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if (position >= tags.size())
|
||||
return;
|
||||
String tag = tags.get(position);
|
||||
|
@ -1754,11 +1662,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
toot_content.setText(newContent);
|
||||
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
|
||||
toot_content.setSelection(newPosition);
|
||||
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
|
||||
toot_content.setThreshold(1);
|
||||
toot_content.setAdapter(tagsSearchAdapter);
|
||||
toot_content.setAdapter(tagsSearchAdapter1);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1776,10 +1683,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
restored = id;
|
||||
attachments = status.getMedia_attachments();
|
||||
|
||||
ArrayList<ImageView> toRemove = new ArrayList<>();
|
||||
|
||||
String content = status.getContent();
|
||||
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
|
||||
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[/\\w._-]*)\"\\s?[^.]*<\\s?/\\s?a\\s?>)");
|
||||
Matcher matcher = mentionLink.matcher(content);
|
||||
if (matcher.find()) {
|
||||
content = matcher.replaceAll("$3@$2");
|
||||
|
@ -1870,10 +1776,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
private void restoreServerSchedule(Status status) {
|
||||
|
||||
attachments = status.getMedia_attachments();
|
||||
ArrayList<ImageView> toRemove = new ArrayList<>();
|
||||
|
||||
String content = status.getContent();
|
||||
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
|
||||
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?://([\\da-z.-]+\\.[a-z.]{2,10})/(@[/\\w._-]*)\"\\s?[^.]*<\\s?/\\s?a\\s?>)");
|
||||
Matcher matcher = mentionLink.matcher(content);
|
||||
if (matcher.find()) {
|
||||
content = matcher.replaceAll("$3@$2");
|
||||
|
@ -1885,7 +1789,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
content = Html.fromHtml(content).toString();
|
||||
}
|
||||
if (attachments != null && attachments.size() > 0) {
|
||||
int i = 0;
|
||||
for (final Attachment attachment : attachments) {
|
||||
String url = attachment.getPreview_url();
|
||||
if (url == null || url.trim().equals(""))
|
||||
|
@ -1910,17 +1813,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
});
|
||||
imageView.setTag(attachment.getId());
|
||||
|
||||
imageView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
imageView.setOnLongClickListener(view -> false);
|
||||
if (attachments.size() < max_media_count)
|
||||
upload_media.setEnabled(true);
|
||||
toot_sensitive.setVisibility(View.VISIBLE);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
imageSlider.setVisibility(View.GONE);
|
||||
|
@ -2025,7 +1921,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
|
|||
boolean error = false;
|
||||
UploadServiceSingleBroadcastReceiver uploadReceiver;
|
||||
String filename;
|
||||
UpdateAccountInfoAsyncTask.SOCIAL social;
|
||||
boolean pixelfedStory;
|
||||
|
||||
asyncPicture(Activity activity, boolean pixelfedStory, Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
|
||||
|
|
Loading…
Reference in New Issue