Android Open Source - blokish Rate Dialog






From Project

Back to project page blokish.

License

The source code is released under:

GNU General Public License

If you think the Android project blokish listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.scoutant.blokish;
//from   ww  w. j  a  v  a2  s.  c  o m
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;

public class RateDialog extends Dialog {
  private SharedPreferences.Editor editor; 
    private final static String APP_PNAME = "org.scoutant.blokish";
  public RateDialog(final Context context) {
    super(context);
        editor = context.getSharedPreferences("apprater", 0).edit();    
    setContentView( R.layout.rate);
    // Cf layout issue http://groups.google.com/group/android-developers/browse_thread/thread/f0bb813f643604ec?pli=1
    getWindow().setLayout( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    Button now = (Button) findViewById(R.id.now);
    now.setOnClickListener( new android.view.View.OnClickListener(){
      public void onClick(View v) {
        context.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
        resetCounter();
        RateDialog.this.dismiss();
      }
    });
    Button later = (Button) findViewById(R.id.later);
    later.setOnClickListener( new android.view.View.OnClickListener(){
      public void onClick(View v) {
        resetCounter();
        RateDialog.this.dismiss();
      }
    });
    Button never = (Button) findViewById(R.id.never);
    never.setOnClickListener( new android.view.View.OnClickListener(){
      public void onClick(View v) {
                if (editor != null) editor.putBoolean("dontshowagain", true).commit();
        RateDialog.this.dismiss();
      }
    });
  }
  
  private void resetCounter() {
    if (editor== null) return;
    editor.putLong("launch_count", 0);
    editor.putLong("date_firstlaunch", 0);
    editor.commit();
  }
  
}




Java Source Code List

org.scoutant.blokish.AppRater.java
org.scoutant.blokish.BusyIndicator.java
org.scoutant.blokish.ButtonsView.java
org.scoutant.blokish.EndGameDialog.java
org.scoutant.blokish.GameView.java
org.scoutant.blokish.Help.java
org.scoutant.blokish.PieceUI.java
org.scoutant.blokish.RateDialog.java
org.scoutant.blokish.Settings.java
org.scoutant.blokish.SplashScreen.java
org.scoutant.blokish.UI.java
org.scoutant.blokish.model.AI.java
org.scoutant.blokish.model.Board.java
org.scoutant.blokish.model.Game.java
org.scoutant.blokish.model.Move.java
org.scoutant.blokish.model.Piece.java
org.scoutant.blokish.model.Square.java