Add release note inside the app.

This commit is contained in:
tom79 2019-11-22 19:10:20 +01:00
parent 7449f5b1df
commit a80d2a730f
12 changed files with 190 additions and 33 deletions

View File

@ -242,20 +242,20 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "kasun", "toot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "fedilab", "framapiaf.org", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "fedilab", "oot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "mmarif", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "guzzisti", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
SpannableString name = new SpannableString("@fedilab@framapiaf.org");
SpannableString name = new SpannableString("@fedilab@toot.fedilab.app");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_developers.setText(name);
txt_developers.setVisibility(View.VISIBLE);
txt_developers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.openBrowser(AboutActivity.this, "https://framapiaf.org/@fedilab");
Helper.openBrowser(AboutActivity.this, "https://toot.fedilab.app/@fedilab");
}
});
name = new SpannableString("@mmarif@mastodon.social");
@ -314,7 +314,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
@Override
public void onRetrieveRemoteAccount(Results results) {
public void onRetrieveRemoteAccount(Results results, boolean developerAccount) {
if (results == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return;

View File

@ -33,6 +33,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.util.Patterns;
@ -74,7 +75,10 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.tabs.TabLayout;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -93,19 +97,23 @@ import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.asynctasks.RetrieveInstanceAsyncTask;
import app.fedilab.android.asynctasks.RetrieveMetaDataAsyncTask;
import app.fedilab.android.asynctasks.RetrievePeertubeInformationAsyncTask;
import app.fedilab.android.asynctasks.RetrieveRelationshipAsyncTask;
import app.fedilab.android.asynctasks.RetrieveRemoteDataAsyncTask;
import app.fedilab.android.asynctasks.SyncTimelinesAsyncTask;
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
import app.fedilab.android.asynctasks.UpdateAccountInfoByIDAsyncTask;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.Account;
import app.fedilab.android.client.Entities.Error;
import app.fedilab.android.client.Entities.Filters;
import app.fedilab.android.client.Entities.Instance;
import app.fedilab.android.client.Entities.ManageTimelines;
import app.fedilab.android.client.Entities.Relationship;
import app.fedilab.android.client.Entities.Results;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.TagTimeline;
import app.fedilab.android.client.Entities.Version;
import app.fedilab.android.drawers.AccountSearchDevAdapter;
import app.fedilab.android.fragments.DisplayAccountsFragment;
import app.fedilab.android.fragments.DisplayBookmarksPixelfedFragment;
import app.fedilab.android.fragments.DisplayDraftsFragment;
@ -123,12 +131,14 @@ import app.fedilab.android.fragments.TabLayoutNotificationsFragment;
import app.fedilab.android.fragments.TabLayoutScheduleFragment;
import app.fedilab.android.fragments.WhoToFollowFragment;
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.ExpandableHeightListView;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MenuFloating;
import app.fedilab.android.interfaces.OnFilterActionInterface;
import app.fedilab.android.interfaces.OnRetrieveEmojiAccountInterface;
import app.fedilab.android.interfaces.OnRetrieveInstanceInterface;
import app.fedilab.android.interfaces.OnRetrieveMetaDataInterface;
import app.fedilab.android.interfaces.OnRetrieveRelationshipInterface;
import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface;
import app.fedilab.android.interfaces.OnSyncTimelineInterface;
import app.fedilab.android.interfaces.OnUpdateAccountInfoInterface;
@ -147,7 +157,7 @@ import static app.fedilab.android.helper.Helper.changeDrawableColor;
public abstract class BaseMainActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface, OnRetrieveEmojiAccountInterface, OnFilterActionInterface, OnSyncTimelineInterface {
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface, OnRetrieveRemoteAccountInterface, OnRetrieveEmojiAccountInterface, OnFilterActionInterface, OnSyncTimelineInterface, OnRetrieveRelationshipInterface {
public static String currentLocale;
@ -184,6 +194,8 @@ public abstract class BaseMainActivity extends BaseActivity
private Activity activity;
private BroadcastReceiver hidde_menu, update_topbar;
private Instance instanceClass;
private View dialogReleaseNoteView;
private List<Account> developers;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -1184,7 +1196,6 @@ public abstract class BaseMainActivity extends BaseActivity
delete_instance.setVisibility(View.GONE);
}
});
final int[] count2 = {0};
// Asked once for notification opt-in
boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false);
@ -1276,14 +1287,68 @@ public abstract class BaseMainActivity extends BaseActivity
}
});
try {
dialogBuilderOptin.show();
} catch (Exception ignored) {
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
dialogBuilderOptin.show();
}
}, 1000);
} catch (Exception ignored) {}
}else{
int lastReleaseNoteRead = sharedpreferences.getInt(Helper.SET_POPUP_RELEASE_NOTES, 0);
int versionCode = BuildConfig.VERSION_CODE;
if( lastReleaseNoteRead != versionCode ){ //Need to push release notes
new RetrieveRemoteDataAsyncTask(getApplicationContext(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open("changelogs/"+versionCode+".txt")));
String mLine;
StringBuilder finalContent = new StringBuilder();
while ((mLine = reader.readLine()) != null) {
finalContent.append(mLine).append("\n");
}
AlertDialog.Builder dialogBuilderOptin = new AlertDialog.Builder(BaseMainActivity.this, style);
LayoutInflater inflater = getLayoutInflater();
dialogReleaseNoteView = inflater.inflate(R.layout.popup_release_notes, new LinearLayout(getApplicationContext()), false);
dialogBuilderOptin.setView(dialogReleaseNoteView);
TextView release_title = dialogReleaseNoteView.findViewById(R.id.release_title);
TextView release_notes = dialogReleaseNoteView.findViewById(R.id.release_notes);
release_title.setText(getString(R.string.release_note_title, BuildConfig.VERSION_NAME));
release_notes.setText(finalContent);
dialogBuilderOptin.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
try {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
dialogBuilderOptin.show();
}
}, 1000);
} catch (Exception ignored) {}
}
catch (IOException ignored) {}
finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ignored) {}
}
}
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_POPUP_RELEASE_NOTES, versionCode);
editor.apply();
}
}
Helper.switchLayout(BaseMainActivity.this);
mamageNewIntent(getIntent());
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
@ -2000,23 +2065,45 @@ public abstract class BaseMainActivity extends BaseActivity
}
@Override
public void onRetrieveRemoteAccount(Results results) {
public void onRetrieveRemoteAccount(Results results, boolean developerAccount) {
if (results == null)
return;
List<Account> accounts = results.getAccounts();
List<Status> statuses = results.getStatuses();
if (accounts != null && accounts.size() > 0) {
Intent intent = new Intent(BaseMainActivity.this, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", accounts.get(0));
intent.putExtras(b);
startActivity(intent);
} else if (statuses != null && statuses.size() > 0) {
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
Bundle b = new Bundle();
b.putParcelable("status", statuses.get(0));
intent.putExtras(b);
startActivity(intent);
if( !developerAccount) {
if (accounts != null && accounts.size() > 0) {
Intent intent = new Intent(BaseMainActivity.this, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putParcelable("account", accounts.get(0));
intent.putExtras(b);
startActivity(intent);
} else if (statuses != null && statuses.size() > 0) {
Intent intent = new Intent(getApplicationContext(), ShowConversationActivity.class);
Bundle b = new Bundle();
b.putParcelable("status", statuses.get(0));
intent.putExtras(b);
startActivity(intent);
}
}else{
if( accounts != null && accounts.size() > 0 ) {
developers = new ArrayList<>();
developers.addAll(accounts);
new RetrieveRelationshipAsyncTask(getApplicationContext(), accounts.get(0).getId(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}
@Override
public void onRetrieveRelationship(Relationship relationship, Error error) {
if( dialogReleaseNoteView != null && developers != null && developers.size() > 0){
if( !relationship.isFollowing()){
ExpandableHeightListView lv_developers = dialogReleaseNoteView.findViewById(R.id.lv_developers);
lv_developers.setExpanded(true);
AccountSearchDevAdapter accountSearchWebAdapterDeveloper = new AccountSearchDevAdapter(developers);
lv_developers.setAdapter(accountSearchWebAdapterDeveloper);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
}
}
}
@ -2315,6 +2402,8 @@ public abstract class BaseMainActivity extends BaseActivity
return toot.getVisibility() == View.VISIBLE;
}
public enum iconLauncher {
BUBBLES,
FEDIVERSE,

View File

@ -140,7 +140,7 @@ public class OpencollectiveActivity extends BaseActivity implements OnRetrieveRe
@Override
public void onRetrieveRemoteAccount(Results results) {
public void onRetrieveRemoteAccount(Results results, boolean devAccount) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
if (results == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();

View File

@ -139,7 +139,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
@Override
public void onRetrieveRemoteAccount(Results results) {
public void onRetrieveRemoteAccount(Results results, boolean devAccount) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
if (results == null) {
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();

View File

@ -53,7 +53,7 @@ public class RetrieveOpenCollectiveAsyncTask extends AsyncTask<Void, Void, Void>
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveRemoteAccount(results);
listener.onRetrieveRemoteAccount(results, false);
}
public enum Type {

View File

@ -39,8 +39,16 @@ public class RetrieveRemoteDataAsyncTask extends AsyncTask<Void, Void, Void> {
private String url;
private Results results;
private WeakReference<Context> contextReference;
private boolean developerAccount = false;
public RetrieveRemoteDataAsyncTask(Context context, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface) {
this.url = "https://toot.fedilab.app/@fedilab";
developerAccount = true;
this.listener = onRetrieveRemoteAccountInterface;
this.contextReference = new WeakReference<>(context);
}
public RetrieveRemoteDataAsyncTask(Context context, String username, String instance, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface) {
this.url = Helper.instanceWithProtocol(context, instance) + "/@" + username;
this.listener = onRetrieveRemoteAccountInterface;
@ -64,7 +72,7 @@ public class RetrieveRemoteDataAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveRemoteAccount(results);
listener.onRetrieveRemoteAccount(results, developerAccount);
}
}

View File

@ -13,7 +13,6 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
@ -268,8 +267,6 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
Preference pref_import = findPreference("pref_import");
Preference pref_export = findPreference("pref_export");
Preference reset_pref = findPreference("reset_pref");
Log.v(Helper.TAG,"preferenceScreen! " + preferenceScreen);
Log.v(Helper.TAG,"theme_link_color! " + theme_link_color);
if (!sharedpreferences.getBoolean("use_custom_theme", false) ) {
preferenceScreen.removePreference(theme_link_color);
preferenceScreen.removePreference(theme_boost_header_color);

View File

@ -264,7 +264,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
}
@Override
public void onRetrieveRemoteAccount(Results results) {
public void onRetrieveRemoteAccount(Results results, boolean devAccount) {
if (results == null) {
return;
}

View File

@ -337,6 +337,7 @@ public class Helper {
public static final String SET_TIME_TO = "set_time_to";
public static final String SET_AUTO_STORE = "set_auto_store";
public static final String SET_POPUP_PUSH = "set_popup_push_new";
public static final String SET_POPUP_RELEASE_NOTES = "set_popup_push_release_notes";
public static final String SET_NSFW_TIMEOUT = "set_nsfw_timeout";
public static final String SET_MED_DESC_TIMEOUT = "set_med_desc_timeout";
public static final String SET_MEDIA_URLS = "set_media_urls";

View File

@ -22,5 +22,5 @@ import app.fedilab.android.client.Entities.Results;
* Interface for retrieving a remote account
*/
public interface OnRetrieveRemoteAccountInterface {
void onRetrieveRemoteAccount(Results results);
void onRetrieveRemoteAccount(Results results, boolean developerAccount);
}

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2019 Thomas Schneider
This file is a part of Fedilab
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with Fedilab; if not,
see <http://www.gnu.org/licenses>.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/release_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:textSize="18sp" />
<TextView
android:id="@+id/release_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="10dp"
android:gravity="start"
android:textSize="14sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="10dp"
android:text="@string/follow_account_update"
android:gravity="start"
android:textSize="16sp" />
<app.fedilab.android.helper.ExpandableHeightListView
android:id="@+id/lv_developers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:scrollbars="none" />
</LinearLayout>
</ScrollView>

View File

@ -1173,4 +1173,6 @@
<string name="instance_count">Instance count</string>
<string name="blocked">Blocked</string>
<string name="poll_finish_in">End in %s</string>
<string name="release_note_title">What\'s new in %s</string>
<string name="follow_account_update">You can follow our developer account for updates</string>
</resources>