Style all switches equally, without indentation

This commit is contained in:
Daniel Martí 2015-04-16 18:41:39 +02:00
parent d6a8ef9e59
commit e1a6e2386f
15 changed files with 257 additions and 260 deletions

View File

@ -232,91 +232,91 @@ public class FDroid extends ActionBarActivity {
switch (item.getItemId()) {
case R.id.action_update_repo:
updateRepos();
return true;
case R.id.action_update_repo:
updateRepos();
return true;
case R.id.action_manage_repos:
Intent i = new Intent(this, ManageReposActivity.class);
startActivityForResult(i, REQUEST_MANAGEREPOS);
return true;
case R.id.action_manage_repos:
Intent i = new Intent(this, ManageReposActivity.class);
startActivityForResult(i, REQUEST_MANAGEREPOS);
return true;
case R.id.action_settings:
Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
startActivityForResult(prefs, REQUEST_PREFS);
return true;
case R.id.action_settings:
Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
startActivityForResult(prefs, REQUEST_PREFS);
return true;
case R.id.action_swap:
startActivity(new Intent(this, SwapActivity.class));
return true;
case R.id.action_swap:
startActivity(new Intent(this, SwapActivity.class));
return true;
case R.id.action_search:
onSearchRequested();
return true;
case R.id.action_search:
onSearchRequested();
return true;
case R.id.action_bluetooth_apk:
/*
* If Bluetooth has not been enabled/turned on, then enabling
* device discoverability will automatically enable Bluetooth
*/
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
// if this is successful, the Bluetooth transfer is started
return true;
case R.id.action_bluetooth_apk:
/*
* If Bluetooth has not been enabled/turned on, then enabling
* device discoverability will automatically enable Bluetooth
*/
Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
// if this is successful, the Bluetooth transfer is started
return true;
case R.id.action_about:
View view;
if (Build.VERSION.SDK_INT >= 11) {
LayoutInflater li = LayoutInflater.from(this);
view = li.inflate(R.layout.about, null);
} else {
view = View.inflate(
new ContextThemeWrapper(this, R.style.AboutDialogLight),
R.layout.about, null);
}
case R.id.action_about:
View view;
if (Build.VERSION.SDK_INT >= 11) {
LayoutInflater li = LayoutInflater.from(this);
view = li.inflate(R.layout.about, null);
} else {
view = View.inflate(
new ContextThemeWrapper(this, R.style.AboutDialogLight),
R.layout.about, null);
}
// Fill in the version...
try {
PackageInfo pi = getPackageManager()
.getPackageInfo(getApplicationContext()
.getPackageName(), 0);
((TextView) view.findViewById(R.id.version))
.setText(pi.versionName);
} catch (Exception e) {
}
// Fill in the version...
try {
PackageInfo pi = getPackageManager()
.getPackageInfo(getApplicationContext()
.getPackageName(), 0);
((TextView) view.findViewById(R.id.version))
.setText(pi.versionName);
} catch (Exception e) {
}
Builder p;
if (Build.VERSION.SDK_INT >= 11) {
p = new AlertDialog.Builder(this).setView(view);
} else {
p = new AlertDialog.Builder(
new ContextThemeWrapper(
this, R.style.AboutDialogLight)
).setView(view);
}
final AlertDialog alrt = p.create();
alrt.setIcon(R.drawable.ic_launcher);
alrt.setTitle(getString(R.string.about_title));
alrt.setButton(AlertDialog.BUTTON_NEUTRAL,
getString(R.string.about_website),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
Uri uri = Uri.parse("https://f-droid.org");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
});
alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alrt.show();
return true;
Builder p;
if (Build.VERSION.SDK_INT >= 11) {
p = new AlertDialog.Builder(this).setView(view);
} else {
p = new AlertDialog.Builder(
new ContextThemeWrapper(
this, R.style.AboutDialogLight)
).setView(view);
}
final AlertDialog alrt = p.create();
alrt.setIcon(R.drawable.ic_launcher);
alrt.setTitle(getString(R.string.about_title));
alrt.setButton(AlertDialog.BUTTON_NEUTRAL,
getString(R.string.about_website),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
Uri uri = Uri.parse("https://f-droid.org");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
});
alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alrt.show();
return true;
}
return super.onOptionsItemSelected(item);
}

