mirror of https://github.com/ThmmyNoLife/mTHMMY
Apostolos Fanakis
6 years ago
7 changed files with 391 additions and 2 deletions
@ -0,0 +1,97 @@ |
|||
{ |
|||
"changelogs": [ |
|||
{ |
|||
"version_code": 13, |
|||
"version": "5.0.0", |
|||
"release_date": "Someday in september.... hopefully", |
|||
"video": "Maybe someday", |
|||
"prelude": "May be useful sometimes.. like a text above the actual change list", |
|||
"change_list": [ |
|||
{ |
|||
"change": "feature", |
|||
"title": "Brand new editor view ARISES!", |
|||
"description": "Take advantage of the new post content editor to post like you never before. (hint: it can emoji)" |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "Uploads!", |
|||
"description": "Yes, it's true, you can now upload files. Small files, big files. It's really up to you." |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "New topics ooooonnn the wayyyyy.", |
|||
"description": "It was something missing." |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "Postal manipulation.", |
|||
"description": "Edit or delete your posts, if you dare." |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "Quotes: year 2018.", |
|||
"description": "You can quote from multiple pages. We did this too, just because." |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "Tweak it.", |
|||
"description": "Settings are now available, in case you want to change your notifications sound." |
|||
}, |
|||
{ |
|||
"change": "feature", |
|||
"title": "OMG this is a long changelog!!", |
|||
"description": "Well get used to it, we have ultra cool changelogs now!" |
|||
}, |
|||
{ |
|||
"change": "bug", |
|||
"title": "Unread posts missing.", |
|||
"description": "Know how you could only see the first page of your unread messages? Not anymore!" |
|||
},{ |
|||
"change": "bug", |
|||
"title": "Many bugs.", |
|||
"description": "We fixed a ton of other bugs to the app is now like 36.2% more bug free." |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "Much cutter icons in boards.", |
|||
"description": "Sticky icon changed to much the overall greatness of the forum, also a dot was added. Don't you just love dots?" |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "Post actions overflow.", |
|||
"description": "We noticed how post cards were getting cramped up by all the quote buttons and whatnot, so we moved some to an overflow." |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "Vectors once again.", |
|||
"description": "All icons are now in vector format. No zoom is scary in this parts!" |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "Reporting.", |
|||
"description": "Long overdue job was done in the reporting class. We shall now have an easier time fixing bothering bugs." |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "No wifi, no topic.", |
|||
"description": "Added a message in topics that warns when no connection is available." |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "Get mentioned.", |
|||
"description": "A yellow border is added to posts that quote you. It's beautiful!" |
|||
}, |
|||
{ |
|||
"change": "improvement", |
|||
"title": "The inner update.", |
|||
"description": "Updated the libraries used. So expect 4% better behavior." |
|||
}, |
|||
{ |
|||
"change": "undef", |
|||
"title": "You made it!", |
|||
"description": "Congrats, this is the end.. of the changelog! Have a cookie \uD83C\uDF6A" |
|||
} |
|||
] |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,155 @@ |
|||
package gr.thmmy.mthmmy.utils; |
|||
|
|||
import android.content.Context; |
|||
import android.content.SharedPreferences; |
|||
import android.support.annotation.Nullable; |
|||
import android.support.v7.app.AlertDialog; |
|||
import android.support.v7.preference.PreferenceManager; |
|||
import android.text.Spannable; |
|||
import android.text.SpannableStringBuilder; |
|||
import android.text.style.ForegroundColorSpan; |
|||
import android.view.LayoutInflater; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.TextView; |
|||
|
|||
import org.json.JSONArray; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
import gr.thmmy.mthmmy.BuildConfig; |
|||
import gr.thmmy.mthmmy.R; |
|||
import gr.thmmy.mthmmy.activities.main.MainActivity; |
|||
import timber.log.Timber; |
|||
|
|||
public class Changelog { |
|||
public enum LAUNCH_TYPE { |
|||
FIRST_LAUNCH_EVER, FIRST_LAUNCH_AFTER_UPDATE, NORMAL_LAUNCH |
|||
} |
|||
|
|||
private static final String PREF_VERSION_CODE_KEY = "VERSION_CODE"; |
|||
|
|||
@Nullable |
|||
public static LAUNCH_TYPE getLaunchType(Context context) { |
|||
final int notThere = -1; |
|||
|
|||
//Gets current version code
|
|||
int currentVersionCode = BuildConfig.VERSION_CODE; |
|||
//Gets saved version code
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
|||
int savedVersionCode = prefs.getInt(PREF_VERSION_CODE_KEY, notThere); |
|||
|
|||
//Checks for first run or upgrade
|
|||
if (currentVersionCode == savedVersionCode) { |
|||
//This is just a normal run
|
|||
return LAUNCH_TYPE.NORMAL_LAUNCH; |
|||
} else if (savedVersionCode == notThere) { |
|||
//Updates the shared preferences with the current version code
|
|||
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply(); |
|||
return LAUNCH_TYPE.FIRST_LAUNCH_EVER; |
|||
} else if (currentVersionCode > savedVersionCode) { |
|||
//Updates the shared preferences with the current version code
|
|||
prefs.edit().putInt(PREF_VERSION_CODE_KEY, currentVersionCode).apply(); |
|||
return LAUNCH_TYPE.FIRST_LAUNCH_AFTER_UPDATE; |
|||
} |
|||
//Manually changed the shared prefs?? Omg
|
|||
return null; |
|||
} |
|||
|
|||
public static AlertDialog getChangelogDialog(Context context) { |
|||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
|||
LayoutInflater inflater = ((MainActivity) context).getLayoutInflater(); |
|||
LinearLayout changelogView = (LinearLayout) inflater.inflate(R.layout.dialog_changelog, null); |
|||
|
|||
builder.setNegativeButton(R.string.dialog_not_interested_button, (dialog, which) -> dialog.dismiss()); |
|||
|
|||
try { |
|||
JSONObject jsonObject = new JSONObject(loadJSONFromAssets(context)); |
|||
JSONArray jsonArray = jsonObject.getJSONArray("changelogs"); |
|||
|
|||
for (int i = 0; i < jsonArray.length(); i++) { |
|||
JSONObject jsonObjectInner = jsonArray.getJSONObject(i); |
|||
int versionCode = jsonObjectInner.getInt("version_code"); |
|||
|
|||
if (versionCode == BuildConfig.VERSION_CODE) { |
|||
TextView version = changelogView.findViewById(R.id.version); |
|||
version.setText(context.getResources().getString(R.string.changelog_version_text, |
|||
jsonObjectInner.getString("version"))); |
|||
|
|||
TextView releaseDate = changelogView.findViewById(R.id.release_date); |
|||
releaseDate.setText(jsonObjectInner.getString("release_date")); |
|||
|
|||
LinearLayout changeListView = changelogView.findViewById(R.id.changelog_content); |
|||
|
|||
JSONArray changeList = jsonObjectInner.getJSONArray("change_list"); |
|||
for (int changeIndex = 0; changeIndex < changeList.length(); ++changeIndex) { |
|||
TextView changeText = new TextView(changeListView.getContext()); |
|||
changeText.setTextColor(context.getResources().getColor(R.color.primary_text)); |
|||
LinearLayout.LayoutParams params = new LinearLayout. |
|||
LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
|||
LinearLayout.LayoutParams.WRAP_CONTENT); |
|||
params.setMargins(0, 5, 0, 5); |
|||
changeText.setLayoutParams(params); |
|||
|
|||
JSONObject change = changeList.getJSONObject(changeIndex); |
|||
String changeType = change.getString("change"), |
|||
changeTitle = change.getString("title"), |
|||
changeDescription = change.getString("description"); |
|||
int changeColor; |
|||
|
|||
switch (changeType) { |
|||
case "feature": |
|||
changeColor = R.color.changelog_feature_dot; |
|||
break; |
|||
case "bug": |
|||
changeColor = R.color.changelog_bug_dot; |
|||
break; |
|||
case "improvement": |
|||
changeColor = R.color.changelog_improvement_dot; |
|||
break; |
|||
default: |
|||
changeColor = R.color.changelog_default_dot; |
|||
break; |
|||
} |
|||
|
|||
SpannableStringBuilder spannable = new SpannableStringBuilder("• " + |
|||
changeTitle + " " + changeDescription); |
|||
spannable.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), |
|||
0, changeTitle.length() + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
|||
spannable.setSpan(new ForegroundColorSpan(context.getResources().getColor(changeColor)), |
|||
0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
|||
|
|||
|
|||
changeText.setText(spannable); |
|||
changeListView.addView(changeText); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} catch (JSONException exception) { |
|||
Timber.e(exception, "Couldn't read changelog json from assets"); |
|||
} |
|||
|
|||
builder.setView(changelogView); |
|||
return builder.create(); |
|||
} |
|||
|
|||
@SuppressWarnings("ResultOfMethodCallIgnored") |
|||
private static String loadJSONFromAssets(Context context) { |
|||
String json; |
|||
try { |
|||
InputStream is = context.getAssets().open("changelog.json"); |
|||
int size = is.available(); |
|||
byte[] buffer = new byte[size]; |
|||
is.read(buffer); |
|||
is.close(); |
|||
json = new String(buffer, "UTF-8"); |
|||
} catch (IOException ex) { |
|||
ex.printStackTrace(); |
|||
return null; |
|||
} |
|||
return json; |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="47.5dp" |
|||
android:height="47.5dp" |
|||
android:viewportHeight="47.5" |
|||
android:viewportWidth="47.5"> |
|||
<group |
|||
android:scaleX="1.25" |
|||
android:scaleY="-1.25" |
|||
android:translateY="47.5"> |
|||
<path |
|||
android:fillColor="#553986" |
|||
android:pathData="M31 6l-4 0 0 -4 4 0 0 4z" /> |
|||
<path |
|||
android:fillColor="#553986" |
|||
android:pathData="M7 2L11 2 11 6 7 6 7 2Z" /> |
|||
<path |
|||
android:fillColor="#553986" |
|||
android:pathData="M21 24l4 0 0 -8 -4 0 0 8zm-4 -8l-4 0 0 8 4 0 0 -8zm14 11l-2 0 0 2 -2 0 0 2 -3 0 0 4 -2 0 0 -4 -6 0 0 4 -2 0 0 -4 -3 0 0 -2 -2 0 0 -2 -2 0 0 -7 -4 0 0 -2 4 0 0 -7 4 0 0 -5 5 0 0 5 6 0 0 -5 5 0 0 5 4 0 0 7 4 0 0 2 -4 0 0 7z" /> |
|||
<path |
|||
android:fillColor="#553986" |
|||
android:pathData="M35 20l2 0 0 11 -2 0 0 -11z" /> |
|||
<path |
|||
android:fillColor="#553986" |
|||
android:pathData="M1 20L3 20 3 31 1 31 1 20Z" /> |
|||
</group> |
|||
</vector> |
@ -0,0 +1,85 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:background="@color/background" |
|||
android:orientation="vertical" |
|||
android:paddingEnd="12dp" |
|||
android:paddingStart="12dp" |
|||
android:paddingTop="8dp"> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="horizontal"> |
|||
|
|||
<ImageView |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginEnd="5dp" |
|||
android:contentDescription="@string/alien_monster_mascot_description" |
|||
app:srcCompat="@drawable/twitter_unicode_alien_monster" /> |
|||
|
|||
<android.support.v7.widget.AppCompatTextView |
|||
android:layout_width="0dp" |
|||
android:layout_height="47.5dp" |
|||
android:layout_weight="1" |
|||
android:gravity="bottom" |
|||
android:text="@string/alien_monster_mascot_speech" |
|||
android:textColor="@color/primary_text" |
|||
app:autoSizeTextType="uniform" /> |
|||
</LinearLayout> |
|||
|
|||
<!-- Video might go here --> |
|||
|
|||
<android.support.v7.widget.AppCompatTextView |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginBottom="4dp" |
|||
android:layout_marginTop="8dp" |
|||
android:singleLine="true" |
|||
android:text="@string/changelog_subtitle" |
|||
android:textColor="@color/accent" |
|||
app:autoSizeTextType="uniform" /> |
|||
|
|||
<View |
|||
android:layout_width="match_parent" |
|||
android:layout_height="1dp" |
|||
android:layout_marginBottom="6dp" |
|||
android:background="@color/accent" /> |
|||
|
|||
<LinearLayout |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginBottom="12dp" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:id="@+id/version" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:textColor="@color/secondary_text" |
|||
android:textSize="12sp" /> |
|||
|
|||
<TextView |
|||
android:id="@+id/release_date" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:textAlignment="textEnd" |
|||
android:textColor="@color/secondary_text" |
|||
android:textSize="12sp" /> |
|||
</LinearLayout> |
|||
|
|||
<ScrollView |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content"> |
|||
|
|||
<LinearLayout |
|||
android:id="@+id/changelog_content" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:background="@color/background" |
|||
android:orientation="vertical" /> |
|||
</ScrollView> |
|||
</LinearLayout> |
Loading…
Reference in new issue