Compare commits

..

10 Commits

Author SHA1 Message Date
sk
ef207f885b increase update check interval 2022-11-04 03:37:32 +01:00
sk
c4eee28335 Merge branch 'feature/check-for-update-button' into fork 2022-11-04 03:34:06 +01:00
sk
6fe466779e add toash message 2022-11-04 03:33:41 +01:00
sk
e71db1b883 custom app name in strings 2022-11-04 03:11:10 +01:00
sk
b6efafe99d Merge branch 'feature/check-for-update-button' into fork 2022-11-04 03:09:39 +01:00
sk
688d466f8e implement manual update check settings item 2022-11-04 03:09:19 +01:00
Samuel Kaiser
3c5797932e add download badge 2022-11-03 17:42:31 +01:00
sk
48a5e262ce bump version 2022-11-03 17:18:57 +01:00
sk
63b0365208 remove reverted default visibility 2022-11-03 17:18:42 +01:00
sk
972c05d60b Revert "set unlisted as default visibility"
This reverts commit d34653750e.
2022-11-03 17:13:10 +01:00
9 changed files with 90 additions and 27 deletions

View File

@@ -4,6 +4,8 @@
> A fork of the [official Mastodon Android app](https://github.com/mastodon/mastodon-android) adding important features that are missing in the official app and possibly wont ever be implemented, such as the federated timeline, unlisted posting, bookmarks and an image description viewer. > A fork of the [official Mastodon Android app](https://github.com/mastodon/mastodon-android) adding important features that are missing in the official app and possibly wont ever be implemented, such as the federated timeline, unlisted posting, bookmarks and an image description viewer.
[![Download button](https://img.shields.io/badge/dynamic/json?color=ae218a&label=download%20apk&prefix=mastodos%20&query=%24.tag_name&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fsk22%2Fmastodon-android-fork%2Freleases%2Flatest&style=for-the-badge)](https://github.com/sk22/mastodon-android-fork/releases/latest/download/mastodos.apk)
## Changes ## Changes
### Features ### Features
@@ -17,7 +19,6 @@
### Behavior ### Behavior
* [Set “Unlisted” as default posting visibility](https://github.com/sk22/mastodon-android-fork/tree/feature/enable-unlisted-as-default)
* [Make back button return to the home tab before exiting the app](https://github.com/sk22/mastodon-android-fork/tree/feature/back-returns-home) ([Fixes issue](https://github.com/mastodon/mastodon-android/issues/118)) * [Make back button return to the home tab before exiting the app](https://github.com/sk22/mastodon-android-fork/tree/feature/back-returns-home) ([Fixes issue](https://github.com/mastodon/mastodon-android/issues/118))
* [Always preserve content warnings when replying](https://github.com/sk22/mastodon-android-fork/tree/feature/always-preserve-cw) ([Fixes issue](https://github.com/mastodon/mastodon-android/issues/113)) * [Always preserve content warnings when replying](https://github.com/sk22/mastodon-android-fork/tree/feature/always-preserve-cw) ([Fixes issue](https://github.com/mastodon/mastodon-android/issues/113))
* [Display full image when adding image description](https://github.com/sk22/mastodon-android-fork/tree/feature/compose-image-description-full-image) ([Pull request](https://github.com/mastodon/mastodon-android/pull/182)) * [Display full image when adding image description](https://github.com/sk22/mastodon-android-fork/tree/feature/compose-image-description-full-image) ([Pull request](https://github.com/mastodon/mastodon-android/pull/182))

View File

@@ -9,8 +9,8 @@ android {
applicationId "org.joinmastodon.android.sk" applicationId "org.joinmastodon.android.sk"
minSdk 23 minSdk 23
targetSdk 33 targetSdk 33
versionCode 27 versionCode 28
versionName "1.1.4+fork.27" versionName "1.1.4+fork.28"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@@ -26,6 +26,8 @@ import org.joinmastodon.android.api.MastodonAPIController;
import org.joinmastodon.android.events.SelfUpdateStateChangedEvent; import org.joinmastodon.android.events.SelfUpdateStateChangedEvent;
import java.io.File; import java.io.File;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -36,7 +38,7 @@ import okhttp3.Response;
@Keep @Keep
public class GithubSelfUpdaterImpl extends GithubSelfUpdater{ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
private static final long CHECK_PERIOD=24*3600*1000L; private static final long CHECK_PERIOD=6*3600*1000L;
private static final String TAG="GithubSelfUpdater"; private static final String TAG="GithubSelfUpdater";
private UpdateState state=UpdateState.NO_UPDATE; private UpdateState state=UpdateState.NO_UPDATE;
@@ -101,6 +103,12 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
} }
} }
@Override
public void checkForUpdates() {
setState(UpdateState.CHECKING);
MastodonAPIController.runInBackground(this::actuallyCheckForUpdates);
}
private void actuallyCheckForUpdates(){ private void actuallyCheckForUpdates(){
Request req=new Request.Builder() Request req=new Request.Builder()
.url("https://api.github.com/repos/sk22/mastodon-android-fork/releases/latest") .url("https://api.github.com/repos/sk22/mastodon-android-fork/releases/latest")

View File

@@ -185,7 +185,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private ImageView sendError; private ImageView sendError;
private View sendingOverlay; private View sendingOverlay;
private WindowManager wm; private WindowManager wm;
private StatusPrivacy statusVisibility=StatusPrivacy.UNLISTED; private StatusPrivacy statusVisibility=StatusPrivacy.PUBLIC;
private ComposeAutocompleteSpan currentAutocompleteSpan; private ComposeAutocompleteSpan currentAutocompleteSpan;
private FrameLayout mainEditTextWrap; private FrameLayout mainEditTextWrap;
private ComposeAutocompleteViewController autocompleteViewController; private ComposeAutocompleteViewController autocompleteViewController;

View File

@@ -15,6 +15,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
@@ -71,6 +72,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
private PushSubscription pushSubscription; private PushSubscription pushSubscription;
private ImageView themeTransitionWindowView; private ImageView themeTransitionWindowView;
private TextItem checkForUpdateItem;
@Override @Override
public void onCreate(Bundle savedInstanceState){ public void onCreate(Bundle savedInstanceState){
@@ -118,6 +120,10 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms"))); items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms")));
items.add(new RedHeaderItem(R.string.settings_spicy)); items.add(new RedHeaderItem(R.string.settings_spicy));
if (GithubSelfUpdater.needSelfUpdating()) {
checkForUpdateItem = new TextItem(R.string.check_for_update, GithubSelfUpdater.getInstance()::checkForUpdates);
items.add(checkForUpdateItem);
}
items.add(new TextItem(R.string.settings_clear_cache, this::clearImageCache)); items.add(new TextItem(R.string.settings_clear_cache, this::clearImageCache));
items.add(new TextItem(R.string.log_out, this::confirmLogOut)); items.add(new TextItem(R.string.log_out, this::confirmLogOut));
@@ -326,11 +332,25 @@ public class SettingsFragment extends MastodonToolbarFragment{
@Subscribe @Subscribe
public void onSelfUpdateStateChanged(SelfUpdateStateChangedEvent ev){ public void onSelfUpdateStateChanged(SelfUpdateStateChangedEvent ev){
if(items.get(0) instanceof UpdateItem item){ checkForUpdateItem.loading = ev.state == GithubSelfUpdater.UpdateState.CHECKING;
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(0); if (list.findViewHolderForAdapterPosition(items.indexOf(checkForUpdateItem)) instanceof TextViewHolder tvh) tvh.rebind();
if(holder instanceof UpdateViewHolder uvh){
uvh.bind(item); UpdateItem updateItem = null;
} if(items.get(0) instanceof UpdateItem item0) {
updateItem = item0;
} else if (ev.state != GithubSelfUpdater.UpdateState.CHECKING
&& ev.state != GithubSelfUpdater.UpdateState.NO_UPDATE) {
updateItem = new UpdateItem();
items.add(0, updateItem);
list.setAdapter(new SettingsAdapter());
}
if(updateItem != null && list.findViewHolderForAdapterPosition(0) instanceof UpdateViewHolder uvh){
uvh.bind(updateItem);
}
if (ev.state == GithubSelfUpdater.UpdateState.NO_UPDATE) {
Toast.makeText(getActivity(), R.string.no_update_available, Toast.LENGTH_SHORT).show();
} }
} }
@@ -398,10 +418,16 @@ public class SettingsFragment extends MastodonToolbarFragment{
private class TextItem extends Item{ private class TextItem extends Item{
private String text; private String text;
private Runnable onClick; private Runnable onClick;
private boolean loading;
public TextItem(@StringRes int text, Runnable onClick){ public TextItem(@StringRes int text, Runnable onClick) {
this(text, onClick, false);
}
public TextItem(@StringRes int text, Runnable onClick, boolean loading){
this.text=getString(text); this.text=getString(text);
this.onClick=onClick; this.onClick=onClick;
this.loading=loading;
} }
@Override @Override
@@ -630,14 +656,18 @@ public class SettingsFragment extends MastodonToolbarFragment{
private class TextViewHolder extends BindableViewHolder<TextItem> implements UsableRecyclerView.Clickable{ private class TextViewHolder extends BindableViewHolder<TextItem> implements UsableRecyclerView.Clickable{
private final TextView text; private final TextView text;
private final ProgressBar progress;
public TextViewHolder(){ public TextViewHolder(){
super(getActivity(), R.layout.item_settings_text, list); super(getActivity(), R.layout.item_settings_text, list);
text=(TextView) itemView; text = itemView.findViewById(R.id.text);
progress = itemView.findViewById(R.id.progress);
} }
@Override @Override
public void onBind(TextItem item){ public void onBind(TextItem item){
text.setText(item.text); text.setText(item.text);
progress.animate().alpha(item.loading ? 1 : 0);
} }
@Override @Override
@@ -692,8 +722,9 @@ public class SettingsFragment extends MastodonToolbarFragment{
@Override @Override
public void onBind(UpdateItem item){ public void onBind(UpdateItem item){
GithubSelfUpdater updater=GithubSelfUpdater.getInstance(); GithubSelfUpdater updater=GithubSelfUpdater.getInstance();
GithubSelfUpdater.UpdateInfo info=updater.getUpdateInfo();
GithubSelfUpdater.UpdateState state=updater.getState(); GithubSelfUpdater.UpdateState state=updater.getState();
if (state == GithubSelfUpdater.UpdateState.CHECKING) return;
GithubSelfUpdater.UpdateInfo info=updater.getUpdateInfo();
if(state!=GithubSelfUpdater.UpdateState.DOWNLOADED){ if(state!=GithubSelfUpdater.UpdateState.DOWNLOADED){
text.setText(getString(R.string.update_available, info.version)); text.setText(getString(R.string.update_available, info.version));
button.setText(getString(R.string.download_update, UiUtils.formatFileSize(getActivity(), info.size, false))); button.setText(getString(R.string.download_update, UiUtils.formatFileSize(getActivity(), info.size, false)));

View File

@@ -23,6 +23,8 @@ public abstract class GithubSelfUpdater{
return BuildConfig.BUILD_TYPE.equals("githubRelease") || BuildConfig.BUILD_TYPE.equals("debug"); return BuildConfig.BUILD_TYPE.equals("githubRelease") || BuildConfig.BUILD_TYPE.equals("debug");
} }
public abstract void checkForUpdates();
public abstract void maybeCheckForUpdates(); public abstract void maybeCheckForUpdates();
public abstract GithubSelfUpdater.UpdateState getState(); public abstract GithubSelfUpdater.UpdateState getState();

View File

@@ -1,13 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:orientation="horizontal"
android:layout_height="48dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp" android:paddingRight="16dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textSize="16sp" android:layoutDirection="locale">
android:textColor="?android:textColorPrimary" <TextView
android:singleLine="true" android:id="@+id/text"
android:ellipsize="end" android:layout_width="match_parent"
tools:text="daffdsa"/> android:layout_weight="1"
android:layout_height="48dp"
android:paddingRight="16dp"
android:gravity="center_vertical"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"
android:singleLine="true"
android:ellipsize="end"
tools:text="Account settings"/>
<ProgressBar
android:id="@+id/progress"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:alpha="0"
/>
</LinearLayout>

View File

@@ -271,7 +271,7 @@
<string name="settings_privacy_policy">Datenschutzbestimmungen</string> <string name="settings_privacy_policy">Datenschutzbestimmungen</string>
<string name="settings_spicy">Gefährliches</string> <string name="settings_spicy">Gefährliches</string>
<string name="settings_clear_cache">Medien-Cache leeren</string> <string name="settings_clear_cache">Medien-Cache leeren</string>
<string name="settings_app_version">Mastodon für Android v%1$s (%2$d)</string> <string name="settings_app_version">Mastodos v%1$s (%2$d)</string>
<string name="media_cache_cleared">Medien-Cache geleert</string> <string name="media_cache_cleared">Medien-Cache geleert</string>
<string name="confirm_log_out">Bist du dir sicher, dass du dich abmelden möchtest?</string> <string name="confirm_log_out">Bist du dir sicher, dass du dich abmelden möchtest?</string>
<string name="sensitive_content">Sensibler Inhalt</string> <string name="sensitive_content">Sensibler Inhalt</string>
@@ -387,10 +387,12 @@
<string name="upload_error_connection_lost">Dein Gerät hat gerade keinen Zugang zum Internet</string> <string name="upload_error_connection_lost">Dein Gerät hat gerade keinen Zugang zum Internet</string>
<string name="upload_processing">wird verarbeitet </string> <string name="upload_processing">wird verarbeitet </string>
<!-- %s is version like 1.2.3 --> <!-- %s is version like 1.2.3 -->
<string name="update_available">Mastodon für Android %s kann nun heruntergeladen werden.</string> <string name="update_available">Mastodos %s kann nun heruntergeladen werden.</string>
<!-- %s is version like 1.2.3 --> <!-- %s is version like 1.2.3 -->
<string name="update_ready">Mastodon für Android %s wurde heruntergeladen und kann nun installiert werden.</string> <string name="update_ready">Mastodos %s wurde heruntergeladen und kann nun installiert werden.</string>
<!-- %s is file size --> <!-- %s is file size -->
<string name="download_update">Download (%s)</string> <string name="download_update">Download (%s)</string>
<string name="install_update">Installieren</string> <string name="install_update">Installieren</string>
<string name="check_for_update">Auf Update prüfen</string>
<string name="no_update_available">Kein Update verfügbar</string>
</resources> </resources>

View File

@@ -275,7 +275,7 @@
<string name="settings_privacy_policy">Privacy policy</string> <string name="settings_privacy_policy">Privacy policy</string>
<string name="settings_spicy">The spicy zone</string> <string name="settings_spicy">The spicy zone</string>
<string name="settings_clear_cache">Clear media cache</string> <string name="settings_clear_cache">Clear media cache</string>
<string name="settings_app_version">Mastodon for Android v%1$s (%2$d)</string> <string name="settings_app_version">Mastodos v%1$s (%2$d)</string>
<string name="media_cache_cleared">Media cache cleared</string> <string name="media_cache_cleared">Media cache cleared</string>
<string name="confirm_log_out">Are you sure you want to sign out?</string> <string name="confirm_log_out">Are you sure you want to sign out?</string>
<string name="sensitive_content">Sensitive content</string> <string name="sensitive_content">Sensitive content</string>
@@ -396,12 +396,14 @@
<string name="upload_error_connection_lost">Your device lost connection to the internet</string> <string name="upload_error_connection_lost">Your device lost connection to the internet</string>
<string name="upload_processing">Processing…</string> <string name="upload_processing">Processing…</string>
<!-- %s is version like 1.2.3 --> <!-- %s is version like 1.2.3 -->
<string name="update_available">Mastodon for Android %s is ready to download.</string> <string name="update_available">Mastodos %s is ready to download.</string>
<!-- %s is version like 1.2.3 --> <!-- %s is version like 1.2.3 -->
<string name="update_ready">Mastodon for Android %s is downloaded and ready to install.</string> <string name="update_ready">Mastodos %s is downloaded and ready to install.</string>
<!-- %s is file size --> <!-- %s is file size -->
<string name="download_update">Download (%s)</string> <string name="download_update">Download (%s)</string>
<string name="install_update">Install</string> <string name="install_update">Install</string>
<string name="check_for_update">Check for update</string>
<string name="no_update_available">No update available</string>
<string name="privacy_policy_title">Mastodon and your privacy</string> <string name="privacy_policy_title">Mastodon and your privacy</string>
<string name="privacy_policy_subtitle">Although the Mastodon app does not collect any data, the server you sign up through may have a different policy. Take a minute to review and agree to the Mastodon app privacy policy and your server\'s privacy policy.</string> <string name="privacy_policy_subtitle">Although the Mastodon app does not collect any data, the server you sign up through may have a different policy. Take a minute to review and agree to the Mastodon app privacy policy and your server\'s privacy policy.</string>
<string name="i_agree">I Agree</string> <string name="i_agree">I Agree</string>