View File

@ -101,15 +101,15 @@ public class FDroidApp extends Application {
public void applyTheme(Activity activity) {
switch (curTheme) {
case dark:
activity.setTheme(R.style.AppThemeDark);
break;
case light:
activity.setTheme(R.style.AppThemeLight);
break;
case lightWithDarkActionBar:
activity.setTheme(R.style.AppThemeLightWithDarkActionBar);
break;
case dark:
activity.setTheme(R.style.AppThemeDark);
break;
case light:
activity.setTheme(R.style.AppThemeLight);
break;
case lightWithDarkActionBar:
activity.setTheme(R.style.AppThemeLightWithDarkActionBar);
break;
}
}

View File

@ -64,9 +64,9 @@ public class PreferencesActivity extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}

View File

@ -354,28 +354,28 @@ public class ApkProvider extends FDroidProvider {
QuerySelection query = new QuerySelection(selection, selectionArgs);
switch (matcher.match(uri)) {
case CODE_LIST:
break;
case CODE_LIST:
break;
case CODE_SINGLE:
query = query.add(querySingle(uri));
break;
case CODE_SINGLE:
query = query.add(querySingle(uri));
break;
case CODE_APP:
query = query.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_APP:
query = query.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_APKS:
query = query.add(queryApks(uri.getLastPathSegment()));
break;
case CODE_APKS:
query = query.add(queryApks(uri.getLastPathSegment()));
break;
case CODE_REPO:
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
case CODE_REPO:
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
default:
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
default:
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
}
Query queryBuilder = new Query();
@ -423,27 +423,27 @@ public class ApkProvider extends FDroidProvider {
switch (matcher.match(uri)) {
case CODE_REPO:
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
case CODE_REPO:
query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment())));
break;
case CODE_APP:
query = query.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_APP:
query = query.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_APKS:
query = query.add(queryApks(uri.getLastPathSegment()));
break;
case CODE_APKS:
query = query.add(queryApks(uri.getLastPathSegment()));
break;
case CODE_LIST:
throw new UnsupportedOperationException("Can't delete all apks.");
case CODE_LIST:
throw new UnsupportedOperationException("Can't delete all apks.");
case CODE_SINGLE:
throw new UnsupportedOperationException("Can't delete individual apks.");
case CODE_SINGLE:
throw new UnsupportedOperationException("Can't delete individual apks.");
default:
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
default:
Log.e(TAG, "Invalid URI for apk content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
}
int rowsAffected = write().delete(getTableName(), query.getSelection(), query.getArgs());

View File

