Android Open Source - MYKey_SoftKeyboard String Key Modify Activity






From Project

Back to project page MYKey_SoftKeyboard.

License

The source code is released under:

Apache License

If you think the Android project MYKey_SoftKeyboard 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 string_Key;
/*  w  w w . j  a v a 2  s.c  o  m*/
import java.util.ArrayList;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import com.android.mykey.*;
import com.android.mykey.R.*;

public class StringKeyModifyActivity extends Activity implements OnItemClickListener{
  private ArrayList<StringKeyItem> strKeyItems;
  private StringKeyListAdapter adapter;
  private ListView strKeyListView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.string_key_modify_activity);
    
    StringKeyHandler strKeyHnd = StringKeyHandler.getInstance(getApplicationContext());
    strKeyItems = strKeyHnd.getItems();
    
    adapter = new StringKeyListAdapter(this, android.R.layout.simple_list_item_1, strKeyItems);
  
    strKeyListView = (ListView) findViewById(R.id.stringListView);
    strKeyListView.setOnItemClickListener(this);
    strKeyListView.setAdapter(adapter);
  }
  

  
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position,
      long id) {
    
    final StringKeyItem tmpItem = strKeyItems.get(position);
    
    KeyInfoDialog kd = new KeyInfoDialog(StringKeyModifyActivity.this);
    kd.setTitle("Modify");
    kd.setKeyItem(tmpItem);
    
    
    kd.setOnDismissListener(new OnDismissListener() {
      
      @Override
      public void onDismiss(DialogInterface dialog) {
        KeyInfoDialog tmpKd = (KeyInfoDialog) dialog;
        tmpItem.setKeyText(tmpKd.getKeyText());
        
        StringKeyHandler strKeyHnd = StringKeyHandler.getInstance(getApplicationContext());
        strKeyHnd.updateStringKeyInfo(tmpItem);
        
        strKeyItems = strKeyHnd.getItems();
        
        adapter = new StringKeyListAdapter(StringKeyModifyActivity.this, android.R.layout.simple_list_item_1, strKeyItems);
        strKeyListView.setAdapter(adapter);
      }
    });
    
    kd.setOnCancelListener(new OnCancelListener() {
      
      @Override
      public void onCancel(DialogInterface dialog) {
        
      }
    });
    
    
    kd.show();
  }
  
  class KeyInfoDialog extends Dialog implements OnTouchListener{
    private TextView keyLabelView;
    private EditText keyTextView;
    private Button commitBtn;
    private Button cancelBtn;
    private StringKeyItem item;
    private String beforeModify;

    public KeyInfoDialog(Context context) {
      super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.key_text_modify);
      
      keyLabelView = (TextView) findViewById(R.id.keyLabelTextView);
      keyTextView = (EditText) findViewById(R.id.keyTextEditView);
      commitBtn = (Button) findViewById(R.id.commitButton);
      cancelBtn = (Button) findViewById(R.id.cancelButton);
      
      keyLabelView.setText(item.getKeyLabel());
      keyTextView.setText(item.getKeyText());
      beforeModify = keyTextView.getText().toString();
      
      commitBtn.setOnTouchListener(this);
      cancelBtn.setOnTouchListener(this);
    }
    
    
    public void setKeyItem(StringKeyItem item){
      this.item = item;
    }
    
    public String getKeyText(){
      return keyTextView.getText().toString();
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      if(v.equals(commitBtn)){
        dismiss();
      }
      else if(v.equals(cancelBtn)){
        keyTextView.setText(beforeModify);
        cancel();
      }
      
      return false;
    }

    
  }
}




Java Source Code List

com.android.mykey.LatinKeyboardView.java
com.android.mykey.LatinKeyboard.java
com.android.mykey.SoftKeyboard.java
ime_preferences.ImePreferencesActivity.java
key_process.Buffer.java
key_process.FinalCombinationInfo.java
key_process.KeyInfo.java
key_process.KeyMap.java
key_process.KeyProcessor.java
korean_automata.CombinationState.java
korean_automata.KoreanAutomata.java
korean_automata.PhonemeCategoryConverter.java
korean_automata.Proc1.java
korean_automata.Proc2.java
korean_automata.Proc3.java
korean_automata.Proc4.java
korean_automata.StArea.java
korean_automata.StEmpty.java
korean_automata.StError.java
korean_automata.StFirstArea.java
korean_automata.StFirstVowelAndFirst.java
korean_automata.StFirstVowel.java
korean_automata.StFirst.java
korean_automata.StMultiFinal.java
korean_automata.StSingleFinalAndFirst.java
korean_automata.StSingleFinal.java
korean_automata.StVowel.java
korean_automata.VerifyComb.java
string_Key.StringKeyHandler.java
string_Key.StringKeyListAdapter.java
string_Key.StringKeyModifyActivity.java