From 776ad3f540385dc9f03770a759b2aa960230a624 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 9 May 2014 13:35:49 -0400 Subject: [PATCH 1/4] use only android-14 items in SelectLocalApps until appcompat-v7 is added Set android-14 as minimum for SelectLocalApps and make sure that everything will work on >= 14. fixes #26 https://gitlab.com/fdroid/fdroidclient/issues/26 --- res/layout/select_local_apps_list_item.xml | 8 ++++---- src/org/fdroid/fdroid/views/LocalRepoActivity.java | 2 +- .../fdroid/views/fragments/SelectLocalAppsFragment.java | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/res/layout/select_local_apps_list_item.xml b/res/layout/select_local_apps_list_item.xml index eb77c8fd7..895d3a3a1 100644 --- a/res/layout/select_local_apps_list_item.xml +++ b/res/layout/select_local_apps_list_item.xml @@ -27,8 +27,8 @@ @@ -41,8 +41,8 @@ android:id="@+id/application_label" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="?android:attr/listPreferredItemPaddingStart" - android:layout_marginStart="?android:attr/listPreferredItemPaddingStart" + android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft" + android:layout_marginStart="?android:attr/listPreferredItemPaddingLeft" android:layout_marginTop="6dip" android:textAppearance="?android:attr/textAppearanceListItem" /> diff --git a/src/org/fdroid/fdroid/views/LocalRepoActivity.java b/src/org/fdroid/fdroid/views/LocalRepoActivity.java index 5e1ffc23a..aaf7695d0 100644 --- a/src/org/fdroid/fdroid/views/LocalRepoActivity.java +++ b/src/org/fdroid/fdroid/views/LocalRepoActivity.java @@ -139,7 +139,7 @@ public class LocalRepoActivity extends Activity { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.local_repo_activity, menu); - if (Build.VERSION.SDK_INT < 11) // TODO remove after including appcompat-v7 + if (Build.VERSION.SDK_INT < 14) // TODO remove after including appcompat-v7 menu.findItem(R.id.menu_setup_repo).setVisible(false); return true; } diff --git a/src/org/fdroid/fdroid/views/fragments/SelectLocalAppsFragment.java b/src/org/fdroid/fdroid/views/fragments/SelectLocalAppsFragment.java index 87d692f9d..24b254cc6 100644 --- a/src/org/fdroid/fdroid/views/fragments/SelectLocalAppsFragment.java +++ b/src/org/fdroid/fdroid/views/fragments/SelectLocalAppsFragment.java @@ -86,7 +86,6 @@ public class SelectLocalAppsFragment extends ListFragment @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { - Log.i("SelectLocalAppsFragment", "ViewBinder " + columnIndex); if (columnIndex == cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID)) { String packageName = cursor.getString(columnIndex); TextView textView = (TextView) view.findViewById(R.id.package_name); From 09cbd036fa71acb040b1a777eb40c33b477d4660 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 9 May 2014 14:18:43 -0400 Subject: [PATCH 2/4] make new instances of LocalRepoActivity show state properly LocalRepoActivity needs to get the current state of the LocalRepoService so it can correctly represent it in the UI. fixes #25 https://gitlab.com/fdroid/fdroidclient/issues/25 --- src/org/fdroid/fdroid/FDroidApp.java | 4 ++++ src/org/fdroid/fdroid/views/LocalRepoActivity.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index 1e120dd97..c344db3c5 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -327,4 +327,8 @@ public class FDroidApp extends Application { } } } + + public static boolean isLocalRepoServiceRunnig() { + return localRepoServiceIsBound; + } } diff --git a/src/org/fdroid/fdroid/views/LocalRepoActivity.java b/src/org/fdroid/fdroid/views/LocalRepoActivity.java index aaf7695d0..b7d4e3f21 100644 --- a/src/org/fdroid/fdroid/views/LocalRepoActivity.java +++ b/src/org/fdroid/fdroid/views/LocalRepoActivity.java @@ -58,6 +58,7 @@ public class LocalRepoActivity extends Activity { public void onResume() { super.onResume(); resetNetworkInfo(); + setRepoSwitchChecked(FDroidApp.isLocalRepoServiceRunnig()); LocalBroadcastManager.getInstance(this).registerReceiver(onWifiChange, new IntentFilter(WifiStateChangeService.BROADCAST)); @@ -71,6 +72,9 @@ public class LocalRepoActivity extends Activity { // start repo by default FDroidApp.startLocalRepoService(LocalRepoActivity.this); + // reset the timer if viewing this Activity again + if (stopTimer != null) + stopTimer.cancel(); // automatically turn off after 15 minutes stopTimer = new Timer(); stopTimer.schedule(new TimerTask() { From 8a6204205f1e7d380cf78c1e1626eb5b573c6451 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 15 May 2014 11:46:17 -0400 Subject: [PATCH 3/4] store "Add Repo" AlertDialog to prevent crash on rotation When the "Add Repo" dialog was showing and the screen was rotated, it would first leak the AlertDialog because it was not dismissed, then it would crash after rotation, because the AlertDialog was trying to be restored but no longer existed. That's what I think was happening at least... the solution surprised me a bit here... --- .../views/fragments/RepoListFragment.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/org/fdroid/fdroid/views/fragments/RepoListFragment.java b/src/org/fdroid/fdroid/views/fragments/RepoListFragment.java index 07ae9a41f..0fc2b8fa1 100644 --- a/src/org/fdroid/fdroid/views/fragments/RepoListFragment.java +++ b/src/org/fdroid/fdroid/views/fragments/RepoListFragment.java @@ -58,6 +58,7 @@ import java.util.Locale; public class RepoListFragment extends ListFragment implements LoaderManager.LoaderCallbacks, RepoAdapter.EnabledListener { + private AlertDialog addRepoDialog; private static final String DEFAULT_NEW_REPO_TEXT = "https://"; private final int ADD_REPO = 1; private final int UPDATE_REPOS = 2; @@ -309,7 +310,7 @@ public class RepoListFragment extends ListFragment private void showAddRepo(String newAddress, String newFingerprint) { View view = getLayoutInflater(null).inflate(R.layout.addrepo, null); - final AlertDialog alrt = new AlertDialog.Builder(getActivity()).setView(view).create(); + addRepoDialog = new AlertDialog.Builder(getActivity()).setView(view).create(); final EditText uriEditText = (EditText) view.findViewById(R.id.edit_uri); final EditText fingerprintEditText = (EditText) view.findViewById(R.id.edit_fingerprint); @@ -322,9 +323,9 @@ public class RepoListFragment extends ListFragment ? RepoProvider.Helper.findByAddress(getActivity(), newAddress) : null; - alrt.setIcon(android.R.drawable.ic_menu_add); - alrt.setTitle(getString(R.string.repo_add_title)); - alrt.setButton(DialogInterface.BUTTON_POSITIVE, + addRepoDialog.setIcon(android.R.drawable.ic_menu_add); + addRepoDialog.setTitle(getString(R.string.repo_add_title)); + addRepoDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.repo_add_add), new DialogInterface.OnClickListener() { @Override @@ -344,7 +345,7 @@ public class RepoListFragment extends ListFragment } }); - alrt.setButton(DialogInterface.BUTTON_NEGATIVE, + addRepoDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override @@ -352,7 +353,7 @@ public class RepoListFragment extends ListFragment dialog.dismiss(); } }); - alrt.show(); + addRepoDialog.show(); final TextView overwriteMessage = (TextView) view.findViewById(R.id.overwrite_message); overwriteMessage.setVisibility(View.GONE); @@ -361,8 +362,8 @@ public class RepoListFragment extends ListFragment positiveAction = PositiveAction.ADD_NEW; } else { // found the address in the DB of existing repos - final Button addButton = alrt.getButton(DialogInterface.BUTTON_POSITIVE); - alrt.setTitle(R.string.repo_exists); + final Button addButton = addRepoDialog.getButton(DialogInterface.BUTTON_POSITIVE); + addRepoDialog.setTitle(R.string.repo_exists); overwriteMessage.setVisibility(View.VISIBLE); if (newFingerprint != null) newFingerprint = newFingerprint.toUpperCase(Locale.ENGLISH); @@ -375,7 +376,7 @@ public class RepoListFragment extends ListFragment // this entry already exists and is not enabled, offer to enable // it if (repo.inuse) { - alrt.dismiss(); + addRepoDialog.dismiss(); Toast.makeText(getActivity(), R.string.repo_exists_and_enabled, Toast.LENGTH_LONG).show(); return; @@ -439,6 +440,7 @@ public class RepoListFragment extends ListFragment */ private void finishedAddingRepo() { changed = true; + addRepoDialog = null; if (isImportingRepo) { getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); From c819d56f188a04c6984ececa9a5f627e674b4ecc Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 15 May 2014 14:32:16 -0400 Subject: [PATCH 4/4] add link to SDK references for android-support jar I tried lots of things to make it more general, but the implementation of this jar properties file is just too simple, so no variables can be used. I renamed the other files related to android-support to match the naming scheme. --- ...roid-support-v4.txt => android-support-v4.jar.LICENSE} | 0 ...droid-support-v4.txt => android-support-v4.jar.README} | 0 libs/android-support-v4.jar.properties | 8 ++++++++ 3 files changed, 8 insertions(+) rename libs/{NOTICE.android-support-v4.txt => android-support-v4.jar.LICENSE} (100%) rename libs/{README.android-support-v4.txt => android-support-v4.jar.README} (100%) create mode 100644 libs/android-support-v4.jar.properties diff --git a/libs/NOTICE.android-support-v4.txt b/libs/android-support-v4.jar.LICENSE similarity index 100% rename from libs/NOTICE.android-support-v4.txt rename to libs/android-support-v4.jar.LICENSE diff --git a/libs/README.android-support-v4.txt b/libs/android-support-v4.jar.README similarity index 100% rename from libs/README.android-support-v4.txt rename to libs/android-support-v4.jar.README diff --git a/libs/android-support-v4.jar.properties b/libs/android-support-v4.jar.properties new file mode 100644 index 000000000..bc9c2009a --- /dev/null +++ b/libs/android-support-v4.jar.properties @@ -0,0 +1,8 @@ +src=android-support-v4.jar +doc=/opt/android-sdk/docs/reference +# The String value of 'doc' is handed straight to `new java.io.File()` so it +# is not possible to use variables. Therefore, change "/opt/android-sdk" to +# the path to your Android SDK, i.e. the value of $ANDROID_HOME or ${sdk.dir} +# +# Here's the relevant source: +# https://android-review.googlesource.com/#/c/35702/3/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java