Obey checkstyle rule preventing 'm' prefix for member variables
Required a couple of undesirable changes, such as: * sCollated -> collated * mFDroidApp -> fdroidApp (note the lower case 'd') Otherwise it was relatively minor given how many member variables there are in the code base.
This commit is contained in:
parent
4f7116fcfb
commit
a00534c7c7
@ -158,7 +158,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
|
||||
class ApkListAdapter extends ArrayAdapter<Apk> {
|
||||
|
||||
private final LayoutInflater mInflater = (LayoutInflater) context.getSystemService(
|
||||
private final LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
ApkListAdapter(Context context, App app) {
|
||||
@ -204,7 +204,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
ViewHolder holder;
|
||||
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.apklistitem, parent, false);
|
||||
convertView = inflater.inflate(R.layout.apklistitem, parent, false);
|
||||
|
||||
holder = new ViewHolder();
|
||||
holder.version = (TextView) convertView.findViewById(R.id.version);
|
||||
@ -1157,7 +1157,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
String url = null;
|
||||
App app = appDetails.getApp();
|
||||
@ -1268,7 +1268,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Website button
|
||||
View tv = view.findViewById(R.id.website);
|
||||
if (!TextUtils.isEmpty(app.webURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1276,7 +1276,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Email button
|
||||
tv = view.findViewById(R.id.email);
|
||||
if (!TextUtils.isEmpty(app.email)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1284,7 +1284,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Source button
|
||||
tv = view.findViewById(R.id.source);
|
||||
if (!TextUtils.isEmpty(app.sourceURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1292,7 +1292,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Issues button
|
||||
tv = view.findViewById(R.id.issues);
|
||||
if (!TextUtils.isEmpty(app.trackerURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1300,7 +1300,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Changelog button
|
||||
tv = view.findViewById(R.id.changelog);
|
||||
if (!TextUtils.isEmpty(app.changelogURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1308,7 +1308,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Donate button
|
||||
tv = view.findViewById(R.id.donate);
|
||||
if (!TextUtils.isEmpty(app.donateURL)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1316,7 +1316,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Bitcoin
|
||||
tv = view.findViewById(R.id.bitcoin);
|
||||
if (!TextUtils.isEmpty(app.bitcoinAddr)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1324,7 +1324,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Litecoin
|
||||
tv = view.findViewById(R.id.litecoin);
|
||||
if (!TextUtils.isEmpty(app.litecoinAddr)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1332,7 +1332,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
// Flattr
|
||||
tv = view.findViewById(R.id.flattr);
|
||||
if (!TextUtils.isEmpty(app.flattrID)) {
|
||||
tv.setOnClickListener(mOnClickListener);
|
||||
tv.setOnClickListener(onClickListener);
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
@ -1620,7 +1620,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
NfcHelper.disableAndroidBeam(appDetails);
|
||||
// Set Install button and hide second button
|
||||
btMain.setText(R.string.menu_install);
|
||||
btMain.setOnClickListener(mOnClickListener);
|
||||
btMain.setOnClickListener(onClickListener);
|
||||
btMain.setEnabled(true);
|
||||
} else if (app.isInstalled()) {
|
||||
// If App is installed
|
||||
@ -1638,7 +1638,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
btMain.setText(R.string.menu_uninstall);
|
||||
}
|
||||
}
|
||||
btMain.setOnClickListener(mOnClickListener);
|
||||
btMain.setOnClickListener(onClickListener);
|
||||
btMain.setEnabled(true);
|
||||
}
|
||||
TextView author = (TextView) view.findViewById(R.id.author);
|
||||
@ -1656,7 +1656,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
App app = appDetails.getApp();
|
||||
AppDetails activity = (AppDetails) getActivity();
|
||||
|
@ -57,17 +57,17 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
private static final int REQUEST_PERMISSION_DIALOG = 3;
|
||||
private static final int REQUEST_UNINSTALL_DIALOG = 4;
|
||||
|
||||
private FDroidApp mFDroidApp;
|
||||
private App mApp;
|
||||
private RecyclerView mRecyclerView;
|
||||
private AppDetailsRecyclerViewAdapter mAdapter;
|
||||
private LocalBroadcastManager mLocalBroadcastManager;
|
||||
private String mActiveDownloadUrlString;
|
||||
private FDroidApp fdroidApp;
|
||||
private App app;
|
||||
private RecyclerView recyclerView;
|
||||
private AppDetailsRecyclerViewAdapter adapter;
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private String activeDownloadUrlString;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mFDroidApp = (FDroidApp) getApplication();
|
||||
//mFDroidApp.applyTheme(this);
|
||||
fdroidApp = (FDroidApp) getApplication();
|
||||
//fdroidApp.applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.app_details2);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
@ -80,17 +80,17 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
return;
|
||||
}
|
||||
|
||||
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.rvDetails);
|
||||
mAdapter = new AppDetailsRecyclerViewAdapter(this, mApp, this);
|
||||
recyclerView = (RecyclerView) findViewById(R.id.rvDetails);
|
||||
adapter = new AppDetailsRecyclerViewAdapter(this, app, this);
|
||||
LinearLayoutManager lm = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||
lm.setStackFromEnd(false);
|
||||
mRecyclerView.setLayoutManager(lm);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
recyclerView.setLayoutManager(lm);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
// Load the feature graphic, if present
|
||||
if (!TextUtils.isEmpty(mApp.iconUrlLarge)) {
|
||||
if (!TextUtils.isEmpty(app.iconUrlLarge)) {
|
||||
ImageView ivFeatureGraphic = (ImageView) findViewById(R.id.feature_graphic);
|
||||
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
|
||||
.cacheInMemory(false)
|
||||
@ -98,7 +98,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
.imageScaleType(ImageScaleType.NONE)
|
||||
.bitmapConfig(Bitmap.Config.RGB_565)
|
||||
.build();
|
||||
ImageLoader.getInstance().displayImage(mApp.iconUrlLarge, ivFeatureGraphic, displayImageOptions);
|
||||
ImageLoader.getInstance().displayImage(app.iconUrlLarge, ivFeatureGraphic, displayImageOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mApp = newApp;
|
||||
app = newApp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,17 +135,17 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
if (mApp == null) {
|
||||
if (app == null) {
|
||||
return true;
|
||||
}
|
||||
MenuItem itemIgnoreAll = menu.findItem(R.id.action_ignore_all);
|
||||
if (itemIgnoreAll != null) {
|
||||
itemIgnoreAll.setChecked(mApp.getPrefs(this).ignoreAllUpdates);
|
||||
itemIgnoreAll.setChecked(app.getPrefs(this).ignoreAllUpdates);
|
||||
}
|
||||
MenuItem itemIgnoreThis = menu.findItem(R.id.action_ignore_this);
|
||||
if (itemIgnoreThis != null) {
|
||||
itemIgnoreThis.setVisible(mApp.hasUpdates());
|
||||
itemIgnoreThis.setChecked(mApp.getPrefs(this).ignoreThisUpdate >= mApp.suggestedVersionCode);
|
||||
itemIgnoreThis.setVisible(app.hasUpdates());
|
||||
itemIgnoreThis.setChecked(app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -155,25 +155,25 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
if (item.getItemId() == R.id.action_share) {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, mApp.name);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, mApp.name + " (" + mApp.summary + ") - https://f-droid.org/app/" + mApp.packageName);
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, app.name);
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, app.name + " (" + app.summary + ") - https://f-droid.org/app/" + app.packageName);
|
||||
|
||||
boolean showNearbyItem = mApp.isInstalled() && mFDroidApp.bluetoothAdapter != null;
|
||||
boolean showNearbyItem = app.isInstalled() && fdroidApp.bluetoothAdapter != null;
|
||||
ShareChooserDialog.createChooser((CoordinatorLayout) findViewById(R.id.rootCoordinator), this, this, shareIntent, showNearbyItem);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_ignore_all) {
|
||||
mApp.getPrefs(this).ignoreAllUpdates ^= true;
|
||||
item.setChecked(mApp.getPrefs(this).ignoreAllUpdates);
|
||||
AppPrefsProvider.Helper.update(this, mApp, mApp.getPrefs(this));
|
||||
app.getPrefs(this).ignoreAllUpdates ^= true;
|
||||
item.setChecked(app.getPrefs(this).ignoreAllUpdates);
|
||||
AppPrefsProvider.Helper.update(this, app, app.getPrefs(this));
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_ignore_this) {
|
||||
if (mApp.getPrefs(this).ignoreThisUpdate >= mApp.suggestedVersionCode) {
|
||||
mApp.getPrefs(this).ignoreThisUpdate = 0;
|
||||
if (app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode) {
|
||||
app.getPrefs(this).ignoreThisUpdate = 0;
|
||||
} else {
|
||||
mApp.getPrefs(this).ignoreThisUpdate = mApp.suggestedVersionCode;
|
||||
app.getPrefs(this).ignoreThisUpdate = app.suggestedVersionCode;
|
||||
}
|
||||
item.setChecked(mApp.getPrefs(this).ignoreThisUpdate > 0);
|
||||
AppPrefsProvider.Helper.update(this, mApp, mApp.getPrefs(this));
|
||||
item.setChecked(app.getPrefs(this).ignoreThisUpdate > 0);
|
||||
AppPrefsProvider.Helper.update(this, app, app.getPrefs(this));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -198,7 +198,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_ENABLE_BLUETOOTH:
|
||||
mFDroidApp.sendViaBluetooth(this, resultCode, mApp.packageName);
|
||||
fdroidApp.sendViaBluetooth(this, resultCode, app.packageName);
|
||||
break;
|
||||
case REQUEST_PERMISSION_DIALOG:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
@ -244,8 +244,8 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
alert.show();
|
||||
return;
|
||||
}
|
||||
if (mApp.installedSig != null && apk.sig != null
|
||||
&& !apk.sig.equals(mApp.installedSig)) {
|
||||
if (app.installedSig != null && apk.sig != null
|
||||
&& !apk.sig.equals(app.installedSig)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(R.string.SignatureMismatch).setPositiveButton(
|
||||
R.string.ok,
|
||||
@ -276,39 +276,39 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
}
|
||||
|
||||
private void startInstall(Apk apk) {
|
||||
mActiveDownloadUrlString = apk.getUrl();
|
||||
activeDownloadUrlString = apk.getUrl();
|
||||
registerDownloaderReceiver();
|
||||
InstallManagerService.queue(this, mApp, apk);
|
||||
InstallManagerService.queue(this, app, apk);
|
||||
}
|
||||
|
||||
private void startUninstall() {
|
||||
registerUninstallReceiver();
|
||||
InstallerService.uninstall(this, mApp.installedApk);
|
||||
InstallerService.uninstall(this, app.installedApk);
|
||||
}
|
||||
|
||||
private void registerUninstallReceiver() {
|
||||
mLocalBroadcastManager.registerReceiver(uninstallReceiver,
|
||||
Installer.getUninstallIntentFilter(mApp.packageName));
|
||||
localBroadcastManager.registerReceiver(uninstallReceiver,
|
||||
Installer.getUninstallIntentFilter(app.packageName));
|
||||
}
|
||||
|
||||
private void unregisterUninstallReceiver() {
|
||||
mLocalBroadcastManager.unregisterReceiver(uninstallReceiver);
|
||||
localBroadcastManager.unregisterReceiver(uninstallReceiver);
|
||||
}
|
||||
|
||||
private void registerDownloaderReceiver() {
|
||||
if (mActiveDownloadUrlString != null) { // if a download is active
|
||||
String url = mActiveDownloadUrlString;
|
||||
mLocalBroadcastManager.registerReceiver(downloadReceiver,
|
||||
if (activeDownloadUrlString != null) { // if a download is active
|
||||
String url = activeDownloadUrlString;
|
||||
localBroadcastManager.registerReceiver(downloadReceiver,
|
||||
DownloaderService.getIntentFilter(url));
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterDownloaderReceiver() {
|
||||
mLocalBroadcastManager.unregisterReceiver(downloadReceiver);
|
||||
localBroadcastManager.unregisterReceiver(downloadReceiver);
|
||||
}
|
||||
|
||||
private void unregisterInstallReceiver() {
|
||||
mLocalBroadcastManager.unregisterReceiver(installReceiver);
|
||||
localBroadcastManager.unregisterReceiver(installReceiver);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
|
||||
@ -316,16 +316,16 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case Downloader.ACTION_STARTED:
|
||||
mAdapter.setProgress(-1, -1, R.string.download_pending);
|
||||
adapter.setProgress(-1, -1, R.string.download_pending);
|
||||
break;
|
||||
case Downloader.ACTION_PROGRESS:
|
||||
mAdapter.setProgress(intent.getIntExtra(Downloader.EXTRA_BYTES_READ, -1),
|
||||
adapter.setProgress(intent.getIntExtra(Downloader.EXTRA_BYTES_READ, -1),
|
||||
intent.getIntExtra(Downloader.EXTRA_TOTAL_BYTES, -1), 0);
|
||||
break;
|
||||
case Downloader.ACTION_COMPLETE:
|
||||
// Starts the install process once the download is complete.
|
||||
cleanUpFinishedDownload();
|
||||
mLocalBroadcastManager.registerReceiver(installReceiver,
|
||||
localBroadcastManager.registerReceiver(installReceiver,
|
||||
Installer.getInstallIntentFilter(intent.getData()));
|
||||
break;
|
||||
case Downloader.ACTION_INTERRUPTED:
|
||||
@ -350,15 +350,15 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case Installer.ACTION_INSTALL_STARTED:
|
||||
mAdapter.setProgress(-1, -1, R.string.installing);
|
||||
adapter.setProgress(-1, -1, R.string.installing);
|
||||
break;
|
||||
case Installer.ACTION_INSTALL_COMPLETE:
|
||||
mAdapter.clearProgress();
|
||||
adapter.clearProgress();
|
||||
unregisterInstallReceiver();
|
||||
onAppChanged();
|
||||
break;
|
||||
case Installer.ACTION_INSTALL_INTERRUPTED:
|
||||
mAdapter.clearProgress();
|
||||
adapter.clearProgress();
|
||||
onAppChanged();
|
||||
|
||||
String errorMessage =
|
||||
@ -369,7 +369,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
|
||||
String title = String.format(
|
||||
getString(R.string.install_error_notify_title),
|
||||
mApp.name);
|
||||
app.name);
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetails2.this);
|
||||
alertBuilder.setTitle(title);
|
||||
@ -401,15 +401,15 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case Installer.ACTION_UNINSTALL_STARTED:
|
||||
mAdapter.setProgress(-1, -1, R.string.uninstalling);
|
||||
adapter.setProgress(-1, -1, R.string.uninstalling);
|
||||
break;
|
||||
case Installer.ACTION_UNINSTALL_COMPLETE:
|
||||
mAdapter.clearProgress();
|
||||
adapter.clearProgress();
|
||||
onAppChanged();
|
||||
unregisterUninstallReceiver();
|
||||
break;
|
||||
case Installer.ACTION_UNINSTALL_INTERRUPTED:
|
||||
mAdapter.clearProgress();
|
||||
adapter.clearProgress();
|
||||
String errorMessage =
|
||||
intent.getStringExtra(Installer.EXTRA_ERROR_MESSAGE);
|
||||
|
||||
@ -458,13 +458,13 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
}
|
||||
|
||||
setApp(newApp);
|
||||
return this.mApp != null;
|
||||
return this.app != null;
|
||||
}
|
||||
|
||||
private void calcActiveDownloadUrlString(String packageName) {
|
||||
String urlString = getPreferences(MODE_PRIVATE).getString(packageName, null);
|
||||
if (DownloaderService.isQueuedOrActive(urlString)) {
|
||||
mActiveDownloadUrlString = urlString;
|
||||
activeDownloadUrlString = urlString;
|
||||
} else {
|
||||
// this URL is no longer active, remove it
|
||||
getPreferences(MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
@ -475,21 +475,21 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
* Remove progress listener, suppress progress bar, set downloadHandler to null.
|
||||
*/
|
||||
private void cleanUpFinishedDownload() {
|
||||
mActiveDownloadUrlString = null;
|
||||
mAdapter.clearProgress();
|
||||
activeDownloadUrlString = null;
|
||||
adapter.clearProgress();
|
||||
unregisterDownloaderReceiver();
|
||||
}
|
||||
|
||||
private void onAppChanged() {
|
||||
mRecyclerView.post(new Runnable() {
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!reset(mApp.packageName)) {
|
||||
if (!reset(app.packageName)) {
|
||||
AppDetails2.this.finish();
|
||||
return;
|
||||
}
|
||||
AppDetailsRecyclerViewAdapter adapter = (AppDetailsRecyclerViewAdapter) mRecyclerView.getAdapter();
|
||||
adapter.updateItems(mApp);
|
||||
AppDetailsRecyclerViewAdapter adapter = (AppDetailsRecyclerViewAdapter) recyclerView.getAdapter();
|
||||
adapter.updateItems(app);
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
});
|
||||
@ -497,12 +497,12 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
|
||||
@Override
|
||||
public boolean isAppDownloading() {
|
||||
return !TextUtils.isEmpty(mActiveDownloadUrlString);
|
||||
return !TextUtils.isEmpty(activeDownloadUrlString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndroidBeam() {
|
||||
NfcHelper.setAndroidBeam(this, mApp.packageName);
|
||||
NfcHelper.setAndroidBeam(this, app.packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -524,39 +524,39 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
|
||||
@Override
|
||||
public void installCancel() {
|
||||
if (!TextUtils.isEmpty(mActiveDownloadUrlString)) {
|
||||
InstallManagerService.cancel(this, mActiveDownloadUrlString);
|
||||
if (!TextUtils.isEmpty(activeDownloadUrlString)) {
|
||||
InstallManagerService.cancel(this, activeDownloadUrlString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchApk() {
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(mApp.packageName);
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(app.packageName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApk() {
|
||||
Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(this, mApp.packageName, mApp.suggestedVersionCode);
|
||||
Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(this, app.packageName, app.suggestedVersionCode);
|
||||
installApk(apkToInstall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeApk() {
|
||||
Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(this, mApp.packageName, mApp.suggestedVersionCode);
|
||||
Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(this, app.packageName, app.suggestedVersionCode);
|
||||
installApk(apkToInstall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninstallApk() {
|
||||
Apk apk = mApp.installedApk;
|
||||
Apk apk = app.installedApk;
|
||||
if (apk == null) {
|
||||
// TODO ideally, app would be refreshed immediately after install, then this
|
||||
// workaround would be unnecessary
|
||||
try {
|
||||
PackageInfo pi = getPackageManager().getPackageInfo(mApp.packageName, 0);
|
||||
PackageInfo pi = getPackageManager().getPackageInfo(app.packageName, 0);
|
||||
apk = ApkProvider.Helper.findApkFromAnyRepo(this, pi.packageName, pi.versionCode);
|
||||
mApp.installedApk = apk;
|
||||
app.installedApk = apk;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return; // not installed
|
||||
|
@ -202,7 +202,7 @@ public final class PRNGFixes {
|
||||
* each instance needs to seed itself if the client does not explicitly
|
||||
* seed it.
|
||||
*/
|
||||
private boolean mSeeded;
|
||||
private boolean seeded;
|
||||
|
||||
@Override
|
||||
protected void engineSetSeed(byte[] bytes) {
|
||||
@ -218,13 +218,13 @@ public final class PRNGFixes {
|
||||
// Log and ignore.
|
||||
Log.w(TAG, "Failed to mix seed into " + URANDOM_FILE);
|
||||
} finally {
|
||||
mSeeded = true;
|
||||
seeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void engineNextBytes(byte[] bytes) {
|
||||
if (!mSeeded) {
|
||||
if (!seeded) {
|
||||
// Mix in the device- and invocation-specific seed.
|
||||
engineSetSeed(generateSeed());
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ final class BonjourFinder extends PeerFinder implements ServiceListener {
|
||||
|
||||
private JmDNS jmdns;
|
||||
private WifiManager wifiManager;
|
||||
private WifiManager.MulticastLock mMulticastLock;
|
||||
private WifiManager.MulticastLock multicastLock;
|
||||
|
||||
private BonjourFinder(Context context, Subscriber<? super Peer> subscriber) {
|
||||
super(context, subscriber);
|
||||
@ -58,8 +58,8 @@ final class BonjourFinder extends PeerFinder implements ServiceListener {
|
||||
|
||||
if (wifiManager == null) {
|
||||
wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mMulticastLock = wifiManager.createMulticastLock(context.getPackageName());
|
||||
mMulticastLock.setReferenceCounted(false);
|
||||
multicastLock = wifiManager.createMulticastLock(context.getPackageName());
|
||||
multicastLock.setReferenceCounted(false);
|
||||
}
|
||||
|
||||
if (isScanning) {
|
||||
@ -68,7 +68,7 @@ final class BonjourFinder extends PeerFinder implements ServiceListener {
|
||||
}
|
||||
|
||||
isScanning = true;
|
||||
mMulticastLock.acquire();
|
||||
multicastLock.acquire();
|
||||
|
||||
try {
|
||||
Utils.debugLog(TAG, "Searching for Bonjour (mDNS) clients...");
|
||||
@ -146,8 +146,8 @@ final class BonjourFinder extends PeerFinder implements ServiceListener {
|
||||
private void cancel() {
|
||||
Utils.debugLog(TAG, "Cancelling BonjourFinder, releasing multicast lock, removing jmdns service listeners");
|
||||
|
||||
if (mMulticastLock != null) {
|
||||
mMulticastLock.release();
|
||||
if (multicastLock != null) {
|
||||
multicastLock.release();
|
||||
}
|
||||
|
||||
isScanning = false;
|
||||
|
@ -129,7 +129,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
* 1. Check for root access
|
||||
*/
|
||||
private final AsyncTask<Void, Void, Boolean> checkRootTask = new AsyncTask<Void, Void, Boolean>() {
|
||||
ProgressDialog mProgressDialog;
|
||||
ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
@ -139,11 +139,11 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
|
||||
FDroidApp.getCurThemeResId());
|
||||
|
||||
mProgressDialog = new ProgressDialog(theme);
|
||||
mProgressDialog.setMessage(getString(R.string.requesting_root_access_body));
|
||||
mProgressDialog.setIndeterminate(true);
|
||||
mProgressDialog.setCancelable(false);
|
||||
mProgressDialog.show();
|
||||
progressDialog = new ProgressDialog(theme);
|
||||
progressDialog.setMessage(getString(R.string.requesting_root_access_body));
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -155,7 +155,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
protected void onPostExecute(Boolean rootGranted) {
|
||||
super.onPostExecute(rootGranted);
|
||||
|
||||
mProgressDialog.dismiss();
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (rootGranted) {
|
||||
// root access granted
|
||||
@ -193,7 +193,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
* 2. Install into system
|
||||
*/
|
||||
private final AsyncTask<Void, Void, Void> installTask = new AsyncTask<Void, Void, Void>() {
|
||||
ProgressDialog mProgressDialog;
|
||||
ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
@ -203,11 +203,11 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
|
||||
FDroidApp.getCurThemeResId());
|
||||
|
||||
mProgressDialog = new ProgressDialog(theme);
|
||||
mProgressDialog.setMessage(InstallExtension.create(getApplicationContext()).getInstallingString());
|
||||
mProgressDialog.setIndeterminate(true);
|
||||
mProgressDialog.setCancelable(false);
|
||||
mProgressDialog.show();
|
||||
progressDialog = new ProgressDialog(theme);
|
||||
progressDialog.setMessage(InstallExtension.create(getApplicationContext()).getInstallingString());
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -298,7 +298,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
}
|
||||
|
||||
private final AsyncTask<Void, Void, Void> uninstallTask = new AsyncTask<Void, Void, Void>() {
|
||||
ProgressDialog mProgressDialog;
|
||||
ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
@ -308,11 +308,11 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
|
||||
FDroidApp.getCurThemeResId());
|
||||
|
||||
mProgressDialog = new ProgressDialog(theme);
|
||||
mProgressDialog.setMessage(getString(R.string.system_install_uninstalling));
|
||||
mProgressDialog.setIndeterminate(true);
|
||||
mProgressDialog.setCancelable(false);
|
||||
mProgressDialog.show();
|
||||
progressDialog = new ProgressDialog(theme);
|
||||
progressDialog.setMessage(getString(R.string.system_install_uninstalling));
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -325,7 +325,7 @@ public class InstallExtensionDialogActivity extends FragmentActivity {
|
||||
protected void onPostExecute(Void unused) {
|
||||
super.onPostExecute(unused);
|
||||
|
||||
mProgressDialog.dismiss();
|
||||
progressDialog.dismiss();
|
||||
|
||||
// app is uninstalled but still display, kill it!
|
||||
System.exit(0);
|
||||
|
@ -90,7 +90,7 @@ public class AppSecurityPermissions {
|
||||
// PermissionGroupInfo implements Parcelable but its Parcel constructor is private and thus cannot be extended.
|
||||
@SuppressLint("ParcelCreator")
|
||||
static class MyPermissionGroupInfo extends PermissionGroupInfo {
|
||||
CharSequence mLabel;
|
||||
CharSequence label;
|
||||
|
||||
final List<MyPermissionInfo> newPermissions = new ArrayList<>();
|
||||
final List<MyPermissionInfo> allPermissions = new ArrayList<>();
|
||||
@ -185,7 +185,7 @@ public class AppSecurityPermissions {
|
||||
}
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(group.mLabel);
|
||||
builder.setTitle(group.label);
|
||||
if (perm.descriptionRes != 0) {
|
||||
builder.setMessage(perm.loadDescription(pm));
|
||||
} else {
|
||||
@ -431,22 +431,22 @@ public class AppSecurityPermissions {
|
||||
|
||||
private static class PermissionGroupInfoComparator implements Comparator<MyPermissionGroupInfo> {
|
||||
|
||||
private final Collator sCollator = Collator.getInstance();
|
||||
private final Collator collator = Collator.getInstance();
|
||||
|
||||
public final int compare(MyPermissionGroupInfo a, MyPermissionGroupInfo b) {
|
||||
return sCollator.compare(a.mLabel, b.mLabel);
|
||||
return collator.compare(a.label, b.label);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PermissionInfoComparator implements Comparator<MyPermissionInfo> {
|
||||
|
||||
private final Collator sCollator = Collator.getInstance();
|
||||
private final Collator collator = Collator.getInstance();
|
||||
|
||||
PermissionInfoComparator() {
|
||||
}
|
||||
|
||||
public final int compare(MyPermissionInfo a, MyPermissionInfo b) {
|
||||
return sCollator.compare(a.label, b.label);
|
||||
return collator.compare(a.label, b.label);
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,13 +482,13 @@ public class AppSecurityPermissions {
|
||||
|
||||
for (MyPermissionGroupInfo pgrp : permGroups.values()) {
|
||||
if (pgrp.labelRes != 0 || pgrp.nonLocalizedLabel != null) {
|
||||
pgrp.mLabel = pgrp.loadLabel(pm);
|
||||
pgrp.label = pgrp.loadLabel(pm);
|
||||
} else {
|
||||
try {
|
||||
ApplicationInfo app = pm.getApplicationInfo(pgrp.packageName, 0);
|
||||
pgrp.mLabel = app.loadLabel(pm);
|
||||
pgrp.label = app.loadLabel(pm);
|
||||
} catch (NameNotFoundException e) {
|
||||
pgrp.mLabel = pgrp.loadLabel(pm);
|
||||
pgrp.label = pgrp.loadLabel(pm);
|
||||
}
|
||||
}
|
||||
permGroupsList.add(pgrp);
|
||||
|
@ -85,40 +85,40 @@ public class AppDetailsRecyclerViewAdapter
|
||||
private static final int VIEWTYPE_VERSIONS = 6;
|
||||
private static final int VIEWTYPE_VERSION = 7;
|
||||
|
||||
private final Context mContext;
|
||||
private final Context context;
|
||||
@NonNull
|
||||
private App mApp;
|
||||
private final AppDetailsRecyclerViewAdapterCallbacks mCallbacks;
|
||||
private RecyclerView mRecyclerView;
|
||||
private ArrayList<Object> mItems;
|
||||
private ArrayList<Apk> mVersions;
|
||||
private boolean mShowVersions;
|
||||
private App app;
|
||||
private final AppDetailsRecyclerViewAdapterCallbacks callbacks;
|
||||
private RecyclerView recyclerView;
|
||||
private ArrayList<Object> items;
|
||||
private ArrayList<Apk> versions;
|
||||
private boolean showVersions;
|
||||
|
||||
private HeaderViewHolder mHeaderView;
|
||||
private HeaderViewHolder headerView;
|
||||
|
||||
public AppDetailsRecyclerViewAdapter(Context context, @NonNull App app, AppDetailsRecyclerViewAdapterCallbacks callbacks) {
|
||||
mContext = context;
|
||||
mCallbacks = callbacks;
|
||||
mApp = app;
|
||||
this.context = context;
|
||||
this.callbacks = callbacks;
|
||||
this.app = app;
|
||||
updateItems(app);
|
||||
}
|
||||
|
||||
public void updateItems(@NonNull App app) {
|
||||
mApp = app;
|
||||
this.app = app;
|
||||
|
||||
// Get versions
|
||||
mVersions = new ArrayList<>();
|
||||
final List<Apk> apks = ApkProvider.Helper.findByPackageName(mContext, mApp.packageName);
|
||||
versions = new ArrayList<>();
|
||||
final List<Apk> apks = ApkProvider.Helper.findByPackageName(context, this.app.packageName);
|
||||
for (final Apk apk : apks) {
|
||||
if (apk.compatible || Preferences.get().showIncompatibleVersions()) {
|
||||
mVersions.add(apk);
|
||||
versions.add(apk);
|
||||
}
|
||||
}
|
||||
|
||||
if (mItems == null) {
|
||||
mItems = new ArrayList<>();
|
||||
if (items == null) {
|
||||
items = new ArrayList<>();
|
||||
} else {
|
||||
mItems.clear();
|
||||
items.clear();
|
||||
}
|
||||
addItem(VIEWTYPE_HEADER);
|
||||
addItem(VIEWTYPE_SCREENSHOTS);
|
||||
@ -132,10 +132,10 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
private void setShowVersions(boolean showVersions) {
|
||||
mShowVersions = showVersions;
|
||||
mItems.removeAll(mVersions);
|
||||
this.showVersions = showVersions;
|
||||
items.removeAll(versions);
|
||||
if (showVersions) {
|
||||
mItems.addAll(mItems.indexOf(VIEWTYPE_VERSIONS) + 1, mVersions);
|
||||
items.addAll(items.indexOf(VIEWTYPE_VERSIONS) + 1, versions);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@ -148,28 +148,28 @@ public class AppDetailsRecyclerViewAdapter
|
||||
} else if (item == VIEWTYPE_PERMISSIONS && !shouldShowPermissions()) {
|
||||
return;
|
||||
}
|
||||
mItems.add(item);
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
private boolean shouldShowPermissions() {
|
||||
// Figure out if we should show permissions section
|
||||
Apk curApk = null;
|
||||
for (int i = 0; i < mVersions.size(); i++) {
|
||||
final Apk apk = mVersions.get(i);
|
||||
if (apk.versionCode == mApp.suggestedVersionCode) {
|
||||
for (int i = 0; i < versions.size(); i++) {
|
||||
final Apk apk = versions.get(i);
|
||||
if (apk.versionCode == app.suggestedVersionCode) {
|
||||
curApk = apk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final boolean curApkCompatible = curApk != null && curApk.compatible;
|
||||
return mVersions.size() > 0 && (curApkCompatible || Preferences.get().showIncompatibleVersions());
|
||||
return versions.size() > 0 && (curApkCompatible || Preferences.get().showIncompatibleVersions());
|
||||
}
|
||||
|
||||
private boolean shouldShowDonate() {
|
||||
return uriIsSetAndCanBeOpened(mApp.donateURL) ||
|
||||
uriIsSetAndCanBeOpened(mApp.getBitcoinUri()) ||
|
||||
uriIsSetAndCanBeOpened(mApp.getLitecoinUri()) ||
|
||||
uriIsSetAndCanBeOpened(mApp.getFlattrUri());
|
||||
return uriIsSetAndCanBeOpened(app.donateURL) ||
|
||||
uriIsSetAndCanBeOpened(app.getBitcoinUri()) ||
|
||||
uriIsSetAndCanBeOpened(app.getLitecoinUri()) ||
|
||||
uriIsSetAndCanBeOpened(app.getFlattrUri());
|
||||
}
|
||||
|
||||
public void clearProgress() {
|
||||
@ -177,8 +177,8 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
public void setProgress(int bytesDownloaded, int totalBytes, int resIdString) {
|
||||
if (mHeaderView != null) {
|
||||
mHeaderView.setProgress(bytesDownloaded, totalBytes, resIdString);
|
||||
if (headerView != null) {
|
||||
headerView.setProgress(bytesDownloaded, totalBytes, resIdString);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
int viewType = getItemViewType(position);
|
||||
if (viewType == VIEWTYPE_HEADER) {
|
||||
HeaderViewHolder header = (HeaderViewHolder) holder;
|
||||
mHeaderView = header;
|
||||
headerView = header;
|
||||
header.bindModel();
|
||||
} else if (viewType == VIEWTYPE_SCREENSHOTS) {
|
||||
((ScreenShotsViewHolder) holder).bindModel();
|
||||
@ -233,7 +233,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
} else if (viewType == VIEWTYPE_VERSIONS) {
|
||||
((VersionsViewHolder) holder).bindModel();
|
||||
} else if (viewType == VIEWTYPE_VERSION) {
|
||||
final Apk apk = (Apk) mItems.get(position);
|
||||
final Apk apk = (Apk) items.get(position);
|
||||
((VersionViewHolder) holder).bindModel(apk);
|
||||
}
|
||||
}
|
||||
@ -241,22 +241,22 @@ public class AppDetailsRecyclerViewAdapter
|
||||
@Override
|
||||
public void onViewRecycled(RecyclerView.ViewHolder holder) {
|
||||
if (holder instanceof HeaderViewHolder) {
|
||||
mHeaderView = null;
|
||||
headerView = null;
|
||||
}
|
||||
super.onViewRecycled(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mItems.size();
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mItems.get(position) instanceof Apk) {
|
||||
if (items.get(position) instanceof Apk) {
|
||||
return VIEWTYPE_VERSION;
|
||||
}
|
||||
return (Integer) mItems.get(position);
|
||||
return (Integer) items.get(position);
|
||||
}
|
||||
|
||||
public class HeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -308,12 +308,12 @@ public class AppDetailsRecyclerViewAdapter
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Remember current scroll position so that we can restore it
|
||||
LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||
LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int pos = lm.findFirstVisibleItemPosition();
|
||||
int posOffset = 0;
|
||||
if (pos != RecyclerView.NO_POSITION) {
|
||||
View firstChild = mRecyclerView.getChildAt(0);
|
||||
posOffset = (firstChild == null) ? 0 : (firstChild.getTop()); // - mRecyclerView.getPaddingTop());
|
||||
View firstChild = recyclerView.getChildAt(0);
|
||||
posOffset = (firstChild == null) ? 0 : (firstChild.getTop()); // - recyclerView.getPaddingTop());
|
||||
}
|
||||
if (TextViewCompat.getMaxLines(descriptionView) != MAX_LINES) {
|
||||
descriptionView.setMaxLines(MAX_LINES);
|
||||
@ -367,16 +367,16 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
public void bindModel() {
|
||||
ImageLoader.getInstance().displayImage(mApp.iconUrlLarge, iconView, displayImageOptions);
|
||||
titleView.setText(mApp.name);
|
||||
if (!TextUtils.isEmpty(mApp.author)) {
|
||||
authorView.setText(mContext.getString(R.string.by_author) + " " + mApp.author);
|
||||
ImageLoader.getInstance().displayImage(app.iconUrlLarge, iconView, displayImageOptions);
|
||||
titleView.setText(app.name);
|
||||
if (!TextUtils.isEmpty(app.author)) {
|
||||
authorView.setText(context.getString(R.string.by_author) + " " + app.author);
|
||||
authorView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
authorView.setVisibility(View.GONE);
|
||||
}
|
||||
summaryView.setText(mApp.summary);
|
||||
final Spanned desc = Html.fromHtml(mApp.description, null, new Utils.HtmlTagHandler());
|
||||
summaryView.setText(app.summary);
|
||||
final Spanned desc = Html.fromHtml(app.description, null, new Utils.HtmlTagHandler());
|
||||
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
descriptionView.setText(trimTrailingNewlines(desc));
|
||||
if (descriptionView.getText() instanceof Spannable) {
|
||||
@ -403,36 +403,36 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
});
|
||||
buttonSecondaryView.setText(R.string.menu_uninstall);
|
||||
buttonSecondaryView.setVisibility(mApp.isInstalled() ? View.VISIBLE : View.INVISIBLE);
|
||||
buttonSecondaryView.setOnClickListener(mOnUnInstallClickListener);
|
||||
buttonSecondaryView.setVisibility(app.isInstalled() ? View.VISIBLE : View.INVISIBLE);
|
||||
buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
|
||||
buttonPrimaryView.setText(R.string.menu_install);
|
||||
buttonPrimaryView.setVisibility(mVersions.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
if (mCallbacks.isAppDownloading()) {
|
||||
buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
if (callbacks.isAppDownloading()) {
|
||||
buttonPrimaryView.setText(R.string.downloading);
|
||||
buttonPrimaryView.setEnabled(false);
|
||||
} else if (!mApp.isInstalled() && mApp.suggestedVersionCode > 0 && mVersions.size() > 0) {
|
||||
} else if (!app.isInstalled() && app.suggestedVersionCode > 0 && versions.size() > 0) {
|
||||
// Check count > 0 due to incompatible apps resulting in an empty list.
|
||||
mCallbacks.disableAndroidBeam();
|
||||
callbacks.disableAndroidBeam();
|
||||
// Set Install button and hide second button
|
||||
buttonPrimaryView.setText(R.string.menu_install);
|
||||
buttonPrimaryView.setOnClickListener(mOnInstallClickListener);
|
||||
buttonPrimaryView.setOnClickListener(onInstallClickListener);
|
||||
buttonPrimaryView.setEnabled(true);
|
||||
} else if (mApp.isInstalled()) {
|
||||
mCallbacks.enableAndroidBeam();
|
||||
if (mApp.canAndWantToUpdate(mContext)) {
|
||||
} else if (app.isInstalled()) {
|
||||
callbacks.enableAndroidBeam();
|
||||
if (app.canAndWantToUpdate(context)) {
|
||||
buttonPrimaryView.setText(R.string.menu_upgrade);
|
||||
buttonPrimaryView.setOnClickListener(mOnUpgradeClickListener);
|
||||
buttonPrimaryView.setOnClickListener(onUpgradeClickListener);
|
||||
} else {
|
||||
if (mContext.getPackageManager().getLaunchIntentForPackage(mApp.packageName) != null) {
|
||||
if (context.getPackageManager().getLaunchIntentForPackage(app.packageName) != null) {
|
||||
buttonPrimaryView.setText(R.string.menu_launch);
|
||||
buttonPrimaryView.setOnClickListener(mOnLaunchClickListener);
|
||||
buttonPrimaryView.setOnClickListener(onLaunchClickListener);
|
||||
} else {
|
||||
buttonPrimaryView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
buttonPrimaryView.setEnabled(true);
|
||||
}
|
||||
if (mCallbacks.isAppDownloading()) {
|
||||
if (callbacks.isAppDownloading()) {
|
||||
buttonLayout.setVisibility(View.GONE);
|
||||
progressLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@ -442,7 +442,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
progressCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.installCancel();
|
||||
callbacks.installCancel();
|
||||
}
|
||||
});
|
||||
|
||||
@ -452,12 +452,12 @@ public class AppDetailsRecyclerViewAdapter
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
mRecyclerView = recyclerView;
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
|
||||
mRecyclerView = null;
|
||||
this.recyclerView = null;
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
@ -471,9 +471,9 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
public void bindModel() {
|
||||
LinearLayoutManager lm = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
LinearLayoutManager lm = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
||||
recyclerView.setLayoutManager(lm);
|
||||
ScreenShotsRecyclerViewAdapter adapter = new ScreenShotsRecyclerViewAdapter(itemView.getContext(), mApp);
|
||||
ScreenShotsRecyclerViewAdapter adapter = new ScreenShotsRecyclerViewAdapter(itemView.getContext(), app);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
@ -513,23 +513,23 @@ public class AppDetailsRecyclerViewAdapter
|
||||
contentView.removeAllViews();
|
||||
|
||||
// Donate button
|
||||
if (uriIsSetAndCanBeOpened(mApp.donateURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_donate, R.drawable.ic_donate, mApp.donateURL);
|
||||
if (uriIsSetAndCanBeOpened(app.donateURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_donate, R.drawable.ic_donate, app.donateURL);
|
||||
}
|
||||
|
||||
// Bitcoin
|
||||
if (uriIsSetAndCanBeOpened(mApp.getBitcoinUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_bitcoin, R.drawable.ic_bitcoin, mApp.getBitcoinUri());
|
||||
if (uriIsSetAndCanBeOpened(app.getBitcoinUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_bitcoin, R.drawable.ic_bitcoin, app.getBitcoinUri());
|
||||
}
|
||||
|
||||
// Litecoin
|
||||
if (uriIsSetAndCanBeOpened(mApp.getLitecoinUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_litecoin, R.drawable.ic_litecoin, mApp.getLitecoinUri());
|
||||
if (uriIsSetAndCanBeOpened(app.getLitecoinUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_litecoin, R.drawable.ic_litecoin, app.getLitecoinUri());
|
||||
}
|
||||
|
||||
// Flattr
|
||||
if (uriIsSetAndCanBeOpened(mApp.getFlattrUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_flattr, R.drawable.ic_flattr, mApp.getFlattrUri());
|
||||
if (uriIsSetAndCanBeOpened(app.getFlattrUri())) {
|
||||
addLinkItemView(contentView, R.string.menu_flattr, R.drawable.ic_flattr, app.getFlattrUri());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,11 +555,11 @@ public class AppDetailsRecyclerViewAdapter
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setShowVersions(!mShowVersions);
|
||||
setShowVersions(!showVersions);
|
||||
}
|
||||
});
|
||||
headerView.setText(R.string.versions);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_access_time_24dp_grey600, 0, mShowVersions ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_access_time_24dp_grey600, 0, showVersions ? R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -581,8 +581,8 @@ public class AppDetailsRecyclerViewAdapter
|
||||
headerView.setText(R.string.permissions);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(headerView, R.drawable.ic_lock_24dp_grey600, 0, R.drawable.ic_expand_more_grey600, 0);
|
||||
contentView.removeAllViews();
|
||||
AppDiff appDiff = new AppDiff(mContext.getPackageManager(), mVersions.get(0));
|
||||
AppSecurityPermissions perms = new AppSecurityPermissions(mContext, appDiff.pkgInfo);
|
||||
AppDiff appDiff = new AppDiff(context.getPackageManager(), versions.get(0));
|
||||
AppSecurityPermissions perms = new AppSecurityPermissions(context, appDiff.pkgInfo);
|
||||
contentView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_ALL));
|
||||
}
|
||||
}
|
||||
@ -607,28 +607,28 @@ public class AppDetailsRecyclerViewAdapter
|
||||
contentView.removeAllViews();
|
||||
|
||||
// Source button
|
||||
if (uriIsSetAndCanBeOpened(mApp.sourceURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_source, R.drawable.ic_source_code, mApp.sourceURL);
|
||||
if (uriIsSetAndCanBeOpened(app.sourceURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_source, R.drawable.ic_source_code, app.sourceURL);
|
||||
}
|
||||
|
||||
// Issues button
|
||||
if (uriIsSetAndCanBeOpened(mApp.trackerURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_issues, R.drawable.ic_issues, mApp.trackerURL);
|
||||
if (uriIsSetAndCanBeOpened(app.trackerURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_issues, R.drawable.ic_issues, app.trackerURL);
|
||||
}
|
||||
|
||||
// Changelog button
|
||||
if (uriIsSetAndCanBeOpened(mApp.changelogURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_changelog, R.drawable.ic_changelog, mApp.changelogURL);
|
||||
if (uriIsSetAndCanBeOpened(app.changelogURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_changelog, R.drawable.ic_changelog, app.changelogURL);
|
||||
}
|
||||
|
||||
// Website button
|
||||
if (uriIsSetAndCanBeOpened(mApp.webURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_website, R.drawable.ic_website, mApp.webURL);
|
||||
if (uriIsSetAndCanBeOpened(app.webURL)) {
|
||||
addLinkItemView(contentView, R.string.menu_website, R.drawable.ic_website, app.webURL);
|
||||
}
|
||||
|
||||
// Email button
|
||||
final String subject = Uri.encode(mContext.getString(R.string.app_details_subject, mApp.name));
|
||||
String emailUrl = mApp.email == null ? null : ("mailto:" + mApp.email + "?subject=" + subject);
|
||||
final String subject = Uri.encode(context.getString(R.string.app_details_subject, app.name));
|
||||
String emailUrl = app.email == null ? null : ("mailto:" + app.email + "?subject=" + subject);
|
||||
if (uriIsSetAndCanBeOpened(emailUrl)) {
|
||||
addLinkItemView(contentView, R.string.menu_email, R.drawable.ic_email, emailUrl);
|
||||
}
|
||||
@ -658,22 +658,22 @@ public class AppDetailsRecyclerViewAdapter
|
||||
added = (TextView) view.findViewById(R.id.added);
|
||||
nativecode = (TextView) view.findViewById(R.id.nativecode);
|
||||
|
||||
int margin = mContext.getResources().getDimensionPixelSize(R.dimen.layout_horizontal_margin);
|
||||
int padding = mContext.getResources().getDimensionPixelSize(R.dimen.details_activity_padding);
|
||||
int margin = context.getResources().getDimensionPixelSize(R.dimen.layout_horizontal_margin);
|
||||
int padding = context.getResources().getDimensionPixelSize(R.dimen.details_activity_padding);
|
||||
ViewCompat.setPaddingRelative(view, margin + padding + ViewCompat.getPaddingStart(view), view.getPaddingTop(), ViewCompat.getPaddingEnd(view), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
public void bindModel(final Apk apk) {
|
||||
java.text.DateFormat df = DateFormat.getDateFormat(mContext);
|
||||
java.text.DateFormat df = DateFormat.getDateFormat(context);
|
||||
|
||||
version.setText(mContext.getString(R.string.version)
|
||||
version.setText(context.getString(R.string.version)
|
||||
+ " " + apk.versionName
|
||||
+ (apk.versionCode == mApp.suggestedVersionCode ? " ☆" : ""));
|
||||
+ (apk.versionCode == app.suggestedVersionCode ? " ☆" : ""));
|
||||
|
||||
status.setText(getInstalledStatus(apk));
|
||||
|
||||
repository.setText(mContext.getString(R.string.repo_provider,
|
||||
RepoProvider.Helper.findById(mContext, apk.repo).getName()));
|
||||
repository.setText(context.getString(R.string.repo_provider,
|
||||
RepoProvider.Helper.findById(context, apk.repo).getName()));
|
||||
|
||||
if (apk.size > 0) {
|
||||
size.setText(Utils.getFriendlySize(apk.size));
|
||||
@ -685,16 +685,16 @@ public class AppDetailsRecyclerViewAdapter
|
||||
if (!Preferences.get().expertMode()) {
|
||||
api.setVisibility(View.GONE);
|
||||
} else if (apk.minSdkVersion > 0 && apk.maxSdkVersion < Apk.SDK_VERSION_MAX_VALUE) {
|
||||
api.setText(mContext.getString(R.string.minsdk_up_to_maxsdk,
|
||||
api.setText(context.getString(R.string.minsdk_up_to_maxsdk,
|
||||
Utils.getAndroidVersionName(apk.minSdkVersion),
|
||||
Utils.getAndroidVersionName(apk.maxSdkVersion)));
|
||||
api.setVisibility(View.VISIBLE);
|
||||
} else if (apk.minSdkVersion > 0) {
|
||||
api.setText(mContext.getString(R.string.minsdk_or_later,
|
||||
api.setText(context.getString(R.string.minsdk_or_later,
|
||||
Utils.getAndroidVersionName(apk.minSdkVersion)));
|
||||
api.setVisibility(View.VISIBLE);
|
||||
} else if (apk.maxSdkVersion > 0) {
|
||||
api.setText(mContext.getString(R.string.up_to_maxsdk,
|
||||
api.setText(context.getString(R.string.up_to_maxsdk,
|
||||
Utils.getAndroidVersionName(apk.maxSdkVersion)));
|
||||
api.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -706,7 +706,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
|
||||
if (apk.added != null) {
|
||||
added.setText(mContext.getString(R.string.added_on,
|
||||
added.setText(context.getString(R.string.added_on,
|
||||
df.format(apk.added)));
|
||||
added.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@ -722,7 +722,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
if (apk.incompatibleReasons != null) {
|
||||
incompatibleReasons.setText(
|
||||
mContext.getResources().getString(
|
||||
context.getResources().getString(
|
||||
R.string.requires_features,
|
||||
TextUtils.join(", ", apk.incompatibleReasons)));
|
||||
incompatibleReasons.setVisibility(View.VISIBLE);
|
||||
@ -748,7 +748,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.installApk(apk);
|
||||
callbacks.installApk(apk);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -769,60 +769,60 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
private String getInstalledStatus(final Apk apk) {
|
||||
// Definitely not installed.
|
||||
if (apk.versionCode != mApp.installedVersionCode) {
|
||||
return mContext.getString(R.string.app_not_installed);
|
||||
if (apk.versionCode != app.installedVersionCode) {
|
||||
return context.getString(R.string.app_not_installed);
|
||||
}
|
||||
// Definitely installed this version.
|
||||
if (apk.sig != null && apk.sig.equals(mApp.installedSig)) {
|
||||
return mContext.getString(R.string.app_installed);
|
||||
if (apk.sig != null && apk.sig.equals(app.installedSig)) {
|
||||
return context.getString(R.string.app_installed);
|
||||
}
|
||||
// Installed the same version, but from someplace else.
|
||||
final String installerPkgName;
|
||||
try {
|
||||
installerPkgName = mContext.getPackageManager().getInstallerPackageName(mApp.packageName);
|
||||
installerPkgName = context.getPackageManager().getInstallerPackageName(app.packageName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.w("AppDetailsAdapter", "Application " + mApp.packageName + " is not installed anymore");
|
||||
return mContext.getString(R.string.app_not_installed);
|
||||
Log.w("AppDetailsAdapter", "Application " + app.packageName + " is not installed anymore");
|
||||
return context.getString(R.string.app_not_installed);
|
||||
}
|
||||
if (TextUtils.isEmpty(installerPkgName)) {
|
||||
return mContext.getString(R.string.app_inst_unknown_source);
|
||||
return context.getString(R.string.app_inst_unknown_source);
|
||||
}
|
||||
final String installerLabel = InstalledAppProvider
|
||||
.getApplicationLabel(mContext, installerPkgName);
|
||||
return mContext.getString(R.string.app_inst_known_source, installerLabel);
|
||||
.getApplicationLabel(context, installerPkgName);
|
||||
return context.getString(R.string.app_inst_known_source, installerLabel);
|
||||
}
|
||||
|
||||
private void onLinkClicked(String url) {
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
mCallbacks.openUrl(url);
|
||||
callbacks.openUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener mOnInstallClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onInstallClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.installApk();
|
||||
callbacks.installApk();
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener mOnUnInstallClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onUnInstallClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.uninstallApk();
|
||||
callbacks.uninstallApk();
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener mOnUpgradeClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onUpgradeClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.upgradeApk();
|
||||
callbacks.upgradeApk();
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener mOnLaunchClickListener = new View.OnClickListener() {
|
||||
private final View.OnClickListener onLaunchClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallbacks.launchApk();
|
||||
callbacks.launchApk();
|
||||
}
|
||||
};
|
||||
|
||||
@ -831,7 +831,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
|
||||
return intent.resolveActivity(mContext.getPackageManager()) != null;
|
||||
return intent.resolveActivity(context.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ import org.fdroid.fdroid.data.App;
|
||||
|
||||
public abstract class AppListAdapter extends CursorAdapter {
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
private LayoutInflater inflater;
|
||||
private DisplayImageOptions displayImageOptions;
|
||||
private String upgradeFromTo;
|
||||
|
||||
@ -44,7 +44,7 @@ public abstract class AppListAdapter extends CursorAdapter {
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
mInflater = (LayoutInflater) context.getSystemService(
|
||||
inflater = (LayoutInflater) context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
displayImageOptions = Utils.getImageLoadingOptions().build();
|
||||
upgradeFromTo = context.getResources().getString(R.string.upgrade_from_to);
|
||||
@ -64,7 +64,7 @@ public abstract class AppListAdapter extends CursorAdapter {
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
View view = mInflater.inflate(R.layout.applistitem, parent, false);
|
||||
View view = inflater.inflate(R.layout.applistitem, parent, false);
|
||||
|
||||
ViewHolder holder = new ViewHolder();
|
||||
holder.name = (TextView) view.findViewById(R.id.name);
|
||||
|
@ -9,8 +9,8 @@ import android.view.View;
|
||||
|
||||
public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
|
||||
private View mLastSavedTarget;
|
||||
private int mLastSavedDistance;
|
||||
private View lastSavedTarget;
|
||||
private int lastSavedDistance;
|
||||
|
||||
public interface LinearSnapHelperListener {
|
||||
/**
|
||||
@ -21,17 +21,17 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
void onSnappedToView(View view, int position);
|
||||
}
|
||||
|
||||
private final LinearLayoutManager mLlm;
|
||||
private final OrientationHelper mOrientationHelper;
|
||||
private LinearSnapHelperListener mListener;
|
||||
private final LinearLayoutManager layoutManager;
|
||||
private final OrientationHelper orientationHelper;
|
||||
private LinearSnapHelperListener listener;
|
||||
|
||||
public LinearLayoutManagerSnapHelper(LinearLayoutManager llm) {
|
||||
this.mLlm = llm;
|
||||
this.mOrientationHelper = OrientationHelper.createHorizontalHelper(mLlm);
|
||||
public LinearLayoutManagerSnapHelper(LinearLayoutManager layoutManager) {
|
||||
this.layoutManager = layoutManager;
|
||||
this.orientationHelper = OrientationHelper.createHorizontalHelper(this.layoutManager);
|
||||
}
|
||||
|
||||
public void setLinearSnapHelperListener(LinearSnapHelperListener listener) {
|
||||
mListener = listener;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,7 +39,7 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
View snappedView = super.findSnapView(layoutManager);
|
||||
if (snappedView != null && layoutManager.canScrollHorizontally()) {
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
mLastSavedTarget = null;
|
||||
lastSavedTarget = null;
|
||||
|
||||
int distSnap = super.calculateDistanceToFinalSnap(layoutManager, snappedView)[0];
|
||||
|
||||
@ -55,10 +55,10 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
}
|
||||
}
|
||||
|
||||
int snapPositionFirst = mOrientationHelper.getDecoratedMeasurement(((LinearLayoutManager) layoutManager).findViewByPosition(firstChild)) / 2;
|
||||
int snapPositionLast = mOrientationHelper.getTotalSpace() - mOrientationHelper.getDecoratedMeasurement(((LinearLayoutManager) layoutManager).findViewByPosition(lastChild)) / 2;
|
||||
int snapPositionFirst = orientationHelper.getDecoratedMeasurement(((LinearLayoutManager) layoutManager).findViewByPosition(firstChild)) / 2;
|
||||
int snapPositionLast = orientationHelper.getTotalSpace() - orientationHelper.getDecoratedMeasurement(((LinearLayoutManager) layoutManager).findViewByPosition(lastChild)) / 2;
|
||||
|
||||
int centerSnapPosition = mOrientationHelper.getTotalSpace() / 2;
|
||||
int centerSnapPosition = orientationHelper.getTotalSpace() / 2;
|
||||
|
||||
if (idxSnap != -1) {
|
||||
int currentSmallestDistance = Integer.MAX_VALUE;
|
||||
@ -73,7 +73,7 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
currentSmallestDistance = dist;
|
||||
currentSmallestDistanceView = view;
|
||||
}
|
||||
} else if (i > idxSnap && lastChild == (mLlm.getItemCount() - 1)) {
|
||||
} else if (i > idxSnap && lastChild == (this.layoutManager.getItemCount() - 1)) {
|
||||
int snapPosition = snapPositionLast - (lastChild - i) * (snapPositionLast - centerSnapPosition) / (lastChild - idxSnap);
|
||||
int viewPosition = view.getLeft() + view.getWidth() / 2;
|
||||
int dist = snapPosition - viewPosition;
|
||||
@ -85,27 +85,27 @@ public class LinearLayoutManagerSnapHelper extends LinearSnapHelper {
|
||||
}
|
||||
if (Math.abs(distSnap) > Math.abs(currentSmallestDistance)) {
|
||||
snappedView = currentSmallestDistanceView;
|
||||
mLastSavedTarget = currentSmallestDistanceView;
|
||||
mLastSavedDistance = -currentSmallestDistance;
|
||||
lastSavedTarget = currentSmallestDistanceView;
|
||||
lastSavedDistance = -currentSmallestDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mListener != null) {
|
||||
if (listener != null) {
|
||||
int snappedPosition = 0;
|
||||
if (snappedView != null) {
|
||||
snappedPosition = mLlm.getPosition(snappedView);
|
||||
snappedPosition = this.layoutManager.getPosition(snappedView);
|
||||
}
|
||||
mListener.onSnappedToView(snappedView, snappedPosition);
|
||||
listener.onSnappedToView(snappedView, snappedPosition);
|
||||
}
|
||||
return snappedView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) {
|
||||
if (targetView == mLastSavedTarget) {
|
||||
if (targetView == lastSavedTarget) {
|
||||
int[] out = new int[2];
|
||||
out[0] = mLastSavedDistance;
|
||||
out[0] = lastSavedDistance;
|
||||
out[1] = 0;
|
||||
return out;
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
private static final int VIEWTYPE_SWAP = 1;
|
||||
private static final int VIEWTYPE_INTENT = 0;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private ArrayList<ResolveInfo> mTargets;
|
||||
private int mParentWidth;
|
||||
private Intent mShareIntent;
|
||||
private boolean mShowNearby;
|
||||
private RecyclerView recyclerView;
|
||||
private ArrayList<ResolveInfo> targets;
|
||||
private int parentWidth;
|
||||
private Intent shareIntent;
|
||||
private boolean showNearby;
|
||||
|
||||
public interface ShareChooserDialogListener {
|
||||
|
||||
@ -50,25 +50,25 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
|
||||
}
|
||||
|
||||
private ShareChooserDialogListener mListener;
|
||||
private ShareChooserDialogListener listener;
|
||||
|
||||
private void setListener(ShareChooserDialogListener listener) {
|
||||
mListener = listener;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mParentWidth = getArguments().getInt(ARG_WIDTH, 640);
|
||||
mShareIntent = getArguments().getParcelable(ARG_INTENT);
|
||||
mShowNearby = getArguments().getBoolean(ARG_SHOW_NEARBY, false);
|
||||
mTargets = new ArrayList<>();
|
||||
List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentActivities(mShareIntent, 0);
|
||||
parentWidth = getArguments().getInt(ARG_WIDTH, 640);
|
||||
shareIntent = getArguments().getParcelable(ARG_INTENT);
|
||||
showNearby = getArguments().getBoolean(ARG_SHOW_NEARBY, false);
|
||||
targets = new ArrayList<>();
|
||||
List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentActivities(shareIntent, 0);
|
||||
if (resInfo != null && resInfo.size() > 0) {
|
||||
for (ResolveInfo resolveInfo : resInfo) {
|
||||
String packageName = resolveInfo.activityInfo.packageName;
|
||||
if (!packageName.equals(BuildConfig.APPLICATION_ID)) { // Remove ourselves
|
||||
mTargets.add(resolveInfo);
|
||||
targets.add(resolveInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
public void onShow(DialogInterface dialogInterface) {
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
dialog.getWindow().setLayout(
|
||||
mParentWidth - Utils.dpToPx(0, getContext()), // Set margins here!
|
||||
parentWidth - Utils.dpToPx(0, getContext()), // Set margins here!
|
||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
});
|
||||
@ -98,19 +98,19 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
}
|
||||
|
||||
private void setupView(View v) {
|
||||
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view_apps);
|
||||
recyclerView = (RecyclerView) v.findViewById(R.id.recycler_view_apps);
|
||||
|
||||
// Figure out how many columns that fit in the given parent width. Give them 100dp.
|
||||
int appWidth = Utils.dpToPx(80, getContext());
|
||||
final int nCols = (mParentWidth - /* padding */ Utils.dpToPx(8, getContext())) / appWidth;
|
||||
final int nCols = (parentWidth - /* padding */ Utils.dpToPx(8, getContext())) / appWidth;
|
||||
GridLayoutManager glm = new GridLayoutManager(getContext(), nCols);
|
||||
|
||||
// Ensure that if available, the "Nearby Swap" item spans the entire width.
|
||||
glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
if (mRecyclerView.getAdapter() != null) {
|
||||
if (mRecyclerView.getAdapter().getItemViewType(position) == VIEWTYPE_SWAP) {
|
||||
if (recyclerView.getAdapter() != null) {
|
||||
if (recyclerView.getAdapter().getItemViewType(position) == VIEWTYPE_SWAP) {
|
||||
return nCols;
|
||||
}
|
||||
return 1;
|
||||
@ -118,7 +118,7 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
mRecyclerView.setLayoutManager(glm);
|
||||
recyclerView.setLayoutManager(glm);
|
||||
|
||||
class VH extends RecyclerView.ViewHolder {
|
||||
public final ImageView icon;
|
||||
@ -131,24 +131,24 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
mRecyclerView.setAdapter(new RecyclerView.Adapter<VH>() {
|
||||
recyclerView.setAdapter(new RecyclerView.Adapter<VH>() {
|
||||
|
||||
private ArrayList<ResolveInfo> mIntents;
|
||||
private ArrayList<ResolveInfo> intents;
|
||||
|
||||
RecyclerView.Adapter init(List<ResolveInfo> targetedShareIntents) {
|
||||
mIntents = new ArrayList<>();
|
||||
if (mShowNearby) {
|
||||
mIntents.add(null);
|
||||
intents = new ArrayList<>();
|
||||
if (showNearby) {
|
||||
intents.add(null);
|
||||
}
|
||||
for (ResolveInfo ri : targetedShareIntents) {
|
||||
mIntents.add(ri);
|
||||
intents.add(ri);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (mIntents.get(position) == null) {
|
||||
if (intents.get(position) == null) {
|
||||
return VIEWTYPE_SWAP;
|
||||
}
|
||||
return VIEWTYPE_INTENT;
|
||||
@ -166,26 +166,26 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mListener != null) {
|
||||
mListener.onNearby();
|
||||
if (listener != null) {
|
||||
listener.onNearby();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final ResolveInfo ri = mIntents.get(position);
|
||||
final ResolveInfo ri = intents.get(position);
|
||||
holder.icon.setImageDrawable(ri.loadIcon(getContext().getPackageManager()));
|
||||
holder.label.setText(ri.loadLabel(getContext().getPackageManager()));
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mListener != null) {
|
||||
Intent intent = new Intent(mShareIntent);
|
||||
if (listener != null) {
|
||||
Intent intent = new Intent(shareIntent);
|
||||
ComponentName name = new ComponentName(ri.activityInfo.applicationInfo.packageName,
|
||||
ri.activityInfo.name);
|
||||
intent.setComponent(name);
|
||||
mListener.onResolvedShareIntent(intent);
|
||||
listener.onResolvedShareIntent(intent);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
@ -194,9 +194,9 @@ public class ShareChooserDialog extends BottomSheetDialogFragment {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mIntents.size();
|
||||
return intents.size();
|
||||
}
|
||||
}.init(mTargets));
|
||||
}.init(targets));
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class SelectAppsView extends ListView implements
|
||||
private static final int LOADER_INSTALLED_APPS = 253341534;
|
||||
|
||||
private AppListAdapter adapter;
|
||||
private String mCurrentFilterString;
|
||||
private String currentFilterString;
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
@ -154,10 +154,10 @@ public class SelectAppsView extends ListView implements
|
||||
@Override
|
||||
public CursorLoader onCreateLoader(int id, Bundle args) {
|
||||
Uri uri;
|
||||
if (TextUtils.isEmpty(mCurrentFilterString)) {
|
||||
if (TextUtils.isEmpty(currentFilterString)) {
|
||||
uri = InstalledAppProvider.getContentUri();
|
||||
} else {
|
||||
uri = InstalledAppProvider.getSearchUri(mCurrentFilterString);
|
||||
uri = InstalledAppProvider.getSearchUri(currentFilterString);
|
||||
}
|
||||
return new CursorLoader(
|
||||
getActivity(),
|
||||
@ -192,13 +192,13 @@ public class SelectAppsView extends ListView implements
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
||||
if (mCurrentFilterString == null && newFilter == null) {
|
||||
if (currentFilterString == null && newFilter == null) {
|
||||
return true;
|
||||
}
|
||||
if (mCurrentFilterString != null && mCurrentFilterString.equals(newFilter)) {
|
||||
if (currentFilterString != null && currentFilterString.equals(newFilter)) {
|
||||
return true;
|
||||
}
|
||||
mCurrentFilterString = newFilter;
|
||||
currentFilterString = newFilter;
|
||||
getActivity().getSupportLoaderManager().restartLoader(LOADER_INSTALLED_APPS, null, this);
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class SwapAppsView extends ListView implements
|
||||
|
||||
private Repo repo;
|
||||
private AppListAdapter adapter;
|
||||
private String mCurrentFilterString;
|
||||
private String currentFilterString;
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
@ -190,9 +190,9 @@ public class SwapAppsView extends ListView implements
|
||||
|
||||
@Override
|
||||
public CursorLoader onCreateLoader(int id, Bundle args) {
|
||||
Uri uri = TextUtils.isEmpty(mCurrentFilterString)
|
||||
Uri uri = TextUtils.isEmpty(currentFilterString)
|
||||
? AppProvider.getRepoUri(repo)
|
||||
: AppProvider.getSearchUri(repo, mCurrentFilterString);
|
||||
: AppProvider.getSearchUri(repo, currentFilterString);
|
||||
|
||||
return new CursorLoader(getActivity(), uri, AppMetadataTable.Cols.ALL, null, null, AppMetadataTable.Cols.NAME);
|
||||
}
|
||||
@ -210,13 +210,13 @@ public class SwapAppsView extends ListView implements
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
|
||||
if (mCurrentFilterString == null && newFilter == null) {
|
||||
if (currentFilterString == null && newFilter == null) {
|
||||
return true;
|
||||
}
|
||||
if (mCurrentFilterString != null && mCurrentFilterString.equals(newFilter)) {
|
||||
if (currentFilterString != null && currentFilterString.equals(newFilter)) {
|
||||
return true;
|
||||
}
|
||||
mCurrentFilterString = newFilter;
|
||||
currentFilterString = newFilter;
|
||||
getActivity().getSupportLoaderManager().restartLoader(LOADER_SWAPABLE_APPS, null, this);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user