Search in sources :

Example 1 with GitHubUpdater

use of velitasali.updatewithgithub.GitHubUpdater in project TrebleShot by genonbeta.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mDrawerLayout = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_navigationDrawerOpen, R.string.text_navigationDrawerClose);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mActionMode = findViewById(R.id.content_powerful_action_mode);
    mNavigationView = findViewById(R.id.nav_view);
    mFAB = findViewById(R.id.content_fab);
    mNavigationView.setNavigationItemSelectedListener(this);
    mFragmentDeviceList = Fragment.instantiate(this, NetworkDeviceListFragment.class.getName());
    mFragmentFileExplorer = Fragment.instantiate(this, FileExplorerFragment.class.getName());
    mFragmentTransactions = Fragment.instantiate(this, TransactionGroupListFragment.class.getName());
    mFragmentShareApp = Fragment.instantiate(this, ApplicationListFragment.class.getName());
    mFragmentShareImage = Fragment.instantiate(this, ImageListFragment.class.getName());
    mFragmentShareMusic = Fragment.instantiate(this, MusicListFragment.class.getName());
    mFragmentShareVideo = Fragment.instantiate(this, VideoListFragment.class.getName());
    mFragmentShareText = Fragment.instantiate(this, TextStreamListFragment.class.getName());
    mActionMode.setOnSelectionTaskListener(new PowerfulActionMode.OnSelectionTaskListener() {

        @Override
        public void onSelectionTask(boolean started, PowerfulActionMode actionMode) {
            toolbar.setVisibility(!started ? View.VISIBLE : View.GONE);
        }
    });
    if (mPreferences.contains("availableVersion") && mUpdater.isNewVersion(mPreferences.getString("availableVersion", null))) {
        highlightUpdater(mPreferences.getString("availableVersion", null));
    } else {
        mUpdater.checkForUpdates(false, new GitHubUpdater.OnInfoAvailableListener() {

            @Override
            public void onInfoAvailable(boolean newVersion, String versionName, String title, String description, String releaseDate) {
                mPreferences.edit().putString("availableVersion", versionName).apply();
                if (newVersion)
                    highlightUpdater(versionName);
            }
        });
    }
    NetworkDevice localDevice = AppUtils.getLocalDevice(getApplicationContext());
    if (mPreferences.getInt("migrated_version", localDevice.versionNumber) < localDevice.versionNumber) {
    // migrating to a new version
    }
    mPreferences.edit().putInt("migrated_version", localDevice.versionNumber).apply();
    if (!checkRequestedFragment(getIntent()) && !restorePreviousFragment()) {
        changeFragment(mFragmentDeviceList);
        mNavigationView.setCheckedItem(R.id.menu_activity_main_device_list);
    }
}
Also used : PowerfulActionMode(com.genonbeta.TrebleShot.widget.PowerfulActionMode) GitHubUpdater(velitasali.updatewithgithub.GitHubUpdater) NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with GitHubUpdater

use of velitasali.updatewithgithub.GitHubUpdater in project TrebleShot by genonbeta.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);
    mTextUpdates = findViewById(R.id.activity_about_update_text);
    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SENDTO);
            intent.setType("*/*");
            intent.setData(Uri.parse("mailto:" + AppConfig.EMAIL_DEVELOPER));
            intent.putExtra(Intent.EXTRA_EMAIL, AppConfig.EMAIL_DEVELOPER);
            intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.text_appName));
            startActivity(Intent.createChooser(intent, getString(R.string.text_application)));
        }
    });
    findViewById(R.id.activity_about_see_source_layout).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(AppConfig.URI_REPO_APP)));
        }
    });
    findViewById(R.id.activity_about_translate_layout).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(AppConfig.URI_TRANSLATE)));
        }
    });
    findViewById(R.id.activity_about_update_layout).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mUpdater.checkForUpdates(true, null);
        }
    });
    if (mPreferences.contains("availableVersion") && mUpdater.isNewVersion(mPreferences.getString("availableVersion", null)))
        highlightUpdater(mPreferences.getString("availableVersion", null));
    else
        mUpdater.checkForUpdates(false, new GitHubUpdater.OnInfoAvailableListener() {

            @Override
            public void onInfoAvailable(boolean newVersion, String versionName, String title, String description, String releaseDate) {
                mPreferences.edit().putString("availableVersion", versionName).apply();
                if (newVersion)
                    highlightUpdater(versionName);
            }
        });
    GitHubContributorsListFragment contributorsListFragment = (GitHubContributorsListFragment) getSupportFragmentManager().findFragmentById(R.id.activity_about_contributors_fragment);
    if (contributorsListFragment != null)
        contributorsListFragment.getListView().setNestedScrollingEnabled(false);
}
Also used : GitHubUpdater(velitasali.updatewithgithub.GitHubUpdater) GitHubContributorsListFragment(com.genonbeta.TrebleShot.fragment.external.GitHubContributorsListFragment) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)2 GitHubUpdater (velitasali.updatewithgithub.GitHubUpdater)2 Intent (android.content.Intent)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 View (android.view.View)1 TextView (android.widget.TextView)1 GitHubContributorsListFragment (com.genonbeta.TrebleShot.fragment.external.GitHubContributorsListFragment)1 NetworkDevice (com.genonbeta.TrebleShot.object.NetworkDevice)1 PowerfulActionMode (com.genonbeta.TrebleShot.widget.PowerfulActionMode)1