@ -87,16 +87,14 @@ public abstract class FDroidProvider extends ContentProvider {
@Override
public String getType(Uri uri) {
String type;
switch(getMatcher().match(uri)) {
case CODE_LIST:
type = "dir";
break;
case CODE_SINGLE:
default:
type = "item";
break;
switch (getMatcher().match(uri)) {
case CODE_LIST:
type = "dir";
break;
case CODE_SINGLE:
default:
type = "item";
break;
}
return "vnd.android.cursor." + type + "/vnd." + AUTHORITY + "." + getProviderName();
}

View File

@ -143,21 +143,21 @@ public class InstalledAppProvider extends FDroidProvider {
QuerySelection selection = new QuerySelection(customSelection, selectionArgs);
switch (matcher.match(uri)) {
case CODE_LIST:
break;
case CODE_LIST:
break;
case CODE_SINGLE:
selection = selection.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_SINGLE:
selection = selection.add(queryApp(uri.getLastPathSegment()));
break;
case CODE_SEARCH:
selection = selection.add(querySearch(uri.getLastPathSegment()));
break;
case CODE_SEARCH:
selection = selection.add(querySearch(uri.getLastPathSegment()));
break;
default:
String message = "Invalid URI for installed app content provider: " + uri;
Log.e(TAG, message);
throw new UnsupportedOperationException(message);
default:
String message = "Invalid URI for installed app content provider: " + uri;
Log.e(TAG, message);
throw new UnsupportedOperationException(message);
}
Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, sortOrder);

View File

@ -281,22 +281,22 @@ public class RepoProvider extends FDroidProvider {
}
switch (matcher.match(uri)) {
case CODE_LIST:
// Do nothing (don't restrict query)
break;
case CODE_LIST:
// Do nothing (don't restrict query)
break;
case CODE_SINGLE:
selection = ( selection == null ? "" : selection + " AND " ) +
DataColumns._ID + " = " + uri.getLastPathSegment();
break;
case CODE_SINGLE:
selection = ( selection == null ? "" : selection + " AND " ) +
DataColumns._ID + " = " + uri.getLastPathSegment();
break;
case CODE_ALL_EXCEPT_SWAP:
selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL ";
break;
case CODE_ALL_EXCEPT_SWAP:
selection = DataColumns.IS_SWAP + " = 0 OR " + DataColumns.IS_SWAP + " IS NULL ";
break;
default:
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
default:
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
}
Cursor cursor = read().query(getTableName(), projection, selection,
@ -346,18 +346,18 @@ public class RepoProvider extends FDroidProvider {
public int delete(Uri uri, String where, String[] whereArgs) {
switch (matcher.match(uri)) {
case CODE_LIST:
// Don't support deleting of multiple repos.
return 0;
case CODE_LIST:
// Don't support deleting of multiple repos.
return 0;
case CODE_SINGLE:
where = ( where == null ? "" : where + " AND " ) +
"_ID = " + uri.getLastPathSegment();
break;
case CODE_SINGLE:
where = ( where == null ? "" : where + " AND " ) +
"_ID = " + uri.getLastPathSegment();
break;
default:
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
default:
Log.e(TAG, "Invalid URI for repo content provider: " + uri);
throw new UnsupportedOperationException("Invalid URI for repo content provider: " + uri);
}
int rowsAffected = write().delete(getTableName(), where, whereArgs);

View File

@ -91,16 +91,16 @@ public class DefaultInstaller extends Installer {
* never executed on Androids before 4.0
*/
switch (requestCode) {
case REQUEST_CODE_INSTALL:
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
case REQUEST_CODE_INSTALL:
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
return true;
case REQUEST_CODE_DELETE:
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
return true;
case REQUEST_CODE_DELETE:
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
return true;
default:
return false;
return true;
default:
return false;
}
}

View File

@ -99,34 +99,34 @@ public class DefaultInstallerSdk14 extends Installer {
@Override
public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE_INSTALL:
if (resultCode == Activity.RESULT_OK) {
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
} else if (resultCode == Activity.RESULT_CANCELED) {
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
InstallerCallback.ERROR_CODE_CANCELED);
} else {
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
InstallerCallback.ERROR_CODE_OTHER);
}
case REQUEST_CODE_INSTALL:
if (resultCode == Activity.RESULT_OK) {
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
} else if (resultCode == Activity.RESULT_CANCELED) {
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
InstallerCallback.ERROR_CODE_CANCELED);
} else {
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
InstallerCallback.ERROR_CODE_OTHER);
}
return true;
case REQUEST_CODE_DELETE:
if (resultCode == Activity.RESULT_OK) {
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
} else if (resultCode == Activity.RESULT_CANCELED) {
mCallback.onError(InstallerCallback.OPERATION_DELETE,
InstallerCallback.ERROR_CODE_CANCELED);
} else {
// UninstallAppProgress actually returns
// Activity.RESULT_FIRST_USER if something breaks
mCallback.onError(InstallerCallback.OPERATION_DELETE,
InstallerCallback.ERROR_CODE_OTHER);
}
return true;
case REQUEST_CODE_DELETE:
if (resultCode == Activity.RESULT_OK) {
mCallback.onSuccess(InstallerCallback.OPERATION_DELETE);
} else if (resultCode == Activity.RESULT_CANCELED) {
mCallback.onError(InstallerCallback.OPERATION_DELETE,
InstallerCallback.ERROR_CODE_CANCELED);
} else {
// UninstallAppProgress actually returns
// Activity.RESULT_FIRST_USER if something breaks
mCallback.onError(InstallerCallback.OPERATION_DELETE,
InstallerCallback.ERROR_CODE_OTHER);
}
return true;
default:
return false;
return true;
default:
return false;
}
}

View File

