Skip to content

Commit

Permalink
bug fix, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Sep 5, 2022
1 parent d9ac1d8 commit 332d5e2
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 44 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

Expand Down
1 change: 0 additions & 1 deletion app/src/main/assets/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<head>
<style>
body { font-size: x-small; font-family: sans-serif; } pre { background-color: #eeeeee; padding: 1em; white-space: normal; }

</style>
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.json.JSONObject;
import org.nuclearfog.twidda.backend.api.impl.DirectmessageV1;
import org.nuclearfog.twidda.backend.api.impl.LocationV1;
import org.nuclearfog.twidda.backend.api.impl.MetricsImpl;
import org.nuclearfog.twidda.backend.api.impl.MetricsV2;
import org.nuclearfog.twidda.backend.api.impl.RelationV1;
import org.nuclearfog.twidda.backend.api.impl.TrendV1;
import org.nuclearfog.twidda.backend.api.impl.TweetV1;
Expand Down Expand Up @@ -1220,14 +1220,14 @@ public Directmessages getDirectmessages(String cursor) throws TwitterException {
*/
public Metrics getTweetMetrics(long tweetId) throws TwitterException {
List<String> params = new ArrayList<>();
params.add(MetricsImpl.PARAMS);
params.add(MetricsV2.PARAMS);
try {
Response response = get(TWEET_UNI + tweetId, params);
ResponseBody body = response.body();
if (body != null && response.code() == 200) {
JSONObject json = new JSONObject(body.string());
if (json.opt("data") != null) {
return new MetricsImpl(json);
return new MetricsV2(json);
}
}
throw new TwitterException(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
*
* @author nuclearfog
*/
public class MetricsImpl implements Metrics {
public class MetricsV2 implements Metrics {

/**
* parameters to get extra information
*/
public static final String PARAMS = "tweet.fields=organic_metrics%2Cpublic_metrics";

private int impressions;
Expand All @@ -25,7 +28,7 @@ public class MetricsImpl implements Metrics {
/**
* @param json tweet json object containing metrics information
*/
public MetricsImpl(JSONObject json) throws JSONException {
public MetricsV2(JSONObject json) throws JSONException {
JSONObject metricsData = json.getJSONObject("data");
JSONObject metricsOrganic = metricsData.getJSONObject("organic_metrics");
JSONObject metricsPublic = metricsData.getJSONObject("public_metrics");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public static int calculateIndexOffset(String text, int limit) {
// determine if a pair of chars represent an emoji
if (Character.isSurrogatePair(text.charAt(c), text.charAt(c + 1))) {
offset++;
limit++;
}
}
return offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ else if (returnCode == LoginActivity.RETURN_LOGIN_SUCCESSFUL) {
case REQUEST_ACCOUNT_CHANGE:
// check if account or theme changed
if (returnCode == AccountActivity.RETURN_ACCOUNT_CHANGED
|| returnCode == AccountActivity.RETURN_SETTINGS_CHANGED) {
|| returnCode == AccountActivity.RETURN_SETTINGS_CHANGED) {
AppStyles.setTheme(root, settings.getBackgroundColor());
AppStyles.setTabIcons(tabLayout, settings, R.array.home_tab_icons);
adapter.notifySettingsChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected void onCreate(Bundle savedInst) {
}
username.setText(author.getUsername());
screenname.setText(author.getScreenname());
tweetText.setText(Tagger.makeTextWithLinks(tweet.getText(),settings.getHighlightColor(), this));
tweetText.setText(Tagger.makeTextWithLinks(tweet.getText(), settings.getHighlightColor(), this));
created.setText(StringTools.formatCreationTime(getResources(), tweet.getTimestamp()));
}
profile.setOnClickListener(this);
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/drawable/quote.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M5.315,3.401c-1.61,0 -2.916,1.343 -2.916,3c0,1.656 1.306,3 2.916,3c2.915,0 0.972,5.799 -2.916,5.799v1.4C9.338,16.601 12.057,3.401 5.315,3.401zM13.715,3.401c-1.609,0 -2.915,1.343 -2.915,3c0,1.656 1.306,3 2.915,3c2.916,0 0.973,5.799 -2.915,5.799v1.4C17.738,16.601 20.457,3.401 13.715,3.401z"
android:fillColor="#FFFFFF"/>
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M5.315,3.401c-1.61,0 -2.916,1.343 -2.916,3c0,1.656 1.306,3 2.916,3c2.915,0 0.972,5.799 -2.916,5.799v1.4C9.338,16.601 12.057,3.401 5.315,3.401zM13.715,3.401c-1.609,0 -2.915,1.343 -2.915,3c0,1.656 1.306,3 2.915,3c2.916,0 0.973,5.799 -2.915,5.799v1.4C17.738,16.601 20.457,3.401 13.715,3.401z"
android:fillColor="#FFFFFF" />
</vector>
14 changes: 7 additions & 7 deletions app/src/main/res/drawable/views.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M10,4.4C3.439,4.4 0,9.232 0,10c0,0.766 3.439,5.6 10,5.6c6.56,0 10,-4.834 10,-5.6C20,9.232 16.56,4.4 10,4.4zM10,14.307c-2.455,0 -4.445,-1.928 -4.445,-4.307S7.545,5.691 10,5.691s4.444,1.93 4.444,4.309S12.455,14.307 10,14.307zM10,10c-0.407,-0.447 0.663,-2.154 0,-2.154c-1.228,0 -2.223,0.965 -2.223,2.154S8.772,12.154 10,12.154c1.227,0 2.223,-0.965 2.223,-2.154C12.223,9.453 10.346,10.379 10,10z"
android:fillColor="#FFFFFF"/>
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M10,4.4C3.439,4.4 0,9.232 0,10c0,0.766 3.439,5.6 10,5.6c6.56,0 10,-4.834 10,-5.6C20,9.232 16.56,4.4 10,4.4zM10,14.307c-2.455,0 -4.445,-1.928 -4.445,-4.307S7.545,5.691 10,5.691s4.444,1.93 4.444,4.309S12.455,14.307 10,14.307zM10,10c-0.407,-0.447 0.663,-2.154 0,-2.154c-1.228,0 -2.223,0.965 -2.223,2.154S8.772,12.154 10,12.154c1.227,0 2.223,-0.965 2.223,-2.154C12.223,9.453 10.346,10.379 10,10z"
android:fillColor="#FFFFFF" />
</vector>
33 changes: 16 additions & 17 deletions app/src/main/res/layout/page_metrics.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/metrics_root"
android:layout_width="match_parent"
Expand All @@ -22,7 +21,7 @@
android:layout_marginStart="@dimen/metrics_profileimage_margin"
android:layout_marginTop="@dimen/metrics_profileimage_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/metrics_toolbar"/>
app:layout_constraintTop_toBottomOf="@id/metrics_toolbar" />

<TextView
android:id="@+id/metrics_username"
Expand All @@ -35,7 +34,7 @@
app:layout_constraintStart_toEndOf="@id/metrics_profile"
app:layout_constraintTop_toTopOf="@id/metrics_profile"
app:layout_constraintBottom_toTopOf="@id/metrics_screenname"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />

<TextView
android:id="@+id/metrics_screenname"
Expand All @@ -48,7 +47,7 @@
app:layout_constraintStart_toEndOf="@id/metrics_profile"
app:layout_constraintTop_toBottomOf="@id/metrics_username"
app:layout_constraintBottom_toTopOf="@id/metrics_created"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />

<TextView
android:id="@+id/metrics_created"
Expand All @@ -60,14 +59,14 @@
app:layout_constraintStart_toEndOf="@id/metrics_profile"
app:layout_constraintTop_toBottomOf="@id/metrics_screenname"
app:layout_constraintBottom_toBottomOf="@id/metrics_profile"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />

<androidx.constraintlayout.widget.Barrier
android:id="@+id/metrics_tweet_barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:barrierDirection="bottom"
app:constraint_referenced_ids="metrics_screenname,metrics_profile"/>
app:constraint_referenced_ids="metrics_screenname,metrics_profile" />

<TextView
android:id="@+id/metrics_tweet"
Expand All @@ -78,7 +77,7 @@
android:layout_margin="@dimen/metrics_textview_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/metrics_tweet_barrier"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent" />

<ScrollView
android:id="@+id/metrics_scroll"
Expand All @@ -102,7 +101,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_retweets"
Expand All @@ -112,7 +111,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_favorits"
Expand All @@ -122,7 +121,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_replies"
Expand All @@ -132,7 +131,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_quotes"
Expand All @@ -142,7 +141,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_link_count"
Expand All @@ -152,7 +151,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_profile_count"
Expand All @@ -162,7 +161,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

<TextView
android:id="@+id/metrics_video_clicks"
Expand All @@ -172,7 +171,7 @@
android:drawablePadding="@dimen/metrics_padding_drawable_big"
android:layout_margin="@dimen/metrics_item_margin"
android:textSize="@dimen/metrics_textsize_big"
android:gravity="end"/>
android:gravity="end" />

</LinearLayout>

Expand All @@ -185,6 +184,6 @@
app:layout_constraintStart_toStartOf="@id/metrics_scroll"
app:layout_constraintTop_toTopOf="@id/metrics_scroll"
app:layout_constraintBottom_toBottomOf="@id/metrics_scroll"
app:layout_constraintEnd_toEndOf="@id/metrics_scroll"/>
app:layout_constraintEnd_toEndOf="@id/metrics_scroll" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
2 changes: 1 addition & 1 deletion app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFA500</color>
<color name="ic_launcher_background">#FFA500</color>
</resources>

0 comments on commit 332d5e2

Please sign in to comment.