diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c36cac993..d9ed11d1f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -501,6 +501,8 @@ android:value=".views.main.MainActivity" /> + + diff --git a/app/src/main/java/org/fdroid/fdroid/AboutActivity.java b/app/src/main/java/org/fdroid/fdroid/AboutActivity.java new file mode 100644 index 000000000..3e5587f6c --- /dev/null +++ b/app/src/main/java/org/fdroid/fdroid/AboutActivity.java @@ -0,0 +1,34 @@ +package org.fdroid.fdroid; + +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.TextView; + +public class AboutActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.about); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + setFinishOnTouchOutside(false); + } + + String versionName = Utils.getVersionName(this); + if (versionName != null) { + ((TextView) findViewById(R.id.version)).setText(versionName); + } + + findViewById(R.id.ok_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } +} diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index b26768c86..c812e1273 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -623,4 +623,19 @@ public final class Utils { Resources r = ctx.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); } + + @SuppressWarnings("unused") + public static class Profiler { + public final long startTime = System.currentTimeMillis(); + public final String logTag; + + public Profiler(String logTag) { + this.logTag = logTag; + } + + public void log(String message) { + long duration = System.currentTimeMillis() - startTime; + Utils.debugLog(logTag, "[" + duration + "ms] " + message); + } + } } diff --git a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java index 14b4b7d51..9a2bba8a2 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java +++ b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java @@ -207,6 +207,13 @@ public class PreferencesFragment extends PreferenceFragment */ private void initPrivilegedInstallerPreference() { final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER); + + // This code will be run each time the activity is resumed, and so we may have already removed + // this preference. + if (pref == null) { + return; + } + Preferences p = Preferences.get(); boolean enabled = p.isPrivilegedInstallerEnabled(); boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity()) diff --git a/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java index d5e2bb2b7..93391776c 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/whatsnew/WhatsNewAdapter.java @@ -53,19 +53,27 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { } return new AppCardController(activity, activity.getLayoutInflater().inflate(layout, parent, false)); - } @Override public int getItemViewType(int position) { if (position == 0) { return R.id.whats_new_feature; - } else if (position <= 2) { - return R.id.whats_new_large_tile; - } else if (position <= 4) { - return R.id.whats_new_small_tile; } else { - return R.id.whats_new_regular_list; + int relativePositionInCycle = position % 5; + switch (relativePositionInCycle) { + case 1: + case 2: + return R.id.whats_new_large_tile; + + case 3: + case 4: + return R.id.whats_new_small_tile; + + case 0: + default: + return R.id.whats_new_regular_list; + } } } @@ -85,17 +93,14 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { notifyDataSetChanged(); } - // TODO: Replace with https://github.com/lucasr/twoway-view which looks really really cool, but - // no longer under active development (despite heaps of forks/stars on github). public static class SpanSizeLookup extends GridLayoutManager.SpanSizeLookup { @Override public int getSpanSize(int position) { - if (position == 0) { + int relativePositionInCycle = position % 5; + if (relativePositionInCycle == 0) { return 2; - } else if (position <= 4) { - return 1; } else { - return 2; + return 1; } } } @@ -119,18 +124,18 @@ public class WhatsNewAdapter extends RecyclerView.Adapter { int horizontalPadding = (int) context.getResources().getDimension(R.dimen.whats_new__padding__app_card__horizontal); int verticalPadding = (int) context.getResources().getDimension(R.dimen.whats_new__padding__app_card__vertical); + int relativePositionInCycle = position % 5; if (position == 0) { // Don't set any padding for the first item as the FeatureImage behind it needs to butt right // up against the left/top/right of the screen. outRect.set(0, 0, 0, verticalPadding); - } else if (position <= 4) { - // Odd items are on the left, even on the right. + } else if (relativePositionInCycle != 0) { // The item on the left will have both left and right padding. The item on the right // will only have padding on the right. This will allow the same amount of padding // on the left, centre, and right of the grid, rather than double the padding in the // middle (which would happen if both left+right paddings were set for both items). boolean isLtr = ViewCompat.getLayoutDirection(parent) == ViewCompat.LAYOUT_DIRECTION_LTR; - boolean isAtStart = (position % 2) == 1; + boolean isAtStart = relativePositionInCycle == 1 || relativePositionInCycle == 3; int paddingStart = isAtStart ? horizontalPadding : 0; int paddingLeft = isLtr ? paddingStart : horizontalPadding; int paddingRight = isLtr ? horizontalPadding : paddingStart; diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml index 3d3d49a18..a08684e5d 100644 --- a/app/src/main/res/layout/about.xml +++ b/app/src/main/res/layout/about.xml @@ -50,6 +50,25 @@ android:text="@string/license_gplv3_later" style="@style/BodyText" /> + + +