Android Open Source - MConsole Server Console Fragment






From Project

Back to project page MConsole.

License

The source code is released under:

MIT License

If you think the Android project MConsole 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 pl.skifo.mconsole;
//w w  w .  ja  va 2  s .  c o  m
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ScrollView;

public class ServerConsoleFragment extends Fragment {
    
    private CommandPrompt prompt;
    private ConsoleOutputImpl consoleOut;
    private Context ctx;
    
//    public ServerConsoleFragment() {
//    }
//    
//    public ServerConsoleFragment(Context ctx, CommandPrompt prompt) {
//        this.prompt = prompt;
//        this.ctx = ctx; 
//    }
    
    //http://s3.amazonaws.com/MinecraftSkins/PLAYERSNAMEHERE.png
    
    private AutoCompleteTextView inputLine; 
    private static final String[] COUNTRIES = new String[] {
        "ban",  //+
        "ban-ip", //+
        "banlist", //+
        "clear", //+
                 // ++++++++++++++++++++++++ debug
        "defaultgamemode", //+
        "deop", //+
        "difficulty", //+
        "effect", //+
        "enchant", //+
        "gamemode", //+
        "gamerule", //+
        "give", //+
        "help", //+
        "kick", //+
        "kill", //+
        "list", //+
        "me", //+
        "op", //+
        "pardon", //+
        "pardon-ip", //+
        "playsound", //+
        "plugins", // ----------------------------
        "reload", // --------------------------
        "save-all", //+
        "save-off", //+
        "save-on", //+
        "say", //+
        "scoreboard", //+
        "seed", // +
                // ++++++++++++++++++++++++++ setblock
                // ++++++++++++++++++++++++++ setidletimeout
                // ++++++++++++++++++++++++++ setworldspawn
        "spawnpoint", // +
        "spreadplayers", // +
        "stop", // +
        "tell", // +
                // ++++++++++++++++++++++++++ tellraw
        "testfor", // +
        "time", // +
        "timings",
        "toggledownfall", // +
        "tp", // +
        "version", // --------------------------
        "weather", // +
        "whitelist", // +
        "xp" // +        
    };
    
    
    
    
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        ctx = activity;
        if (activity instanceof CommandPrompt) {
            prompt = (CommandPrompt)activity;
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onCreateView: "+savedInstanceState);
        
        View rootView = inflater.inflate(R.layout.fragment_console, container, false);
        consoleOut = (pl.skifo.mconsole.ConsoleOutputImpl) rootView.findViewById(R.id.console_output);
        consoleOut.setParent((ScrollView)rootView.findViewById(R.id.console_output_scroll_container));
        
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx,
                android.R.layout.simple_dropdown_item_1line, COUNTRIES);
        inputLine = (AutoCompleteTextView)rootView.findViewById(R.id.input_line);
        inputLine.setAdapter(adapter);


        Button b = (Button) rootView.findViewById(R.id.send_button);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (prompt != null)
                    prompt.sendCommand(inputLine.getText().toString(), consoleOut);
                inputLine.setText("");
            }
        });
        return rootView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onCreate: "+savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        // TODO Auto-generated method stub
        super.onDestroyView();
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onDestroyView");
    }

    @Override
    public void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onPause");
    }

    @Override
    public void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onResume");
    }
    

    @Override
    public void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onStart");
    }

    @Override
    public void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onStop");
    }

    @Override
    public void onViewStateRestored(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onViewStateRestored(savedInstanceState);
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onViewStateRestored: "+savedInstanceState);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(outState);
        if (MConsoleActivity.LOG_DEBUG) MConsoleActivity.d("SvConFrag", "onSaveInstanceState: "+outState);
    }
}




Java Source Code List

pl.skifo.mconsole.AttributedBlock.java
pl.skifo.mconsole.AttributedLine.java
pl.skifo.mconsole.AttributedString.java
pl.skifo.mconsole.BanlistDialog.java
pl.skifo.mconsole.CommandPrompt.java
pl.skifo.mconsole.CommandResponseEvaluator.java
pl.skifo.mconsole.CommandSet.java
pl.skifo.mconsole.ConfirmDialog.java
pl.skifo.mconsole.ConsoleOutputImpl.java
pl.skifo.mconsole.ConsoleOutput.java
pl.skifo.mconsole.MConsoleActivity.java
pl.skifo.mconsole.MinecraftColorScheme.java
pl.skifo.mconsole.PlayerActionTp.java
pl.skifo.mconsole.PlayerAdminBan.java
pl.skifo.mconsole.PlayerAdminMode.java
pl.skifo.mconsole.PlayerListAdapter.java
pl.skifo.mconsole.PlayersFragment.java
pl.skifo.mconsole.ResponseEvaluator.java
pl.skifo.mconsole.ResponseReceiver.java
pl.skifo.mconsole.ResponseToastGenerator.java
pl.skifo.mconsole.SayDialog.java
pl.skifo.mconsole.ServerConnector.java
pl.skifo.mconsole.ServerConsoleFragment.java
pl.skifo.mconsole.ServerConsole.java
pl.skifo.mconsole.ServerFragment.java
pl.skifo.mconsole.ServerInfo.java
pl.skifo.mconsole.ServerResponse.java
pl.skifo.mconsole.SimpleToastResponseReceiver.java
pl.skifo.mconsole.TabsPagerAdapter.java
pl.skifo.mconsole.TellDialog.java
pl.skifo.mconsole.TimeSetDialog.java
pl.skifo.mconsole.UserActionDialog.java
pl.skifo.mconsole.UserAdminDialog.java