Search in sources :

Example 6 with FDroidApp

use of org.fdroid.fdroid.FDroidApp in project fdroidclient by f-droid.

the class AppDetailsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    FDroidApp fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.app_details2);
    MaterialToolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // clear title
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    supportPostponeEnterTransition();
    String packageName = getPackageNameFromIntent(getIntent());
    if (!resetCurrentApp(packageName)) {
        finish();
        return;
    }
    bluetoothAdapter = getBluetoothAdapter();
    localBroadcastManager = LocalBroadcastManager.getInstance(this);
    recyclerView = (RecyclerView) findViewById(R.id.rvDetails);
    adapter = new AppDetailsRecyclerViewAdapter(this, app, this);
    LinearLayoutManager lm = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    lm.setStackFromEnd(false);
    // Has to be invoked after AppDetailsRecyclerViewAdapter is created.
    refreshStatus();
    recyclerView.setLayoutManager(lm);
    recyclerView.setAdapter(adapter);
    recyclerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            supportStartPostponedEnterTransition();
            return true;
        }
    });
    // Load the feature graphic, if present
    final FeatureImage featureImage = (FeatureImage) findViewById(R.id.feature_graphic);
    RequestOptions displayImageOptions = new RequestOptions();
    String featureGraphicUrl = app.getFeatureGraphicUrl(this);
    featureImage.loadImageAndDisplay(displayImageOptions, featureGraphicUrl, app.getIconUrl(this));
}
Also used : MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) FeatureImage(org.fdroid.fdroid.views.apps.FeatureImage) RequestOptions(com.bumptech.glide.request.RequestOptions) FDroidApp(org.fdroid.fdroid.FDroidApp) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ViewTreeObserver(android.view.ViewTreeObserver)

Example 7 with FDroidApp

use of org.fdroid.fdroid.FDroidApp in project fdroidclient by f-droid.

the class ScreenShotsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    FDroidApp fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screenshots);
    String packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME);
    int startPosition = getIntent().getIntExtra(EXTRA_START_POSITION, 0);
    App app = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
    String[] screenshots = app.getAllScreenshots(this);
    ViewPager viewPager = (ViewPager) findViewById(R.id.screenshot_view_pager);
    ScreenShotPagerAdapter adapter = new ScreenShotPagerAdapter(getSupportFragmentManager(), screenshots);
    viewPager.setAdapter(adapter);
    viewPager.setCurrentItem(startPosition);
    // display some nice animation while swiping
    viewPager.setPageTransformer(true, new DepthPageTransformer());
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) App(org.fdroid.fdroid.data.App) FDroidApp(org.fdroid.fdroid.FDroidApp) ViewPager(androidx.viewpager.widget.ViewPager)

Example 8 with FDroidApp

use of org.fdroid.fdroid.FDroidApp in project fdroidclient by f-droid.

the class AppListActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    FDroidApp fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_list);
    keyboardStateMonitor = new Utils.KeyboardStateMonitor(findViewById(R.id.app_list_root));
    savedSearchSettings = getSavedSearchSettings(this);
    searchTerms = savedSearchSettings.getString(SEARCH_TERMS_KEY, null);
    sortClauseSelected = savedSearchSettings.getString(SORT_CLAUSE_KEY, SortClause.LAST_UPDATED);
    searchInput = (EditText) findViewById(R.id.search);
    searchInput.setText(searchTerms);
    searchInput.addTextChangedListener(new CategoryTextWatcher(this, searchInput, this));
    searchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // Hide the keyboard (http://stackoverflow.com/a/1109108 (when pressing search)
                InputMethodManager inputManager = ContextCompat.getSystemService(AppListActivity.this, InputMethodManager.class);
                inputManager.hideSoftInputFromWindow(searchInput.getWindowToken(), 0);
                // Change focus from the search input to the app list.
                appView.requestFocus();
                return true;
            }
            return false;
        }
    });
    sortImage = (ImageView) findViewById(R.id.sort);
    final Drawable lastUpdated = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.ic_last_updated)).mutate();
    final Drawable words = DrawableCompat.wrap(ContextCompat.getDrawable(AppListActivity.this, R.drawable.ic_sort)).mutate();
    sortImage.setImageDrawable(SortClause.WORDS.equals(sortClauseSelected) ? words : lastUpdated);
    sortImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            switch(sortClauseSelected) {
                case SortClause.WORDS:
                    sortClauseSelected = SortClause.LAST_UPDATED;
                    DrawableCompat.setTint(lastUpdated, FDroidApp.isAppThemeLight() ? Color.BLACK : Color.WHITE);
                    sortImage.setImageDrawable(lastUpdated);
                    break;
                case SortClause.LAST_UPDATED:
                    sortClauseSelected = SortClause.WORDS;
                    DrawableCompat.setTint(words, FDroidApp.isAppThemeLight() ? Color.BLACK : Color.WHITE);
                    sortImage.setImageDrawable(words);
                    break;
            }
            putSavedSearchSettings(getApplicationContext(), SORT_CLAUSE_KEY, sortClauseSelected);
            getSupportLoaderManager().restartLoader(0, null, AppListActivity.this);
            appView.scrollToPosition(0);
        }
    });
    hiddenAppNotice = findViewById(R.id.hiddenAppNotice);
    hiddenAppNotice.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            intent.putExtra(MainActivity.EXTRA_VIEW_SETTINGS, true);
            getApplicationContext().startActivity(intent);
        }
    });
    emptyState = (TextView) findViewById(R.id.empty_state);
    View backButton = findViewById(R.id.back);
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    View clearButton = findViewById(R.id.clear);
    clearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            searchInput.setText("");
            searchInput.requestFocus();
            if (!keyboardStateMonitor.isKeyboardVisible()) {
                InputMethodManager inputMethodManager = ContextCompat.getSystemService(AppListActivity.this, InputMethodManager.class);
                inputMethodManager.toggleSoftInputFromWindow(v.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
            }
        }
    });
    appAdapter = new AppListAdapter(this);
    appView = (RecyclerView) findViewById(R.id.app_list);
    appView.setHasFixedSize(true);
    appView.setLayoutManager(new LinearLayoutManager(this));
    appView.setAdapter(appAdapter);
    parseIntentForSearchQuery();
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) Drawable(android.graphics.drawable.Drawable) InputMethodManager(android.view.inputmethod.InputMethodManager) Intent(android.content.Intent) MainActivity(org.fdroid.fdroid.views.main.MainActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) Utils(org.fdroid.fdroid.Utils) TextUtils(android.text.TextUtils) TextView(android.widget.TextView)