@ -20,12 +20,12 @@ public class IconDownloader extends BaseImageDownloader {
@Override
public InputStream getStream(String imageUri, Object extra) throws IOException {
switch (Scheme.ofUri(imageUri)) {
case HTTP:
case HTTPS:
Downloader downloader = DownloaderFactory.create(imageUri, context);
return downloader.getInputStream();
default:
return super.getStream(imageUri, extra);
case HTTP:
case HTTPS:
Downloader downloader = DownloaderFactory.create(imageUri, context);
return downloader.getInputStream();
default:
return super.getStream(imageUri, extra);
}
}
}

View File

@ -105,7 +105,7 @@ public class LocalHTTPD extends NanoHTTPD {
private Response handlePost(IHTTPSession session) {
Uri uri = Uri.parse(session.getUri());
switch(uri.getPath()) {
switch (uri.getPath()) {
case "/request-swap":
if (!session.getParms().containsKey("repo")) {
Log.e(TAG, "Malformed /request-swap request to local repo HTTP server. Should have posted a 'repo' parameter." );

View File

@ -32,31 +32,30 @@ public class AppListFragmentPagerAdapter extends FragmentPagerAdapter {
@Override
public Fragment getItem(int i) {
if (i == 0) {
switch (i) {
case 0:
return new AvailableAppsFragment();
}
if (i == 1) {
case 1:
return new InstalledAppsFragment();
default:
return new CanUpdateAppsFragment();
}
return new CanUpdateAppsFragment();
}
@Override
public int getCount() {
return 3;
}
public int getCount() { return 3; }
@Override
public String getPageTitle(int i) {
switch(i) {
case 0:
return parent.getString(R.string.tab_noninstalled);
case 1:
return parent.getString(R.string.inst);
case 2:
return getUpdateTabTitle();
default:
return "";
switch (i) {
case 0:
return parent.getString(R.string.tab_noninstalled);
case 1:
return parent.getString(R.string.inst);
case 2:
return getUpdateTabTitle();
default:
return "";
}
}

View File

@ -161,15 +161,15 @@ public class LocalRepoActivity extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_setup_repo:
startActivityForResult(new Intent(this, SelectLocalAppsActivity.class), UPDATE_REPO);
return true;
case R.id.menu_send_fdroid_via_wifi:
startActivity(new Intent(this, QrWizardWifiNetworkActivity.class));
return true;
case R.id.menu_settings:
startActivityForResult(new Intent(this, PreferencesActivity.class), SET_IP_ADDRESS);
return true;
case R.id.menu_setup_repo:
startActivityForResult(new Intent(this, SelectLocalAppsActivity.class), UPDATE_REPO);
return true;
case R.id.menu_send_fdroid_via_wifi:
startActivity(new Intent(this, QrWizardWifiNetworkActivity.class));
return true;
case R.id.menu_settings:
startActivityForResult(new Intent(this, PreferencesActivity.class), SET_IP_ADDRESS);
return true;
}
return false;
}
@ -190,17 +190,17 @@ public class LocalRepoActivity extends ActionBarActivity {
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
repoProgress = new ProgressDialog(this);
repoProgress.setMessage("Scanning Apps. Please wait...");
repoProgress.setIndeterminate(false);
repoProgress.setMax(100);
repoProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
repoProgress.setCancelable(false);
repoProgress.show();
return repoProgress;
default:
return null;
case 0:
repoProgress = new ProgressDialog(this);
repoProgress.setMessage("Scanning Apps. Please wait...");
repoProgress.setIndeterminate(false);
repoProgress.setMax(100);
repoProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
repoProgress.setCancelable(false);
repoProgress.show();
return repoProgress;
default:
return null;
}
}

View File

@ -115,9 +115,9 @@ public class RepoDetailsActivity extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}

View File

@ -47,13 +47,13 @@ public class SelectLocalAppsActivity extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
setResult(RESULT_CANCELED);
finish();
return true;
case R.id.action_settings:
startActivity(new Intent(this, PreferencesActivity.class));
return true;
case android.R.id.home:
setResult(RESULT_CANCELED);
finish();
return true;
case R.id.action_settings:
startActivity(new Intent(this, PreferencesActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
@ -75,12 +75,12 @@ public class SelectLocalAppsActivity extends ActionBarActivity {
@Override
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.action_update_repo:
setResult(RESULT_OK);
finish();
return true;
default:
return false;
case R.id.action_update_repo:
setResult(RESULT_OK);
finish();
return true;
default:
return false;
}
}