Search in sources :

Example 1 with MarkDownWindow

use of com.topjohnwu.magisk.asyncs.MarkDownWindow in project MagiskManager by topjohnwu.

the class ReposAdapter method onBindItemViewHolder.

@Override
public void onBindItemViewHolder(RepoHolder holder, int section, int position) {
    Repo repo = repoPairs.get(section).second.get(position);
    Context context = holder.itemView.getContext();
    holder.title.setText(repo.getName());
    holder.versionName.setText(repo.getVersion());
    String author = repo.getAuthor();
    holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
    holder.description.setText(repo.getDescription());
    holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString()));
    holder.infoLayout.setOnClickListener(v -> new MarkDownWindow((Activity) context, null, repo.getDetailUrl()).exec());
    holder.downloadImage.setOnClickListener(v -> {
        String filename = repo.getName() + "-" + repo.getVersion() + ".zip";
        new AlertDialogBuilder((Activity) context).setTitle(context.getString(R.string.repo_install_title, repo.getName())).setMessage(context.getString(R.string.repo_install_msg, filename)).setCancelable(true).setPositiveButton(R.string.install, (d, i) -> new ProcessRepoZip((Activity) context, repo.getZipUrl(), Utils.getLegalFilename(filename), true).exec()).setNeutralButton(R.string.download, (d, i) -> new ProcessRepoZip((Activity) context, repo.getZipUrl(), Utils.getLegalFilename(filename), false).exec()).setNegativeButton(R.string.no_thanks, null).show();
    });
}
Also used : Context(android.content.Context) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) ButterKnife(butterknife.ButterKnife) MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) Pair(android.util.Pair) ImageView(android.widget.ImageView) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) R(com.topjohnwu.magisk.R) ProcessRepoZip(com.topjohnwu.magisk.asyncs.ProcessRepoZip) Module(com.topjohnwu.magisk.container.Module) RepoDatabaseHelper(com.topjohnwu.magisk.database.RepoDatabaseHelper) Map(java.util.Map) View(android.view.View) Cursor(android.database.Cursor) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) Utils(com.topjohnwu.magisk.utils.Utils) Activity(android.app.Activity) Repo(com.topjohnwu.magisk.container.Repo) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) Repo(com.topjohnwu.magisk.container.Repo) ProcessRepoZip(com.topjohnwu.magisk.asyncs.ProcessRepoZip) Activity(android.app.Activity) MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow)

Example 2 with MarkDownWindow

use of com.topjohnwu.magisk.asyncs.MarkDownWindow in project MagiskManager by topjohnwu.

the class MainActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    MagiskManager mm = getMagiskManager();
    prefs = mm.prefs;
    if (!mm.hasInit) {
        Intent intent = new Intent(this, SplashActivity.class);
        String section = getIntent().getStringExtra(Const.Key.OPEN_SECTION);
        if (section != null) {
            intent.putExtra(Const.Key.OPEN_SECTION, section);
        }
        startActivity(intent);
        finish();
    }
    String perm = getIntent().getStringExtra(Const.Key.INTENT_PERM);
    if (perm != null) {
        ActivityCompat.requestPermissions(this, new String[] { perm }, 0);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.magisk, R.string.magisk) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // this disables the arrow @ completed tate
            super.onDrawerSlide(drawerView, 0);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            // this disables the animation
            super.onDrawerSlide(drawerView, 0);
        }
    };
    toolbarElevation = toolbar.getElevation();
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    if (savedInstanceState == null)
        navigate(getIntent().getStringExtra(Const.Key.OPEN_SECTION));
    navigationView.setNavigationItemSelectedListener(this);
    if (mm.prefs.getInt(Const.Key.APP_VER, -1) < BuildConfig.VERSION_CODE) {
        prefs.edit().putInt(Const.Key.APP_VER, BuildConfig.VERSION_CODE).apply();
        new MarkDownWindow(this, getString(R.string.app_changelog), getResources().openRawResource(R.raw.changelog)).exec();
    }
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View)

Example 3 with MarkDownWindow

use of com.topjohnwu.magisk.asyncs.MarkDownWindow in project MagiskManager by topjohnwu.

the class AboutActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(view -> finish());
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setTitle(R.string.about);
        ab.setDisplayHomeAsUpEnabled(true);
    }
    appVersionInfo.setSummary(String.format(Locale.US, "%s (%d) (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getPackageName()));
    appChangelog.removeSummary();
    appChangelog.setOnClickListener(v -> {
        new MarkDownWindow(this, getString(R.string.app_changelog), getResources().openRawResource(R.raw.changelog)).exec();
    });
    String translators = getString(R.string.translators);
    if (TextUtils.isEmpty(translators)) {
        appTranslators.setVisibility(View.GONE);
    } else {
        appTranslators.setSummary(translators);
    }
    appSourceCode.removeSummary();
    appSourceCode.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.SOURCE_CODE_URL))));
    supportThread.removeSummary();
    supportThread.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.XDA_THREAD))));
    donation.removeSummary();
    donation.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Const.Url.DONATION_URL))));
    setFloating();
}
Also used : MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow) Intent(android.content.Intent) ActionBar(android.support.v7.app.ActionBar)

Aggregations

MarkDownWindow (com.topjohnwu.magisk.asyncs.MarkDownWindow)3 Intent (android.content.Intent)2 View (android.view.View)2 BindView (butterknife.BindView)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Cursor (android.database.Cursor)1 NavigationView (android.support.design.widget.NavigationView)1 ActionBar (android.support.v7.app.ActionBar)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextUtils (android.text.TextUtils)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ButterKnife (butterknife.ButterKnife)1 R (com.topjohnwu.magisk.R)1