Example 9 with FDroidApp

use of org.fdroid.fdroid.FDroidApp in project fdroidclient by f-droid.

the class MainActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    FDroidApp fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    adapter = new MainViewAdapter(this);
    pager = (RecyclerView) findViewById(R.id.main_view_pager);
    pager.setHasFixedSize(true);
    pager.setLayoutManager(new NonScrollingHorizontalLayoutManager(this));
    pager.setAdapter(adapter);
    // reverting back to the "Latest" screen again, in completely non-deterministic ways.
    if (Build.VERSION.SDK_INT <= 15) {
        pager.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    }
    bottomNavigation = (BottomNavigationView) findViewById(R.id.bottom_navigation);
    bottomNavigation.setOnNavigationItemSelectedListener(item -> {
        pager.scrollToPosition(item.getOrder());
        if (item.getItemId() == R.id.nearby) {
            NearbyViewBinder.updateUsbOtg(MainActivity.this);
        }
        return true;
    });
    updatesBadge = bottomNavigation.getOrCreateBadge(R.id.updates);
    updatesBadge.setVisible(false);
    IntentFilter updateableAppsFilter = new IntentFilter(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED);
    updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
    updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
    LocalBroadcastManager.getInstance(this).registerReceiver(onUpdateableAppsChanged, updateableAppsFilter);
    initialRepoUpdateIfRequired();
    Intent intent = getIntent();
    handleSearchOrAppViewIntent(intent);
}
Also used : IntentFilter(android.content.IntentFilter) FDroidApp(org.fdroid.fdroid.FDroidApp) Intent(android.content.Intent)

Example 10 with FDroidApp

use of org.fdroid.fdroid.FDroidApp in project fdroidclient by f-droid.

the class PanicPreferencesActivity method onCreate.

@Override
public void onCreate(Bundle bundle) {
    FDroidApp fdroidApp = (FDroidApp) getApplication();
    fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
    super.onCreate(bundle);
    setContentView(R.layout.activity_panic_settings);
    MaterialToolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Also used : MaterialToolbar(com.google.android.material.appbar.MaterialToolbar) FDroidApp(org.fdroid.fdroid.FDroidApp)

Aggregations

FDroidApp (org.fdroid.fdroid.FDroidApp)16 Intent (android.content.Intent)7 MaterialToolbar (com.google.android.material.appbar.MaterialToolbar)7 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)5 IntentFilter (android.content.IntentFilter)3 View (android.view.View)3 TextView (android.widget.TextView)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 Uri (android.net.Uri)2 TextUtils (android.text.TextUtils)2 MenuItem (android.view.MenuItem)2 ImageView (android.widget.ImageView)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 Utils (org.fdroid.fdroid.Utils)2 Repo (org.fdroid.fdroid.data.Repo)2 TargetApi (android.annotation.TargetApi)1 PendingIntent (android.app.PendingIntent)1 BroadcastReceiver (android.content.BroadcastReceiver)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1